[iOS] Unable to make a selection in jsfiddle.net using arrow keys when requesting...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 16:05:18 +0000 (16:05 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2019 16:05:18 +0000 (16:05 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240926 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/html/HTMLInputElement.cpp

index 02b62d4..ad89714 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-04  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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  <zalan@apple.com>
 
         [LFC][IFC] Make InlineFormattingContext::collectInlineContent non-recursive.
index 27fb1f0..655c4ed 100644 (file)
@@ -93,6 +93,9 @@ public:
     // 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;
 };
index 43ae3b4..cafd2dd 100644 (file)
@@ -469,14 +469,13 @@ void HTMLInputElement::updateFocusAppearance(SelectionRestorationMode restoratio
 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());
 }