Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Unified Diff: third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp

Issue 1872303002: Simplify slot assignments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: :) Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp
diff --git a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp
index 2c8a2ed430baf716e62b7bb6cdb3b1f2d016f00d..12632179e87871347659c0991a8d4657bd557cab 100644
--- a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp
+++ b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.cpp
@@ -25,57 +25,36 @@ static void detachNotAssignedNode(Node& node)
node.lazyReattachIfAttached();
}
-inline static bool isDefaultSlotName(const AtomicString& name)
-{
- return name.isNull() || name.isEmpty();
-}
-
void SlotAssignment::resolveAssignment(ShadowRoot& shadowRoot)
{
m_assignment.clear();
using Name2Slot = HeapHashMap<AtomicString, Member<HTMLSlotElement>>;
Name2Slot name2slot;
- HTMLSlotElement* defaultSlot = nullptr;
const HeapVector<Member<HTMLSlotElement>>& slots = shadowRoot.descendantSlots();
for (Member<HTMLSlotElement> slot : slots) {
slot->willUpdateDistribution();
- AtomicString name = slot->fastGetAttribute(HTMLNames::nameAttr);
- if (isDefaultSlotName(name)) {
- if (!defaultSlot)
- defaultSlot = slot.get();
- } else {
- name2slot.add(name, slot.get());
- }
+ name2slot.add(slot->name(), slot.get());
}
for (Node& child : NodeTraversal::childrenOf(*shadowRoot.host())) {
- if (child.isElementNode()) {
- if (isActiveInsertionPoint(child)) {
- // TODO(hayato): Support re-distribution across v0 and v1 shadow trees
- detachNotAssignedNode(child);
- continue;
- }
- AtomicString slotName = toElement(child).fastGetAttribute(HTMLNames::slotAttr);
- if (isDefaultSlotName(slotName)) {
- if (defaultSlot)
- assign(child, *defaultSlot);
- else
- detachNotAssignedNode(child);
- } else {
- HTMLSlotElement* slot = name2slot.get(slotName);
- if (slot)
- assign(child, *slot);
- else
- detachNotAssignedNode(child);
- }
- } else if (defaultSlot && child.isTextNode()) {
- assign(child, *defaultSlot);
- } else {
+ if (child.isElementNode() && isActiveInsertionPoint(child)) {
+ // TODO(hayato): Support re-distribution across v0 and v1 shadow trees
detachNotAssignedNode(child);
+ continue;
}
+ if (!child.slottable()) {
+ detachNotAssignedNode(child);
+ continue;
+ }
+ AtomicString slotName = child.slotName();
+ HTMLSlotElement* slot = name2slot.get(slotName);
+ if (slot)
+ assign(child, *slot);
+ else
+ detachNotAssignedNode(child);
}
// Update each slot's distribution in reverse tree order so that a child slot is visited before its parent slot.
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698