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

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

Issue 2726593002: Use mayNotBeMainThread() for wrapper optimization (Closed)
Patch Set: Renaming + move decrement to destructor 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
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/TextControlElement.h" 10 #include "core/html/TextControlElement.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 toLayoutTextFragment(associatedLayoutObjectOf(*text, 2)); 100 toLayoutTextFragment(associatedLayoutObjectOf(*text, 2));
101 EXPECT_EQ(layoutObject0, layoutObject2) 101 EXPECT_EQ(layoutObject0, layoutObject2)
102 << "close parenthesis should be part of first letter."; 102 << "close parenthesis should be part of first letter.";
103 103
104 LayoutTextFragment* layoutObject3 = 104 LayoutTextFragment* layoutObject3 =
105 toLayoutTextFragment(associatedLayoutObjectOf(*text, 3)); 105 toLayoutTextFragment(associatedLayoutObjectOf(*text, 3));
106 EXPECT_TRUE(layoutObject3->isRemainingTextLayoutObject()); 106 EXPECT_TRUE(layoutObject3->isRemainingTextLayoutObject());
107 } 107 }
108 108
109 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterSplit) { 109 TEST_F(VisibleUnitsTest, associatedLayoutObjectOfFirstLetterSplit) {
110 ScriptState* scriptState = ScriptState::forMainWorld(document().frame());
111 ScriptState::Scope scope(scriptState);
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 ScriptState* scriptState = ScriptState::forMainWorld(document().frame());
1372 ScriptState::Scope scope(scriptState);
1373
1368 const char* bodyContent = 1374 const char* bodyContent =
1369 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>"; 1375 "<style>p:first-letter {color:red;}</style><p id=sample>abc</p>";
1370 setBodyContent(bodyContent); 1376 setBodyContent(bodyContent);
1371 1377
1372 Node* sample = document().getElementById("sample"); 1378 Node* sample = document().getElementById("sample");
1373 Node* firstLetter = sample->firstChild(); 1379 Node* firstLetter = sample->firstChild();
1374 // Split "abc" into "a" "bc" 1380 // Split "abc" into "a" "bc"
1375 Text* remaining = toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION); 1381 Text* remaining = toText(firstLetter)->splitText(1, ASSERT_NO_EXCEPTION);
1376 updateAllLifecyclePhases(); 1382 updateAllLifecyclePhases();
1377 1383
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) { 2021 TEST_F(VisibleUnitsTest, localSelectionRectOfPositionTemplateNotCrash) {
2016 setBodyContent("<div>foo<img></div>"); 2022 setBodyContent("<div>foo<img></div>");
2017 2023
2018 Node* node = document().querySelector("img"); 2024 Node* node = document().querySelector("img");
2019 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create( 2025 IntRect rect = absoluteSelectionBoundsOf(VisiblePosition::create(
2020 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren)))); 2026 PositionWithAffinity(Position(node, PositionAnchorType::AfterChildren))));
2021 EXPECT_FALSE(rect.isEmpty()); 2027 EXPECT_FALSE(rect.isEmpty());
2022 } 2028 }
2023 2029
2024 } // namespace blink 2030 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698