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

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

Issue 2220923002: Make computeInlineBoxPosition() to handle unicode-bidi:isolate correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-08T15:03:39 Created 4 years, 4 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 "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/HTMLTextFormControlElement.h" 10 #include "core/html/HTMLTextFormControlElement.h"
11 #include "core/layout/LayoutTextFragment.h" 11 #include "core/layout/LayoutTextFragment.h"
12 #include "core/layout/line/InlineBox.h" 12 #include "core/layout/line/InlineTextBox.h"
13 #include <ostream> // NOLINT 13 #include <ostream> // NOLINT
14 14
15 namespace blink { 15 namespace blink {
16 16
17 namespace { 17 namespace {
18 18
19 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex tAffinity affinity = TextAffinity::Downstream) 19 PositionWithAffinity positionWithAffinityInDOMTree(Node& anchor, int offset, Tex tAffinity affinity = TextAffinity::Downstream)
20 { 20 {
21 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)), affinity); 21 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)), affinity);
22 } 22 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 0), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 0))); 239 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 0), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 0)));
240 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 1), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 1))); 240 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(three, 1), TextAffinit y::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*three, 1)));
241 241
242 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 0 ))); 242 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 0 )));
243 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 1 ))); 243 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(four, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*four, 1 )));
244 244
245 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 0 ))); 245 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 0), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 0 )));
246 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 1 ))); 246 EXPECT_EQ(computeInlineBoxPosition(PositionInFlatTree(five, 1), TextAffinity ::Downstream), computeInlineBoxPosition(createVisiblePositionInFlatTree(*five, 1 )));
247 } 247 }
248 248
249 TEST_F(VisibleUnitsTest, computeInlineBoxPositionBidiIsolate)
250 {
251 // "|" is bidi-level 0, and "foo" and "bar" are bidi-level 2
252 setBodyContent("|<span id=sample style='unicode-bidi: isolate;'>foo<br>bar</ span>|");
253
254 Element* sample = document().getElementById("sample");
255 Node* text = sample->firstChild();
256
257 const InlineBoxPosition& actual = computeInlineBoxPosition(Position(text, 0) , TextAffinity::Downstream);
258 EXPECT_EQ(toLayoutText(text->layoutObject())->firstTextBox(), actual.inlineB ox);
259 }
260
249 TEST_F(VisibleUnitsTest, endOfDocument) 261 TEST_F(VisibleUnitsTest, endOfDocument)
250 { 262 {
251 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>"; 263 const char* bodyContent = "<a id=host><b id=one>1</b><b id=two>22</b></a>";
252 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>"; 264 const char* shadowContent = "<p><content select=#two></content></p><p><conte nt select=#one></content></p>";
253 setBodyContent(bodyContent); 265 setBodyContent(bodyContent);
254 setShadowContent(shadowContent, "host"); 266 setShadowContent(shadowContent, "host");
255 267
256 Element* one = document().getElementById("one"); 268 Element* one = document().getElementById("one");
257 Element* two = document().getElementById("two"); 269 Element* two = document().getElementById("two");
258 270
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 { 1327 {
1316 // Repro case of crbug.com/584030 1328 // Repro case of crbug.com/584030
1317 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>"; 1329 const char* bodyContent = "<button><rt><script>document.designMode = 'on'</s cript></rt></button>";
1318 setBodyContent(bodyContent); 1330 setBodyContent(bodyContent);
1319 1331
1320 Node* button = document().querySelector("button"); 1332 Node* button = document().querySelector("button");
1321 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button)); 1333 EXPECT_TRUE(endsOfNodeAreVisuallyDistinctPositions(button));
1322 } 1334 }
1323 1335
1324 } // namespace blink 1336 } // 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