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

Unified Diff: Source/WebCore/editing/Editor.cpp

Issue 10382217: Merge 117307 - Avoid jumpscroll when entering new text in a multi-line editor. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 7 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 | « Source/WebCore/editing/Editor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/editing/Editor.cpp
===================================================================
--- Source/WebCore/editing/Editor.cpp (revision 117418)
+++ Source/WebCore/editing/Editor.cpp (working copy)
@@ -944,9 +944,11 @@
if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(), EditorInsertActionTyped))
return true;
+ VisiblePosition caret = m_frame->selection()->selection().visibleStart();
+ bool alignToEdge = isEndOfDocument(caret);
bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate();
TypingCommand::insertLineBreak(m_frame->document(), autocorrectionIsApplied ? TypingCommand::RetainAutocorrectionIndicator : 0);
- revealSelectionAfterEditingOperation();
+ revealSelectionAfterEditingOperation(alignToEdge ? ScrollAlignment::alignToEdgeIfNeeded : ScrollAlignment::alignCenterIfNeeded);
return true;
}
@@ -962,9 +964,11 @@
if (!shouldInsertText("\n", m_frame->selection()->toNormalizedRange().get(), EditorInsertActionTyped))
return true;
+ VisiblePosition caret = m_frame->selection()->selection().visibleStart();
+ bool alignToEdge = isEndOfDocument(caret);
bool autocorrectionIsApplied = m_alternativeTextController->applyAutocorrectionBeforeTypingIfAppropriate();
TypingCommand::insertParagraphSeparator(m_frame->document(), autocorrectionIsApplied ? TypingCommand::RetainAutocorrectionIndicator : 0);
- revealSelectionAfterEditingOperation();
+ revealSelectionAfterEditingOperation(alignToEdge ? ScrollAlignment::alignToEdgeIfNeeded : ScrollAlignment::alignCenterIfNeeded);
return true;
}
@@ -2282,12 +2286,12 @@
return avoidIntersectionWithNode(selection.toNormalizedRange().get(), m_deleteButtonController->containerElement());
}
-void Editor::revealSelectionAfterEditingOperation()
+void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignment)
{
if (m_ignoreCompositionSelectionChange)
return;
- m_frame->selection()->revealSelection(ScrollAlignment::alignCenterIfNeeded);
+ m_frame->selection()->revealSelection(alignment);
}
void Editor::setIgnoreCompositionSelectionChange(bool ignore)
« no previous file with comments | « Source/WebCore/editing/Editor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698