Chromium Code Reviews| 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/editing/EphemeralRange.h" | 5 #include "core/editing/EphemeralRange.h" |
| 6 | 6 |
| 7 #include "core/dom/Range.h" | 7 #include "core/dom/Range.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 // Tree iterators have only |operator !=| ATM. | 141 // Tree iterators have only |operator !=| ATM. |
| 142 EXPECT_FALSE(iterable.begin() != iterable.end()); | 142 EXPECT_FALSE(iterable.begin() != iterable.end()); |
| 143 | 143 |
| 144 const EphemeralRange singlePositionRange(getBodyRange()->startPosition()); | 144 const EphemeralRange singlePositionRange(getBodyRange()->startPosition()); |
| 145 EXPECT_FALSE(singlePositionRange.isNull()); | 145 EXPECT_FALSE(singlePositionRange.isNull()); |
| 146 EXPECT_EQ(std::string(), traverseRange(singlePositionRange)); | 146 EXPECT_EQ(std::string(), traverseRange(singlePositionRange)); |
| 147 EXPECT_EQ(singlePositionRange.startPosition().nodeAsRangeFirstNode(), | 147 EXPECT_EQ(singlePositionRange.startPosition().nodeAsRangeFirstNode(), |
| 148 singlePositionRange.endPosition().nodeAsRangePastLastNode()); | 148 singlePositionRange.endPosition().nodeAsRangePastLastNode()); |
| 149 } | 149 } |
| 150 | 150 |
| 151 TEST_F(EphemeralRangeTest, commonAncesstorDOM) { | |
| 152 const char* bodyContent = | |
| 153 "<p id='host'>00<b id='one'>11</b><b id='two'>22</b><b " | |
|
yosin_UTC9
2017/03/06 07:35:30
Could you use multiple lines string literal to bet
tanvir
2017/03/06 14:42:01
When i tried to do using staring literal, i was un
yosin_UTC9
2017/03/07 01:55:02
Thanks for trying. It seems "raw string literal" h
| |
| 154 "id='three'>33</b></p>"; | |
| 155 setBodyContent(bodyContent); | |
| 156 | |
| 157 const Position startPosition(document().getElementById("one"), 0); | |
| 158 const Position endPosition(document().getElementById("two"), 0); | |
| 159 const EphemeralRange range(startPosition, endPosition); | |
| 160 EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer()); | |
| 161 } | |
| 162 | |
| 163 TEST_F(EphemeralRangeTest, commonAncesstorFlatTree) { | |
| 164 const char* bodyContent = | |
| 165 "<b id=zero>0</b><p id=host><b id=one>1</b><b id=two>22</b></p><b " | |
| 166 "id=three>333</b>"; | |
| 167 const char* shadowContent = | |
| 168 "<p id=four>4444</p><content select=#two></content><content " | |
| 169 "select=#one></content><p id=five>55555</p>"; | |
| 170 setBodyContent(bodyContent); | |
| 171 | |
|
Xiaocheng
2017/03/06 07:33:20
nit: remove this extra blank line.
tanvir
2017/03/06 14:42:01
Done.
| |
| 172 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | |
| 173 | |
| 174 const PositionInFlatTree startPosition(document().getElementById("one"), 0); | |
| 175 const PositionInFlatTree endPosition(shadowRoot->getElementById("five"), 0); | |
| 176 const EphemeralRangeInFlatTree range(startPosition, endPosition); | |
| 177 EXPECT_EQ(document().getElementById("host"), range.commonAncestorContainer()); | |
| 178 } | |
| 179 | |
| 151 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |