Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: Source/core/svg/SVGUseElement.cpp

Issue 269843002: Use m_targetElementInstance in fewer places (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGUseElement.cpp
diff --git a/Source/core/svg/SVGUseElement.cpp b/Source/core/svg/SVGUseElement.cpp
index 82701d0b4c2d78767fd02c75f80906475ed450ca..9dba7e31c49bdf02a08d7986044b12a592b5767d 100644
--- a/Source/core/svg/SVGUseElement.cpp
+++ b/Source/core/svg/SVGUseElement.cpp
@@ -491,25 +491,27 @@ void SVGUseElement::buildShadowAndInstanceTree(SVGElement* target)
// Expand means: replace the actual <symbol> element by the <svg> element.
expandSymbolElementsInShadowTree(shadowTreeRootElement);
+ Node* shadowTreeTargetNode = shadowTreeRootElement->firstChild();
// Now that the shadow tree is completly expanded, we can associate
// shadow tree elements <-> instances in the instance tree.
- associateInstancesWithShadowTreeElements(shadowTreeRootElement->firstChild(), m_targetElementInstance.get());
-
- ASSERT(m_targetElementInstance->correspondingElement());
- transferUseWidthAndHeightIfNeeded(*this, m_targetElementInstance->shadowTreeElement(), *m_targetElementInstance->correspondingElement());
+ associateInstancesWithShadowTreeElements(shadowTreeTargetNode, m_targetElementInstance.get());
pdr. 2014/05/03 21:02:08 Can this be moved below the !shadowTreeTargetNode
// If no shadow tree element is present, this means that the reference root
// element was removed, as it is disallowed (ie. <use> on <foreignObject>)
// Do NOT leave an inconsistent instance tree around, instead destruct it.
- if (!m_targetElementInstance->shadowTreeElement()) {
+ if (!shadowTreeTargetNode) {
clearResourceReferences();
return;
}
- ASSERT(m_targetElementInstance->shadowTreeElement()->parentNode() == shadowTreeRootElement);
+ SVGElement* shadowTreeTargetElement = toSVGElement(shadowTreeTargetNode);
+ ASSERT(shadowTreeTargetElement->correspondingElement());
+ transferUseWidthAndHeightIfNeeded(*this, shadowTreeTargetElement, *shadowTreeTargetElement->correspondingElement());
+
+ ASSERT(shadowTreeTargetNode()->parentNode() == shadowTreeRootElement);
// Transfer event listeners assigned to the referenced element to our shadow tree elements.
- transferEventListenersToShadowTree(m_targetElementInstance.get());
+ transferEventListenersToShadowTree(shadowTreeTargetElement);
// Update relative length information.
updateRelativeLengthsInformation();
@@ -551,7 +553,7 @@ void SVGUseElement::toClipPath(Path& path)
{
ASSERT(path.isEmpty());
- Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0;
+ Node* n = userAgentShadowRoot()->firstChild();
if (!n)
return;
@@ -571,12 +573,10 @@ void SVGUseElement::toClipPath(Path& path)
RenderObject* SVGUseElement::rendererClipChild() const
{
- Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0;
- if (!n)
- return 0;
-
- if (n->isSVGElement() && isDirectReference(*n))
- return toSVGElement(n)->renderer();
+ if (Node* n = userAgentShadowRoot()->firstChild()) {
+ if (n->isSVGElement() && isDirectReference(*n))
+ return toSVGElement(n)->renderer();
+ }
return 0;
}
@@ -808,21 +808,18 @@ void SVGUseElement::expandSymbolElementsInShadowTree(Node* element)
expandSymbolElementsInShadowTree(child.get());
}
-void SVGUseElement::transferEventListenersToShadowTree(SVGElementInstance* target)
+void SVGUseElement::transferEventListenersToShadowTree(SVGElement* shadowElement)
pdr. 2014/05/03 21:02:08 For consistency, can we call this the shadowTreeTa
{
- if (!target)
+ if (!shadowElement)
return;
- SVGElement* originalElement = target->correspondingElement();
+ SVGElement* originalElement = shadowElement->correspondingElement();
ASSERT(originalElement);
+ if (EventTargetData* data = originalElement->eventTargetData())
+ data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(shadowElement);
- if (SVGElement* shadowTreeElement = target->shadowTreeElement()) {
- if (EventTargetData* data = originalElement->eventTargetData())
- data->eventListenerMap.copyEventListenersNotCreatedFromMarkupToTarget(shadowTreeElement);
- }
-
- for (SVGElementInstance* instance = target->firstChild(); instance; instance = instance->nextSibling())
- transferEventListenersToShadowTree(instance);
+ for (SVGElement* child = Traversal<SVGElement>::firstChild(*shadowElement); child; child = Traversal<SVGElement>::nextSibling(*child))
+ transferEventListenersToShadowTree(child);
}
void SVGUseElement::associateInstancesWithShadowTreeElements(Node* target, SVGElementInstance* targetInstance)
« no previous file with comments | « Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698