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

Unified Diff: Source/core/editing/FrameSelection.cpp

Issue 431983005: FrameSelection::updateApperance for caret should not cause layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: wip 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
« no previous file with comments | « no previous file | Source/core/html/HTMLTextFormControlElementTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 126cf31b027d91093ffe0a4c0c60c848d0ee21ed..154cddaa21f1dedffd729f4deb78493f397db868 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -272,8 +272,6 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
setFocusedNodeIfNeeded();
if (!(options & DoNotUpdateAppearance)) {
- m_frame->document()->updateLayoutIgnorePendingStylesheets();
-
// Hits in compositing/overflow/do-not-paint-outline-into-composited-scrolling-contents.html
DisableCompositingQueryAsserts disabler;
updateAppearance();
@@ -1233,12 +1231,14 @@ static bool isTextFormControl(const VisibleSelection& selection)
LayoutRect FrameSelection::localCaretRect()
{
if (shouldUpdateCaretRect()) {
- if (!isNonOrphanedCaret(m_selection))
+ if (!isNonOrphanedCaret(m_selection)) {
clearCaretRect();
- else if (isTextFormControl(m_selection))
+ } else if (isTextFormControl(m_selection)) {
+ m_frame->document()->updateLayoutIgnorePendingStylesheets();
m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), PositionWithAffinity(m_selection.start().isCandidate() ? m_selection.start() : Position(), m_selection.affinity()));
- else
+ } else {
m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), VisiblePosition(m_selection.start(), m_selection.affinity()));
+ }
}
return localCaretRectWithoutUpdate();
@@ -1292,8 +1292,10 @@ void FrameSelection::invalidateCaretRect()
void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect)
{
- if (m_selection.isCaret() && m_caretPaint)
+ if (m_selection.isCaret() && m_caretPaint) {
+ localCaretRect();
yosin_UTC9 2014/08/04 01:44:23 The name of |localCaretRect()| make me to feel it
yoichio 2014/08/04 02:12:18 Done.
CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, paintOffset, clipRect);
+ }
}
bool FrameSelection::contains(const LayoutPoint& point)
@@ -1542,6 +1544,7 @@ inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame)
void FrameSelection::updateAppearance()
{
+ bool isTextForm = isTextFormControl(m_selection);
// Paint a block cursor instead of a caret in overtype mode unless the caret is at the end of a line (in this case
// the FrameSelection will paint a blinking caret as usual).
VisiblePosition forwardPosition;
@@ -1550,7 +1553,7 @@ void FrameSelection::updateAppearance()
m_caretPaint = forwardPosition.isNull();
}
- bool caretRectChangedOrCleared = recomputeCaretRect();
+ bool caretRectChangedOrCleared = isTextForm || recomputeCaretRect();
bool shouldBlink = shouldBlinkCaret() && forwardPosition.isNull();
// If the caret moved, stop the blink timer so we can restart with a
@@ -1581,7 +1584,11 @@ void FrameSelection::updateAppearance()
// Construct a new VisibleSolution, since m_selection is not necessarily valid, and the following steps
// assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69563> and <rdar://problem/10232866>.
- VisibleSelection selection(m_selection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : m_selection.visibleEnd());
+ VisibleSelection selection;
+ if (isTextForm)
+ selection.setWithoutValidation(m_selection.start(), forwardPosition.isNotNull() ? forwardPosition.deepEquivalent() : m_selection.end());
+ else
+ selection = VisibleSelection(m_selection.visibleStart(), forwardPosition.isNotNull() ? forwardPosition : m_selection.visibleEnd());
if (!selection.isRange()) {
view->clearSelection();
@@ -1657,8 +1664,6 @@ void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*)
void FrameSelection::notifyRendererOfSelectionChange(EUserTriggered userTriggered)
{
- m_frame->document()->updateRenderTreeIfNeeded();
-
if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start()))
textControl->selectionChanged(userTriggered == UserTriggered);
}
« no previous file with comments | « no previous file | Source/core/html/HTMLTextFormControlElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698