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

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

Issue 2726593002: Use mayNotBeMainThread() for wrapper optimization (Closed)
Patch Set: Use V8TestingScope Created 3 years, 9 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/dom/StaticRangeTest.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
8 #include "bindings/core/v8/V8BindingForTesting.h"
7 #include "core/dom/Text.h" 9 #include "core/dom/Text.h"
8 #include "core/editing/EditingTestBase.h" 10 #include "core/editing/EditingTestBase.h"
9 #include "core/editing/VisiblePosition.h" 11 #include "core/editing/VisiblePosition.h"
10 #include "core/html/TextControlElement.h" 12 #include "core/html/TextControlElement.h"
11 #include "core/layout/LayoutTextFragment.h" 13 #include "core/layout/LayoutTextFragment.h"
12 #include "core/layout/line/InlineTextBox.h" 14 #include "core/layout/line/InlineTextBox.h"
13 #include <ostream> // NOLINT
14 15
15 namespace blink { 16 namespace blink {
16 17
17 namespace { 18 namespace {
18 19
19 PositionWithAffinity positionWithAffinityInDOMTree( 20 PositionWithAffinity positionWithAffinityInDOMTree(
20 Node& anchor, 21 Node& anchor,
21 int offset, 22 int offset,
22 TextAffinity affinity = TextAffinity::Downstream) { 23 TextAffinity affinity = TextAffinity::Downstream) {
23 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)), 24 return PositionWithAffinity(canonicalPositionOf(Position(&anchor, offset)),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 toLayoutTextFragment(associatedLayoutObjectOf(*text, 2)); 101 toLayoutTextFragment(associatedLayoutObjectOf(*text, 2));
101 EXPECT_EQ(layoutObject0, layoutObject2) 102 EXPECT_EQ(layoutObject0, layoutObject2)
102 << "close parenthesis should be part of first letter."; 103 << "close parenthesis should be part of first letter.";
103 104
104 LayoutTextFragment* layoutObject3 = 105 LayoutTextFragment* layoutObject3 =
105 toLayoutTextFragment(associatedLayoutObjectOf(*text, 3)); 106 toLayoutTextFragment(associatedLayoutObjectOf(*text, 3));
106 EXPECT_TRUE(layoutObject3->isRemainingTextLayoutObject()); 107 EXPECT_TRUE(layoutObject3->isRemainingTextLayoutObject());
107 } 108 }
108 109
109 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterSplit) { 110 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterSplit) {
111 V8TestingScope scope;
112
110 const char* bodyContent = 113 const char* bodyContent =
111 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>"; 114 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>";
112 setBodyContent(bodyContent); 115 setBodyContent(bodyContent);
113 116
114 Node* sample = document().getElementById("sample"); 117 Node* sample = document().getElementById("sample");
115 Node* firstLetter = sample->firstChild(); 118 Node* firstLetter = sample->firstChild();
116 // Split "abc" into "a" "bc" 119 // Split "abc" into "a" "bc"
117 toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION); 120 toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION);
118 updateAllLifecyclePhases(); 121 updateAllLifecyclePhases();
119 122
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 Position::lastPositionInNode(sample->parentNode()))); 1361 Position::lastPositionInNode(sample->parentNode())));
1359 EXPECT_EQ( 1362 EXPECT_EQ(
1360 Position(sample, 6), 1363 Position(sample, 6),
1361 mostBackwardCaretPosition(Position::afterNode(sample->parentNode()))); 1364 mostBackwardCaretPosition(Position::afterNode(sample->parentNode())));
1362 EXPECT_EQ(Position::lastPositionInNode(document().body()), 1365 EXPECT_EQ(Position::lastPositionInNode(document().body()),
1363 mostBackwardCaretPosition( 1366 mostBackwardCaretPosition(
1364 Position::lastPositionInNode(document().body()))); 1367 Position::lastPositionInNode(document().body())));
1365 } 1368 }
1366 1369
1367 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetterSplit) { 1370 TEST_F(VisibleUnitsTest, mostBackwardCaretPositionFirstLetterSplit) {
1371 V8TestingScope scope;
1372
1368 const char* bodyContent = 1373 const char* bodyContent =
1369 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>"; 1374 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>";
1370 setBodyContent(bodyContent); 1375 setBodyContent(bodyContent);
1371 1376
1372 Node* sample = document().getElementById("sample"); 1377 Node* sample = document().getElementById("sample");
1373 Node* firstLetter = sample->firstChild(); 1378 Node* firstLetter = sample->firstChild();
1374 // Split "abc" into "a" "bc" 1379 // Split "abc" into "a" "bc"
1375 Text* remaining = toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION); 1380 Text* remaining = toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION);
1376 updateAllLifecyclePhases(); 1381 updateAllLifecyclePhases();
1377 1382
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { 2020 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) {
2016 setBodyContent("<div>foo<img></div>"); 2021 setBodyContent("<div>foo<img></div>");
2017 2022
2018 Node* node = document().querySelector("img"); 2023 Node* node = document().querySelector("img");
2019 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( 2024 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create(
2020 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); 2025 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren))));
2021 EXPECT_FALSE(rect.isEmpty()); 2026 EXPECT_FALSE(rect.isEmpty());
2022 } 2027 }
2023 2028
2024 } // namespace blink 2029 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StaticRangeTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698