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

Side by Side Diff: third_party/WebKit/Source/core/editing/VisibleUnitsTest.cpp

Issue 2926823002: Introduce LocalCaretRect for refactoring Local{Caret,Selection}RectPosition() (Closed)
Patch Set: 2017-06-09T15:11:53 Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
1989 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) { 1987 canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter) {
1990 SetBodyContent("<p> &#x20E3;</p>"); // Leading space is necessary 1988 SetBodyContent("<p> &#x20E3;</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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698