void SVGUseElement::buildPendingResource() { if (inUseShadowTree()) return; clearShadowTree(); cancelShadowTreeRecreation(); if (!referencedScope() || !inDocument()) return; AtomicString id; Element* target = SVGURIReference::targetElementFromIRIString(hrefString(), treeScope(), &id, externalDocument()); if (!target || !target->inDocument()) { // If we can't find the target of an external element, just give up. // We can't observe if the target somewhen enters the external document, nor should we do it. if (externalDocument()) return; if (id.isEmpty()) return; referencedScope()->document().accessSVGExtensions().addPendingResource(id, this); ASSERT(hasPendingResources()); return; } if (target->isSVGElement()) { buildShadowAndInstanceTree(toSVGElement(target)); invalidateDependentShadowTrees(); } ASSERT(!m_needsShadowTreeRecreation); }
void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) { if (SVGURIReference::isKnownAttribute(attrName)) { SVGElement::InvalidationGuard invalidationGuard(this); m_loader->handleSourceAttribute(hrefString()); return; } SVGElement::svgAttributeChanged(attrName); }
PassRefPtrWillBeRawPtr<FilterEffect> SVGFEImageElement::build(SVGFilterBuilder*, Filter* filter) { if (m_cachedImage) { // Don't use the broken image icon on image loading errors. RefPtr<Image> image = m_cachedImage->errorOccurred() ? nullptr : m_cachedImage->image(); return FEImage::createWithImage(filter, image, m_preserveAspectRatio->currentValue()); } return FEImage::createWithIRIReference(filter, treeScope(), hrefString(), m_preserveAspectRatio->currentValue()); }
void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) { if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) { SVGElement::InvalidationGuard invalidationGuard(this); if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr) { invalidateSVGPresentationAttributeStyle(); setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::fromAttribute(attrName)); } updateRelativeLengthsInformation(); if (m_targetElementInstance) { ASSERT(m_targetElementInstance->correspondingElement()); transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance.get(), *m_targetElementInstance->correspondingElement()); } LayoutObject* object = this->layoutObject(); if (object) markForLayoutAndParentResourceInvalidation(object); return; } if (SVGURIReference::isKnownAttribute(attrName)) { SVGElement::InvalidationGuard invalidationGuard(this); if (isStructurallyExternal()) { KURL url = document().completeURL(hrefString()); const KURL& existingURL = m_resource ? m_resource->url() : KURL(); if (url.hasFragmentIdentifier() && !equalIgnoringFragmentIdentifier(url, existingURL)) { FetchRequest request(ResourceRequest(url), localName()); setDocumentResource(DocumentResource::fetchSVGDocument(request, document().fetcher())); } } else { setDocumentResource(nullptr); } invalidateShadowTree(); return; } SVGGraphicsElement::svgAttributeChanged(attrName); }
void SVGUseElement::updateTargetReference() { SVGURLReferenceResolver resolver(hrefString(), document()); m_elementIdentifier = resolver.fragmentIdentifier(); m_elementIdentifierIsLocal = resolver.isLocal(); if (m_elementIdentifierIsLocal) { setDocumentResource(nullptr); return; } KURL resolvedUrl = resolver.absoluteUrl(); if (m_elementIdentifier.isEmpty() || (m_resource && equalIgnoringFragmentIdentifier(resolvedUrl, m_resource->url()))) return; FetchRequest request(ResourceRequest(resolvedUrl), localName()); setDocumentResource( DocumentResource::fetchSVGDocument(request, document().fetcher())); }
void SVGAElement::svgAttributeChanged(const QualifiedName& attrName) { // Unlike other SVG*Element classes, SVGAElement only listens to SVGURIReference changes // as none of the other properties changes the linking behaviour for our <a> element. if (SVGURIReference::isKnownAttribute(attrName)) { SVGElement::InvalidationGuard invalidationGuard(this); bool wasLink = isLink(); setIsLink(!hrefString().isNull()); if (wasLink != isLink()) setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::LinkColorChange)); return; } SVGGraphicsElement::svgAttributeChanged(attrName); }
void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) { if (!isSupportedAttribute(attrName)) { SVGElement::svgAttributeChanged(attrName); return; } SVGElement::InvalidationGuard invalidationGuard(this); if (attrName == SVGNames::typeAttr || attrName == HTMLNames::onerrorAttr) return; if (SVGURIReference::isKnownAttribute(attrName)) { m_loader->handleSourceAttribute(hrefString()); return; } ASSERT_NOT_REACHED(); }
void SVGAElement::defaultEventHandler(Event* event) { if (isLink()) { ASSERT(event->target()); Node* target = event->target()->toNode(); ASSERT(target); if ((focused() || target->focused()) && isEnterKeyKeypressEvent(event)) { event->setDefaultHandled(); dispatchSimulatedClick(event); return; } if (isLinkClick(event)) { String url = stripLeadingAndTrailingHTMLSpaces(hrefString()); if (url[0] == '#') { Element* targetElement = treeScope().getElementById(AtomicString(url.substring(1))); if (targetElement && isSVGSMILElement(*targetElement)) { toSVGSMILElement(targetElement)->beginByLinkActivation(); event->setDefaultHandled(); return; } } AtomicString target(m_svgTarget->currentValue()->value()); if (target.isEmpty() && fastGetAttribute(XLinkNames::showAttr) == "new") target = AtomicString("_blank", AtomicString::ConstructFromLiteral); event->setDefaultHandled(); LocalFrame* frame = document().frame(); if (!frame) return; FrameLoadRequest frameRequest(&document(), ResourceRequest(document().completeURL(url)), target); frameRequest.setTriggeringEvent(event); frame->loader().load(frameRequest); return; } } SVGGraphicsElement::defaultEventHandler(event); }
void SVGFEImageElement::buildPendingResource() { clearResourceReferences(); if (!inDocument()) return; AtomicString id; Element* target = SVGURIReference::targetElementFromIRIString(hrefString(), treeScope(), &id); if (!target) { if (id.isEmpty()) { fetchImageResource(); } else { document().accessSVGExtensions().addPendingResource(id, this); ASSERT(hasPendingResources()); } } else if (target->isSVGElement()) { // Register us with the target in the dependencies map. Any change of hrefElement // that leads to relayout/repainting now informs us, so we can react to it. addReferenceTo(toSVGElement(target)); } invalidate(); }
const AtomicString SVGImageElement::imageSourceURL() const { return AtomicString(hrefString()); }
SVGPathElement* SVGMPathElement::pathElement() { Element* target = targetElementFromIRIString(hrefString(), treeScope()); return isSVGPathElement(target) ? toSVGPathElement(target) : 0; }
String SVGScriptElement::sourceAttributeValue() const { return hrefString(); }
KURL SVGURIReference::legacyHrefURL(const Document& document) const { return document.completeURL(stripLeadingAndTrailingHTMLSpaces(hrefString())); }