Commit 12e739ce authored by Takayoshi Kochi's avatar Takayoshi Kochi Committed by Commit Bot

Simplify logic for <shadow> distribution.

We no longer have multiple shadow roots, <shadow> behaves almost
identical to <content> without select attribute.
We only have to care for the case when <content> and <shadow> are
used in the same shadow root.

This CL simplifies code that used to handle multiple shadow cases
for <shadow> elements in V0 distribution logic.

No visible behavioral change is expected.

Bug: 624724
Change-Id: I88f237f2d26519cd400ef13605f4b3115843b4b7
Reviewed-on: https://chromium-review.googlesource.com/923446Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Commit-Queue: Takayoshi Kochi <kochi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537592}
parent 39e3d01a
...@@ -155,18 +155,15 @@ ElementShadowV0::DestinationInsertionPointsFor(const Node* key) const { ...@@ -155,18 +155,15 @@ ElementShadowV0::DestinationInsertionPointsFor(const Node* key) const {
} }
void ElementShadowV0::Distribute() { void ElementShadowV0::Distribute() {
HeapVector<Member<HTMLShadowElement>, 32> shadow_insertion_points;
DistributionPool pool(element_shadow_->Host()); DistributionPool pool(element_shadow_->Host());
ShadowRoot& root = GetShadowRoot();
HTMLShadowElement* shadow_insertion_point = nullptr; HTMLShadowElement* shadow_insertion_point = nullptr;
for (const auto& point : root.DescendantInsertionPoints()) {
for (const auto& point : GetShadowRoot().DescendantInsertionPoints()) {
if (!point->IsActive()) if (!point->IsActive())
continue; continue;
if (auto* shadow = ToHTMLShadowElementOrNull(*point)) { if (auto* shadow = ToHTMLShadowElementOrNull(*point)) {
DCHECK(!shadow_insertion_point); DCHECK(!shadow_insertion_point);
shadow_insertion_point = shadow; shadow_insertion_point = shadow;
shadow_insertion_points.push_back(shadow_insertion_point);
} else { } else {
pool.DistributeTo(point, this); pool.DistributeTo(point, this);
if (ElementShadow* shadow = if (ElementShadow* shadow =
...@@ -178,10 +175,7 @@ void ElementShadowV0::Distribute() { ...@@ -178,10 +175,7 @@ void ElementShadowV0::Distribute() {
} }
} }
for (size_t i = shadow_insertion_points.size(); i > 0; --i) { if (shadow_insertion_point) {
HTMLShadowElement* shadow_insertion_point = shadow_insertion_points[i - 1];
ShadowRoot* root = shadow_insertion_point->ContainingShadowRoot();
DCHECK(root);
pool.DistributeTo(shadow_insertion_point, this); pool.DistributeTo(shadow_insertion_point, this);
if (ElementShadow* shadow = if (ElementShadow* shadow =
ShadowWhereNodeCanBeDistributedForV0(*shadow_insertion_point)) ShadowWhereNodeCanBeDistributedForV0(*shadow_insertion_point))
......
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