Title: [121121] trunk
Revision
121121
Author
[email protected]
Date
2012-06-24 14:44:47 -0700 (Sun, 24 Jun 2012)

Log Message

After Editor::setComposition is called, input should scroll to the end of the composition.
https://bugs.webkit.org/show_bug.cgi?id=88999

Patch by Oli Lan <[email protected]> on 2012-06-24
Reviewed by Ryosuke Niwa.

Source/WebCore:

This fixes an issue where after a call to setComposition, the start of the composition is revealed
(scrolled to) instead of the end (where the caret/editing point should be).

The change is to allow revealSelectionAfterEditingOperation to take a revealExtent parameter,
and to pass that parameter as true when calling from setIgnoreCompositionSelectionChange, which is
called at the end of setComposition.

Test: fast/forms/input-set-composition-scroll.html

* editing/Editor.cpp:
(WebCore::Editor::revealSelectionAfterEditingOperation):
(WebCore::Editor::setIgnoreCompositionSelectionChange):
* editing/Editor.h:
(Editor):

LayoutTests:

This tests that after setComposition is called, the input scrolls to the end of the composition
(i.e. that the end of the selection/composition is revealed).

* fast/forms/input-set-composition-scroll-expected.txt: Added.
* fast/forms/input-set-composition-scroll.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121120 => 121121)


--- trunk/LayoutTests/ChangeLog	2012-06-24 18:44:02 UTC (rev 121120)
+++ trunk/LayoutTests/ChangeLog	2012-06-24 21:44:47 UTC (rev 121121)
@@ -1,3 +1,16 @@
+2012-06-24  Oli Lan  <[email protected]>
+
+        After Editor::setComposition is called, input should scroll to the end of the composition.
+        https://bugs.webkit.org/show_bug.cgi?id=88999
+
+        Reviewed by Ryosuke Niwa.
+
+        This tests that after setComposition is called, the input scrolls to the end of the composition
+        (i.e. that the end of the selection/composition is revealed).
+
+        * fast/forms/input-set-composition-scroll-expected.txt: Added.
+        * fast/forms/input-set-composition-scroll.html: Added.
+
 2012-06-24  Adam Barth  <[email protected]>
 
         The comment in test_expectations_android.txt is unclear as to the purpose of this file.

Added: trunk/LayoutTests/fast/forms/input-set-composition-scroll-expected.txt (0 => 121121)


--- trunk/LayoutTests/fast/forms/input-set-composition-scroll-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-set-composition-scroll-expected.txt	2012-06-24 21:44:47 UTC (rev 121121)
@@ -0,0 +1,5 @@
+This tests whether an input field scrolls to the end of the new composition when setComposition is called.
+
+
+SUCCESS: input has scrolled to the end of the composition
+

Added: trunk/LayoutTests/fast/forms/input-set-composition-scroll.html (0 => 121121)


--- trunk/LayoutTests/fast/forms/input-set-composition-scroll.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-set-composition-scroll.html	2012-06-24 21:44:47 UTC (rev 121121)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<p>This tests whether an input field scrolls to the end of the new composition when setComposition is called.</p>
+<input size="10"/>
+<pre id="log">
+</pre>
+<script>
+function log(s) {
+    document.getElementById('log').appendChild(document.createTextNode(s + "\n"));
+}
+
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+
+var input = document.querySelector('input');
+input.focus();
+textInputController.setComposition('longsinglewordstringcomposition');
+var maxScrollLeft = input.scrollWidth - input.clientWidth;
+if (maxScrollLeft - input.scrollLeft < 5)
+    log("SUCCESS: input has scrolled to the end of the composition");
+else
+    log("FAILED: input has not scrolled to the end of the composition. scrollLeft=" + input.scrollLeft);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (121120 => 121121)


--- trunk/Source/WebCore/ChangeLog	2012-06-24 18:44:02 UTC (rev 121120)
+++ trunk/Source/WebCore/ChangeLog	2012-06-24 21:44:47 UTC (rev 121121)
@@ -1,3 +1,25 @@
+2012-06-24  Oli Lan  <[email protected]>
+
+        After Editor::setComposition is called, input should scroll to the end of the composition.
+        https://bugs.webkit.org/show_bug.cgi?id=88999
+
+        Reviewed by Ryosuke Niwa.
+
+        This fixes an issue where after a call to setComposition, the start of the composition is revealed
+        (scrolled to) instead of the end (where the caret/editing point should be).
+
+        The change is to allow revealSelectionAfterEditingOperation to take a revealExtent parameter,
+        and to pass that parameter as true when calling from setIgnoreCompositionSelectionChange, which is
+        called at the end of setComposition.
+
+        Test: fast/forms/input-set-composition-scroll.html
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::revealSelectionAfterEditingOperation):
+        (WebCore::Editor::setIgnoreCompositionSelectionChange):
+        * editing/Editor.h:
+        (Editor):
+
 2012-06-24  Joshua Bell  <[email protected]>
 
         Web Inspector: Simplify InspectorIndexedDBAgent to use IDB metadata API

Modified: trunk/Source/WebCore/editing/Editor.cpp (121120 => 121121)


--- trunk/Source/WebCore/editing/Editor.cpp	2012-06-24 18:44:02 UTC (rev 121120)
+++ trunk/Source/WebCore/editing/Editor.cpp	2012-06-24 21:44:47 UTC (rev 121121)
@@ -2296,12 +2296,12 @@
     return avoidIntersectionWithNode(selection.toNormalizedRange().get(), m_deleteButtonController->containerElement());
 }
 
-void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignment)
+void Editor::revealSelectionAfterEditingOperation(const ScrollAlignment& alignment, RevealExtentOption revealExtentOption)
 {
     if (m_ignoreCompositionSelectionChange)
         return;
 
-    m_frame->selection()->revealSelection(alignment);
+    m_frame->selection()->revealSelection(alignment, revealExtentOption == RevealExtent);
 }
 
 void Editor::setIgnoreCompositionSelectionChange(bool ignore)
@@ -2311,7 +2311,7 @@
 
     m_ignoreCompositionSelectionChange = ignore;
     if (!ignore)
-        revealSelectionAfterEditingOperation();
+        revealSelectionAfterEditingOperation(ScrollAlignment::alignToEdgeIfNeeded, RevealExtent);
 }
 
 PassRefPtr<Range> Editor::compositionRange() const

Modified: trunk/Source/WebCore/editing/Editor.h (121120 => 121121)


--- trunk/Source/WebCore/editing/Editor.h	2012-06-24 18:44:02 UTC (rev 121120)
+++ trunk/Source/WebCore/editing/Editor.h	2012-06-24 21:44:47 UTC (rev 121121)
@@ -422,7 +422,13 @@
     PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy, Frame*);
     void pasteAsPlainTextWithPasteboard(Pasteboard*);
     void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
-    void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded);
+
+    enum RevealExtentOption {
+        RevealExtent,
+        DoNotRevealExtent
+    };
+
+    void revealSelectionAfterEditingOperation(const ScrollAlignment& = ScrollAlignment::alignCenterIfNeeded, RevealExtentOption = DoNotRevealExtent);
     void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
     TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to