SelectionController::positionForPlatform should ask EditingBehavior for platform...
authortonikitoo@webkit.org <tonikitoo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2016 18:50:55 +0000 (18:50 +0000)
committertonikitoo@webkit.org <tonikitoo@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Mar 2016 18:50:55 +0000 (18:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=41976

Reviewed by Darin Adler.

SSIA.

No new tests needed.

* editing/EditingBehavior.h:
(WebCore::EditingBehavior::shouldAlwaysExtendSelectionFromExtentEndpoint):
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::positionForPlatform):

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

Source/WebCore/ChangeLog
Source/WebCore/editing/EditingBehavior.h
Source/WebCore/editing/FrameSelection.cpp

index 05e8404..fbefaca 100644 (file)
@@ -1,3 +1,19 @@
+2016-03-31  Antonio Gomes  <tonikitoo@webkit.org>
+
+        SelectionController::positionForPlatform should ask EditingBehavior for platform specific behavior
+        https://bugs.webkit.org/show_bug.cgi?id=41976
+
+        Reviewed by Darin Adler.
+
+        SSIA.
+
+        No new tests needed.
+
+        * editing/EditingBehavior.h:
+        (WebCore::EditingBehavior::shouldAlwaysExtendSelectionFromExtentEndpoint):
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::positionForPlatform):
+
 2016-03-31  Jeremy Jones  <jeremyj@apple.com>
 
         mediaShouldUsePersistentCache() is redundant. Use Page::usesEphemeralSession() instead.
index 56841dc..42fb0d6 100644 (file)
@@ -91,6 +91,9 @@ public:
 
     bool shouldSelectBasedOnDictionaryLookup() const { return m_type == EditingMacBehavior; }
 
+    // Linux and Windows always extend selections from the extent endpoint.
+    bool shouldAlwaysExtendSelectionFromExtentEndpoint() const { return m_type != EditingMacBehavior && m_type != EditingIOSBehavior; }
+
 private:
     EditingBehaviorType m_type;
 };
index 194b08d..7199062 100644 (file)
@@ -620,14 +620,14 @@ void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
 
 VisiblePosition FrameSelection::positionForPlatform(bool isGetStart) const
 {
-    if (m_frame && (m_frame->settings().editingBehaviorType() == EditingMacBehavior || m_frame->settings().editingBehaviorType() == EditingIOSBehavior))
-        return isGetStart ? m_selection.visibleStart() : m_selection.visibleEnd();
-    // Linux and Windows always extend selections from the extent endpoint.
     // FIXME: VisibleSelection should be fixed to ensure as an invariant that
     // base/extent always point to the same nodes as start/end, but which points
     // to which depends on the value of isBaseFirst. Then this can be changed
     // to just return m_sel.extent().
-    return m_selection.isBaseFirst() ? m_selection.visibleEnd() : m_selection.visibleStart();
+    if (m_frame && m_frame->editor().behavior().shouldAlwaysExtendSelectionFromExtentEndpoint())
+        return m_selection.isBaseFirst() ? m_selection.visibleEnd() : m_selection.visibleStart();
+
+    return isGetStart ? m_selection.visibleStart() : m_selection.visibleEnd();
 }
 
 VisiblePosition FrameSelection::startForPlatform() const