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

Unified Diff: Source/core/editing/FrameSelection.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: fix 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
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 55db7b776bc49c8f96fb84cccf87fef731630808..382c3ddf8a6a40c23d47edecbd59ee823a08f78b 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -1222,13 +1222,22 @@ static bool isNonOrphanedCaret(const VisibleSelection& selection)
return selection.isCaret() && !selection.start().isOrphan() && !selection.end().isOrphan();
}
+static bool isTextFormControl(const VisibleSelection& selection)
+{
+ return !!enclosingTextFormControl(selection.start());
yosin_UTC9 2014/07/29 07:00:20 nit: I don't think we need to use |!!| for casting
yoichio 2014/07/29 08:05:17 Done.
+}
+
LayoutRect FrameSelection::localCaretRect()
{
if (shouldUpdateCaretRect()) {
- if (!isNonOrphanedCaret(m_selection))
+ if (!isNonOrphanedCaret(m_selection)) {
clearCaretRect();
- else if (updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start(), m_selection.affinity())))
- m_absCaretBoundsDirty = true;
+ } else {
+ if (isTextFormControl(m_selection))
yosin_UTC9 2014/07/29 07:00:20 nit: We can combine |else| and |if|.
yoichio 2014/07/29 08:05:17 Done.
+ m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), PositionWithAffinity(m_selection.start().isCandidate() ? m_selection.start() : Position(), m_selection.affinity()));
yosin_UTC9 2014/07/29 07:00:20 Q: Why do we need to check |start()| is editable p
yoichio 2014/07/29 08:05:17 updateCaretRect suppose that an argument Visible p
+ else
+ m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start(), m_selection.affinity()));
+ }
}
return localCaretRectWithoutUpdate();

Powered by Google App Engine
This is Rietveld 408576698