bool BaseMultipleFieldsDateAndTimeInputType::isMouseFocusable() const { return element()->isTextFormControlFocusable(); }
void ImageLoader::updateFromElement() { // If we're not making renderers for the page, then don't load images. We don't want to slow // down the raw HTML parsing case by loading images we don't intend to display. Document& document = element().document(); if (!document.hasLivingRenderTree()) return; AtomicString attr = element().imageSourceURL(); if (attr == m_failedLoadURL) return; // Do not load any image if the 'src' attribute is missing or if it is // an empty string. CachedResourceHandle<CachedImage> newImage = 0; if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) { CachedResourceRequest request(ResourceRequest(document.completeURL(sourceURI(attr)))); request.setInitiator(&element()); String crossOriginMode = element().fastGetAttribute(HTMLNames::crossoriginAttr); if (!crossOriginMode.isNull()) { StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials; updateRequestForAccessControl(request.mutableResourceRequest(), document.securityOrigin(), allowCredentials); } if (m_loadManually) { bool autoLoadOtherImages = document.cachedResourceLoader()->autoLoadImages(); document.cachedResourceLoader()->setAutoLoadImages(false); newImage = new CachedImage(request.resourceRequest(), m_element.document().page()->sessionID()); newImage->setLoading(true); newImage->setOwningCachedResourceLoader(document.cachedResourceLoader()); document.cachedResourceLoader()->m_documentResources.set(newImage->url(), newImage.get()); document.cachedResourceLoader()->setAutoLoadImages(autoLoadOtherImages); } else newImage = document.cachedResourceLoader()->requestImage(request); // If we do not have an image here, it means that a cross-site // violation occurred, or that the image was blocked via Content // Security Policy, or the page is being dismissed. Trigger an // error event if the page is not being dismissed. if (!newImage && !pageIsBeingDismissed(document)) { m_failedLoadURL = attr; m_hasPendingErrorEvent = true; errorEventSender().dispatchEventSoon(*this); } else clearFailedLoadURL(); } else if (!attr.isNull()) { // Fire an error event if the url is empty. m_failedLoadURL = attr; m_hasPendingErrorEvent = true; errorEventSender().dispatchEventSoon(*this); } CachedImage* oldImage = m_image.get(); if (newImage != oldImage) { if (m_hasPendingBeforeLoadEvent) { beforeLoadEventSender().cancelEvent(*this); m_hasPendingBeforeLoadEvent = false; } if (m_hasPendingLoadEvent) { loadEventSender().cancelEvent(*this); m_hasPendingLoadEvent = false; } // Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute. // If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by // this load and we should not cancel the event. // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two. if (m_hasPendingErrorEvent && newImage) { errorEventSender().cancelEvent(*this); m_hasPendingErrorEvent = false; } m_image = newImage; m_hasPendingBeforeLoadEvent = !document.isImageDocument() && newImage; m_hasPendingLoadEvent = newImage; m_imageComplete = !newImage; if (newImage) { if (!document.isImageDocument()) { if (!document.hasListenerType(Document::BEFORELOAD_LISTENER)) dispatchPendingBeforeLoadEvent(); else beforeLoadEventSender().dispatchEventSoon(*this); } else updateRenderer(); // If newImage is cached, addClient() will result in the load event // being queued to fire. Ensure this happens after beforeload is // dispatched. newImage->addClient(this); } if (oldImage) oldImage->removeClient(this); } if (RenderImageResource* imageResource = renderImageResource()) imageResource->resetAnimation(); // Only consider updating the protection ref-count of the Element immediately before returning // from this function as doing so might result in the destruction of this ImageLoader. updatedHasPendingEvent(); }
void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY) { if (paintInfo.context->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN) return; paintInfo.context->save(); paintInfo.context->concatCTM(AffineTransform().translate(parentX, parentY)); paintInfo.context->concatCTM(localTransform()); paintInfo.context->concatCTM(translationForAttributes()); FloatRect boundingBox = FloatRect(0, 0, width(), height()); SVGElement* svgElement = static_cast<SVGElement*>(element()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement); const SVGRenderStyle* svgStyle = style()->svgStyle(); AtomicString filterId(SVGURIReference::getTarget(svgStyle->filter())); AtomicString clipperId(SVGURIReference::getTarget(svgStyle->clipPath())); AtomicString maskerId(SVGURIReference::getTarget(svgStyle->maskElement())); #if ENABLE(SVG_EXPERIMENTAL_FEATURES) SVGResourceFilter* filter = getFilterById(document(), filterId); #endif SVGResourceClipper* clipper = getClipperById(document(), clipperId); SVGResourceMasker* masker = getMaskerById(document(), maskerId); #if ENABLE(SVG_EXPERIMENTAL_FEATURES) if (filter) filter->prepareFilter(paintInfo.context, boundingBox); else if (!filterId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement); #endif if (clipper) { clipper->addClient(styledElement); clipper->applyClip(paintInfo.context, boundingBox); } else if (!clipperId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement); if (masker) { masker->addClient(styledElement); masker->applyMask(paintInfo.context, boundingBox); } else if (!maskerId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement); float opacity = style()->opacity(); if (opacity < 1.0f) { paintInfo.context->clip(enclosingIntRect(boundingBox)); paintInfo.context->beginTransparencyLayer(opacity); } PaintInfo pi(paintInfo); pi.rect = absoluteTransform().inverse().mapRect(pi.rect); SVGImageElement* imageElt = static_cast<SVGImageElement*>(node()); FloatRect destRect(m_x, m_y, contentWidth(), contentHeight()); FloatRect srcRect(0, 0, image()->width(), image()->height()); if (imageElt->preserveAspectRatio()->align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE) adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()); paintInfo.context->drawImage(image(), destRect, srcRect); #if ENABLE(SVG_EXPERIMENTAL_FEATURES) if (filter) filter->applyFilter(paintInfo.context, boundingBox); #endif if (opacity < 1.0f) paintInfo.context->endTransparencyLayer(); paintInfo.context->restore(); }
void BaseChooserOnlyDateAndTimeInputType::accessKeyAction(bool sendMouseEvents) { BaseDateAndTimeInputType::accessKeyAction(sendMouseEvents); BaseClickableWithKeyInputType::accessKeyAction(element(), sendMouseEvents); }
bool ScriptLoader::ignoresLoadRequest() const { return m_alreadyStarted || m_isExternalScript || m_parserInserted || !element() || !element()->inDocument(); }
bool EmailInputType::typeMismatch() const { return typeMismatchFor(element().value()); }
FloatRect RenderPath::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect&, const Path& path) const { Document* doc = document(); SVGElement* svgElement = static_cast<SVGElement*>(element()); ASSERT(svgElement && svgElement->document() && svgElement->isStyled()); SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement); const SVGRenderStyle* svgStyle = style()->svgStyle(); AtomicString startMarkerId(svgStyle->startMarker()); AtomicString midMarkerId(svgStyle->midMarker()); AtomicString endMarkerId(svgStyle->endMarker()); SVGResourceMarker* startMarker = getMarkerById(doc, startMarkerId); SVGResourceMarker* midMarker = getMarkerById(doc, midMarkerId); SVGResourceMarker* endMarker = getMarkerById(doc, endMarkerId); if (!startMarker && !startMarkerId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(startMarkerId, styledElement); else if (startMarker) startMarker->addClient(styledElement); if (!midMarker && !midMarkerId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(midMarkerId, styledElement); else if (midMarker) midMarker->addClient(styledElement); if (!endMarker && !endMarkerId.isEmpty()) svgElement->document()->accessSVGExtensions()->addPendingResource(endMarkerId, styledElement); else if (endMarker) endMarker->addClient(styledElement); if (!startMarker && !midMarker && !endMarker) return FloatRect(); double strokeWidth = SVGRenderStyle::cssPrimitiveToLength(this, svgStyle->strokeWidth(), 1.0f); DrawMarkersData data(context, startMarker, midMarker, strokeWidth); path.apply(&data, drawStartAndMidMarkers); data.previousMarkerData.marker = endMarker; data.previousMarkerData.type = End; drawMarkerWithData(context, data.previousMarkerData); // We know the marker boundaries, only after they're drawn! // Otherwhise we'd need to do all the marker calculation twice // once here (through paint()) and once in absoluteClippedOverflowRect(). FloatRect bounds; if (startMarker) bounds.unite(startMarker->cachedBounds()); if (midMarker) bounds.unite(midMarker->cachedBounds()); if (endMarker) bounds.unite(endMarker->cachedBounds()); return bounds; }
void NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior, ExceptionState& exceptionState) const { element().setValue(serializeForNumberType(newValue), eventBehavior); }
bool NumberInputType::typeMismatch() const { ASSERT(!typeMismatchFor(element().value())); return false; }
void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior) { if (!valueChanged && sanitizedValue.isEmpty() && !element().innerEditorValue().isEmpty()) element().updateView(); TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior); }
double NumberInputType::valueAsDouble() const { return parseToDoubleForNumberType(element().value()); }
TPZString asString() const { return TPZString(timeStamp()) + " " + element().asString(); }
bool BaseMultipleFieldsDateAndTimeInputType::isEditControlOwnerDisabled() const { return element()->disabled(); }
AtomicString BaseMultipleFieldsDateAndTimeInputType::localeIdentifier() const { return element()->computeInheritedLanguage(); }
LayoutObject* SearchInputType::createLayoutObject(const ComputedStyle&) const { return new LayoutSearchField(&element()); }
String NumberInputType::visibleValue() const { return localizeValue(element().value()); }
bool XSAXMLScanner::scanStartTag(bool& gotData) { // Assume we will still have data until proven otherwise. It will only // ever be false if this is the root and its empty. gotData = true; // Reset element content fContent.reset(); // The current position is after the open bracket, so we need to read in // in the element name. int prefixColonPos; if (!fReaderMgr.getQName(fQNameBuf, &prefixColonPos)) { if (fQNameBuf.isEmpty()) emitError(XMLErrs::ExpectedElementName); else emitError(XMLErrs::InvalidElementName, fQNameBuf.getRawBuffer()); fReaderMgr.skipToChar(chOpenAngle); return false; } // See if its the root element const bool isRoot = fElemStack.isEmpty(); // Skip any whitespace after the name fReaderMgr.skipPastSpaces(); // First we have to do the rawest attribute scan. We don't do any // normalization of them at all, since we don't know yet what type they // might be (since we need the element decl in order to do that.) const XMLCh* qnameRawBuf = fQNameBuf.getRawBuffer(); bool isEmpty; XMLSize_t attCount = rawAttrScan(qnameRawBuf, *fRawAttrList, isEmpty); // save the contentleafname and currentscope before addlevel, for later use ContentLeafNameTypeVector* cv = 0; XMLContentModel* cm = 0; unsigned int currentScope = Grammar::TOP_LEVEL_SCOPE; bool laxThisOne = false; if (!isRoot) { // schema validator will have correct type if validating SchemaElementDecl* tempElement = (SchemaElementDecl*) fElemStack.topElement()->fThisElement; SchemaElementDecl::ModelTypes modelType = tempElement->getModelType(); ComplexTypeInfo *currType = 0; if (fValidate) { currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo(); if (currType) modelType = (SchemaElementDecl::ModelTypes)currType->getContentType(); else // something must have gone wrong modelType = SchemaElementDecl::Any; } else { currType = tempElement->getComplexTypeInfo(); } if ((modelType == SchemaElementDecl::Mixed_Simple) || (modelType == SchemaElementDecl::Mixed_Complex) || (modelType == SchemaElementDecl::Children)) { cm = currType->getContentModel(); cv = cm->getContentLeafNameTypeVector(); currentScope = fElemStack.getCurrentScope(); } else if (modelType == SchemaElementDecl::Any) { laxThisOne = true; } } // Now, since we might have to update the namespace map for this element, // but we don't have the element decl yet, we just tell the element stack // to expand up to get ready. XMLSize_t elemDepth = fElemStack.addLevel(); fElemStack.setValidationFlag(fValidate); fElemStack.setPrefixColonPos(prefixColonPos); // Make an initial pass through the list and find any xmlns attributes or // schema attributes. if (attCount) scanRawAttrListforNameSpaces(attCount); // Resolve the qualified name to a URI and name so that we can look up // the element decl for this element. We have now update the prefix to // namespace map so we should get the correct element now. unsigned int uriId = resolveQNameWithColon ( qnameRawBuf, fPrefixBuf, ElemStack::Mode_Element, prefixColonPos ); //if schema, check if we should lax or skip the validation of this element bool parentValidation = fValidate; if (cv) { QName element(fPrefixBuf.getRawBuffer(), &qnameRawBuf[prefixColonPos + 1], uriId, fMemoryManager); // elementDepth will be > 0, as cv is only constructed if element is not // root. laxThisOne = laxElementValidation(&element, cv, cm, elemDepth - 1); } // Look up the element now in the grammar. This will get us back a // generic element decl object. We tell him to fault one in if he does // not find it. bool wasAdded = false; const XMLCh* nameRawBuf = &qnameRawBuf[prefixColonPos + 1]; XMLElementDecl* elemDecl = fGrammar->getElemDecl ( uriId, nameRawBuf, qnameRawBuf, currentScope ); if (!elemDecl) { // URI is different, so we try to switch grammar if (uriId != fURIStringPool->getId(fGrammar->getTargetNamespace())) { switchGrammar(getURIText(uriId), laxThisOne); } // look for a global element declaration elemDecl = fGrammar->getElemDecl( uriId, nameRawBuf, qnameRawBuf, Grammar::TOP_LEVEL_SCOPE ); if (!elemDecl) { // if still not found, look in list of undeclared elements elemDecl = fElemNonDeclPool->getByKey( nameRawBuf, uriId, (int)Grammar::TOP_LEVEL_SCOPE); if (!elemDecl) { elemDecl = new (fMemoryManager) SchemaElementDecl ( fPrefixBuf.getRawBuffer(), nameRawBuf, uriId , SchemaElementDecl::Any, Grammar::TOP_LEVEL_SCOPE , fMemoryManager ); elemDecl->setId (fElemNonDeclPool->put( (void*)elemDecl->getBaseName(), uriId, (int)Grammar::TOP_LEVEL_SCOPE, (SchemaElementDecl*)elemDecl)); wasAdded = true; } } } // We do something different here according to whether we found the // element or not. bool bXsiTypeSet= (fValidator)?((SchemaValidator*)fValidator)->getIsXsiTypeSet():false; if (wasAdded || !elemDecl->isDeclared()) { if (laxThisOne && !bXsiTypeSet) { fValidate = false; fElemStack.setValidationFlag(fValidate); } // If validating then emit an error if (fValidate) { // This is to tell the reuse Validator that this element was // faulted-in, was not an element in the grammar pool originally elemDecl->setCreateReason(XMLElementDecl::JustFaultIn); if(!bXsiTypeSet) fValidator->emitError ( XMLValid::ElementNotDefined, elemDecl->getFullName() ); } } // Now we can update the element stack to set the current element // decl. We expanded the stack above, but couldn't store the element // decl because we didn't know it yet. fElemStack.setElement(elemDecl, fReaderMgr.getCurrentReaderNum()); fElemStack.setCurrentURI(uriId); if (isRoot) { fRootElemName = XMLString::replicate(qnameRawBuf, fMemoryManager); } // Validate the element if (fValidate) { fValidator->validateElement(elemDecl); } // squirrel away the element's QName, so that we can do an efficient // end-tag match fElemStack.setCurrentSchemaElemName(fQNameBuf.getRawBuffer()); ComplexTypeInfo* typeinfo = (fValidate) ? ((SchemaValidator*)fValidator)->getCurrentTypeInfo() : ((SchemaElementDecl*) elemDecl)->getComplexTypeInfo(); if (typeinfo) { currentScope = typeinfo->getScopeDefined(); // switch grammar if the typeinfo has a different grammar XMLCh* typeName = typeinfo->getTypeName(); int comma = XMLString::indexOf(typeName, chComma); if (comma > 0) { XMLBufBid bbPrefix(&fBufMgr); XMLBuffer& prefixBuf = bbPrefix.getBuffer(); prefixBuf.append(typeName, comma); switchGrammar(prefixBuf.getRawBuffer(), laxThisOne); } } fElemStack.setCurrentScope(currentScope); // Set element next state if (elemDepth >= fElemStateSize) { resizeElemState(); } fElemState[elemDepth] = 0; fElemLoopState[elemDepth] = 0; fElemStack.setCurrentGrammar(fGrammar); // If this is the first element and we are validating, check the root // element. if (!isRoot && parentValidation) { fElemStack.addChild(elemDecl->getElementName(), true); } // Now lets get the fAttrList filled in. This involves faulting in any // defaulted and fixed attributes and normalizing the values of any that // we got explicitly. // // We update the attCount value with the total number of attributes, but // it goes in with the number of values we got during the raw scan of // explictly provided attrs above. attCount = buildAttList(*fRawAttrList, attCount, elemDecl, *fAttrList); if(attCount) { // clean up after ourselves: // clear the map used to detect duplicate attributes fUndeclaredAttrRegistry->removeAll(); } // Since the element may have default values, call start tag now regardless if it is empty or not // If we have a document handler, then tell it about this start tag if (fDocHandler) { fDocHandler->startElement ( *elemDecl, uriId, fPrefixBuf.getRawBuffer(), *fAttrList , attCount, false, isRoot ); } // may be where we output something... // If empty, validate content right now if we are validating and then // pop the element stack top. Else, we have to update the current stack // top's namespace mapping elements. if (isEmpty) { // Pop the element stack back off since it'll never be used now fElemStack.popTop(); // If validating, then insure that its legal to have no content if (fValidate) { XMLSize_t failure; bool res = fValidator->checkContent(elemDecl, 0, 0, &failure); if (!res) { // REVISIT: in the case of xsi:type, this may // return the wrong string... fValidator->emitError ( XMLValid::ElementNotValidForContent , elemDecl->getFullName() , elemDecl->getFormattedContentModel() ); } } // If we have a doc handler, tell it about the end tag if (fDocHandler) { fDocHandler->endElement ( *elemDecl, uriId, isRoot, fPrefixBuf.getRawBuffer() ); } // If the elem stack is empty, then it was an empty root if (isRoot) { gotData = false; } else { // Restore the grammar fGrammar = fElemStack.getCurrentGrammar(); fGrammarType = fGrammar->getGrammarType(); fValidator->setGrammar(fGrammar); // Restore the validation flag fValidate = fElemStack.getValidationFlag(); } } return true; }
bool NumberInputType::hasBadInput() const { String standardValue = convertFromVisibleValue(element().innerEditorValue()); return !standardValue.isEmpty() && !std::isfinite(parseToDoubleForNumberType(standardValue)); }
bool RenderPath::calculateLocalTransform() { TransformationMatrix oldTransform = m_localTransform; m_localTransform = static_cast<SVGStyledTransformableElement*>(element())->animatedLocalTransform(); return (m_localTransform != oldTransform); }
const T& operator()(const int nn) const { return element(nn); }
void BaseChooserOnlyDateAndTimeInputType::handleKeypressEvent(KeyboardEvent* event) { BaseClickableWithKeyInputType::handleKeypressEvent(element(), event); }
polynomial& operator=(const polynomial<T>& o) { vals = std::make_shared<std::vector<T>>(o.size()); copy_n(&o(0),o.size(),&element(0)); return *this; }
void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value) { element().setValue(value, DispatchInputAndChangeEvent); }
void qt_dbtreemodel_impl::_find_updated_rows( list_row* it, const string& sql ) { if ( !( _dbconn.get() && _dbconn->valid() && _root && _parent && it ) ) return; auto_ptr<list_row> clone( new list_row( _dbconn.get(), it->rowkeyfield(), it->level(), it->parent() ) ); clone->exec( sql.c_str() ); size_t num = 0; list_row::iterator unit = clone->begin(); bool setparent = false; QModelIndex unit_parent; while( unit != clone->end() ) { if( !setparent ) { // определяем родителя один раз unit_parent = parent(*unit); setparent = true; } list_row::iterator upd = find_if( it->begin(), it->end(), prow_eq(*unit) ); if( upd != it->end() ) { // найден строка -- проверить на предмет изменений bool for_update = false; for( int i = 0; i < (*upd)->size(); ++i ) { if( (**upd)[i] != (**unit)[i] ) { for_update = true; break; } } list_row *children = (*upd)->children(); if (children) { _find_updated_rows( children, children->sql() ); } if (for_update) { tree_element element( upd - it->begin(), *unit, unit_parent ); _updated[it].push_back( element ); unit = clone->erase( unit ); ++num; continue; } } else { tree_element element( num, *unit, unit_parent ); tree_elements :: iterator p = find( _inserted[it].begin(), _inserted[it].end(), element ); if( p == _inserted[it].end() ) { _inserted[it].push_back( element ); unit = clone->erase( unit ); ++num; continue; } } ++num; ++unit; } std::sort( _updated[it].begin(), _updated[it].end() ); std::sort( _inserted[it].begin(), _inserted[it].end() ); }
void DateTimeLocalInputType::warnIfValueIsInvalid(const String& value) const { if (value != element().sanitizeValue(value)) addWarningToConsole("The specified value %s does not conform to the required format. The format is \"yyyy-MM-ddThh:mm\" followed by optional \":ss\" or \":ss.SSS\".", value); }
void SearchInputType::searchEventTimerFired(Timer<SearchInputType>*) { element().onSearch(); }
void ImageLoader::timerFired(Timer<ImageLoader>&) { element().deref(); }
bool SearchInputType::searchEventsShouldBeDispatched() const { return element().hasAttribute(incrementalAttr); }
IntSize CSSCanvasValue::fixedSize(const RenderObject* renderer) { if (HTMLCanvasElement* elt = element(&renderer->document())) return IntSize(elt->width(), elt->height()); return IntSize(); }
bool BaseMultipleFieldsDateAndTimeInputType::isKeyboardFocusable(KeyboardEvent*) const { return element()->isTextFormControlFocusable(); }