void SVGFEImageElement::buildPendingResource() { clearResourceReferences(); if (!inDocument()) return; String id; Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!target) { if (hasPendingResources()) return; if (id.isEmpty()) requestImageResource(); 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. document()->accessSVGExtensions()->addElementReferencingTarget(this, static_cast<SVGElement*>(target)); } invalidate(); }
void SVGMPathElement::buildPendingResource() { clearResourceReferences(); if (!inDocument()) return; String id; Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!target) { // Do not register as pending if we are already pending this resource. if (document().accessSVGExtensions()->isPendingResource(this, id)) return; if (!id.isEmpty()) { 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. document().accessSVGExtensions()->addElementReferencingTarget(this, toSVGElement(target)); } targetPathChanged(); }
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 SVGTRefElement::buildPendingResource() { // Remove any existing event listener. m_targetListener->detach(); // If we're not yet in a document, this function will be called again from insertedInto(). if (!inDocument()) return; String id; RefPtr<Element> target = SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!target.get()) { if (id.isEmpty()) return; document().accessSVGExtensions().addPendingResource(id, this); ASSERT(hasPendingResources()); return; } // Don't set up event listeners if this is a shadow tree node. // SVGUseElement::transferEventListenersToShadowTree() handles this task, and addEventListener() // expects every element instance to have an associated shadow tree element - which is not the // case when we land here from SVGUseElement::buildShadowTree(). if (!isInShadowTree()) m_targetListener->attach(target); updateReferencedText(target.get()); }
void SVGUseElement::insertedIntoDocument() { // This functions exists to assure assumptions made in the code regarding SVGElementInstance creation/destruction are satisfied. SVGStyledTransformableElement::insertedIntoDocument(); ASSERT(!m_targetElementInstance || !isWellFormedDocument(document())); ASSERT(!hasPendingResources() || !isWellFormedDocument(document())); }
void SVGUseElement::svgAttributeChanged(const QualifiedName& attrName) { SVGStyledTransformableElement::svgAttributeChanged(attrName); bool isXYAttribute = attrName == SVGNames::xAttr || attrName == SVGNames::yAttr; bool isWidthHeightAttribute = attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr; if (isXYAttribute || isWidthHeightAttribute) updateRelativeLengthsInformation(); if (SVGTests::handleAttributeChange(this, attrName)) return; RenderObject* object = renderer(); if (!object) return; if (SVGURIReference::isKnownAttribute(attrName)) { if (hasPendingResources()) { OwnPtr<SVGDocumentExtensions::SVGPendingElements> clients(document()->accessSVGExtensions()->removePendingResource(m_resourceId)); ASSERT(!clients->isEmpty()); const SVGDocumentExtensions::SVGPendingElements::const_iterator end = clients->end(); for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients->begin(); it != end; ++it) { ASSERT((*it)->hasPendingResources()); (*it)->setHasPendingResources(false); } m_resourceId = String(); setHasPendingResources(false); } invalidateShadowTree(); return; } if (isXYAttribute) { updateContainerOffsets(); return; } if (isWidthHeightAttribute) { updateContainerSizes(); return; } // Be very careful here, if svgAttributeChanged() has been called because a SVG CSS property changed, we do NOT want to reclone the tree! if (SVGStyledElement::isKnownAttribute(attrName)) { setNeedsStyleRecalc(); return; } if (SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName)) invalidateShadowTree(); }
void HTMLImportLoader::notifyParserStopped() { setState(finishParsing()); if (!hasPendingResources()) setState(finishLoading()); DocumentParser* parser = m_document->parser(); ASSERT(parser); parser->removeClient(this); }
Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode* rootParent) { // This functions exists to assure assumptions made in the code regarding SVGElementInstance creation/destruction are satisfied. SVGGraphicsElement::insertedInto(rootParent); if (!rootParent->inDocument()) return InsertionDone; ASSERT(!m_targetElementInstance || !isWellFormedDocument(&document())); ASSERT(!hasPendingResources() || !isWellFormedDocument(&document())); invalidateShadowTree(); return InsertionDone; }
void SVGFEImageElement::buildPendingResource() { clearResourceReferences(); if (!inDocument()) return; String id; Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!target) { if (hasPendingResources()) return; if (id.isEmpty()) requestImageResource(); else { document()->accessSVGExtensions()->addPendingResource(id, this); ASSERT(hasPendingResources()); } } invalidate(); }
Node::InsertionNotificationRequest SVGUseElement::insertedInto(ContainerNode& rootParent) { // This functions exists to assure assumptions made in the code regarding SVGElementInstance creation/destruction are satisfied. SVGGraphicsElement::insertedInto(rootParent); if (!rootParent.inDocument()) return InsertionDone; ASSERT(!m_targetElementInstance || !isWellFormedDocument(document())); ASSERT(!hasPendingResources() || !isWellFormedDocument(document())); if (!m_wasInsertedByParser) buildPendingResource(); SVGExternalResourcesRequired::insertedIntoDocument(this); return InsertionDone; }
void SVGSMILElement::buildPendingResource() { clearResourceAndEventBaseReferences(); if (!isConnected()) { // Reset the target element if we are no longer in the document. setTargetElement(nullptr); return; } AtomicString id; const AtomicString& href = SVGURIReference::legacyHrefString(*this); Element* target; if (href.isEmpty()) target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : nullptr; else target = SVGURIReference::targetElementFromIRIString(href, treeScope(), &id); SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : nullptr; if (svgTarget && !svgTarget->isConnected()) svgTarget = nullptr; if (svgTarget != targetElement()) setTargetElement(svgTarget); if (!svgTarget) { // Do not register as pending if we are already pending this resource. if (document().accessSVGExtensions().isElementPendingResource(this, id)) return; if (!id.isEmpty()) { document().accessSVGExtensions().addPendingResource(id, this); ASSERT(hasPendingResources()); } } else { // 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(svgTarget); } connectEventBaseConditions(); }
void SVGTRefElement::detachTarget() { // Remove active listeners and clear the text content. clearEventListener(); String emptyContent; ExceptionCode ignore = 0; ASSERT(hasShadowRoot()); Node* container = shadowTree()->oldestShadowRoot()->firstChild(); if (container) container->setTextContent(emptyContent, ignore); // Mark the referenced ID as pending. String id; SVGURIReference::targetElementFromIRIString(href(), document(), &id); if (!hasPendingResources() && !id.isEmpty()) document()->accessSVGExtensions()->addPendingResource(id, this); }
void SVGSMILElement::buildPendingResource() { clearResourceReferences(); if (!inDocument()) { // Reset the target element if we are no longer in the document. setTargetElement(0); return; } String id; String href = getAttribute(XLinkNames::hrefAttr); Element* target; if (href.isEmpty()) target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : 0; else target = SVGURIReference::targetElementFromIRIString(href, document(), &id); SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : 0; if (svgTarget && !svgTarget->inDocument()) svgTarget = 0; if (svgTarget != targetElement()) setTargetElement(svgTarget); if (!svgTarget) { // Do not register as pending if we are already pending this resource. if (document().accessSVGExtensions()->isElementPendingResource(this, id)) return; if (!id.isEmpty()) { document().accessSVGExtensions()->addPendingResource(id, this); ASSERT(hasPendingResources()); } } else { // 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. document().accessSVGExtensions()->addElementReferencingTarget(this, svgTarget); } }
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(); }
void HTMLImportLoader::didFinishParsing() { setState(finishParsing()); if (!hasPendingResources()) setState(finishLoading()); }