Changeset 130588 in webkit


Ignore:
Timestamp:
Oct 6, 2012 12:14:11 PM (12 years ago)
Author:
kling@webkit.org
Message:

Clipboard::types() should return an ordered collection.
<http://webkit.org/b/98547>

Reviewed by Darin Adler.

Let Clipboard::types() return a ListHashSet<String> instead of a HashSet<String> to make sure
it retains the order in which type strings are added.

No test, this fixes an issue that was uncovered when lowering the default table size of WTF
hash tables, causing the HashSet<String> to rehash and reorder itself.

  • bindings/js/JSClipboardCustom.cpp:

(WebCore::JSClipboard::types):

  • bindings/v8/custom/V8ClipboardCustom.cpp:

(WebCore::V8Clipboard::typesAccessorGetter):

  • dom/Clipboard.h:

(Clipboard):

  • platform/blackberry/ClipboardBlackBerry.cpp:

(WebCore::ClipboardBlackBerry::types):

  • platform/blackberry/ClipboardBlackBerry.h:

(ClipboardBlackBerry):

  • platform/chromium/ChromiumDataObject.cpp:

(WebCore::ChromiumDataObject::types):

  • platform/chromium/ChromiumDataObject.h:

(ChromiumDataObject):

  • platform/chromium/ClipboardChromium.cpp:

(WebCore::ClipboardChromium::types):

  • platform/chromium/ClipboardChromium.h:

(ClipboardChromium):

  • platform/efl/ClipboardEfl.cpp:

(WebCore::ClipboardEfl::types):

  • platform/efl/ClipboardEfl.h:

(ClipboardEfl):

  • platform/gtk/ClipboardGtk.cpp:

(WebCore::ClipboardGtk::types):

  • platform/gtk/ClipboardGtk.h:

(ClipboardGtk):

  • platform/mac/ClipboardMac.h:

(ClipboardMac):

  • platform/mac/ClipboardMac.mm:

(WebCore::addHTMLClipboardTypesForCocoaType):
(WebCore::ClipboardMac::types):

  • platform/qt/ClipboardQt.cpp:

(WebCore::ClipboardQt::types):

  • platform/qt/ClipboardQt.h:

(ClipboardQt):

  • platform/win/ClipboardWin.cpp:

(WebCore::addMimeTypesForFormat):
(WebCore::ClipboardWin::types):

  • platform/win/ClipboardWin.h:

(ClipboardWin):

  • platform/wx/ClipboardWx.cpp:

(WebCore::ClipboardWx::types):

  • platform/wx/ClipboardWx.h:

(ClipboardWx):

Location:
trunk/Source/WebCore
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r130587 r130588  
     12012-10-06  Andreas Kling  <kling@webkit.org>
     2
     3        Clipboard::types() should return an ordered collection.
     4        <http://webkit.org/b/98547>
     5
     6        Reviewed by Darin Adler.
     7
     8        Let Clipboard::types() return a ListHashSet<String> instead of a HashSet<String> to make sure
     9        it retains the order in which type strings are added.
     10
     11        No test, this fixes an issue that was uncovered when lowering the default table size of WTF
     12        hash tables, causing the HashSet<String> to rehash and reorder itself.
     13
     14        * bindings/js/JSClipboardCustom.cpp:
     15        (WebCore::JSClipboard::types):
     16        * bindings/v8/custom/V8ClipboardCustom.cpp:
     17        (WebCore::V8Clipboard::typesAccessorGetter):
     18        * dom/Clipboard.h:
     19        (Clipboard):
     20        * platform/blackberry/ClipboardBlackBerry.cpp:
     21        (WebCore::ClipboardBlackBerry::types):
     22        * platform/blackberry/ClipboardBlackBerry.h:
     23        (ClipboardBlackBerry):
     24        * platform/chromium/ChromiumDataObject.cpp:
     25        (WebCore::ChromiumDataObject::types):
     26        * platform/chromium/ChromiumDataObject.h:
     27        (ChromiumDataObject):
     28        * platform/chromium/ClipboardChromium.cpp:
     29        (WebCore::ClipboardChromium::types):
     30        * platform/chromium/ClipboardChromium.h:
     31        (ClipboardChromium):
     32        * platform/efl/ClipboardEfl.cpp:
     33        (WebCore::ClipboardEfl::types):
     34        * platform/efl/ClipboardEfl.h:
     35        (ClipboardEfl):
     36        * platform/gtk/ClipboardGtk.cpp:
     37        (WebCore::ClipboardGtk::types):
     38        * platform/gtk/ClipboardGtk.h:
     39        (ClipboardGtk):
     40        * platform/mac/ClipboardMac.h:
     41        (ClipboardMac):
     42        * platform/mac/ClipboardMac.mm:
     43        (WebCore::addHTMLClipboardTypesForCocoaType):
     44        (WebCore::ClipboardMac::types):
     45        * platform/qt/ClipboardQt.cpp:
     46        (WebCore::ClipboardQt::types):
     47        * platform/qt/ClipboardQt.h:
     48        (ClipboardQt):
     49        * platform/win/ClipboardWin.cpp:
     50        (WebCore::addMimeTypesForFormat):
     51        (WebCore::ClipboardWin::types):
     52        * platform/win/ClipboardWin.h:
     53        (ClipboardWin):
     54        * platform/wx/ClipboardWx.cpp:
     55        (WebCore::ClipboardWx::types):
     56        * platform/wx/ClipboardWx.h:
     57        (ClipboardWx):
     58
    1592012-10-06  Geoffrey Garen  <ggaren@apple.com>
    260
  • trunk/Source/WebCore/bindings/js/JSClipboardCustom.cpp

    r127757 r130588  
    3939#include <runtime/ArrayPrototype.h>
    4040#include <runtime/Error.h>
    41 #include <wtf/HashSet.h>
    4241#include <wtf/text/StringHash.h>
    4342#include <wtf/text/WTFString.h>
     
    5352    Clipboard* clipboard = impl();
    5453
    55     HashSet<String> types = clipboard->types();
     54    ListHashSet<String> types = clipboard->types();
    5655    if (types.isEmpty())
    5756        return jsNull();
    5857
    5958    MarkedArgumentBuffer list;
    60     HashSet<String>::const_iterator end = types.end();
    61     for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
     59    ListHashSet<String>::const_iterator end = types.end();
     60    for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it)
    6261        list.append(jsStringWithCache(exec, *it));
    6362    return constructArray(exec, globalObject(), list);
  • trunk/Source/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp

    r126399 r130588  
    4949    Clipboard* clipboard = V8Clipboard::toNative(info.Holder());
    5050
    51     HashSet<String> types = clipboard->types();
     51    ListHashSet<String> types = clipboard->types();
    5252    if (types.isEmpty())
    5353        return v8::Null(info.GetIsolate());
    5454
    5555    v8::Local<v8::Array> result = v8::Array::New(types.size());
    56     HashSet<String>::const_iterator end = types.end();
     56    ListHashSet<String>::const_iterator end = types.end();
    5757    int index = 0;
    58     for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index)
     58    for (ListHashSet<String>::const_iterator it = types.begin(); it != end; ++it, ++index)
    5959        result->Set(v8Integer(index, info.GetIsolate()), v8String(*it, info.GetIsolate()));
    6060
  • trunk/Source/WebCore/dom/Clipboard.h

    r126390 r130588  
    6767   
    6868        // extensions beyond IE's API
    69         virtual HashSet<String> types() const = 0;
     69        virtual ListHashSet<String> types() const = 0;
    7070        virtual PassRefPtr<FileList> files() const = 0;
    7171
  • trunk/Source/WebCore/platform/blackberry/ClipboardBlackBerry.cpp

    r126390 r130588  
    7979}
    8080
    81 HashSet<String> ClipboardBlackBerry::types() const
     81ListHashSet<String> ClipboardBlackBerry::types() const
    8282{
    8383    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    84         return HashSet<String>();
     84        return ListHashSet<String>();
    8585
    8686    // We use hardcoded list here since there seems to be no API to get the list.
    87     HashSet<String> ret;
     87    ListHashSet<String> ret;
    8888    ret.add("text/plain");
    8989    ret.add("text/html");
  • trunk/Source/WebCore/platform/blackberry/ClipboardBlackBerry.h

    r126390 r130588  
    4040
    4141    // extensions beyond IE's API
    42     virtual HashSet<String> types() const;
     42    virtual ListHashSet<String> types() const;
    4343    virtual PassRefPtr<FileList> files() const;
    4444    virtual DragImageRef createDragImage(IntPoint&) const;
  • trunk/Source/WebCore/platform/chromium/ChromiumDataObject.cpp

    r126390 r130588  
    127127}
    128128
    129 HashSet<String> ChromiumDataObject::types() const
    130 {
    131     HashSet<String> results;
     129ListHashSet<String> ChromiumDataObject::types() const
     130{
     131    ListHashSet<String> results;
    132132    bool containsFiles = false;
    133133    for (size_t i = 0; i < m_itemList.size(); ++i) {
  • trunk/Source/WebCore/platform/chromium/ChromiumDataObject.h

    r127757 r130588  
    3434#include "ChromiumDataObjectItem.h"
    3535#include "Supplementable.h"
    36 #include <wtf/HashSet.h>
     36#include <wtf/ListHashSet.h>
    3737#include <wtf/RefPtr.h>
    3838#include <wtf/Vector.h>
     
    7070    void clearAllExceptFiles();
    7171
    72     HashSet<String> types() const;
     72    ListHashSet<String> types() const;
    7373    String getData(const String& type) const;
    7474    bool setData(const String& type, const String& data);
  • trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp

    r129962 r130588  
    276276
    277277// extensions beyond IE's API
    278 HashSet<String> ClipboardChromium::types() const
     278ListHashSet<String> ClipboardChromium::types() const
    279279{
    280280    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    281         return HashSet<String>();
     281        return ListHashSet<String>();
    282282
    283283    return m_dataObject->types();
  • trunk/Source/WebCore/platform/chromium/ClipboardChromium.h

    r126390 r130588  
    8585
    8686        // extensions beyond IE's API
    87         virtual HashSet<String> types() const;
     87        virtual ListHashSet<String> types() const;
    8888        virtual PassRefPtr<FileList> files() const;
    8989
  • trunk/Source/WebCore/platform/efl/ClipboardEfl.cpp

    r126390 r130588  
    7777}
    7878
    79 HashSet<String> ClipboardEfl::types() const
     79ListHashSet<String> ClipboardEfl::types() const
    8080{
    8181    notImplemented();
    82     return HashSet<String>();
     82    return ListHashSet<String>();
    8383}
    8484
  • trunk/Source/WebCore/platform/efl/ClipboardEfl.h

    r126390 r130588  
    4040    bool setData(const String&, const String&);
    4141
    42     HashSet<String> types() const;
     42    ListHashSet<String> types() const;
    4343    virtual PassRefPtr<FileList> files() const;
    4444
  • trunk/Source/WebCore/platform/gtk/ClipboardGtk.cpp

    r129962 r130588  
    187187}
    188188
    189 HashSet<String> ClipboardGtk::types() const
     189ListHashSet<String> ClipboardGtk::types() const
    190190{
    191191    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    192         return HashSet<String>();
     192        return ListHashSet<String>();
    193193
    194194    if (m_clipboard)
    195195        PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_clipboard);
    196196
    197     HashSet<String> types;
     197    ListHashSet<String> types;
    198198    if (m_dataObject->hasText()) {
    199199        types.add("text/plain");
  • trunk/Source/WebCore/platform/gtk/ClipboardGtk.h

    r126390 r130588  
    5858        bool setData(const String&, const String&);
    5959
    60         virtual HashSet<String> types() const;
     60        virtual ListHashSet<String> types() const;
    6161        virtual PassRefPtr<FileList> files() const;
    6262
  • trunk/Source/WebCore/platform/mac/ClipboardMac.h

    r126390 r130588  
    6363   
    6464    // extensions beyond IE's API
    65     virtual HashSet<String> types() const;
     65    virtual ListHashSet<String> types() const;
    6666    virtual PassRefPtr<FileList> files() const;
    6767
  • trunk/Source/WebCore/platform/mac/ClipboardMac.mm

    r129962 r130588  
    123123}
    124124
    125 static void addHTMLClipboardTypesForCocoaType(HashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
     125static void addHTMLClipboardTypesForCocoaType(ListHashSet<String>& resultTypes, const String& cocoaType, const String& pasteboardName)
    126126{
    127127    // UTI may not do these right, so make sure we get the right, predictable result
     
    285285}
    286286
    287 HashSet<String> ClipboardMac::types() const
     287ListHashSet<String> ClipboardMac::types() const
    288288{
    289289    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    290         return HashSet<String>();
     290        return ListHashSet<String>();
    291291
    292292    Vector<String> types;
     
    296296    // sure it doesn't change between our testing the change count and accessing the data.
    297297    if (m_changeCount != platformStrategies()->pasteboardStrategy()->changeCount(m_pasteboardName))
    298         return HashSet<String>();
    299 
    300     HashSet<String> result;
     298        return ListHashSet<String>();
     299
     300    ListHashSet<String> result;
    301301    // FIXME: This loop could be split into two stages. One which adds all the HTML5 specified types
    302302    // and a second which adds all the extra types from the cocoa clipboard (which is Mac-only behavior).
  • trunk/Source/WebCore/platform/qt/ClipboardQt.cpp

    r129647 r130588  
    184184
    185185// extensions beyond IE's API
    186 HashSet<String> ClipboardQt::types() const
     186ListHashSet<String> ClipboardQt::types() const
    187187{
    188188    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    189         return HashSet<String>();
     189        return ListHashSet<String>();
    190190
    191191    ASSERT(m_readableData);
    192     HashSet<String> result;
     192    ListHashSet<String> result;
    193193    QStringList formats = m_readableData->formats();
    194194    for (int i = 0; i < formats.count(); ++i)
  • trunk/Source/WebCore/platform/qt/ClipboardQt.h

    r126390 r130588  
    5858
    5959    // extensions beyond IE's API
    60     virtual HashSet<String> types() const;
     60    virtual ListHashSet<String> types() const;
    6161    virtual PassRefPtr<FileList> files() const;
    6262
  • trunk/Source/WebCore/platform/win/ClipboardWin.cpp

    r129962 r130588  
    485485}
    486486
    487 static void addMimeTypesForFormat(HashSet<String>& results, const FORMATETC& format)
     487static void addMimeTypesForFormat(ListHashSet<String>& results, const FORMATETC& format)
    488488{
    489489    // URL and Text are provided for compatibility with IE's model
     
    500500
    501501// extensions beyond IE's API
    502 HashSet<String> ClipboardWin::types() const
     502ListHashSet<String> ClipboardWin::types() const
    503503{
    504     HashSet<String> results;
     504    ListHashSet<String> results;
    505505    if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
    506506        return results;
  • trunk/Source/WebCore/platform/win/ClipboardWin.h

    r126390 r130588  
    6565
    6666    // extensions beyond IE's API
    67     virtual HashSet<String> types() const;
     67    virtual ListHashSet<String> types() const;
    6868    virtual PassRefPtr<FileList> files() const;
    6969
  • trunk/Source/WebCore/platform/wx/ClipboardWx.cpp

    r127757 r130588  
    7272
    7373// extensions beyond IE's API
    74 HashSet<String> ClipboardWx::types() const
     74ListHashSet<String> ClipboardWx::types() const
    7575{
    7676    notImplemented();
    77     HashSet<String> result;
     77    ListHashSet<String> result;
    7878    return result;
    7979}
  • trunk/Source/WebCore/platform/wx/ClipboardWx.h

    r126390 r130588  
    4747   
    4848        // extensions beyond IE's API
    49         virtual HashSet<String> types() const;
     49        virtual ListHashSet<String> types() const;
    5050        virtual PassRefPtr<FileList> files() const;
    5151   
Note: See TracChangeset for help on using the changeset viewer.