Commit f4f38664 authored by Hayato Ito's avatar Hayato Ito Committed by Commit Bot

Do some cleanups in HTMLSlotElement

There should be no functional changes from this patch.

Bug: 776656
Change-Id: I975e32a2cd2fa2610352ce1c85f10b3afe5bc688
Reviewed-on: https://chromium-review.googlesource.com/897288Reviewed-by: default avatarTakayoshi Kochi <kochi@chromium.org>
Commit-Queue: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533965}
parent 9a622078
......@@ -254,7 +254,6 @@ Node* HTMLSlotElement::AssignedNodeNextTo(const Node& node) const {
DCHECK(RuntimeEnabledFeatures::IncrementalShadowDOMEnabled());
DCHECK(SupportsAssignment());
ContainingShadowRoot()->GetSlotAssignment().ResolveAssignmentNg();
// TODO(crbug.com/776656): Assert that assigned_nodes_ is up-to-date.
// TODO(crbug.com/776656): Use {node -> index} map to avoid O(N) lookup
size_t index = assigned_nodes_.Find(&node);
DCHECK(index != WTF::kNotFound);
......@@ -267,7 +266,6 @@ Node* HTMLSlotElement::AssignedNodePreviousTo(const Node& node) const {
DCHECK(RuntimeEnabledFeatures::IncrementalShadowDOMEnabled());
DCHECK(SupportsAssignment());
ContainingShadowRoot()->GetSlotAssignment().ResolveAssignmentNg();
// TODO(crbug.com/776656): Assert that assigned_nodes_ is up-to-date.
// TODO(crbug.com/776656): Use {node -> index} map to avoid O(N) lookup
size_t index = assigned_nodes_.Find(&node);
DCHECK(index != WTF::kNotFound);
......@@ -277,6 +275,7 @@ Node* HTMLSlotElement::AssignedNodePreviousTo(const Node& node) const {
}
Node* HTMLSlotElement::DistributedNodeNextTo(const Node& node) const {
DCHECK(!RuntimeEnabledFeatures::IncrementalShadowDOMEnabled());
DCHECK(SupportsAssignment());
const auto& it = distributed_indices_.find(&node);
if (it == distributed_indices_.end())
......@@ -288,6 +287,7 @@ Node* HTMLSlotElement::DistributedNodeNextTo(const Node& node) const {
}
Node* HTMLSlotElement::DistributedNodePreviousTo(const Node& node) const {
DCHECK(!RuntimeEnabledFeatures::IncrementalShadowDOMEnabled());
DCHECK(SupportsAssignment());
const auto& it = distributed_indices_.find(&node);
if (it == distributed_indices_.end())
......@@ -317,11 +317,15 @@ void HTMLSlotElement::AttachLayoutTree(AttachContext& context) {
}
}
// TODO(hayato): Rename this function once we enable IncrementalShadowDOM
// by default because this function doesn't consider fallback elements in case
// of IncementalShadowDOM.
const HeapVector<Member<Node>>&
HTMLSlotElement::ChildrenInFlatTreeIfAssignmentIsSupported() {
return RuntimeEnabledFeatures::IncrementalShadowDOMEnabled()
? AssignedNodes()
: distributed_nodes_;
if (RuntimeEnabledFeatures::IncrementalShadowDOMEnabled())
return AssignedNodes();
DCHECK(!NeedsDistributionRecalc());
return distributed_nodes_;
}
void HTMLSlotElement::DetachLayoutTree(const AttachContext& context) {
......
......@@ -158,9 +158,12 @@ class CORE_EXPORT HTMLSlotElement final : public HTMLElement {
const HeapVector<Member<Node>>& GetDistributedNodes();
HeapVector<Member<Node>> assigned_nodes_;
// For Non-IncrmentalShadowDOM. IncremntalShadowDOM never use these members.
HeapVector<Member<Node>> distributed_nodes_;
HeapVector<Member<Node>> old_distributed_nodes_;
HeapHashMap<Member<const Node>, size_t> distributed_indices_;
bool slotchange_event_enqueued_ = false;
// TODO(hayato): Move this to more appropriate directory (e.g. platform/wtf)
......
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