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

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

Issue 2748563002: Fix another caret paint invalidation issue (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
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8cb6cd6b3d6d981d1de0369303107fd2c9e3c673..4bd31541b2ef82e60fa485d248cd8c2ebcbf785e 100644
--- a/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
+++ b/third_party/WebKit/Source/core/editing/CaretDisplayItemClientTest.cpp
@@ -19,6 +19,7 @@ class CaretDisplayItemClientTest : public RenderingTest {
void SetUp() override {
RenderingTest::SetUp();
enableCompositing();
+ selection().setCaretBlinkingSuspended(true);
}
const RasterInvalidationTracking* getRasterInvalidationTracking() const {
@@ -222,4 +223,52 @@ TEST_F(CaretDisplayItemClientTest, CaretMovesBetweenBlocks) {
document().view()->setTracksPaintInvalidations(false);
}
+TEST_F(CaretDisplayItemClientTest, CaretHideMoveAndShow) {
+ document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
+ document().page()->focusController().setActive(true);
+ document().page()->focusController().setFocused(true);
+
+ Text* text = appendTextNode("Hello, World!");
+ document().body()->focus();
+ updateAllLifecyclePhases();
+ const auto* block = toLayoutBlock(document().body()->layoutObject());
+
+ LayoutRect caretVisualRect = caretDisplayItemClient().visualRect();
+ EXPECT_EQ(1, caretVisualRect.width());
+ EXPECT_EQ(block->location(), caretVisualRect.location());
+
+ // Simulate that the blinking cursor becomes invisible.
+ selection().setCaretVisible(false);
+ // Move the caret to the end of the text.
+ document().view()->setTracksPaintInvalidations(true);
+ selection().setSelection(
+ SelectionInDOMTree::Builder().collapse(Position(text, 5)).build());
+ // Simulate that the cursor blinking is restarted.
+ selection().setCaretVisible(true);
+ updateAllLifecyclePhases();
+
+ LayoutRect newCaretVisualRect = caretDisplayItemClient().visualRect();
+ EXPECT_EQ(caretVisualRect.size(), newCaretVisualRect.size());
+ EXPECT_EQ(caretVisualRect.y(), newCaretVisualRect.y());
+ EXPECT_LT(caretVisualRect.x(), newCaretVisualRect.x());
+
+ const auto& rasterInvalidations =
+ getRasterInvalidationTracking()->trackedRasterInvalidations;
+ ASSERT_EQ(2u, rasterInvalidations.size());
+ EXPECT_EQ(enclosingIntRect(caretVisualRect), rasterInvalidations[0].rect);
+ EXPECT_EQ(block, rasterInvalidations[0].client);
+ EXPECT_EQ(PaintInvalidationCaret, rasterInvalidations[0].reason);
+ EXPECT_EQ(enclosingIntRect(newCaretVisualRect), rasterInvalidations[1].rect);
+ EXPECT_EQ(block, rasterInvalidations[1].client);
+ EXPECT_EQ(PaintInvalidationCaret, rasterInvalidations[1].reason);
+
+ auto objectInvalidations =
+ document().view()->trackedObjectPaintInvalidationsAsJSON();
+ ASSERT_EQ(1u, objectInvalidations->size());
+ String s;
+ JSONObject::cast(objectInvalidations->at(0))->get("object")->asString(&s);
+ EXPECT_EQ("Caret", s);
+ document().view()->setTracksPaintInvalidations(false);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretDisplayItemClient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698