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

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

Issue 2665823002: Invalidate caret during paint invalidation (Closed)
Patch Set: - Created 3 years, 11 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/FrameSelectionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
index 96c14d16f740e3fa91102d8348a283d458a097dd..3f2ef057267ad2612e5a121d3657a5823acd936e 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -14,6 +14,7 @@
#include "core/frame/FrameView.h"
#include "core/html/HTMLBodyElement.h"
#include "core/input/EventHandler.h"
+#include "core/layout/LayoutBlock.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
#include "core/testing/DummyPageHolder.h"
@@ -41,17 +42,6 @@ class FrameSelectionTest : public EditingTestBase {
return dummyPageHolder().frameView().layoutCount();
}
- bool isCaretBoundsDirty() const {
- return selection().m_frameCaret->m_caretRectDirty;
- }
-
- bool shouldPaintCaretForTesting() const {
- return selection().shouldPaintCaretForTesting();
- }
- bool isPreviousCaretDirtyForTesting() const {
- return selection().isPreviousCaretDirtyForTesting();
- }
-
PositionWithAffinity caretPosition() const {
return selection().m_frameCaret->caretPosition();
}
@@ -76,25 +66,6 @@ TEST_F(FrameSelectionTest, SetValidSelection) {
EXPECT_FALSE(selection().isNone());
}
-TEST_F(FrameSelectionTest, InvalidateCaretRect) {
- Text* text = appendTextNode("Hello, World!");
- document().view()->updateAllLifecyclePhases();
-
- selection().setSelection(
- SelectionInDOMTree::Builder().collapse(Position(text, 0)).build());
- selection().setCaretRectNeedsUpdate();
- EXPECT_TRUE(isCaretBoundsDirty());
- selection().invalidateCaretRect();
- EXPECT_FALSE(isCaretBoundsDirty());
-
- document().body()->removeChild(text);
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- selection().setCaretRectNeedsUpdate();
- EXPECT_TRUE(isCaretBoundsDirty());
- selection().invalidateCaretRect();
- EXPECT_FALSE(isCaretBoundsDirty());
-}
-
TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
Text* text = appendTextNode("Hello, World!");
document().view()->updateAllLifecyclePhases();
@@ -106,8 +77,10 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
selection().setCaretVisible(true);
selection().setSelection(
SelectionInDOMTree::Builder().collapse(Position(text, 0)).build());
+ selection().updateForPaintInvalidation();
+ EXPECT_TRUE(toLayoutBlock(document().body()->layoutObject())
+ ->shouldPaintCursorCaret());
EXPECT_TRUE(selection().isCaret());
- EXPECT_TRUE(shouldPaintCaretForTesting());
int startCount = layoutCount();
{
@@ -120,6 +93,7 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
}
std::unique_ptr<PaintController> paintController = PaintController::create();
{
+ selection().updateForPaintInvalidation();
GraphicsContext context(*paintController);
selection().paintCaret(context, LayoutPoint());
}
@@ -127,58 +101,6 @@ TEST_F(FrameSelectionTest, PaintCaretShouldNotLayout) {
EXPECT_EQ(startCount, layoutCount());
}
-TEST_F(FrameSelectionTest, InvalidatePreviousCaretAfterRemovingLastCharacter) {
- Text* text = appendTextNode("Hello, World!");
- document().view()->updateAllLifecyclePhases();
-
- document().body()->setContentEditable("true", ASSERT_NO_EXCEPTION);
- document().body()->focus();
- EXPECT_TRUE(document().body()->isFocused());
-
- selection().setCaretVisible(true);
- EXPECT_TRUE(selection().isCaret());
- EXPECT_TRUE(shouldPaintCaretForTesting());
-
- // Simulate to type "Hello, World!".
- DisableCompositingQueryAsserts disabler;
- document().updateStyleAndLayout();
- selection().setSelection(
- SelectionInDOMTree::Builder().collapse(selection().end()).build());
- selection().setCaretRectNeedsUpdate();
- EXPECT_TRUE(isCaretBoundsDirty());
- EXPECT_FALSE(isPreviousCaretDirtyForTesting());
- selection().invalidateCaretRect();
- EXPECT_FALSE(isCaretBoundsDirty());
- EXPECT_TRUE(isPreviousCaretDirtyForTesting());
-
- // Simulate to remove all except for "H".
- text->replaceWholeText("H");
- document().updateStyleAndLayout();
- selection().setSelection(
- SelectionInDOMTree::Builder().collapse(selection().end()).build());
- selection().setCaretRectNeedsUpdate();
- EXPECT_TRUE(isCaretBoundsDirty());
- // "H" remains so early previousCaret invalidation isn't needed.
- EXPECT_TRUE(isPreviousCaretDirtyForTesting());
- selection().invalidateCaretRect();
- EXPECT_FALSE(isCaretBoundsDirty());
- EXPECT_TRUE(isPreviousCaretDirtyForTesting());
-
- // Simulate to remove the last character.
- document().body()->removeChild(text);
- // This line is the objective of this test.
- // As removing the last character, early previousCaret invalidation is
- // executed.
- EXPECT_FALSE(isPreviousCaretDirtyForTesting());
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- selection().setCaretRectNeedsUpdate();
- EXPECT_TRUE(isCaretBoundsDirty());
- EXPECT_FALSE(isPreviousCaretDirtyForTesting());
- selection().invalidateCaretRect();
- EXPECT_FALSE(isCaretBoundsDirty());
- EXPECT_TRUE(isPreviousCaretDirtyForTesting());
-}
-
#define EXPECT_EQ_SELECTED_TEXT(text) \
EXPECT_EQ(text, WebString(selection().selectedText()).utf8())

Powered by Google App Engine
This is Rietveld 408576698