| OLD | NEW |
| 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/editing/VisibleUnits.h" | 5 #include "core/editing/VisibleUnits.h" |
| 6 | 6 |
| 7 #include "core/dom/Text.h" | 7 #include "core/dom/Text.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 #include "core/editing/VisiblePosition.h" | 9 #include "core/editing/VisiblePosition.h" |
| 10 #include "core/html/TextControlElement.h" | 10 #include "core/html/TextControlElement.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 EXPECT_EQ(Position(html, 0), canonicalPositionOf(Position(html, 0))); | 228 EXPECT_EQ(Position(html, 0), canonicalPositionOf(Position(html, 0))); |
| 229 EXPECT_EQ(Position(html, 1), canonicalPositionOf(Position(html, 1))); | 229 EXPECT_EQ(Position(html, 1), canonicalPositionOf(Position(html, 1))); |
| 230 EXPECT_EQ(Position(html, 2), canonicalPositionOf(Position(html, 2))); | 230 EXPECT_EQ(Position(html, 2), canonicalPositionOf(Position(html, 2))); |
| 231 | 231 |
| 232 EXPECT_EQ(Position(two->firstChild(), 0), | 232 EXPECT_EQ(Position(two->firstChild(), 0), |
| 233 canonicalPositionOf(Position(two, 0))); | 233 canonicalPositionOf(Position(two, 0))); |
| 234 EXPECT_EQ(Position(two->firstChild(), 2), | 234 EXPECT_EQ(Position(two->firstChild(), 2), |
| 235 canonicalPositionOf(Position(two, 1))); | 235 canonicalPositionOf(Position(two, 1))); |
| 236 } | 236 } |
| 237 | 237 |
| 238 // For http://crbug.com/695317 |
| 239 TEST_F(VisibleUnitsTest, canonicalPositionOfWithInputElement) { |
| 240 setBodyContent("<input>123"); |
| 241 Element* const input = document().querySelector("input"); |
| 242 |
| 243 EXPECT_EQ(Position::beforeNode(input), |
| 244 canonicalPositionOf( |
| 245 Position::firstPositionInNode(document().documentElement()))); |
| 246 |
| 247 EXPECT_EQ(PositionInFlatTree::beforeNode(input), |
| 248 canonicalPositionOf(PositionInFlatTree::firstPositionInNode( |
| 249 document().documentElement()))); |
| 250 } |
| 251 |
| 238 TEST_F(VisibleUnitsTest, characterBefore) { | 252 TEST_F(VisibleUnitsTest, characterBefore) { |
| 239 const char* bodyContent = | 253 const char* bodyContent = |
| 240 "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>"; | 254 "<p id=host><b id=one>1</b><b id=two>22</b></p><b id=three>333</b>"; |
| 241 const char* shadowContent = | 255 const char* shadowContent = |
| 242 "<b id=four>4444</b><content select=#two></content><content " | 256 "<b id=four>4444</b><content select=#two></content><content " |
| 243 "select=#one></content><b id=five>5555</b>"; | 257 "select=#one></content><b id=five>5555</b>"; |
| 244 setBodyContent(bodyContent); | 258 setBodyContent(bodyContent); |
| 245 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); | 259 ShadowRoot* shadowRoot = setShadowContent(shadowContent, "host"); |
| 246 | 260 |
| 247 Node* one = document().getElementById("one")->firstChild(); | 261 Node* one = document().getElementById("one")->firstChild(); |
| (...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { | 2015 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { |
| 2002 setBodyContent("<div>foo<img></div>"); | 2016 setBodyContent("<div>foo<img></div>"); |
| 2003 | 2017 |
| 2004 Node* node = document().querySelector("img"); | 2018 Node* node = document().querySelector("img"); |
| 2005 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( | 2019 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( |
| 2006 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); | 2020 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); |
| 2007 EXPECT_FALSE(rect.isEmpty()); | 2021 EXPECT_FALSE(rect.isEmpty()); |
| 2008 } | 2022 } |
| 2009 | 2023 |
| 2010 } // namespace blink | 2024 } // namespace blink |
| OLD | NEW |