Consider replacing return type of Clipboard::types() from HashSet<String> to Vector...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 01:56:54 +0000 (01:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 01:56:54 +0000 (01:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=82888

Patch by Vineet Chaudhary <rgf748@motorola.com> on 2012-08-22
Reviewed by Kentaro Hara.

As part of removing custom bindings of types Array Clipboard::types() needs to return
Vector<String> than HashSet<String>

No new tests. Exixting test should pass with this change as no behavoural changes.

* bindings/js/JSClipboardCustom.cpp: Replace data type from HashSet<> to Vector<>.
(WebCore::JSClipboard::types):
* bindings/v8/custom/V8ClipboardCustom.cpp: Ditto.
(WebCore::V8Clipboard::typesAccessorGetter):
* dom/Clipboard.h: Ditto.
(Clipboard):
* platform/blackberry/ClipboardBlackBerry.cpp: Ditto.
(WebCore::ClipboardBlackBerry::types):
* platform/blackberry/ClipboardBlackBerry.h: Ditto.
(ClipboardBlackBerry):
* platform/chromium/ChromiumDataObject.cpp: Ditto.
(WebCore::ChromiumDataObject::types):
* platform/chromium/ChromiumDataObject.h: Ditto.
(ChromiumDataObject):
* platform/chromium/ClipboardChromium.cpp: Ditto.
(WebCore::ClipboardChromium::types):
* platform/chromium/ClipboardChromium.h: Ditto.
(ClipboardChromium):
* platform/efl/ClipboardEfl.cpp: Ditto.
(WebCore::ClipboardEfl::types):
* platform/efl/ClipboardEfl.h: Ditto.
(ClipboardEfl):
* platform/gtk/ClipboardGtk.cpp: Ditto.
(WebCore::ClipboardGtk::types):
* platform/gtk/ClipboardGtk.h: Ditto.
(ClipboardGtk):
* platform/mac/ClipboardMac.h: Ditto.
(ClipboardMac):
* platform/mac/ClipboardMac.mm: Ditto.
(WebCore::addHTMLClipboardTypesForCocoaType):
(WebCore::ClipboardMac::types):
* platform/qt/ClipboardQt.cpp: Ditto.
(WebCore::ClipboardQt::types):
* platform/qt/ClipboardQt.h: Ditto.
(ClipboardQt):
* platform/win/ClipboardWin.cpp: Ditto.
(WebCore::addMimeTypesForFormat):
(WebCore::ClipboardWin::types):
* platform/win/ClipboardWin.h: Ditto.
(ClipboardWin):
* platform/wx/ClipboardWx.cpp: Ditto.
(WebCore::ClipboardWx::types):
* platform/wx/ClipboardWx.h: Ditto.
(ClipboardWx):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126383 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSClipboardCustom.cpp
Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp
Source/WebCore/dom/Clipboard.h
Source/WebCore/platform/blackberry/ClipboardBlackBerry.cpp
Source/WebCore/platform/blackberry/ClipboardBlackBerry.h
Source/WebCore/platform/chromium/ChromiumDataObject.cpp
Source/WebCore/platform/chromium/ChromiumDataObject.h
Source/WebCore/platform/chromium/ClipboardChromium.cpp
Source/WebCore/platform/chromium/ClipboardChromium.h
Source/WebCore/platform/efl/ClipboardEfl.cpp
Source/WebCore/platform/efl/ClipboardEfl.h
Source/WebCore/platform/gtk/ClipboardGtk.cpp
Source/WebCore/platform/gtk/ClipboardGtk.h
Source/WebCore/platform/mac/ClipboardMac.h
Source/WebCore/platform/mac/ClipboardMac.mm
Source/WebCore/platform/qt/ClipboardQt.cpp
Source/WebCore/platform/qt/ClipboardQt.h
Source/WebCore/platform/win/ClipboardWin.cpp
Source/WebCore/platform/win/ClipboardWin.h
Source/WebCore/platform/wx/ClipboardWx.cpp
Source/WebCore/platform/wx/ClipboardWx.h

index 7e1b942..ed3649f 100644 (file)
@@ -1,3 +1,60 @@
+2012-08-22  Vineet Chaudhary  <rgf748@motorola.com>
+
+        Consider replacing return type of Clipboard::types() from HashSet<String> to Vector<String>.
+        https://bugs.webkit.org/show_bug.cgi?id=82888
+
+        Reviewed by Kentaro Hara.
+
+        As part of removing custom bindings of types Array Clipboard::types() needs to return
+        Vector<String> than HashSet<String>
+
+        No new tests. Exixting test should pass with this change as no behavoural changes.
+
+        * bindings/js/JSClipboardCustom.cpp: Replace data type from HashSet<> to Vector<>.
+        (WebCore::JSClipboard::types):
+        * bindings/v8/custom/V8ClipboardCustom.cpp: Ditto.
+        (WebCore::V8Clipboard::typesAccessorGetter):
+        * dom/Clipboard.h: Ditto.
+        (Clipboard):
+        * platform/blackberry/ClipboardBlackBerry.cpp: Ditto.
+        (WebCore::ClipboardBlackBerry::types):
+        * platform/blackberry/ClipboardBlackBerry.h: Ditto.
+        (ClipboardBlackBerry):
+        * platform/chromium/ChromiumDataObject.cpp: Ditto.
+        (WebCore::ChromiumDataObject::types):
+        * platform/chromium/ChromiumDataObject.h: Ditto.
+        (ChromiumDataObject):
+        * platform/chromium/ClipboardChromium.cpp: Ditto.
+        (WebCore::ClipboardChromium::types):
+        * platform/chromium/ClipboardChromium.h: Ditto.
+        (ClipboardChromium):
+        * platform/efl/ClipboardEfl.cpp: Ditto.
+        (WebCore::ClipboardEfl::types):
+        * platform/efl/ClipboardEfl.h: Ditto.
+        (ClipboardEfl):
+        * platform/gtk/ClipboardGtk.cpp: Ditto.
+        (WebCore::ClipboardGtk::types):
+        * platform/gtk/ClipboardGtk.h: Ditto.
+        (ClipboardGtk):
+        * platform/mac/ClipboardMac.h: Ditto.
+        (ClipboardMac):
+        * platform/mac/ClipboardMac.mm: Ditto.
+        (WebCore::addHTMLClipboardTypesForCocoaType):
+        (WebCore::ClipboardMac::types):
+        * platform/qt/ClipboardQt.cpp: Ditto.
+        (WebCore::ClipboardQt::types):
+        * platform/qt/ClipboardQt.h: Ditto.
+        (ClipboardQt):
+        * platform/win/ClipboardWin.cpp: Ditto.
+        (WebCore::addMimeTypesForFormat):
+        (WebCore::ClipboardWin::types):
+        * platform/win/ClipboardWin.h: Ditto.
+        (ClipboardWin):
+        * platform/wx/ClipboardWx.cpp: Ditto.
+        (WebCore::ClipboardWx::types):
+        * platform/wx/ClipboardWx.h: Ditto.
+        (ClipboardWx):
+
 2012-08-22  James Robinson  <jamesr@chromium.org>
 
         [chromium] Change WebLayer from a concrete type to a pure virtual interface
index 8cfd65a..230d9ac 100644 (file)
@@ -52,13 +52,13 @@ JSValue JSClipboard::types(ExecState* exec) const
 {
     Clipboard* clipboard = impl();
 
-    HashSet<String> types = clipboard->types();
+    Vector<String> types = clipboard->types();
     if (types.isEmpty())
         return jsNull();
 
     MarkedArgumentBuffer list;
-    HashSet<String>::const_iterator end = types.end();
-    for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
+    Vector<String>::const_iterator end = types.end();
+    for (Vector<String>::const_iterator it = types.begin(); it != end; ++it)
         list.append(jsString(exec, stringToUString(*it)));
     return constructArray(exec, globalObject(), list);
 }
index 875f64e..9904387 100644 (file)
@@ -49,14 +49,14 @@ v8::Handle<v8::Value> V8Clipboard::typesAccessorGetter(v8::Local<v8::String> nam
     INC_STATS("DOM.Clipboard.types()");
     Clipboard* clipboard = V8Clipboard::toNative(info.Holder());
 
-    HashSet<String> types = clipboard->types();
+    Vector<String> types = clipboard->types();
     if (types.isEmpty())
         return v8::Null(info.GetIsolate());
 
     v8::Local<v8::Array> result = v8::Array::New(types.size());
-    HashSet<String>::const_iterator end = types.end();
+    Vector<String>::const_iterator end = types.end();
     int index = 0;
-    for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index)
+    for (Vector<String>::const_iterator it = types.begin(); it != end; ++it, ++index)
         result->Set(v8Integer(index, info.GetIsolate()), v8String(*it, info.GetIsolate()));
 
     return result;
index 83f0f24..204cb1a 100644 (file)
@@ -66,7 +66,7 @@ namespace WebCore {
         virtual bool setData(const String& type, const String& data) = 0;
     
         // extensions beyond IE's API
-        virtual HashSet<String> types() const = 0;
+        virtual Vector<String> types() const = 0;
         virtual PassRefPtr<FileList> files() const = 0;
 
         IntPoint dragLocation() const { return m_dragLoc; }
index 2a31be8..0845219 100644 (file)
@@ -78,16 +78,16 @@ bool ClipboardBlackBerry::setData(const String& type, const String& text)
     return true;
 }
 
-HashSet<String> ClipboardBlackBerry::types() const
+Vector<String> ClipboardBlackBerry::types() const
 {
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
-        return HashSet<String>();
+        return Vector<String>();
 
     // We use hardcoded list here since there seems to be no API to get the list.
-    HashSet<String> ret;
-    ret.add("text/plain");
-    ret.add("text/html");
-    ret.add("text/url");
+    Vector<String> ret;
+    ret.append("text/plain");
+    ret.append("text/html");
+    ret.append("text/url");
     return ret;
 }
 
index 17effce..c8d8097 100644 (file)
@@ -39,7 +39,7 @@ public:
     bool setData(const String& type, const String& data);
 
     // extensions beyond IE's API
-    virtual HashSet<String> types() const;
+    virtual Vector<String> types() const;
     virtual PassRefPtr<FileList> files() const;
     virtual DragImageRef createDragImage(IntPoint&) const;
     virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
index ec7eebe..d4dfa5c 100644 (file)
@@ -126,20 +126,20 @@ void ChromiumDataObject::clearAllExceptFiles()
     }
 }
 
-HashSet<String> ChromiumDataObject::types() const
+Vector<String> ChromiumDataObject::types() const
 {
-    HashSet<String> results;
+    Vector<String> results;
     bool containsFiles = false;
     for (size_t i = 0; i < m_itemList.size(); ++i) {
         if (m_itemList[i]->kind() == DataTransferItem::kindString)
-            results.add(m_itemList[i]->type());
+            results.append(m_itemList[i]->type());
         else if (m_itemList[i]->kind() == DataTransferItem::kindFile)
             containsFiles = true;
         else
             ASSERT_NOT_REACHED();
     }
     if (containsFiles)
-        results.add(mimeTypeFiles);
+        results.append(mimeTypeFiles);
     return results;
 }
 
index 1efb4df..db62bc9 100644 (file)
@@ -69,7 +69,7 @@ public:
     void clearData(const String& type);
     void clearAllExceptFiles();
 
-    HashSet<String> types() const;
+    Vector<String> types() const;
     String getData(const String& type) const;
     bool setData(const String& type, const String& data);
 
index b065237..afbd790 100644 (file)
@@ -274,10 +274,10 @@ bool ClipboardChromium::setData(const String& type, const String& data)
 }
 
 // extensions beyond IE's API
-HashSet<String> ClipboardChromium::types() const
+Vector<String> ClipboardChromium::types() const
 {
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
-        return HashSet<String>();
+        return Vector<String>();
 
     return m_dataObject->types();
 }
index a5cbf53..841aae6 100644 (file)
@@ -84,7 +84,7 @@ namespace WebCore {
         bool platformClipboardChanged() const;
 
         // extensions beyond IE's API
-        virtual HashSet<String> types() const;
+        virtual Vector<String> types() const;
         virtual PassRefPtr<FileList> files() const;
 
         void setDragImage(CachedImage*, const IntPoint&);
index 884d387..0a68d40 100644 (file)
@@ -76,10 +76,10 @@ bool ClipboardEfl::setData(const String&, const String&)
     return false;
 }
 
-HashSet<String> ClipboardEfl::types() const
+Vector<String> ClipboardEfl::types() const
 {
     notImplemented();
-    return HashSet<String>();
+    return Vector<String>();
 }
 
 PassRefPtr<FileList> ClipboardEfl::files() const
index 3da598e..b7b3287 100644 (file)
@@ -39,7 +39,7 @@ public:
     String getData(const String&) const;
     bool setData(const String&, const String&);
 
-    HashSet<String> types() const;
+    Vector<String> types() const;
     virtual PassRefPtr<FileList> files() const;
 
     IntPoint dragLocation() const;
index 891126d..3dc7582 100644 (file)
@@ -184,31 +184,31 @@ bool ClipboardGtk::setData(const String& typeString, const String& data)
     return success;
 }
 
-HashSet<String> ClipboardGtk::types() const
+Vector<String> ClipboardGtk::types() const
 {
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
-        return HashSet<String>();
+        return Vector<String>();
 
     if (m_clipboard)
         PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
 
-    HashSet<String> types;
+    Vector<String> types;
     if (m_dataObject->hasText()) {
-        types.add("text/plain");
-        types.add("Text");
-        types.add("text");
+        types.append("text/plain");
+        types.append("Text");
+        types.append("text");
     }
 
     if (m_dataObject->hasMarkup())
-        types.add("text/html");
+        types.append("text/html");
 
     if (m_dataObject->hasURIList()) {
-        types.add("text/uri-list");
-        types.add("URL");
+        types.append("text/uri-list");
+        types.append("URL");
     }
 
     if (m_dataObject->hasFilenames())
-        types.add("Files");
+        types.append("Files");
 
     return types;
 }
index b071c6f..7a6117d 100644 (file)
@@ -57,7 +57,7 @@ namespace WebCore {
         String getData(const String&) const;
         bool setData(const String&, const String&);
 
-        virtual HashSet<String> types() const;
+        virtual Vector<String> types() const;
         virtual PassRefPtr<FileList> files() const;
 
         void setDragImage(CachedImage*, const IntPoint&);
index 75517c1..72e6a36 100644 (file)
@@ -62,7 +62,7 @@ public:
     virtual bool hasData();
     
     // extensions beyond IE's API
-    virtual HashSet<String> types() const;
+    virtual Vector<String> types() const;
     virtual PassRefPtr<FileList> files() const;
 
     void setDragImage(CachedImage*, const IntPoint&);
index 1af14df..63e80be 100644 (file)
@@ -120,15 +120,15 @@ static String utiTypeFromCocoaType(const String& type)
     return String();
 }
 
-static void addHTMLClipboardTypesForCocoaType(HashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
+static void addHTMLClipboardTypesForCocoaType(Vector<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
 {
     // UTI may not do these right, so make sure we get the right, predictable result
     if (cocoaType == String(NSStringPboardType)) {
-        resultTypes.add("text/plain");
+        resultTypes.append("text/plain");
         return;
     }
     if (cocoaType == String(NSURLPboardType)) {
-        resultTypes.add("text/uri-list");
+        resultTypes.append("text/uri-list");
         return;
     }
     if (cocoaType == String(NSFilenamesPboardType)) {
@@ -140,18 +140,18 @@ static void addHTMLClipboardTypesForCocoaType(HashSet<String>& resultTypes, cons
         if (!fileList.isEmpty()) {
             // It is unknown if NSFilenamesPboardType always implies NSURLPboardType in Cocoa,
             // but NSFilenamesPboardType should imply both 'text/uri-list' and 'Files'
-            resultTypes.add("text/uri-list");
-            resultTypes.add("Files");
+            resultTypes.append("text/uri-list");
+            resultTypes.append("Files");
         }
         return;
     }
     String utiType = utiTypeFromCocoaType(cocoaType);
     if (!utiType.isEmpty()) {
-        resultTypes.add(utiType);
+        resultTypes.append(utiType);
         return;
     }
     // No mapping, just pass the whole string though
-    resultTypes.add(cocoaType);
+    resultTypes.append(cocoaType);
 }
 
 void ClipboardMac::clearData(const String& type)
@@ -282,10 +282,10 @@ bool ClipboardMac::setData(const String &type, const String &data)
     return false;
 }
 
-HashSet<String> ClipboardMac::types() const
+Vector<String> ClipboardMac::types() const
 {
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
-        return HashSet<String>();
+        return Vector<String>();
 
     Vector<String> types;
     platformStrategies()->pasteboardStrategy()->getTypes(types, m_pasteboardName);
@@ -293,9 +293,9 @@ HashSet<String> ClipboardMac::types() const
     // Enforce changeCount ourselves for security.  We check after reading instead of before to be
     // sure it doesn't change between our testing the change count and accessing the data.
     if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
-        return HashSet<String>();
+        return Vector<String>();
 
-    HashSet<String> result;
+    Vector<String> result;
     // FIXME: This loop could be split into two stages. One which adds all the HTML5 specified types
     // and a second which adds all the extra types from the cocoa clipboard (which is Mac-only behavior).
     for (size_t i = 0; i < types.size(); i++) {
index 8edbbe3..28e9d13 100644 (file)
@@ -183,16 +183,16 @@ bool ClipboardQt::setData(const String& type, const String& data)
 }
 
 // extensions beyond IE's API
-HashSet<String> ClipboardQt::types() const
+Vector<String> ClipboardQt::types() const
 {
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
-        return HashSet<String>();
+        return Vector<String>();
 
     ASSERT(m_readableData);
-    HashSet<String> result;
+    Vector<String> result;
     QStringList formats = m_readableData->formats();
     for (int i = 0; i < formats.count(); ++i)
-        result.add(formats.at(i));
+        result.append(formats.at(i));
     return result;
 }
 
index 5d09c84..4a9952a 100644 (file)
@@ -57,7 +57,7 @@ public:
     bool setData(const String& type, const String& data);
 
     // extensions beyond IE's API
-    virtual HashSet<String> types() const;
+    virtual Vector<String> types() const;
     virtual PassRefPtr<FileList> files() const;
 
     void setDragImage(CachedImage*, const IntPoint&);
index d1c1386..2f19e3b 100644 (file)
@@ -484,24 +484,24 @@ bool ClipboardWin::setData(const String& type, const String& data)
     return false;
 }
 
-static void addMimeTypesForFormat(HashSet<String>& results, const FORMATETC& format)
+static void addMimeTypesForFormat(Vector<String>& results, const FORMATETC& format)
 {
     // URL and Text are provided for compatibility with IE's model
     if (format.cfFormat == urlFormat()->cfFormat || format.cfFormat == urlWFormat()->cfFormat) {
-        results.add("URL");
-        results.add("text/uri-list");
+        results.append("URL");
+        results.append("text/uri-list");
     }
 
     if (format.cfFormat == plainTextWFormat()->cfFormat || format.cfFormat == plainTextFormat()->cfFormat) {
-        results.add("Text");
-        results.add("text/plain");
+        results.append("Text");
+        results.append("text/plain");
     }
 }
 
 // extensions beyond IE's API
-HashSet<String> ClipboardWin::types() const
+Vector<String> ClipboardWin::types() const
 { 
-    HashSet<String> results; 
+    Vector<String> results;
     if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
         return results;
 
index 8dad415..8db1862 100644 (file)
@@ -64,7 +64,7 @@ public:
     bool setData(const String& type, const String& data);
 
     // extensions beyond IE's API
-    virtual HashSet<String> types() const;
+    virtual Vector<String> types() const;
     virtual PassRefPtr<FileList> files() const;
 
     void setDragImage(CachedImage*, const IntPoint&);
index 9906621..07889db 100644 (file)
@@ -72,10 +72,10 @@ bool ClipboardWx::setData(const String& type, const String& data)
 }
 
 // extensions beyond IE's API
-HashSet<String> ClipboardWx::types() const 
+Vector<String> ClipboardWx::types() const
 {
     notImplemented();
-    HashSet<String> result;
+    Vector<String> result;
     return result;
 }
 
index 9e661d7..cef9854 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
         bool setData(const String& type, const String& data);
     
         // extensions beyond IE's API
-        virtual HashSet<String> types() const;
+        virtual Vector<String> types() const;
         virtual PassRefPtr<FileList> files() const;
     
         IntPoint dragLocation() const;