Title: [106248] trunk/Source/WebCore
Revision
106248
Author
[email protected]
Date
2012-01-30 08:58:20 -0800 (Mon, 30 Jan 2012)

Log Message

Remove all references to NSPasteboard objects from the Pasteboard
class interface on Mac.
https://bugs.webkit.org/show_bug.cgi?id=77261
        
This is cleanup work needed as first step in the direction of
removing access to NSPasteboard from the WebProcess.
This way all access to the NSPasteboard object are internal to
the class.
Removed static methods taking NSPasteboard as paramenter and changed
the constructor of the class to take the pasteboard name instead of
the NSPasteboard object.

Reviewed by Alexey Proskuryakov.

No new tests. There is no change in behavior.

* editing/Editor.cpp: Removed ununsed private method writeSelectionToPasteboard.
(WebCore):
* editing/Editor.h: Ditto.
(Editor):
():
* editing/mac/EditorMac.mm:
(WebCore::Editor::writeSelectionToPasteboard):
(WebCore::Editor::readSelectionFromPasteboard):
* platform/Pasteboard.h:
(Pasteboard):
* platform/mac/ClipboardMac.mm:
(WebCore::ClipboardMac::writeRange):
(WebCore::ClipboardMac::writePlainText):
(WebCore::ClipboardMac::writeURL):
* platform/mac/DragDataMac.mm:
(WebCore::DragData::asPlainText):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::generalPasteboard):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::writeSelectionForTypes): Added.
(WebCore::Pasteboard::writePlainText):
(WebCore::Pasteboard::writeSelection):
(WebCore::Pasteboard::writeURLForTypes): Added.
(WebCore::Pasteboard::writeURL):
(WebCore::Pasteboard::writeImage):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106247 => 106248)


--- trunk/Source/WebCore/ChangeLog	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/ChangeLog	2012-01-30 16:58:20 UTC (rev 106248)
@@ -1,3 +1,49 @@
+2012-01-27  Enrica Casucci  <[email protected]>
+
+        Remove all references to NSPasteboard objects from the Pasteboard
+        class interface on Mac.
+        https://bugs.webkit.org/show_bug.cgi?id=77261
+        
+        This is cleanup work needed as first step in the direction of
+        removing access to NSPasteboard from the WebProcess.
+        This way all access to the NSPasteboard object are internal to
+        the class.
+        Removed static methods taking NSPasteboard as paramenter and changed
+        the constructor of the class to take the pasteboard name instead of
+        the NSPasteboard object.
+
+        Reviewed by Alexey Proskuryakov.
+
+        No new tests. There is no change in behavior.
+
+        * editing/Editor.cpp: Removed ununsed private method writeSelectionToPasteboard.
+        (WebCore):
+        * editing/Editor.h: Ditto.
+        (Editor):
+        ():
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::writeSelectionToPasteboard):
+        (WebCore::Editor::readSelectionFromPasteboard):
+        * platform/Pasteboard.h:
+        (Pasteboard):
+        * platform/mac/ClipboardMac.mm:
+        (WebCore::ClipboardMac::writeRange):
+        (WebCore::ClipboardMac::writePlainText):
+        (WebCore::ClipboardMac::writeURL):
+        * platform/mac/DragDataMac.mm:
+        (WebCore::DragData::asPlainText):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::asFragment):
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::generalPasteboard):
+        (WebCore::Pasteboard::Pasteboard):
+        (WebCore::Pasteboard::writeSelectionForTypes): Added.
+        (WebCore::Pasteboard::writePlainText):
+        (WebCore::Pasteboard::writeSelection):
+        (WebCore::Pasteboard::writeURLForTypes): Added.
+        (WebCore::Pasteboard::writeURL):
+        (WebCore::Pasteboard::writeImage):
+
 2012-01-29  Antti Koivisto  <[email protected]>
 
         Reduce non-CSSOM API of CSSStyleDeclaration

Modified: trunk/Source/WebCore/editing/Editor.cpp (106247 => 106248)


--- trunk/Source/WebCore/editing/Editor.cpp	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/editing/Editor.cpp	2012-01-30 16:58:20 UTC (rev 106248)
@@ -466,11 +466,6 @@
     return !dispatchCPPEvent(eventNames().pasteEvent, ClipboardReadable);
 }
 
-void Editor::writeSelectionToPasteboard(Pasteboard* pasteboard)
-{
-    pasteboard->writeSelection(selectedRange().get(), canSmartCopyOrDelete(), m_frame);
-}
-
 bool Editor::shouldInsertText(const String& text, Range* range, EditorInsertAction action) const
 {
     return client() && client()->shouldInsertText(text, range, action);

Modified: trunk/Source/WebCore/editing/Editor.h (106247 => 106248)


--- trunk/Source/WebCore/editing/Editor.h	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/editing/Editor.h	2012-01-30 16:58:20 UTC (rev 106248)
@@ -407,7 +407,6 @@
     PassRefPtr<Clipboard> newGeneralClipboard(ClipboardAccessPolicy, Frame*);
     void pasteAsPlainTextWithPasteboard(Pasteboard*);
     void pasteWithPasteboard(Pasteboard*, bool allowPlainText);
-    void writeSelectionToPasteboard(Pasteboard*);
     void revealSelectionAfterEditingOperation();
     void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpelling, RefPtr<Range>& firstMisspellingRange);
     TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask);

Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (106247 => 106248)


--- trunk/Source/WebCore/editing/mac/EditorMac.mm	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm	2012-01-30 16:58:20 UTC (rev 106248)
@@ -292,12 +292,13 @@
     RetainPtr<NSMutableArray> types(AdoptNS, [[NSMutableArray alloc] init]);    
     for (size_t i = 0; i < pasteboardTypes.size(); ++i)
         [types.get() addObject:pasteboardTypes[i]];
-    Pasteboard::writeSelection([NSPasteboard pasteboardWithName:pasteboardName], types.get(), selectedRange().get(), true, m_frame);
+    Pasteboard pasteboard(pasteboardName);
+    pasteboard.writeSelectionForTypes(types.get(), selectedRange().get(), true, m_frame);
 }
     
 void Editor::readSelectionFromPasteboard(const String& pasteboardName)
 {
-    Pasteboard pasteboard([NSPasteboard pasteboardWithName:pasteboardName]);
+    Pasteboard pasteboard(pasteboardName);
     if (m_frame->selection()->isContentRichlyEditable())
         pasteWithPasteboard(&pasteboard, true);
     else

Modified: trunk/Source/WebCore/platform/Pasteboard.h (106247 => 106248)


--- trunk/Source/WebCore/platform/Pasteboard.h	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/platform/Pasteboard.h	2012-01-30 16:58:20 UTC (rev 106248)
@@ -80,12 +80,10 @@
     WTF_MAKE_NONCOPYABLE(Pasteboard); WTF_MAKE_FAST_ALLOCATED;
 public:
 #if PLATFORM(MAC)
-    //Helper functions to allow Clipboard to share code
-    static void writeSelection(NSPasteboard*, NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame*);
-    static void writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame);
-    static void writePlainText(NSPasteboard* pasteboard, const String& text);
+    void writeSelectionForTypes(NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame*);
+    void writeURLForTypes(NSArray* types, const KURL&, const String& titleStr, Frame*);
 
-    Pasteboard(NSPasteboard *);
+    Pasteboard(const String& pasteboardName);
 #endif
     
     static Pasteboard* generalPasteboard();

Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (106247 => 106248)


--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm	2012-01-30 16:58:20 UTC (rev 106248)
@@ -367,19 +367,22 @@
 {
     ASSERT(range);
     ASSERT(frame);
-    Pasteboard::writeSelection(m_pasteboard.get(), 0, range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame);
+    Pasteboard pasteboard([m_pasteboard.get() name]);
+    pasteboard.writeSelectionForTypes(nil, range, frame->editor()->smartInsertDeleteEnabled() && frame->selection()->granularity() == WordGranularity, frame);
 }
 
 void ClipboardMac::writePlainText(const String& text)
 {
-    Pasteboard::writePlainText(m_pasteboard.get(), text);
+    Pasteboard pasteboard([m_pasteboard.get() name]);
+    pasteboard.writePlainText(text);
 }
 
 void ClipboardMac::writeURL(const KURL& url, const String& title, Frame* frame)
 {   
     ASSERT(frame);
     ASSERT(m_pasteboard);
-    Pasteboard::writeURL(m_pasteboard.get(), nil, url, title, frame);
+    Pasteboard pasteboard([m_pasteboard.get() name]);
+    pasteboard.writeURLForTypes(nil, url, title, frame);
 }
     
 #if ENABLE(DRAG_SUPPORT)

Modified: trunk/Source/WebCore/platform/mac/DragDataMac.mm (106247 => 106248)


--- trunk/Source/WebCore/platform/mac/DragDataMac.mm	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/platform/mac/DragDataMac.mm	2012-01-30 16:58:20 UTC (rev 106248)
@@ -105,7 +105,7 @@
 
 String DragData::asPlainText(Frame *frame) const
 {
-    Pasteboard pasteboard(m_pasteboard.get());
+    Pasteboard pasteboard([m_pasteboard.get() name]);
     return pasteboard.plainText(frame);
 }
 
@@ -157,13 +157,13 @@
         if (NSString *URLTitleString = [m_pasteboard.get() stringForType:WebURLNamePboardType])
             *title = URLTitleString;
     }
-    Pasteboard pasteboard(m_pasteboard.get());
+    Pasteboard pasteboard([m_pasteboard.get() name]);
     return pasteboard.asURL(frame);
 }
 
 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
 {
-    Pasteboard pasteboard(m_pasteboard.get());
+    Pasteboard pasteboard([m_pasteboard.get() name]);
     
     return pasteboard.documentFragment(frame, range, allowPlainText, chosePlainText);
 }

Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (106247 => 106248)


--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2012-01-30 16:46:56 UTC (rev 106247)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2012-01-30 16:58:20 UTC (rev 106248)
@@ -113,13 +113,14 @@
 
 Pasteboard* Pasteboard::generalPasteboard() 
 {
-    static Pasteboard* pasteboard = new Pasteboard([NSPasteboard generalPasteboard]);
+    static Pasteboard* pasteboard = new Pasteboard(NSGeneralPboard);
     return pasteboard;
 }
 
-Pasteboard::Pasteboard(NSPasteboard* pboard)
-    : m_pasteboard(pboard)
+Pasteboard::Pasteboard(const String& pasteboardName)
+    : m_pasteboard([NSPasteboard pasteboardWithName:pasteboardName])
 {
+    ASSERT(pasteboardName);
 }
 
 void Pasteboard::clear()
@@ -127,7 +128,7 @@
     [m_pasteboard.get() declareTypes:[NSArray array] owner:nil];
 }
 
-void Pasteboard::writeSelection(NSPasteboard* pasteboard, NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
+void Pasteboard::writeSelectionForTypes(NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
 {
     if (!WebArchivePboardType)
         Pasteboard::generalPasteboard(); // Initializes pasteboard types.
@@ -158,26 +159,26 @@
 #endif
 
     NSArray *types = pasteboardTypes ? pasteboardTypes : selectionPasteboardTypes(canSmartCopyOrDelete, [attributedString containsAttachments]);
-    [pasteboard declareTypes:types owner:nil];
+    [m_pasteboard.get() declareTypes:types owner:nil];
     frame->editor()->client()->didSetSelectionTypesForPasteboard();
     
     // Put HTML on the pasteboard.
     if ([types containsObject:WebArchivePboardType]) {
         RefPtr<LegacyWebArchive> archive = LegacyWebArchive::createFromSelection(frame);
         RetainPtr<CFDataRef> data = "" ? archive->rawDataRepresentation() : 0;
-        [pasteboard setData:(NSData *)data.get() forType:WebArchivePboardType];
+        [m_pasteboard.get() setData:(NSData *)data.get() forType:WebArchivePboardType];
     }
     
     // Put the attributed string on the pasteboard (RTF/RTFD format).
     if ([types containsObject:NSRTFDPboardType]) {
         NSData *RTFDData = [attributedString RTFDFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
-        [pasteboard setData:RTFDData forType:NSRTFDPboardType];
+        [m_pasteboard.get() setData:RTFDData forType:NSRTFDPboardType];
     }
     if ([types containsObject:NSRTFPboardType]) {
         if ([attributedString containsAttachments])
             attributedString = attributedStringByStrippingAttachmentCharacters(attributedString);
         NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
-        [pasteboard setData:RTFData forType:NSRTFPboardType];
+        [m_pasteboard.get() setData:RTFData forType:NSRTFPboardType];
     }
     
     // Put plain string on the pasteboard.
@@ -189,48 +190,34 @@
         
         NSString *NonBreakingSpaceString = [NSString stringWithCharacters:&noBreakSpace length:1];
         [s replaceOccurrencesOfString:NonBreakingSpaceString withString:@" " options:0 range:NSMakeRange(0, [s length])];
-        [pasteboard setString:s forType:NSStringPboardType];
+        [m_pasteboard.get() setString:s forType:NSStringPboardType];
         [s release];
     }
     
     if ([types containsObject:WebSmartPastePboardType]) {
-        [pasteboard setData:nil forType:WebSmartPastePboardType];
+        [m_pasteboard.get() setData:nil forType:WebSmartPastePboardType];
     }
 }
 
-void Pasteboard::writePlainText(NSPasteboard* pasteboard, const String& text)
+void Pasteboard::writePlainText(const String& text)
 {
-    NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
-    [pasteboard declareTypes:types owner:nil];
-    
-    [pasteboard setString:text forType:NSStringPboardType];
+    [m_pasteboard.get() declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
+    [m_pasteboard.get() setString:text forType:NSStringPboardType];
 }
     
 void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
 {
-    Pasteboard::writeSelection(m_pasteboard.get(), 0, selectedRange, canSmartCopyOrDelete, frame);
+    writeSelectionForTypes(nil, selectedRange, canSmartCopyOrDelete, frame);
 }
 
-void Pasteboard::writePlainText(const String& text)
+void Pasteboard::writeURLForTypes(NSArray* types, const KURL& url, const String& titleStr, Frame* frame)
 {
     if (!WebArchivePboardType)
         Pasteboard::generalPasteboard(); // Initializes pasteboard types.
-
-    NSArray *types = [NSArray arrayWithObject:NSStringPboardType];
-    NSPasteboard *pasteboard = m_pasteboard.get();
-    [pasteboard declareTypes:types owner:nil];
-
-    [pasteboard setString:text forType:NSStringPboardType];
-}
-
-void Pasteboard::writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame)
-{
-    if (!WebArchivePboardType)
-        Pasteboard::generalPasteboard(); // Initializes pasteboard types.
    
     if (!types) {
         types = writableTypesForURL();
-        [pasteboard declareTypes:types owner:nil];
+        [m_pasteboard.get() declareTypes:types owner:nil];
     }
     
     ASSERT(!url.isEmpty());
@@ -246,23 +233,23 @@
     }
         
     if ([types containsObject:WebURLsWithTitlesPboardType])
-        [pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:userVisibleString], 
+        [m_pasteboard.get() setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:userVisibleString], 
                                      [NSArray arrayWithObject:(NSString*)titleStr.stripWhiteSpace()], 
                                      nil]
                             forType:WebURLsWithTitlesPboardType];
     if ([types containsObject:NSURLPboardType])
-        [cocoaURL writeToPasteboard:pasteboard];
+        [cocoaURL writeToPasteboard:m_pasteboard.get()];
     if ([types containsObject:WebURLPboardType])
-        [pasteboard setString:userVisibleString forType:WebURLPboardType];
+        [m_pasteboard.get() setString:userVisibleString forType:WebURLPboardType];
     if ([types containsObject:WebURLNamePboardType])
-        [pasteboard setString:title forType:WebURLNamePboardType];
+        [m_pasteboard.get() setString:title forType:WebURLNamePboardType];
     if ([types containsObject:NSStringPboardType])
-        [pasteboard setString:userVisibleString forType:NSStringPboardType];
+        [m_pasteboard.get() setString:userVisibleString forType:NSStringPboardType];
 }
     
 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
 {
-    Pasteboard::writeURL(m_pasteboard.get(), nil, url, titleStr, frame);
+    writeURLForTypes(nil, url, titleStr, frame);
 }
 
 static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *url)
@@ -308,7 +295,7 @@
 
     NSArray* types = writableTypesForImage();
     [m_pasteboard.get() declareTypes:types owner:nil];
-    writeURL(m_pasteboard.get(), types, cocoaURL, nsStringNilIfEmpty(title), frame);
+    writeURLForTypes(types, cocoaURL, nsStringNilIfEmpty(title), frame);
     
     Image* image = cachedImage->imageForRenderer(renderer);
     ASSERT(image);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to