Title: [240926] trunk/Source/WebCore
Revision
240926
Author
[email protected]
Date
2019-02-04 08:05:18 -0800 (Mon, 04 Feb 2019)

Log Message

[iOS] Unable to make a selection in jsfiddle.net using arrow keys when requesting desktop site
Followup to https://bugs.webkit.org/show_bug.cgi?id=193758

Reviewed by Daniel Bates.

Put the iOS-specific behavior behind an EditingBehavior check, rather than a compile-time guard. No change in
behavior.

* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldMoveSelectionToEndWhenFocusingTextInput const):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setDefaultSelectionAfterFocus):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240925 => 240926)


--- trunk/Source/WebCore/ChangeLog	2019-02-04 16:02:28 UTC (rev 240925)
+++ trunk/Source/WebCore/ChangeLog	2019-02-04 16:05:18 UTC (rev 240926)
@@ -1,3 +1,18 @@
+2019-02-04  Wenson Hsieh  <[email protected]>
+
+        [iOS] Unable to make a selection in jsfiddle.net using arrow keys when requesting desktop site
+        Followup to https://bugs.webkit.org/show_bug.cgi?id=193758
+
+        Reviewed by Daniel Bates.
+
+        Put the iOS-specific behavior behind an EditingBehavior check, rather than a compile-time guard. No change in
+        behavior.
+
+        * editing/EditingBehavior.h:
+        (WebCore::EditingBehavior::shouldMoveSelectionToEndWhenFocusingTextInput const):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setDefaultSelectionAfterFocus):
+
 2019-02-04  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Make InlineFormattingContext::collectInlineContent non-recursive.

Modified: trunk/Source/WebCore/editing/EditingBehavior.h (240925 => 240926)


--- trunk/Source/WebCore/editing/EditingBehavior.h	2019-02-04 16:02:28 UTC (rev 240925)
+++ trunk/Source/WebCore/editing/EditingBehavior.h	2019-02-04 16:05:18 UTC (rev 240926)
@@ -93,6 +93,9 @@
     // Linux and Windows always extend selections from the extent endpoint.
     bool shouldAlwaysExtendSelectionFromExtentEndpoint() const { return m_type != EditingMacBehavior && m_type != EditingIOSBehavior; }
 
+    // On iOS, we don't want to select all the text when focusing a field. Instead, match platform behavior by going to the end of the line.
+    bool shouldMoveSelectionToEndWhenFocusingTextInput() const { return m_type == EditingIOSBehavior; }
+
 private:
     EditingBehaviorType m_type;
 };

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (240925 => 240926)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2019-02-04 16:02:28 UTC (rev 240925)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2019-02-04 16:05:18 UTC (rev 240926)
@@ -469,14 +469,13 @@
 void HTMLInputElement::setDefaultSelectionAfterFocus(SelectionRevealMode revealMode)
 {
     ASSERT(isTextField());
-#if PLATFORM(IOS_FAMILY)
-    // We don't want to select all the text on iOS when focusing a field. Instead, match platform behavior by going to the end of the line.
-    int start = std::numeric_limits<int>::max();
-    auto direction = SelectionHasForwardDirection;
-#else
     int start = 0;
     auto direction = SelectionHasNoDirection;
-#endif
+    auto* frame = document().frame();
+    if (frame && frame->editor().behavior().shouldMoveSelectionToEndWhenFocusingTextInput()) {
+        start = std::numeric_limits<int>::max();
+        direction = SelectionHasForwardDirection;
+    }
     setSelectionRange(start, std::numeric_limits<int>::max(), direction, revealMode, Element::defaultFocusTextStateChangeIntent());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to