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) {
}
void SVGUseElement::BuildPendingResource() {
// Do not build the shadow/instance tree for nested <use> elements
// because they will get expanded in a second pass -- see
// ExpandUseElementsInShadowTree().
if (InUseShadowTree())
return;
// This runs just before computed style is updated, so this SVGUseElement
// should always be connected to the Document. It should also not be an
// SVGUseElement that is part of a shadow tree, since we should never
// schedule shadow tree updates for those.
DCHECK(!InUseShadowTree());
DCHECK(isConnected());
DetachShadowTree();
ClearResourceReference();
CancelShadowTreeRecreation();
if (!isConnected())
return;
DCHECK(isConnected());
auto* target = DynamicTo<SVGElement>(ResolveTargetElement(kAddObserver));
// TODO(fs): Why would the Element not be "connected" at this point?
if (target && target->isConnected())
if (target) {
DCHECK(target->isConnected());
AttachShadowTree(*target);
}
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