Commit e0d44b5b authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Document invariants in SVGUseElement::BuildPendingResource

When a <use> is scheduled to have its shadow tree built it should be
connected to the document and be the outermost <use>. The Element it
references should also be connected to the document (if it exists).

Simplify the code according to the above and add DCHECKs.

Bug: 997176
Change-Id: I4e9954df674b1dfdc5c1e674ea81df2f6e84d5da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768522Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#690391}
parent 13370095
...@@ -315,21 +315,23 @@ Element* SVGUseElement::ResolveTargetElement(ObserveBehavior observe_behavior) { ...@@ -315,21 +315,23 @@ Element* SVGUseElement::ResolveTargetElement(ObserveBehavior observe_behavior) {
} }
void SVGUseElement::BuildPendingResource() { void SVGUseElement::BuildPendingResource() {
// Do not build the shadow/instance tree for nested <use> elements // This runs just before computed style is updated, so this SVGUseElement
// because they will get expanded in a second pass -- see // should always be connected to the Document. It should also not be an
// ExpandUseElementsInShadowTree(). // SVGUseElement that is part of a shadow tree, since we should never
if (InUseShadowTree()) // schedule shadow tree updates for those.
return; DCHECK(!InUseShadowTree());
DCHECK(isConnected());
DetachShadowTree(); DetachShadowTree();
ClearResourceReference(); ClearResourceReference();
CancelShadowTreeRecreation(); CancelShadowTreeRecreation();
if (!isConnected()) DCHECK(isConnected());
return;
auto* target = DynamicTo<SVGElement>(ResolveTargetElement(kAddObserver)); auto* target = DynamicTo<SVGElement>(ResolveTargetElement(kAddObserver));
// TODO(fs): Why would the Element not be "connected" at this point? if (target) {
if (target && target->isConnected()) DCHECK(target->isConnected());
AttachShadowTree(*target); AttachShadowTree(*target);
}
DCHECK(!needs_shadow_tree_recreation_); DCHECK(!needs_shadow_tree_recreation_);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment