2010-12-09 Maciej Stachowiak <mjs@apple.com>
[WebKit.git] / WebCore / editing / mac / EditorMac.mm
index b5e3b25f947f150748a141daed55efa77ecac330..56b9f7135564f4a481dcf83134e4cf53681dba2d 100644 (file)
@@ -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