[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

tkent at chromium.org tkent at chromium.org
Thu Feb 4 21:36:25 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 6db4906c18ef8fda169df9f718186e70d21fa5d2
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 2 08:25:30 2010 +0000

    2010-02-02  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Fisher.
    
            [Chromium] Should not select a word on right-click.
            https://bugs.webkit.org/show_bug.cgi?id=33364
    
            For non-Mac platforms, do not select a word around the caret when
            a context menu is opening. This behavior is not common in non-Mac
            platforms, and it prevents pasting with a context menu.
    
            In order that the spell checker works without the selection, we
            introduce WebFrame::selectWordAroundCaret(). We can replace a word
            around the caret with selectWordAroundCaret() + replaceSelection().
    
            * public/WebFrame.h: Add pure selectWordAroundCaret() declaration.
            * src/ContextMenuClientImpl.cpp:
            (WebKit::selectMisspelledWord): Move word-selection code to
            WebFrameImpl::selectWordAroundPosition(), and clear the selection
            on non-Mac.
            * src/WebFrameImpl.cpp:
            (WebKit::WebFrameImpl::selectWordAroundPosition):
            (WebKit::WebFrameImpl::selectWordAroundCaret):
            * src/WebFrameImpl.h: Add selectWordAroundCaret() declaration.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54212 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 20fc36f..058279e 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,28 @@
+2010-02-02  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        [Chromium] Should not select a word on right-click.
+        https://bugs.webkit.org/show_bug.cgi?id=33364
+
+        For non-Mac platforms, do not select a word around the caret when
+        a context menu is opening. This behavior is not common in non-Mac
+        platforms, and it prevents pasting with a context menu.
+
+        In order that the spell checker works without the selection, we
+        introduce WebFrame::selectWordAroundCaret(). We can replace a word
+        around the caret with selectWordAroundCaret() + replaceSelection().
+
+        * public/WebFrame.h: Add pure selectWordAroundCaret() declaration.
+        * src/ContextMenuClientImpl.cpp:
+        (WebKit::selectMisspelledWord): Move word-selection code to
+        WebFrameImpl::selectWordAroundPosition(), and clear the selection
+        on non-Mac.
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::selectWordAroundPosition):
+        (WebKit::WebFrameImpl::selectWordAroundCaret):
+        * src/WebFrameImpl.h: Add selectWordAroundCaret() declaration.
+
 2010-02-01  Shinichiro Hamaji  <hamaji at chromium.org>
 
         Unreviewed attempt to fix the broken build.
diff --git a/WebKit/chromium/public/WebFrame.h b/WebKit/chromium/public/WebFrame.h
index 4197c23..575dae6 100644
--- a/WebKit/chromium/public/WebFrame.h
+++ b/WebKit/chromium/public/WebFrame.h
@@ -357,6 +357,11 @@ public:
     virtual WebString selectionAsText() const = 0;
     virtual WebString selectionAsMarkup() const = 0;
 
+    // Expands the selection to a word around the caret and returns
+    // true. Does nothing and returns false if there is no caret or
+    // there is ranged selection.
+    virtual bool selectWordAroundCaret() = 0;
+
 
     // Printing ------------------------------------------------------------
 
diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp
index 72b861f..eb6a6c0 100644
--- a/WebKit/chromium/src/ContextMenuClientImpl.cpp
+++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp
@@ -89,7 +89,7 @@ static bool isASingleWord(const String& text)
 // Helper function to get misspelled word on which context menu
 // is to be evolked. This function also sets the word on which context menu
 // has been evoked to be the selected word, as required. This function changes
-// the selection only when there were no selected characters.
+// the selection only when there were no selected characters on OS X.
 static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame)
 {
     // First select from selectedText to check for multiple word selection.
@@ -110,27 +110,21 @@ static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* select
     VisiblePosition pos(innerNode->renderer()->positionForPoint(
         hitTestResult.localPoint()));
 
-    VisibleSelection selection;
-    if (pos.isNotNull()) {
-        selection = VisibleSelection(pos);
-        selection.expandUsingGranularity(WordGranularity);
-    }
-
-    if (selection.isRange())
-        selectedFrame->setSelectionGranularity(WordGranularity);
-
-    if (selectedFrame->shouldChangeSelection(selection))
-        selectedFrame->selection()->setSelection(selection);
+    if (pos.isNull())
+        return misspelledWord; // It is empty.
 
+    WebFrameImpl::selectWordAroundPosition(selectedFrame, pos);
     misspelledWord = selectedFrame->selectedText().stripWhiteSpace();
 
+#if OS(DARWIN)
     // If misspelled word is still empty, then that portion should not be
     // selected. Set the selection to that position only, and do not expand.
-    if (misspelledWord.isEmpty()) {
-        selection = VisibleSelection(pos);
-        selectedFrame->selection()->setSelection(selection);
-    }
-
+    if (misspelledWord.isEmpty())
+        selectedFrame->selection()->setSelection(VisibleSelection(pos));
+#else
+    // On non-Mac, right-click should not make a range selection in any case.
+    selectedFrame->selection()->setSelection(VisibleSelection(pos));
+#endif
     return misspelledWord;
 }
 
diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp
index 28c27cc..7947c19 100644
--- a/WebKit/chromium/src/WebFrameImpl.cpp
+++ b/WebKit/chromium/src/WebFrameImpl.cpp
@@ -1077,6 +1077,28 @@ WebString WebFrameImpl::selectionAsMarkup() const
     return createMarkup(range.get(), 0);
 }
 
+void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos)
+{
+    VisibleSelection selection(pos);
+    selection.expandUsingGranularity(WordGranularity);
+
+    if (selection.isRange())
+        frame->setSelectionGranularity(WordGranularity);
+
+    if (frame->shouldChangeSelection(selection))
+        frame->selection()->setSelection(selection);
+}
+
+bool WebFrameImpl::selectWordAroundCaret()
+{
+    SelectionController* controller = frame()->selection();
+    ASSERT(!controller->isNone());
+    if (controller->isNone() || controller->isRange())
+        return false;
+    selectWordAroundPosition(frame(), controller->selection().visibleStart());
+    return true;
+}
+
 int WebFrameImpl::printBegin(const WebSize& pageSize)
 {
     ASSERT(!frame()->document()->isFrameSet());
diff --git a/WebKit/chromium/src/WebFrameImpl.h b/WebKit/chromium/src/WebFrameImpl.h
index ba8d279..be12dbf 100644
--- a/WebKit/chromium/src/WebFrameImpl.h
+++ b/WebKit/chromium/src/WebFrameImpl.h
@@ -141,6 +141,7 @@ public:
     virtual WebRange selectionRange() const;
     virtual WebString selectionAsText() const;
     virtual WebString selectionAsMarkup() const;
+    virtual bool selectWordAroundCaret();
     virtual int printBegin(const WebSize& pageSize);
     virtual float printPage(int pageToPrint, WebCanvas*);
     virtual float getPrintPageShrink(int page);
@@ -219,6 +220,8 @@ public:
     WebFrameClient* client() const { return m_client; }
     void dropClient() { m_client = 0; }
 
+    static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition);
+
 private:
     class DeferredScopeStringMatches;
     friend class DeferredScopeStringMatches;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list