OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/SlotScopedTraversal.h" | 5 #include "core/dom/shadow/SlotScopedTraversal.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 Element* slotElement = shadowRoot->querySelector("slot"); | 111 Element* slotElement = shadowRoot->querySelector("slot"); |
112 DCHECK(isHTMLSlotElement(slotElement)); | 112 DCHECK(isHTMLSlotElement(slotElement)); |
113 HTMLSlotElement* slot = toHTMLSlotElement(slotElement); | 113 HTMLSlotElement* slot = toHTMLSlotElement(slotElement); |
114 | 114 |
115 EXPECT_EQ(inner1, SlotScopedTraversal::firstAssignedToSlot(*slot)); | 115 EXPECT_EQ(inner1, SlotScopedTraversal::firstAssignedToSlot(*slot)); |
116 EXPECT_EQ(inner2, SlotScopedTraversal::lastAssignedToSlot(*slot)); | 116 EXPECT_EQ(inner2, SlotScopedTraversal::lastAssignedToSlot(*slot)); |
117 EXPECT_FALSE(SlotScopedTraversal::isSlotScoped(*host)); | 117 EXPECT_FALSE(SlotScopedTraversal::isSlotScoped(*host)); |
118 EXPECT_FALSE(SlotScopedTraversal::isSlotScoped(*slot)); | 118 EXPECT_FALSE(SlotScopedTraversal::isSlotScoped(*slot)); |
119 EXPECT_TRUE(SlotScopedTraversal::isSlotScoped(*inner1)); | 119 EXPECT_TRUE(SlotScopedTraversal::isSlotScoped(*inner1)); |
120 EXPECT_TRUE(SlotScopedTraversal::isSlotScoped(*inner2)); | 120 EXPECT_TRUE(SlotScopedTraversal::isSlotScoped(*inner2)); |
121 EXPECT_EQ(inner1, SlotScopedTraversal::nearestInclusiveAncestorAssignedToSlot( | 121 EXPECT_EQ( |
122 *inner1)); | 122 inner1, |
123 EXPECT_EQ(inner2, SlotScopedTraversal::nearestInclusiveAncestorAssignedToSlot( | 123 SlotScopedTraversal::nearestInclusiveAncestorAssignedToSlot(*inner1)); |
124 *inner2)); | 124 EXPECT_EQ( |
| 125 inner2, |
| 126 SlotScopedTraversal::nearestInclusiveAncestorAssignedToSlot(*inner2)); |
125 EXPECT_EQ(slot, SlotScopedTraversal::findScopeOwnerSlot(*inner1)); | 127 EXPECT_EQ(slot, SlotScopedTraversal::findScopeOwnerSlot(*inner1)); |
126 EXPECT_EQ(slot, SlotScopedTraversal::findScopeOwnerSlot(*inner2)); | 128 EXPECT_EQ(slot, SlotScopedTraversal::findScopeOwnerSlot(*inner2)); |
127 | 129 |
128 Vector<Element*> expectedSequence({inner1, inner2}); | 130 Vector<Element*> expectedSequence({inner1, inner2}); |
129 testExpectedSequence(expectedSequence); | 131 testExpectedSequence(expectedSequence); |
130 } | 132 } |
131 | 133 |
132 TEST_F(SlotScopedTraversalTest, multipleSlots) { | 134 TEST_F(SlotScopedTraversalTest, multipleSlots) { |
133 const char* mainHTML = | 135 const char* mainHTML = |
134 "<div id='host'>" | 136 "<div id='host'>" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 const Vector<Element*> expectedSequence({inner[0], child[0], span[0], | 403 const Vector<Element*> expectedSequence({inner[0], child[0], span[0], |
402 child[1], span[1], inner[1], | 404 child[1], span[1], inner[1], |
403 child[2], span[2], child[3]}); | 405 child[2], span[2], child[3]}); |
404 testExpectedSequence(expectedSequence); | 406 testExpectedSequence(expectedSequence); |
405 } break; | 407 } break; |
406 } | 408 } |
407 } | 409 } |
408 } | 410 } |
409 | 411 |
410 } // namespace blink | 412 } // namespace blink |
OLD | NEW |