Title: [99255] trunk
Revision
99255
Author
[email protected]
Date
2011-11-03 18:18:16 -0700 (Thu, 03 Nov 2011)

Log Message

Enable ctrl-arrow move cursor by word in visual order in cr-win by command line flag.
https://bugs.webkit.org/show_bug.cgi?id=71163

Reviewed by Ryosuke Niwa.

Source/WebCore: 

Add m_visualWordMovementEnabled page setting, trigger visual word movement
function (instead of logical one) when it is set as true.

right|leftWordPosition() are tested in editing/selection/move-by-word-visually*
by using --webkit-visual-word flag.

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::modifyMovingRight):
(WebCore::FrameSelection::modifyMovingLeft):
(WebCore::FrameSelection::visualWordMovementEnabled):
* editing/FrameSelection.h:
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setVisualWordMovementEnabled):
(WebCore::Settings::visualWordMovementEnabled):

Source/WebKit/chromium: 

To minimize the risk to LTR users, we enable this feature first to chromium win
by command line flag. This and corresponding changset in chromium
(http://codereview.chromium.org/8400078/)
should be removed after this feature is enabled without command line flag. 

The work flow is:
1. (chromium) adds command line flag --enable-visual-word-movement,
   pass it to WebCore::Settings through WebPreferences.
2. in FrameSelection::modifyMovingLeft|Right, when 'visualWordMovementEnabled' is true in page's Settings,
   trigger visual word movement instead of logical one.
 
* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setVisualWordMovementEnabled):
* src/WebSettingsImpl.h:

Tools: 

* DumpRenderTree/chromium/WebPreferences.cpp: Set visualWordMovementEabled to false in DRT.
(WebPreferences::applyTo):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99254 => 99255)


--- trunk/Source/WebCore/ChangeLog	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebCore/ChangeLog	2011-11-04 01:18:16 UTC (rev 99255)
@@ -1,3 +1,27 @@
+2011-11-02  Xiaomei Ji  <[email protected]>
+
+        Enable ctrl-arrow move cursor by word in visual order in cr-win by command line flag.
+        https://bugs.webkit.org/show_bug.cgi?id=71163
+
+        Reviewed by Ryosuke Niwa.
+
+        Add m_visualWordMovementEnabled page setting, trigger visual word movement
+        function (instead of logical one) when it is set as true.
+
+        right|leftWordPosition() are tested in editing/selection/move-by-word-visually*
+        by using --webkit-visual-word flag.
+
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::modifyMovingRight):
+        (WebCore::FrameSelection::modifyMovingLeft):
+        (WebCore::FrameSelection::visualWordMovementEnabled):
+        * editing/FrameSelection.h:
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        * page/Settings.h:
+        (WebCore::Settings::setVisualWordMovementEnabled):
+        (WebCore::Settings::visualWordMovementEnabled):
+
 2011-11-03  Levi Weintraub  <[email protected]>
 
         Correct usage of LayoutUnits and integers in Table rendering classes

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (99254 => 99255)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2011-11-04 01:18:16 UTC (rev 99255)
@@ -634,6 +634,10 @@
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).right(true);
         break;
     case WordGranularity:
+        if (visualWordMovementEnabled()) {
+            pos = rightWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
+            break;
+        }
     case SentenceGranularity:
     case LineGranularity:
     case ParagraphGranularity:
@@ -805,6 +809,10 @@
             pos = VisiblePosition(m_selection.extent(), m_selection.affinity()).left(true);
         break;
     case WordGranularity:
+        if (visualWordMovementEnabled()) {
+            pos = leftWordPosition(VisiblePosition(m_selection.extent(), m_selection.affinity()));
+            break;
+        }
     case SentenceGranularity:
     case LineGranularity:
     case ParagraphGranularity:
@@ -1957,6 +1965,12 @@
     return selectStartTarget->dispatchEvent(Event::create(eventNames().selectstartEvent, true, true));
 }
 
+inline bool FrameSelection::visualWordMovementEnabled() const
+{
+    Settings* settings = m_frame ? m_frame->settings() : 0;
+    return settings && settings->visualWordMovementEnabled();
+}
+
 #ifndef NDEBUG
 
 void FrameSelection::formatForDebugger(char* buffer, unsigned length) const

Modified: trunk/Source/WebCore/editing/FrameSelection.h (99254 => 99255)


--- trunk/Source/WebCore/editing/FrameSelection.h	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebCore/editing/FrameSelection.h	2011-11-04 01:18:16 UTC (rev 99255)
@@ -279,6 +279,8 @@
     void setCaretVisibility(CaretVisibility);
 
     bool dispatchSelectStart();
+  
+    bool visualWordMovementEnabled() const;
 
     Frame* m_frame;
 

Modified: trunk/Source/WebCore/page/Settings.cpp (99254 => 99255)


--- trunk/Source/WebCore/page/Settings.cpp	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebCore/page/Settings.cpp	2011-11-04 01:18:16 UTC (rev 99255)
@@ -230,6 +230,7 @@
 #endif
     , m_suppressIncrementalRendering(false)
     , m_backspaceKeyNavigationEnabled(true)
+    , m_visualWordMovementEnabled(false)
     , m_loadsImagesAutomaticallyTimer(this, &Settings::loadsImagesAutomaticallyTimerFired)
 {
     // A Frame may not have been created yet, so we initialize the AtomicString 

Modified: trunk/Source/WebCore/page/Settings.h (99254 => 99255)


--- trunk/Source/WebCore/page/Settings.h	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebCore/page/Settings.h	2011-11-04 01:18:16 UTC (rev 99255)
@@ -485,6 +485,9 @@
         static void setMockScrollbarsEnabled(bool flag);
         static bool mockScrollbarsEnabled();
 
+        void setVisualWordMovementEnabled(bool enabled) { m_visualWordMovementEnabled = enabled; }
+        bool visualWordMovementEnabled() const { return m_visualWordMovementEnabled; }
+
     private:
         Page* m_page;
 
@@ -611,6 +614,7 @@
         bool m_passwordEchoEnabled : 1;
         bool m_suppressIncrementalRendering : 1;
         bool m_backspaceKeyNavigationEnabled : 1;
+        bool m_visualWordMovementEnabled : 1;
 
         Timer<Settings> m_loadsImagesAutomaticallyTimer;
         void loadsImagesAutomaticallyTimerFired(Timer<Settings>*);

Modified: trunk/Source/WebKit/chromium/ChangeLog (99254 => 99255)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-04 01:18:16 UTC (rev 99255)
@@ -1,3 +1,26 @@
+2011-11-02  Xiaomei Ji  <[email protected]>
+
+        Enable ctrl-arrow move cursor by word in visual order in cr-win by command line flag.
+        https://bugs.webkit.org/show_bug.cgi?id=71163
+
+        Reviewed by Ryosuke Niwa.
+
+        To minimize the risk to LTR users, we enable this feature first to chromium win
+        by command line flag. This and corresponding changset in chromium
+        (http://codereview.chromium.org/8400078/)
+        should be removed after this feature is enabled without command line flag. 
+
+        The work flow is:
+        1. (chromium) adds command line flag --enable-visual-word-movement,
+           pass it to WebCore::Settings through WebPreferences.
+        2. in FrameSelection::modifyMovingLeft|Right, when 'visualWordMovementEnabled' is true in page's Settings,
+           trigger visual word movement instead of logical one.
+ 
+        * public/WebSettings.h:
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setVisualWordMovementEnabled):
+        * src/WebSettingsImpl.h:
+
 2011-11-03  Darin Adler  <[email protected]>
 
         Change remaining callers of releaseRef to call leakRef

Modified: trunk/Source/WebKit/chromium/public/WebSettings.h (99254 => 99255)


--- trunk/Source/WebKit/chromium/public/WebSettings.h	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebKit/chromium/public/WebSettings.h	2011-11-04 01:18:16 UTC (rev 99255)
@@ -132,6 +132,7 @@
     virtual void setShouldPrintBackgrounds(bool) = 0;
     virtual void setEnableScrollAnimator(bool) = 0;
     virtual void setHixie76WebSocketProtocolEnabled(bool) = 0;
+    virtual void setVisualWordMovementEnabled(bool) = 0;
 
 protected:
     ~WebSettings() { }

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp (99254 => 99255)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2011-11-04 01:18:16 UTC (rev 99255)
@@ -465,4 +465,9 @@
 #endif
 }
 
+void WebSettingsImpl::setVisualWordMovementEnabled(bool enabled)
+{
+    m_settings->setVisualWordMovementEnabled(enabled);
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.h (99254 => 99255)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2011-11-04 01:18:16 UTC (rev 99255)
@@ -124,6 +124,7 @@
     virtual void setShouldPrintBackgrounds(bool);
     virtual void setEnableScrollAnimator(bool);
     virtual void setHixie76WebSocketProtocolEnabled(bool);
+    virtual void setVisualWordMovementEnabled(bool);
 
 private:
     WebCore::Settings* m_settings;

Modified: trunk/Tools/ChangeLog (99254 => 99255)


--- trunk/Tools/ChangeLog	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Tools/ChangeLog	2011-11-04 01:18:16 UTC (rev 99255)
@@ -1,3 +1,13 @@
+2011-11-02  Xiaomei Ji  <[email protected]>
+
+        Enable ctrl-arrow move cursor by word in visual order in cr-win by command line flag.
+        https://bugs.webkit.org/show_bug.cgi?id=71163
+
+        Reviewed by Ryosuke Niwa.
+
+        * DumpRenderTree/chromium/WebPreferences.cpp: Set visualWordMovementEabled to false in DRT.
+        (WebPreferences::applyTo):
+
 2011-11-03  Eric Seidel  <[email protected]>
 
         Remove deprecated free functions in port.factory

Modified: trunk/Tools/DumpRenderTree/chromium/WebPreferences.cpp (99254 => 99255)


--- trunk/Tools/DumpRenderTree/chromium/WebPreferences.cpp	2011-11-04 00:56:59 UTC (rev 99254)
+++ trunk/Tools/DumpRenderTree/chromium/WebPreferences.cpp	2011-11-04 01:18:16 UTC (rev 99255)
@@ -234,4 +234,5 @@
     // Enable fullscreen so the fullscreen layout tests can run.
     settings->setFullScreenEnabled(true);
     settings->setValidationMessageTimerMagnification(-1);
+    settings->setVisualWordMovementEnabled(false);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to