[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

mjs at apple.com mjs at apple.com
Wed Dec 22 18:18:03 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 32fd619703c6e990ce15638fdb28ea2e019f9ee1
Author: mjs at apple.com <mjs at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 9 18:07:52 2010 +0000

    2010-12-09  Maciej Stachowiak  <mjs at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Implement "Use Selection for Find" in WebKit2
            https://bugs.webkit.org/show_bug.cgi?id=50737
            <rdar://problem/8564881>
    
            Implement a TakeFindStringFromSelection editor command. This is
            used solely to implement the "Use Selection for Find" menu command
            on Mac, and is not made available to script. On WebKit2, it is
            very convenient to reuse the editing machinery since this command
            is very similar to Copy.
    
            * editing/Editor.h:
            * editing/EditorCommand.cpp:
            (WebCore::executeTakeFindStringFromSelection): Call to a mac-only Editor function.
            (WebCore::enabledTakeFindStringFromSelection): Check using Editor::canCopyExcludingStandaloneImage
            (WebCore::createCommandMap): Add "TakeFindStringFromSelection" command.
            * editing/mac/EditorMac.mm:
            (WebCore::Editor::canCopyExcludingStandaloneImages): Helper function; we can't use Editor::canCopy
            since it would make no sense to enable "Use Selection for Find" when viewing a standalone image
            document.
            (WebCore::Editor::takeFindStringFromSelection): Implement by copying the selected text
            to the special Find pasteboard.
    2010-12-09  Maciej Stachowiak  <mjs at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Implement "Use Selection for Find" in WebKit2
            https://bugs.webkit.org/show_bug.cgi?id=50737
            <rdar://problem/8564881>
    
            * UIProcess/API/mac/WKView.mm: Add support for the takeFindStringFromSelection:
            selector as a command.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73621 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5eba82a..dc2838e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-12-09  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Implement "Use Selection for Find" in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=50737
+        <rdar://problem/8564881>
+
+        Implement a TakeFindStringFromSelection editor command. This is
+        used solely to implement the "Use Selection for Find" menu command
+        on Mac, and is not made available to script. On WebKit2, it is
+        very convenient to reuse the editing machinery since this command
+        is very similar to Copy.
+
+        * editing/Editor.h:
+        * editing/EditorCommand.cpp:
+        (WebCore::executeTakeFindStringFromSelection): Call to a mac-only Editor function.
+        (WebCore::enabledTakeFindStringFromSelection): Check using Editor::canCopyExcludingStandaloneImage
+        (WebCore::createCommandMap): Add "TakeFindStringFromSelection" command.
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::canCopyExcludingStandaloneImages): Helper function; we can't use Editor::canCopy
+        since it would make no sense to enable "Use Selection for Find" when viewing a standalone image
+        document.
+        (WebCore::Editor::takeFindStringFromSelection): Implement by copying the selected text
+        to the special Find pasteboard.
+
 2010-12-09  Abhishek Arya  <inferno at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 469e51f..0e4f2ba 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -364,6 +364,8 @@ public:
 #if PLATFORM(MAC)
     NSDictionary* fontAttributesForSelectionStart() const;
     NSWritingDirection baseWritingDirectionForSelectionStart() const;
+    bool canCopyExcludingStandaloneImages();
+    void takeFindStringFromSelection();
 #endif
 
     bool selectionStartHasSpellingMarkerFor(int from, int length) const;
diff --git a/WebCore/editing/EditorCommand.cpp b/WebCore/editing/EditorCommand.cpp
index ab83817..982fc66 100644
--- a/WebCore/editing/EditorCommand.cpp
+++ b/WebCore/editing/EditorCommand.cpp
@@ -1011,6 +1011,14 @@ static bool executeSwapWithMark(Frame* frame, Event*, EditorCommandSource, const
     return true;
 }
 
+#if PLATFORM(MAC)
+static bool executeTakeFindStringFromSelection(Frame* frame, Event*, EditorCommandSource, const String&)
+{
+    frame->editor()->takeFindStringFromSelection();
+    return true;
+}
+#endif
+
 static bool executeToggleBold(Frame* frame, Event*, EditorCommandSource source, const String&)
 {
     return executeToggleStyle(frame, source, EditActionChangeAttributes, CSSPropertyFontWeight, "normal", "bold");
@@ -1229,6 +1237,13 @@ static bool enabledRedo(Frame* frame, Event*, EditorCommandSource)
     return frame->editor()->canRedo();
 }
 
+#if PLATFORM(MAC)
+static bool enabledTakeFindStringFromSelection(Frame* frame, Event*, EditorCommandSource)
+{
+    return frame->editor()->canCopyExcludingStandaloneImages();
+}
+#endif
+
 static bool enabledUndo(Frame* frame, Event*, EditorCommandSource)
 {
     return frame->editor()->canUndo();
@@ -1491,6 +1506,9 @@ static const CommandMap& createCommandMap()
         { "Subscript", { executeSubscript, supported, enabledInRichlyEditableText, stateSubscript, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "Superscript", { executeSuperscript, supported, enabledInRichlyEditableText, stateSuperscript, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "SwapWithMark", { executeSwapWithMark, supportedFromMenuOrKeyBinding, enabledVisibleSelectionAndMark, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+#if PLATFORM(MAC)
+        { "TakeFindStringFromSelection", { executeTakeFindStringFromSelection, supportedFromMenuOrKeyBinding, enabledTakeFindStringFromSelection, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
+#endif
         { "ToggleBold", { executeToggleBold, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ToggleItalic", { executeToggleItalic, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateItalic, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "ToggleUnderline", { executeUnderline, supportedFromMenuOrKeyBinding, enabledInRichlyEditableText, stateUnderline, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
diff --git a/WebCore/editing/mac/EditorMac.mm b/WebCore/editing/mac/EditorMac.mm
index b5e3b25..56b9f71 100644
--- a/WebCore/editing/mac/EditorMac.mm
+++ b/WebCore/editing/mac/EditorMac.mm
@@ -37,6 +37,7 @@
 #import "Pasteboard.h"
 #import "RenderBlock.h"
 #import "RuntimeApplicationChecks.h"
+#import "Sound.h"
 
 namespace WebCore {
 
@@ -187,4 +188,24 @@ NSWritingDirection Editor::baseWritingDirectionForSelectionStart() const
     return result;
 }
 
+bool Editor::canCopyExcludingStandaloneImages()
+{
+    SelectionController* selection = m_frame->selection();
+    return selection->isRange() && !selection->isInPasswordField();
+}
+
+void Editor::takeFindStringFromSelection()
+{
+    if (!canCopyExcludingStandaloneImages()) {
+        systemBeep();
+        return;
+    }
+
+    NSString *nsSelectedText = m_frame->displayStringModifiedByEncoding(selectedText());
+
+    NSPasteboard *findPasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
+    [findPasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+    [findPasteboard setString:nsSelectedText forType:NSStringPboardType];
+}
+
 } // namespace WebCore
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 18bdef4..4b97442 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,14 @@
+2010-12-09  Maciej Stachowiak  <mjs at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Implement "Use Selection for Find" in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=50737
+        <rdar://problem/8564881>
+        
+        * UIProcess/API/mac/WKView.mm: Add support for the takeFindStringFromSelection:
+        selector as a command.
+
 2010-12-09  Brady Eidson  <beidson at apple.com>
 
         Reviewed by Maciej Stachowiak.
diff --git a/WebKit2/UIProcess/API/mac/WKView.mm b/WebKit2/UIProcess/API/mac/WKView.mm
index 3f28f99..4f85c5f 100644
--- a/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/WebKit2/UIProcess/API/mac/WKView.mm
@@ -273,6 +273,7 @@ WEBCORE_COMMAND(paste)
 WEBCORE_COMMAND(delete)
 WEBCORE_COMMAND(pasteAsPlainText)
 WEBCORE_COMMAND(selectAll)
+WEBCORE_COMMAND(takeFindStringFromSelection)
 
 #undef WEBCORE_COMMAND
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list