| 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 <ostream> // NOLINT | 7 #include <ostream> // NOLINT |
| 8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
| 9 #include "core/dom/Text.h" | 9 #include "core/dom/Text.h" |
| 10 #include "core/editing/EditingTestBase.h" | 10 #include "core/editing/EditingTestBase.h" |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 TEST_F(VisibleUnitsTest, localCaretRectOfPosition) { | 1081 TEST_F(VisibleUnitsTest, localCaretRectOfPosition) { |
| 1082 const char* body_content = | 1082 const char* body_content = |
| 1083 "<p id='host'><b id='one'>1</b></p><b id='two'>22</b>"; | 1083 "<p id='host'><b id='one'>1</b></p><b id='two'>22</b>"; |
| 1084 const char* shadow_content = | 1084 const char* shadow_content = |
| 1085 "<b id='two'>22</b><content select=#one></content><b id='three'>333</b>"; | 1085 "<b id='two'>22</b><content select=#one></content><b id='three'>333</b>"; |
| 1086 SetBodyContent(body_content); | 1086 SetBodyContent(body_content); |
| 1087 SetShadowContent(shadow_content, "host"); | 1087 SetShadowContent(shadow_content, "host"); |
| 1088 | 1088 |
| 1089 Element* one = GetDocument().getElementById("one"); | 1089 Element* one = GetDocument().getElementById("one"); |
| 1090 | 1090 |
| 1091 LayoutObject* layout_object_from_dom_tree; | 1091 const LocalCaretRect& caret_rect_from_dom_tree = |
| 1092 LayoutRect layout_rect_from_dom_tree = LocalCaretRectOfPosition( | 1092 LocalCaretRectOfPosition(Position(one->firstChild(), 0)); |
| 1093 Position(one->firstChild(), 0), layout_object_from_dom_tree); | |
| 1094 | 1093 |
| 1095 LayoutObject* layout_object_from_flat_tree; | 1094 const LocalCaretRect& caret_rect_from_flat_tree = |
| 1096 LayoutRect layout_rect_from_flat_tree = LocalCaretRectOfPosition( | 1095 LocalCaretRectOfPosition(PositionInFlatTree(one->firstChild(), 0)); |
| 1097 PositionInFlatTree(one->firstChild(), 0), layout_object_from_flat_tree); | |
| 1098 | 1096 |
| 1099 EXPECT_TRUE(layout_object_from_dom_tree); | 1097 EXPECT_FALSE(caret_rect_from_dom_tree.IsEmpty()); |
| 1100 EXPECT_FALSE(layout_rect_from_dom_tree.IsEmpty()); | 1098 EXPECT_EQ(caret_rect_from_dom_tree.layout_object, |
| 1101 EXPECT_EQ(layout_object_from_dom_tree, layout_object_from_flat_tree); | 1099 caret_rect_from_flat_tree.layout_object); |
| 1102 EXPECT_EQ(layout_rect_from_dom_tree, layout_rect_from_flat_tree); | 1100 EXPECT_EQ(caret_rect_from_dom_tree.rect, caret_rect_from_flat_tree.rect); |
| 1103 } | 1101 } |
| 1104 | 1102 |
| 1105 TEST_F(VisibleUnitsTest, logicalEndOfLine) { | 1103 TEST_F(VisibleUnitsTest, logicalEndOfLine) { |
| 1106 const char* body_content = | 1104 const char* body_content = |
| 1107 "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i " | 1105 "<a id=host><b id=one>11</b><b id=two>22</b></a><i id=three>333</i><i " |
| 1108 "id=four>4444</i><br>"; | 1106 "id=four>4444</i><br>"; |
| 1109 const char* shadow_content = | 1107 const char* shadow_content = |
| 1110 "<div><u id=five>55555</u><content select=#two></content><br><u " | 1108 "<div><u id=five>55555</u><content select=#two></content><br><u " |
| 1111 "id=six>666666</u><br><content select=#one></content><u " | 1109 "id=six>666666</u><br><content select=#one></content><u " |
| 1112 "id=seven>7777777</u></div>"; | 1110 "id=seven>7777777</u></div>"; |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1989 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { | 1987 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { |
| 1990 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary | 1988 SetBodyContent("<p> ⃣</p>"); // Leading space is necessary |
| 1991 | 1989 |
| 1992 Node* paragraph = GetDocument().QuerySelector("p"); | 1990 Node* paragraph = GetDocument().QuerySelector("p"); |
| 1993 Node* text = paragraph->firstChild(); | 1991 Node* text = paragraph->firstChild(); |
| 1994 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); | 1992 Position start = CanonicalPositionOf(Position::BeforeNode(paragraph)); |
| 1995 EXPECT_EQ(Position(text, 2), start); | 1993 EXPECT_EQ(Position(text, 2), start); |
| 1996 } | 1994 } |
| 1997 | 1995 |
| 1998 } // namespace blink | 1996 } // namespace blink |
| OLD | NEW |