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

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

Issue 1671823002: Restrict the types of nodes that could be assigned to a slot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/shadow/SlotAssignment.h" 5 #include "core/dom/shadow/SlotAssignment.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/dom/ElementTraversal.h" 8 #include "core/dom/ElementTraversal.h"
9 #include "core/dom/NodeTraversal.h" 9 #include "core/dom/NodeTraversal.h"
10 #include "core/dom/shadow/InsertionPoint.h" 10 #include "core/dom/shadow/InsertionPoint.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 assign(child, *defaultSlot); 58 assign(child, *defaultSlot);
59 else 59 else
60 detachNotAssignedNode(child); 60 detachNotAssignedNode(child);
61 } else { 61 } else {
62 HTMLSlotElement* slot = name2slot.get(slotName); 62 HTMLSlotElement* slot = name2slot.get(slotName);
63 if (slot) 63 if (slot)
64 assign(child, *slot); 64 assign(child, *slot);
65 else 65 else
66 detachNotAssignedNode(child); 66 detachNotAssignedNode(child);
67 } 67 }
68 } else if (defaultSlot) { 68 } else if (defaultSlot && child.isTextNode()) {
69 assign(child, *defaultSlot); 69 assign(child, *defaultSlot);
70 } else { 70 } else {
71 detachNotAssignedNode(child); 71 detachNotAssignedNode(child);
72 } 72 }
73 } 73 }
74 74
75 // Update each slot's distribution in reverse tree order so that a child slo t is visited before its parent slot. 75 // Update each slot's distribution in reverse tree order so that a child slo t is visited before its parent slot.
76 for (auto slot = slots.rbegin(); slot != slots.rend(); ++slot) 76 for (auto slot = slots.rbegin(); slot != slots.rend(); ++slot)
77 (*slot)->updateDistributedNodesWithFallback(); 77 (*slot)->updateDistributedNodesWithFallback();
78 } 78 }
79 79
80 void SlotAssignment::assign(Node& hostChild, HTMLSlotElement& slot) 80 void SlotAssignment::assign(Node& hostChild, HTMLSlotElement& slot)
81 { 81 {
82 ASSERT(hostChild.isSlotAssignable());
82 m_assignment.add(&hostChild, &slot); 83 m_assignment.add(&hostChild, &slot);
83 slot.appendAssignedNode(hostChild); 84 slot.appendAssignedNode(hostChild);
84 if (isHTMLSlotElement(hostChild)) 85 if (isHTMLSlotElement(hostChild))
85 slot.appendDistributedNodesFrom(toHTMLSlotElement(hostChild)); 86 slot.appendDistributedNodesFrom(toHTMLSlotElement(hostChild));
86 else 87 else
87 slot.appendDistributedNode(hostChild); 88 slot.appendDistributedNode(hostChild);
88 } 89 }
89 90
90 DEFINE_TRACE(SlotAssignment) 91 DEFINE_TRACE(SlotAssignment)
91 { 92 {
92 #if ENABLE(OILPAN) 93 #if ENABLE(OILPAN)
93 visitor->trace(m_assignment); 94 visitor->trace(m_assignment);
94 #endif 95 #endif
95 } 96 }
96 97
97 } // namespace blink 98 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.idl ('k') | third_party/WebKit/Source/core/html/HTMLSlotElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698