Title: [108101] trunk/Source
Revision
108101
Author
[email protected]
Date
2012-02-17 11:54:20 -0800 (Fri, 17 Feb 2012)

Log Message

Refactor DragData class to use PlatformStrategies in the Mac implementation.
https://bugs.webkit.org/show_bug.cgi?id=78768

Reviewed by Darin Adler.

Source/WebCore: 

No new tests. No behavior change.

* WebCore.exp.in: Added new exported method of the PlatformPasteboard class.
* platform/DragData.h:
(WebCore::DragData::pasteboardName): Added pasteboardName and removed pasteboard.
* platform/PasteboardStrategy.h: Added color() method.
* platform/PlatformPasteboard.h: Ditto.
* platform/mac/ClipboardMac.mm:
(WebCore::Clipboard::create): Changed to use pasteboardName() method.
* platform/mac/DragDataMac.mm: All the methods below have been changed to use pasteboardName
and the pasteboardStrategy() methods.
(WebCore::DragData::DragData):
(WebCore::DragData::canSmartReplace):
(WebCore::DragData::containsColor):
(WebCore::DragData::containsFiles):
(WebCore::DragData::numberOfFiles):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsPlainText):
(WebCore::DragData::asPlainText):
(WebCore::DragData::asColor):
(WebCore::DragData::containsCompatibleContent):
(WebCore::DragData::asURL):
(WebCore::DragData::asFragment):
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::color): Added implementation of the color() method.

Source/WebKit/mac: 

* WebCoreSupport/WebPlatformStrategies.h: Added color() method.
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::color):

Source/WebKit2: 

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Added color() method.
(WebKit::WebPlatformStrategies::color):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108100 => 108101)


--- trunk/Source/WebCore/ChangeLog	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/ChangeLog	2012-02-17 19:54:20 UTC (rev 108101)
@@ -1,3 +1,36 @@
+2012-02-17  Enrica Casucci  <[email protected]>
+
+        Refactor DragData class to use PlatformStrategies in the Mac implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=78768
+
+        Reviewed by Darin Adler.
+
+        No new tests. No behavior change.
+
+        * WebCore.exp.in: Added new exported method of the PlatformPasteboard class.
+        * platform/DragData.h:
+        (WebCore::DragData::pasteboardName): Added pasteboardName and removed pasteboard.
+        * platform/PasteboardStrategy.h: Added color() method.
+        * platform/PlatformPasteboard.h: Ditto.
+        * platform/mac/ClipboardMac.mm:
+        (WebCore::Clipboard::create): Changed to use pasteboardName() method.
+        * platform/mac/DragDataMac.mm: All the methods below have been changed to use pasteboardName
+        and the pasteboardStrategy() methods.
+        (WebCore::DragData::DragData):
+        (WebCore::DragData::canSmartReplace):
+        (WebCore::DragData::containsColor):
+        (WebCore::DragData::containsFiles):
+        (WebCore::DragData::numberOfFiles):
+        (WebCore::DragData::asFilenames):
+        (WebCore::DragData::containsPlainText):
+        (WebCore::DragData::asPlainText):
+        (WebCore::DragData::asColor):
+        (WebCore::DragData::containsCompatibleContent):
+        (WebCore::DragData::asURL):
+        (WebCore::DragData::asFragment):
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::color): Added implementation of the color() method.
+
 2012-02-17  Nate Chapin  <[email protected]>
 
         [Chromium mac] Cursors and background images disappear.

Modified: trunk/Source/WebCore/WebCore.exp.in (108100 => 108101)


--- trunk/Source/WebCore/WebCore.exp.in	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-02-17 19:54:20 UTC (rev 108101)
@@ -561,6 +561,7 @@
 __ZN7WebCore18PlatformPasteboard16setStringForTypeERKN3WTF6StringES4_
 __ZN7WebCore18PlatformPasteboard10uniqueNameEv
 __ZNK7WebCore18PlatformPasteboard11changeCountEv
+__ZN7WebCore18PlatformPasteboard5colorEv
 __ZN7WebCore18SearchPopupMenuMacC1EPNS_15PopupMenuClientE
 __ZN7WebCore18isStartOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore18pluginScriptObjectEPN3JSC9ExecStateEPNS_13JSHTMLElementE

Modified: trunk/Source/WebCore/platform/DragData.h (108100 => 108101)


--- trunk/Source/WebCore/platform/DragData.h	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/DragData.h	2012-02-17 19:54:20 UTC (rev 108101)
@@ -36,6 +36,7 @@
 
 #if PLATFORM(MAC)
 #include <wtf/RetainPtr.h>
+#include <wtf/text/WTFString.h>
 
 #ifdef __OBJC__ 
 #import <Foundation/Foundation.h>
@@ -120,7 +121,7 @@
     bool containsFiles() const;
     unsigned numberOfFiles() const;
 #if PLATFORM(MAC)
-    NSPasteboard *pasteboard() { return m_pasteboard.get(); }
+    const String& pasteboardName() { return m_pasteboardName; }
 #endif
 
 #if PLATFORM(QT) || PLATFORM(GTK)
@@ -146,7 +147,7 @@
     DragOperation m_draggingSourceOperationMask;
     DragApplicationFlags m_applicationFlags;
 #if PLATFORM(MAC)
-    RetainPtr<NSPasteboard> m_pasteboard;
+    String m_pasteboardName;
 #endif
 #if PLATFORM(WIN)
     DragDataMap m_dragDataMap;

Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (108100 => 108101)


--- trunk/Source/WebCore/platform/PasteboardStrategy.h	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h	2012-02-17 19:54:20 UTC (rev 108101)
@@ -35,6 +35,8 @@
 
 namespace WebCore {
 
+class Color;
+    
 class PasteboardStrategy {
 public:
 #if PLATFORM(MAC)
@@ -44,6 +46,7 @@
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) = 0;
     virtual int changeCount(const String& pasteboardName) = 0;
     virtual String uniqueName() = 0;
+    virtual Color color(const String& pasteboardName) = 0;
     
     virtual void copy(const String& fromPasteboard, const String& toPasteboard) = 0;
     virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) = 0;

Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (108100 => 108101)


--- trunk/Source/WebCore/platform/PlatformPasteboard.h	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h	2012-02-17 19:54:20 UTC (rev 108101)
@@ -37,6 +37,8 @@
 
 namespace WebCore {
 
+class Color;
+
 class PlatformPasteboard {
 public:
     PlatformPasteboard(const String& pasteboardName);
@@ -47,6 +49,7 @@
     void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType);
     String stringForType(const String& pasteboardType);
     int changeCount() const;
+    Color color();
     
     void copy(const String& fromPasteboard);
     void setTypes(const Vector<String>& pasteboardTypes);

Modified: trunk/Source/WebCore/platform/mac/ClipboardMac.mm (108100 => 108101)


--- trunk/Source/WebCore/platform/mac/ClipboardMac.mm	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/mac/ClipboardMac.mm	2012-02-17 19:54:20 UTC (rev 108101)
@@ -49,7 +49,7 @@
 
 PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame)
 {
-    return ClipboardMac::create(DragAndDrop, [dragData->pasteboard() name], policy, frame);
+    return ClipboardMac::create(DragAndDrop, dragData->pasteboardName(), policy, frame);
 }
 
 ClipboardMac::ClipboardMac(ClipboardType clipboardType, const String& pasteboardName, ClipboardAccessPolicy policy, Frame *frame)

Modified: trunk/Source/WebCore/platform/mac/DragDataMac.mm (108100 => 108101)


--- trunk/Source/WebCore/platform/mac/DragDataMac.mm	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/mac/DragDataMac.mm	2012-02-17 19:54:20 UTC (rev 108101)
@@ -36,6 +36,8 @@
 #import "Frame.h"
 #import "MIMETypeRegistry.h"
 #import "Pasteboard.h"
+#import "PasteboardStrategy.h"
+#import "PlatformStrategies.h"
 #import "Range.h"
 
 namespace WebCore {
@@ -47,7 +49,7 @@
     , m_platformDragData(data)
     , m_draggingSourceOperationMask(sourceOperationMask)
     , m_applicationFlags(flags)
-    , m_pasteboard([m_platformDragData draggingPasteboard])
+    , m_pasteboardName([[m_platformDragData draggingPasteboard] name])
 {
 }
 
@@ -58,92 +60,78 @@
     , m_platformDragData(0)
     , m_draggingSourceOperationMask(sourceOperationMask)
     , m_applicationFlags(flags)
-    , m_pasteboard([NSPasteboard pasteboardWithName:dragStorageName])
+    , m_pasteboardName(dragStorageName)
 {
 }
     
 bool DragData::canSmartReplace() const
 {
-    //Need to call this so that the various Pasteboard type strings are intialised
-    Pasteboard::generalPasteboard();
-    return [[m_pasteboard.get() types] containsObject:String(WebSmartPastePboardType)];
+    return Pasteboard(m_pasteboardName).canSmartReplace();
 }
 
 bool DragData::containsColor() const
 {
-    return [[m_pasteboard.get() types] containsObject:NSColorPboardType];
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(String(NSColorPboardType));
 }
 
 bool DragData::containsFiles() const
 {
-    return [[m_pasteboard.get() types] containsObject:NSFilenamesPboardType];
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(String(NSFilenamesPboardType));
 }
 
 unsigned DragData::numberOfFiles() const
 {
-    if (![[m_pasteboard.get() types] containsObject:NSFilenamesPboardType])
-        return 0;
-    return [[m_pasteboard.get() propertyListForType:NSFilenamesPboardType] count];
+    Vector<String> files;
+    platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
+    return files.size();
 }
 
 void DragData::asFilenames(Vector<String>& result) const
 {
-    NSArray *filenames = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
-    NSEnumerator *fileEnumerator = [filenames objectEnumerator];
-    
-    while (NSString *filename = [fileEnumerator nextObject])
-        result.append(filename);
+    platformStrategies()->pasteboardStrategy()->getPathnamesForType(result, String(NSFilenamesPboardType), m_pasteboardName);
 }
 
 bool DragData::containsPlainText() const
 {
-    NSArray *types = [m_pasteboard.get() types];
-    
-    return [types containsObject:NSStringPboardType] 
-        || [types containsObject:NSRTFDPboardType]
-        || [types containsObject:NSRTFPboardType]
-        || [types containsObject:NSFilenamesPboardType]
-        || [NSURL URLFromPasteboard:m_pasteboard.get()];
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+
+    return types.contains(String(NSStringPboardType))
+        || types.contains(String(NSRTFDPboardType))
+        || types.contains(String(NSRTFPboardType))
+        || types.contains(String(NSFilenamesPboardType))
+        || platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName).length();
 }
 
 String DragData::asPlainText(Frame *frame) const
 {
-    Pasteboard pasteboard([m_pasteboard.get() name]);
-    return pasteboard.plainText(frame);
+    return Pasteboard(m_pasteboardName).plainText(frame);
 }
 
 Color DragData::asColor() const
 {
-    NSColor *color = [NSColor colorFromPasteboard:m_pasteboard.get()];
-    
-    // The color may not be in an RGB colorspace. This commonly occurs when a color is 
-    // dragged from the NSColorPanel grayscale picker.
-    if ([[color colorSpace] colorSpaceModel] != NSRGBColorSpaceModel)
-        color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
-    
-    return makeRGBA((int)([color redComponent] * 255.0 + 0.5), (int)([color greenComponent] * 255.0 + 0.5), 
-                    (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5));
+    return platformStrategies()->pasteboardStrategy()->color(m_pasteboardName);
 }
 
-static NSArray *insertablePasteboardTypes()
-{
-    static NSArray *types = nil;
-    if (!types) {
-        types = [[NSArray alloc] initWithObjects:String(WebArchivePboardType), NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
-#ifdef BUILDING_ON_LEOPARD
-                 NSPICTPboardType,
-#endif
-                 NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil];
-        CFRetain(types);
-    }
-    return types;
-}
-    
 bool DragData::containsCompatibleContent() const
 {
-    NSMutableSet *types = [NSMutableSet setWithArray:[m_pasteboard.get() types]];
-    [types intersectSet:[NSSet setWithArray:insertablePasteboardTypes()]];
-    return [types count] != 0;
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
+    return types.contains(String(WebArchivePboardType))
+        || types.contains(String(NSHTMLPboardType))
+        || types.contains(String(NSFilenamesPboardType))
+        || types.contains(String(NSTIFFPboardType))
+        || types.contains(String(NSPDFPboardType))
+        || types.contains(String(NSURLPboardType))
+        || types.contains(String(NSRTFDPboardType))
+        || types.contains(String(NSRTFPboardType))
+        || types.contains(String(NSStringPboardType))
+        || types.contains(String(NSColorPboardType))
+        || types.contains(String(kUTTypePNG));
 }
     
 bool DragData::containsURL(Frame* frame, FilenameConversionPolicy filenamePolicy) const
@@ -157,39 +145,40 @@
     (void)filenamePolicy;
 
     if (title) {
-        if (NSString *URLTitleString = [m_pasteboard.get() stringForType:String(WebURLNamePboardType)])
+        String URLTitleString = platformStrategies()->pasteboardStrategy()->stringForType(String(WebURLNamePboardType), m_pasteboardName);
+        if (!URLTitleString.isEmpty())
             *title = URLTitleString;
     }
     
-    NSArray *types = [m_pasteboard.get() types];
+    Vector<String> types;
+    platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
     
     // FIXME: using the editorClient to call into WebKit, for now, since 
     // calling webkit_canonicalize from WebCore involves migrating a sizable amount of 
     // helper code that should either be done in a separate patch or figured out in another way.
     
-    if ([types containsObject:NSURLPboardType]) {
-        NSURL *URLFromPasteboard = [NSURL URLFromPasteboard:m_pasteboard.get()];
+    if (types.contains(String(NSURLPboardType))) {
+        NSURL *URLFromPasteboard = [NSURL URLWithString:platformStrategies()->pasteboardStrategy()->stringForType(String(NSURLPboardType), m_pasteboardName)];
         NSString *scheme = [URLFromPasteboard scheme];
         if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"]) {
             return [frame->editor()->client()->canonicalizeURL(URLFromPasteboard) absoluteString];
         }
     }
     
-    if ([types containsObject:NSStringPboardType]) {
-        NSString *URLString = [m_pasteboard.get() stringForType:NSStringPboardType];
-        NSURL *URL = ""
+    if (types.contains(String(NSStringPboardType))) {
+        NSURL *URL = "" m_pasteboardName));
         if (URL)
             return [URL absoluteString];
     }
     
-    if ([types containsObject:NSFilenamesPboardType]) {
-        NSArray *files = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
-        if ([files count] == 1) {
-            NSString *file = [files objectAtIndex:0];
+    if (types.contains(String(NSFilenamesPboardType))) {
+        Vector<String> files;
+        platformStrategies()->pasteboardStrategy()->getPathnamesForType(files, String(NSFilenamesPboardType), m_pasteboardName);
+        if (files.size() == 1) {
             BOOL isDirectory;
-            if ([[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory] && isDirectory)
+            if ([[NSFileManager defaultManager] fileExistsAtPath:files[0] isDirectory:&isDirectory] && isDirectory)
                 return String();
-            return [frame->editor()->client()->canonicalizeURL([NSURL fileURLWithPath:file]) absoluteString];
+            return [frame->editor()->client()->canonicalizeURL([NSURL fileURLWithPath:files[0]]) absoluteString];
         }
     }
     
@@ -198,9 +187,7 @@
 
 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range> range, bool allowPlainText, bool& chosePlainText) const
 {
-    Pasteboard pasteboard([m_pasteboard.get() name]);
-    
-    return pasteboard.documentFragment(frame, range, allowPlainText, chosePlainText);
+    return Pasteboard(m_pasteboardName).documentFragment(frame, range, allowPlainText, chosePlainText);
 }
     
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm (108100 => 108101)


--- trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2012-02-17 19:54:20 UTC (rev 108101)
@@ -24,6 +24,7 @@
  */
 
 #import "config.h"
+#import "Color.h"
 #import "PlatformPasteboard.h"
 
 namespace WebCore {
@@ -73,6 +74,19 @@
     return [[NSPasteboard pasteboardWithUniqueName] name];
 }
 
+Color PlatformPasteboard::color()
+{
+    NSColor *color = [NSColor colorFromPasteboard:m_pasteboard.get()];
+    
+    // The color may not be in an RGB colorspace. This commonly occurs when a color is 
+    // dragged from the NSColorPanel grayscale picker.
+    if ([[color colorSpace] colorSpaceModel] != NSRGBColorSpaceModel)
+        color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
+    
+    return makeRGBA((int)([color redComponent] * 255.0 + 0.5), (int)([color greenComponent] * 255.0 + 0.5), 
+                    (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5));    
+}
+
 void PlatformPasteboard::copy(const String& fromPasteboard)
 {
     NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:fromPasteboard];

Modified: trunk/Source/WebKit/mac/ChangeLog (108100 => 108101)


--- trunk/Source/WebKit/mac/ChangeLog	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-02-17 19:54:20 UTC (rev 108101)
@@ -1,3 +1,14 @@
+2012-02-17  Enrica Casucci  <[email protected]>
+
+        Refactor DragData class to use PlatformStrategies in the Mac implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=78768
+
+        Reviewed by Darin Adler.
+
+        * WebCoreSupport/WebPlatformStrategies.h: Added color() method.
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::color):
+
 2012-02-16  Brady Eidson  <[email protected]>
 
         <rdar://problem/10616280> and https://bugs.webkit.org/show_bug.cgi?id=78767

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h (108100 => 108101)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h	2012-02-17 19:54:20 UTC (rev 108101)
@@ -63,6 +63,7 @@
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual int changeCount(const String& pasteboardName) OVERRIDE;
     virtual String uniqueName() OVERRIDE;
+    virtual WebCore::Color color(const String& pasteboardName) OVERRIDE;
     
     virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
     virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm (108100 => 108101)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm	2012-02-17 19:54:20 UTC (rev 108101)
@@ -28,6 +28,7 @@
 #import "WebPluginDatabase.h"
 #import "WebPluginPackage.h"
 #import <WebCore/BlockExceptions.h>
+#import <WebCore/Color.h>
 #import <WebCore/Page.h>
 #import <WebCore/PageGroup.h>
 #import <WebCore/PlatformPasteboard.h>
@@ -99,38 +100,32 @@
 
 void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.getTypes(types);
+    PlatformPasteboard(pasteboardName).getTypes(types);
 }
 
 PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.bufferForType(pasteboardType);
+    return PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
 }
 
 void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.getPathnamesForType(pathnames, pasteboardType);
+    PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
 }
 
 String WebPlatformStrategies::stringForType(const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.stringForType(pasteboardType);
+    return PlatformPasteboard(pasteboardName).stringForType(pasteboardType);
 }
 
 void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
 {
-    PlatformPasteboard pasteboard(toPasteboard);
-    return pasteboard.copy(fromPasteboard);
+    PlatformPasteboard(toPasteboard).copy(fromPasteboard);
 }
 
 int WebPlatformStrategies::changeCount(const String &pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.changeCount();
+    return PlatformPasteboard(pasteboardName).changeCount();
 }
 
 String WebPlatformStrategies::uniqueName()
@@ -138,26 +133,27 @@
     return PlatformPasteboard::uniqueName();
 }
 
+Color WebPlatformStrategies::color(const String& pasteboardName)
+{
+    return PlatformPasteboard(pasteboardName).color();    
+}
+
 void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setTypes(pasteboardTypes);
+    PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
 }
 
 void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setBufferForType(buffer, pasteboardType);
+    PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
 }
 
 void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.setPathnamesForType(pathnames, pasteboardType);
+    PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
 }
 
 void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setStringForType(string, pasteboardType);    
+    PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);    
 }

Modified: trunk/Source/WebKit2/ChangeLog (108100 => 108101)


--- trunk/Source/WebKit2/ChangeLog	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit2/ChangeLog	2012-02-17 19:54:20 UTC (rev 108101)
@@ -1,3 +1,14 @@
+2012-02-17  Enrica Casucci  <[email protected]>
+
+        Refactor DragData class to use PlatformStrategies in the Mac implementation.
+        https://bugs.webkit.org/show_bug.cgi?id=78768
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: Added color() method.
+        (WebKit::WebPlatformStrategies::color):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+
 2012-02-17  Martin Robinson  <[email protected]>
 
         Fix some warnings encountered during the GTK+ build

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (108100 => 108101)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2012-02-17 19:54:20 UTC (rev 108101)
@@ -33,6 +33,7 @@
 #include "WebCookieManager.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
+#include <WebCore/Color.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformPasteboard.h>
 
@@ -136,38 +137,32 @@
 
 void WebPlatformStrategies::getTypes(Vector<String>& types, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.getTypes(types);
+    PlatformPasteboard(pasteboardName).getTypes(types);
 }
 
 PassRefPtr<WebCore::SharedBuffer> WebPlatformStrategies::bufferForType(const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.bufferForType(pasteboardType);
+    return PlatformPasteboard(pasteboardName).bufferForType(pasteboardType);
 }
 
 void WebPlatformStrategies::getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.getPathnamesForType(pathnames, pasteboardType);
+    PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
 }
 
 String WebPlatformStrategies::stringForType(const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.stringForType(pasteboardType);
+    return PlatformPasteboard(pasteboardName).stringForType(pasteboardType);
 }
 
 void WebPlatformStrategies::copy(const String& fromPasteboard, const String& toPasteboard)
 {
-    PlatformPasteboard pasteboard(toPasteboard);
-    return pasteboard.copy(fromPasteboard);
+    PlatformPasteboard(toPasteboard).copy(fromPasteboard);
 }
 
 int WebPlatformStrategies::changeCount(const WTF::String &pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.changeCount();
+    return PlatformPasteboard(pasteboardName).changeCount();
 }
 
 String WebPlatformStrategies::uniqueName()
@@ -175,28 +170,29 @@
     return PlatformPasteboard::uniqueName();
 }
 
+Color WebPlatformStrategies::color(const String& pasteboardName)
+{
+    return PlatformPasteboard(pasteboardName).color();    
+}
+
 void WebPlatformStrategies::setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setTypes(pasteboardTypes);
+    PlatformPasteboard(pasteboardName).setTypes(pasteboardTypes);
 }
 
 void WebPlatformStrategies::setBufferForType(PassRefPtr<SharedBuffer> buffer, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setBufferForType(buffer, pasteboardType);
+    PlatformPasteboard(pasteboardName).setBufferForType(buffer, pasteboardType);
 }
 
 void WebPlatformStrategies::setPathnamesForType(const Vector<String>& pathnames, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    pasteboard.setPathnamesForType(pathnames, pasteboardType);
+    PlatformPasteboard(pasteboardName).setPathnamesForType(pathnames, pasteboardType);
 }
 
 void WebPlatformStrategies::setStringForType(const String& string, const String& pasteboardType, const String& pasteboardName)
 {
-    PlatformPasteboard pasteboard(pasteboardName);
-    return pasteboard.setStringForType(string, pasteboardType);    
+    PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);    
 }
 #endif
 

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (108100 => 108101)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2012-02-17 19:45:14 UTC (rev 108100)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2012-02-17 19:54:20 UTC (rev 108101)
@@ -69,6 +69,7 @@
     virtual String stringForType(const String& pasteboardType, const String& pasteboardName) OVERRIDE;
     virtual int changeCount(const String& pasteboardName) OVERRIDE;
     virtual String uniqueName() OVERRIDE;
+    virtual WebCore::Color color(const String& pasteboardName) OVERRIDE;
     
     virtual void copy(const String& fromPasteboard, const String& toPasteboard) OVERRIDE;
     virtual void setTypes(const Vector<String>& pasteboardTypes, const String& pasteboardName) OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to