Commit 4e5ac5ac authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Add the "is declarative shadow root" flag, and set it appropriately

This CL implements the "is declarative shadow root" flag, and makes
sure it gets set or cleared appropriately.

This flag will be used in a followup CL, which modifies the behavior
of attachShadow() to allow "overriding" a declarative shadow root.
But in this CL, expect no behavior changes.

Bug: 1042130
Change-Id: I335df00967c2fa9dcce4ded8f6a7cb208a901e68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2155995
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760720}
parent bd024558
......@@ -3774,8 +3774,9 @@ void Element::AttachDeclarativeShadowRoot(HTMLTemplateElement* template_element,
}
ShadowRoot& shadow_root =
AttachShadowRootInternal(type, focus_delegation, slot_assignment);
// 13.1. TODO(masonfreed): Set declarative shadow host element's shadow host's
// is declarative shadow root property to true.
// 13.1. Set declarative shadow host element's shadow host's "is declarative
// shadow root" property to true.
shadow_root.SetIsDeclarativeShadowRoot(true);
// 13.2. Append the declarative template element's DocumentFragment to the
// newly-created shadow root.
shadow_root.appendChild(template_element->DeclarativeShadowContent());
......@@ -3806,10 +3807,10 @@ ShadowRoot& Element::AttachShadowRootInternal(
// 9. Set shadow host’s shadow root to shadow.
ShadowRoot& shadow_root = CreateAndAttachShadowRoot(type);
// 7. Set shadow’s delegates focus to delegates focus.
// 8. TODO(masonfreed): Set shadow’s is declarative shadow root property to
// false.
shadow_root.SetDelegatesFocus(focus_delegation ==
FocusDelegation::kDelegateFocus);
// 8. Set shadow’s "is declarative shadow root" property to false.
shadow_root.SetIsDeclarativeShadowRoot(false);
shadow_root.SetSlotAssignmentMode(slot_assignment_mode);
return shadow_root;
}
......
......@@ -156,6 +156,11 @@ class CORE_EXPORT ShadowRoot final : public DocumentFragment, public TreeScope {
return IsManualSlotting() ? "manual" : "auto";
}
void SetIsDeclarativeShadowRoot(bool flag) {
is_declarative_shadow_root_ = flag;
}
bool IsDeclarativeShadowRoot() const { return is_declarative_shadow_root_; }
bool ContainsShadowRoots() const { return child_shadow_root_count_; }
StyleSheetList& StyleSheets();
......@@ -187,8 +192,9 @@ class CORE_EXPORT ShadowRoot final : public DocumentFragment, public TreeScope {
unsigned registered_with_parent_shadow_root_ : 1;
unsigned delegates_focus_ : 1;
unsigned slot_assignment_mode_ : 1;
unsigned is_declarative_shadow_root_ : 1;
unsigned needs_distribution_recalc_ : 1;
unsigned unused_ : 10;
unsigned unused_ : 9;
DISALLOW_COPY_AND_ASSIGN(ShadowRoot);
};
......
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