FrameSelection::updateApperance for caret should not cause layout.
We do not need update caret rectangle synchronously because we just need updated caret in painting. Thus this CL delays computing new caret rectangle. Source/core/editing/FrameSelection.cpp: - Add ResetCaretBlinkOption to updateAppearance(). The option is set to ResetCaretBlink when it is called from setSelection. If ResetCaretBlink, we reset caret blinking. If we need to repaint caret, set |m_caretRectDirty| flag. If |m_caretRectDirty| is set, we call PageAnimator::scheduleVisualUpdate to trigger repaint. For range, create VisibleSelection without validation like HTMLTextFormControlElement::setSelectionRange. - Add the setCaretRectNeedsUpdate function to just set |m_caretRectDirty| flag and call new scheduleVisualUpdate function, which calls PageAnimator::scheduleVisualUpdate. - FrameSelection::invalidateCaretRect does 1. Checks the dirty flag. 2. Gets new caret rectangle and node which has the caret renderer. 3. if caret is changed, invalidate the new caret rect and the old caret rect. 4. Caches the new caret rect and node. Sets dirty flag off. This function is similar to old recomputeCaretRect(deleted). - Delete unused updateRenderTreeIfneeded() from notifyRenderOfSelectionChange(). In old days, notifyRenderOfSelectionChange() used renderer. - Refactor FrameSelection::absoluteCaretBounds() to call updateCaretRect directly. Since we update layout, ASSERT that document's lifecycle is not in InPaintInvalidation. Source/core/editing/Caret.cpp: - Remove document->updateRenderTreeIfNeeded() from CaretBase::updateCaretRect and call it from caller. - In FrameSelection::paintCaret, call without updateRenderTreeIfNeeded because the tree must be updated on the painting phase. Source/core/frame/FrameView.cpp: - FrameView::invalidateTreeIfNeeded calls FrameSelection::InvalidateCaretRect to invalidate caret rect for each frame. Source/core/html/HTMLTextFormControlElementTest.cpp: - Add new test to confirm setSelectionRange with another start/end not cause layout. - Delete FrameSelectionLocalCaretRectDoesNotCauseLayout because localCaretRect is removed. Layouttests: - This cl reduces redundant RenderObject::invalidatePaintRectangle calls so we need to delete lines from expected.txt but result images are still same. BUG=382809, 397303, 403317 TEST=Layouttests/fast/forms/textarea-scrollbar.html, textarea-scrolled-type.html Review URL: https://codereview.chromium.org/431983005 git-svn-id: svn://svn.chromium.org/blink/trunk@180269 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Showing
This diff is collapsed.
Please register or sign in to comment