| Index: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| index bf89d354ebb0401e3a1e7986bb1eb47a4c570fc8..6e6938883b290df59194b3a37710dd8167f0fb01 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLSlotElement.cpp
|
| @@ -51,6 +51,10 @@ inline HTMLSlotElement::HTMLSlotElement(Document& document)
|
| : HTMLElement(slotTag, document) {
|
| UseCounter::Count(document, UseCounter::kHTMLSlotElement);
|
| SetHasCustomStyleCallbacks();
|
| + // TODO(kochi): This is required for slot fallback contents to be matched
|
| + // against ::slotted() pseudo element in a document tree. Remove this once
|
| + // Shadow DOM V0 code is removed.
|
| + document.SetShadowCascadeOrder(ShadowCascadeOrder::kShadowCascadeV1);
|
| }
|
|
|
| DEFINE_NODE_FACTORY(HTMLSlotElement);
|
| @@ -60,6 +64,35 @@ AtomicString HTMLSlotElement::NormalizeSlotName(const AtomicString& name) {
|
| return (name.IsNull() || name.IsEmpty()) ? g_empty_atom : name;
|
| }
|
|
|
| +// static
|
| +HTMLSlotElement* HTMLSlotElement::FindFallbackSlotElementFor(
|
| + const Element& element) {
|
| + // Check if |element| is a fallback content.
|
| + Element* parent = element.parentElement();
|
| + if (!parent || !isHTMLSlotElement(parent) ||
|
| + !toHTMLSlotElement(parent)->AssignedNodes().IsEmpty())
|
| + return nullptr;
|
| +
|
| + // At this point, |parent| is an immediate parent of element, which is
|
| + // a <slot> with empty assigned nodes. This slot is one of the following:
|
| + // (1) doesn't have any slot in ancestor.
|
| + // (2) have a slot in ancestor which is assigned to another slot.
|
| + // (3) have a slot in ancestor which has assigned nodes.
|
| + // In cases (1) and (2), this slot is a fallback content.
|
| + // In case (3), this slot is not a fallback content.
|
| + HTMLSlotElement* slot = toHTMLSlotElement(parent);
|
| + while ((parent = parent->parentElement())) {
|
| + if (!isHTMLSlotElement(parent))
|
| + continue;
|
| + if (!toHTMLSlotElement(parent)->AssignedNodes().IsEmpty())
|
| + return nullptr;
|
| + slot = toHTMLSlotElement(parent);
|
| + if (slot->AssignedSlot())
|
| + break;
|
| + }
|
| + return slot;
|
| +}
|
| +
|
| const HeapVector<Member<Node>>& HTMLSlotElement::AssignedNodes() {
|
| DCHECK(!NeedsDistributionRecalc());
|
| DCHECK(IsInShadowTree() || assigned_nodes_.IsEmpty());
|
|
|