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

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

Issue 2875303002: Nested <use>s can resolve against an external resource (Closed)
Patch Set: Avoid adding observers for targets of nested <use> elements Created 3 years, 7 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 | « third_party/WebKit/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: third_party/WebKit/Source/core/svg/SVGUseElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
index 8577d27b879bb731073368583540b5c9d901e0e3..0f377678a831344253600b8021db28192d1dd1dd 100644
--- a/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGUseElement.cpp
@@ -298,10 +298,12 @@ void SVGUseElement::ClearResourceReference() {
RemoveAllOutgoingReferences();
}
-Element* SVGUseElement::ResolveTargetElement() {
+Element* SVGUseElement::ResolveTargetElement(ObserveBehavior observe_behavior) {
if (element_identifier_.IsEmpty())
return nullptr;
if (element_identifier_is_local_) {
+ if (observe_behavior == kDontAddObserver)
+ return GetTreeScope().getElementById(element_identifier_);
return ObserveTarget(target_id_observer_, GetTreeScope(),
element_identifier_,
WTF::Bind(&SVGUseElement::InvalidateShadowTree,
@@ -321,7 +323,7 @@ void SVGUseElement::BuildPendingResource() {
CancelShadowTreeRecreation();
if (!isConnected())
return;
- Element* target = ResolveTargetElement();
+ Element* target = ResolveTargetElement(kAddObserver);
// TODO(fs): Why would the Element not be "connected" at this point?
if (target && target->isConnected() && target->IsSVGElement()) {
BuildShadowAndInstanceTree(ToSVGElement(*target));
@@ -554,11 +556,10 @@ void SVGUseElement::CloneNonMarkupEventListeners() {
}
}
-bool SVGUseElement::HasCycleUseReferencing(const SVGUseElement& use,
+bool SVGUseElement::HasCycleUseReferencing(SVGUseElement& use,
const ContainerNode& target_instance,
SVGElement*& new_target) const {
- Element* target_element =
- TargetElementFromIRIString(use.HrefString(), use.GetTreeScope());
+ Element* target_element = use.ResolveTargetElement(kDontAddObserver);
pdr. 2017/05/13 03:10:50 Can you help me understand why we don't want to ad
fs 2017/05/13 08:24:06 We don't want to add an observer, because the elem
new_target = 0;
if (target_element && target_element->IsSVGElement())
new_target = ToSVGElement(target_element);
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGUseElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698