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

Unified Diff: third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp

Issue 2745793002: Fix caret paint invalidation issues (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp b/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
index 141f5a4492ab02fd09291730ea8662d4d630a3e8..8cb6cd6b3d6d981d1de0369303107fd2c9e3c673 100644
--- a/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
+++ b/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
@@ -50,6 +50,14 @@ class CaretDisplayItemClientTest : public RenderingTest {
document().body()->appendChild(block);
return block;
}
+
+ void updateAllLifecyclePhases() {
+ // Partial lifecycle updates should not affect caret paint invalidation.
+ document().view()->updateLifecycleToLayoutClean();
+ document().view()->updateAllLifecyclePhases();
+ // Partial lifecycle updates should not affect caret paint invalidation.
+ document().view()->updateLifecycleToLayoutClean();
+ }
};
TEST_F(CaretDisplayItemClientTest, CaretPaintInvalidation) {
@@ -58,13 +66,13 @@ TEST_F(CaretDisplayItemClientTest, CaretPaintInvalidation) {
document().page()->focusController().setFocused(true);
Text* text = appendTextNode("Hello, World!");
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
const auto* block = toLayoutBlock(document().body()->layoutObject());
// Focus the body. Should invalidate the new caret.
document().view()->setTracksPaintInvalidations(true);
document().body()->focus();
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
EXPECT_TRUE(block->shouldPaintCursorCaret());
LayoutRect caretVisualRect = caretDisplayItemClient().visualRect();
@@ -91,7 +99,7 @@ TEST_F(CaretDisplayItemClientTest, CaretPaintInvalidation) {
document().view()->setTracksPaintInvalidations(true);
selection().setSelection(
SelectionInDOMTree::Builder().collapse(Position(text, 5)).build());
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
EXPECT_TRUE(block->shouldPaintCursorCaret());
LayoutRect newCaretVisualRect = caretDisplayItemClient().visualRect();
@@ -121,7 +129,7 @@ TEST_F(CaretDisplayItemClientTest, CaretPaintInvalidation) {
LayoutRect oldCaretVisualRect = newCaretVisualRect;
document().view()->setTracksPaintInvalidations(true);
selection().setSelection(SelectionInDOMTree());
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
EXPECT_FALSE(block->shouldPaintCursorCaret());
EXPECT_EQ(LayoutRect(), caretDisplayItemClient().visualRect());
@@ -146,13 +154,13 @@ TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) {
document().page()->focusController().setFocused(true);
auto* blockElement1 = appendBlock("Block1");
auto* blockElement2 = appendBlock("Block2");
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
auto* block1 = toLayoutBlock(blockElement1->layoutObject());
auto* block2 = toLayoutBlock(blockElement2->layoutObject());
// Focus the body.
document().body()->focus();
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
LayoutRect caretVisualRect1 = caretDisplayItemClient().visualRect();
EXPECT_EQ(1, caretVisualRect1.width());
EXPECT_EQ(block1->visualRect().location(), caretVisualRect1.location());
@@ -164,7 +172,7 @@ TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) {
selection().setSelection(SelectionInDOMTree::Builder()
.collapse(Position(blockElement2, 0))
.build());
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
LayoutRect caretVisualRect2 = caretDisplayItemClient().visualRect();
EXPECT_EQ(1, caretVisualRect2.width());
@@ -192,7 +200,7 @@ TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) {
selection().setSelection(SelectionInDOMTree::Builder()
.collapse(Position(blockElement1, 0))
.build());
- document().view()->updateAllLifecyclePhases();
+ updateAllLifecyclePhases();
EXPECT_EQ(caretVisualRect1, caretDisplayItemClient().visualRect());
EXPECT_TRUE(block1->shouldPaintCursorCaret());
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp ('k') | third_party/WebKit/Source/core/editing/DragCaret.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698