Diff
Modified: branches/chromium/1132/LayoutTests/editing/input/resources/reveal-utilities.js (117418 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/resources/reveal-utilities.js 2012-05-17 09:12:54 UTC (rev 117418)
+++ branches/chromium/1132/LayoutTests/editing/input/resources/reveal-utilities.js 2012-05-17 09:24:38 UTC (rev 117419)
@@ -64,3 +64,27 @@
document.execCommand("paste");
}
}
+
+function performJumpAtTheEdgeTest(useCtrlKeyModifier)
+{
+ var textArea = document.getElementById("input");
+ textArea.focus();
+ if (window.eventSender) {
+ var previousScrollTop = 0, currentScrollTop = 0;
+ var jumpDetected = false;
+ for (var i = 0; i < 120; ++i) {
+ previousScrollTop = document.body.scrollTop;
+ eventSender.keyDown("\r", useCtrlKeyModifier ? ["ctrlKey"] : []);
+ currentScrollTop = document.body.scrollTop;
+ // Smooth scrolls are allowed.
+ if (Math.abs(previousScrollTop - currentScrollTop) > 24) {
+ jumpDetected = true;
+ break;
+ }
+ }
+ if (!jumpDetected)
+ document.write("PASS");
+ else
+ document.write("FAIL<br>Jump scroll from " + previousScrollTop + " to " + currentScrollTop);
+ }
+}
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable-expected.txt (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable-expected.txt) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable-expected.txt (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable-expected.txt 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,123 @@
+When the caret is scrolled out and resides at the end of the contenteditable, on pressing "Ctrl+Return" it must be scrolled to the bottom of the view, not to the center to avoid undesirable content view jumping.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+PASS
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable.html (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable.html) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable.html (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-contenteditable.html 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<head>
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<div>When the caret is scrolled out and resides at the end of the contenteditable,
+on pressing "Ctrl+Return" it must be scrolled to the bottom of the view,
+not to the center to avoid undesirable content view jumping.</div>
+<div style="height:1000px;">
+ <div style="overflow:visible; height:100px;" contenteditable="true" id="input"></div>
+</div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+performJumpAtTheEdgeTest(true);
+
+</script>
+</body>
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea-expected.txt (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea-expected.txt) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea-expected.txt (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea-expected.txt 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,3 @@
+When the caret is scrolled out and resides at the end of the textarea, on pressing "Return" it must be scrolled to the bottom of the view, not to the center to avoid undesirable content view jumping.
+
+PASS
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea.html (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea.html) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea.html (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-line-break-at-end-of-document-textarea.html 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<head>
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<div>When the caret is scrolled out and resides at the end of the textarea,
+on pressing "Return" it must be scrolled to the bottom of the view,
+not to the center to avoid undesirable content view jumping.</div>
+<div style="overflow:auto;height:1000px;">
+ <textarea rows="50" cols="20" id="input"></textarea>
+</div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+performJumpAtTheEdgeTest(false);
+
+</script>
+</body>
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable-expected.txt (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable-expected.txt) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable-expected.txt (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable-expected.txt 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,123 @@
+When the caret is scrolled out and resides at the end of the contenteditable, on pressing "Return" it must be scrolled to the bottom of the view, not to the center to avoid undesirable content view jumping.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+PASS
Copied: branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable.html (from rev 117307, trunk/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable.html) (0 => 117419)
--- branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable.html (rev 0)
+++ branches/chromium/1132/LayoutTests/editing/input/scroll-to-edge-if-paragraph-separator-at-end-of-document-contenteditable.html 2012-05-17 09:24:38 UTC (rev 117419)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<head>
+<script type="text/_javascript_" src=""
+</head>
+<body>
+<div>When the caret is scrolled out and resides at the end of the contenteditable,
+on pressing "Return" it must be scrolled to the bottom of the view,
+not to the center to avoid undesirable content view jumping.</div>
+<div style="height:1000px;">
+ <div style="overflow:visible; height:100px;" contenteditable="true" id="input"></div>
+</div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+performJumpAtTheEdgeTest(false);
+
+</script>
+</body>
Modified: branches/chromium/1132/Source/WebCore/editing/Editor.cpp (117418 => 117419)
--- branches/chromium/1132/Source/WebCore/editing/Editor.cpp 2012-05-17 09:12:54 UTC (rev 117418)
+++ branches/chromium/1132/Source/WebCore/editing/Editor.cpp 2012-05-17 09:24:38 UTC (rev 117419)
@@ -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)
Modified: branches/chromium/1132/Source/WebCore/editing/Editor.h (117418 => 117419)
--- branches/chromium/1132/Source/WebCore/editing/Editor.h 2012-05-17 09:12:54 UTC (rev 117418)
+++ branches/chromium/1132/Source/WebCore/editing/Editor.h 2012-05-17 09:24:38 UTC (rev 117419)
@@ -421,7 +421,7 @@
PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy, Frame*);
void pasteAsPlainTextWithPasteboard(Pasteboard*);
void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
- void revealSelectionAfterEditingOperation();
+ void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded);
void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);