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

Unified Diff: Source/core/html/HTMLTextFormControlElementTest.cpp

Issue 429453004: Let FrameSelection::localCaretRect on a text input field avoid synchronous layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Nits Created 6 years, 5 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
« Source/core/editing/Caret.h ('K') | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextFormControlElementTest.cpp
diff --git a/Source/core/html/HTMLTextFormControlElementTest.cpp b/Source/core/html/HTMLTextFormControlElementTest.cpp
index 5ac92f8325c2ef0a1593833e244e63404f77ec97..c222c76cdb6fcd3e09f7cc590d015eeed7670de1 100644
--- a/Source/core/html/HTMLTextFormControlElementTest.cpp
+++ b/Source/core/html/HTMLTextFormControlElementTest.cpp
@@ -34,6 +34,10 @@ protected:
DummyPageHolder& page() const { return *m_dummyPageHolder; }
HTMLDocument& document() const { return *m_document; }
HTMLTextFormControlElement& textControl() const { return *m_textControl; }
+ HTMLInputElement& input() const { return *m_input; }
+
+ int layoutCount() const { return page().frameView().layoutCount(); }
+ void forceLayoutFlag();
private:
OwnPtr<SpellCheckerClient> m_spellCheckerClient;
@@ -41,6 +45,7 @@ private:
RefPtrWillBePersistent<HTMLDocument> m_document;
RefPtrWillBePersistent<HTMLTextFormControlElement> m_textControl;
+ RefPtrWillBePersistent<HTMLInputElement> m_input;
};
class DummyTextCheckerClient : public EmptyTextCheckerClient {
@@ -76,6 +81,16 @@ void HTMLTextFormControlElementTest::SetUp()
m_document->view()->updateLayoutAndStyleIfNeededRecursive();
m_textControl = toHTMLTextFormControlElement(m_document->getElementById("textarea"));
m_textControl->focus();
+ m_input = toHTMLInputElement(m_document->getElementById("input"));
+}
+
+void HTMLTextFormControlElementTest::forceLayoutFlag()
+{
+ FrameView& frameView = page().frameView();
+ IntRect frameRect = frameView.frameRect();
+ frameRect.setWidth(frameRect.width() + 1);
+ frameRect.setHeight(frameRect.height() + 1);
+ page().frameView().setFrameRect(frameRect);
}
TEST_F(HTMLTextFormControlElementTest, SetSelectionRange)
@@ -92,6 +107,19 @@ TEST_F(HTMLTextFormControlElementTest, SetSelectionRange)
EXPECT_EQ(3, textControl().selectionEnd());
}
+TEST_F(HTMLTextFormControlElementTest, FrameSelectionLocalCaretRectDoesNotCauseLayout)
+{
+ input().focus();
+ input().setValue("Hello, input form.");
+ FrameSelection& frameSelection = document().frame()->selection();
+ frameSelection.setCaretRectNeedsUpdate();
+
+ forceLayoutFlag();
+ int startLayoutCount = layoutCount();
+ frameSelection.localCaretRect();
+ EXPECT_EQ(startLayoutCount, layoutCount());
+}
+
typedef Position (*PositionFunction)(const Position&);
typedef VisiblePosition(*VisblePositionFunction)(const VisiblePosition&);
@@ -178,10 +206,10 @@ TEST_F(HTMLTextFormControlElementTest, SpellCheckDoesNotCauseUpdateLayout)
ASSERT_EQ(3, input->selectionStart());
OwnPtr<SpellChecker> spellChecker(SpellChecker::create(page().frame()));
- page().frameView().setFrameRect(IntRect(0, 0, 801, 601));
- int startCount = page().frameView().layoutCount();
+ forceLayoutFlag();
+ int startCount = layoutCount();
spellChecker->respondToChangedSelection(oldSelection, FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle);
- EXPECT_EQ(startCount, page().frameView().layoutCount());
+ EXPECT_EQ(startCount, layoutCount());
}
}
« Source/core/editing/Caret.h ('K') | « Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698