[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:26:00 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 12d0e9dc006fb3003987bf5e848f7546d70cd9e8
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 9 01:28:20 2009 +0000

    2009-11-08  Kent Tamura  <tkent at chromium.org>
    
            Reviewed by Darin Adler.
    
            Simplify Icon interface.
            https://bugs.webkit.org/show_bug.cgi?id=31154
    
            - Remove Icon::createIconForFile().  createIconForFiles() covers
              createIconForFile()'s role.
            - Remove FileChooser::chooseIcon()
            - Change the parameter types of FileChooser constructor and the
              factory method, String -> const Vector<String>&, in order to
              support initialization with multiple files.
            - Remove the icon loading code in IconChromiumWin.cpp, which
              doesn't work because of the sandbox.
    
            No tests because it's just a refactoring.
    
            * platform/FileChooser.cpp:
            (WebCore::FileChooser::FileChooser):
            (WebCore::FileChooser::create):
            (WebCore::FileChooser::chooseFile):
            (WebCore::FileChooser::chooseFiles):
            * platform/FileChooser.h:
            * platform/graphics/Icon.h:
            * platform/graphics/chromium/IconChromiumLinux.cpp:
            * platform/graphics/chromium/IconChromiumMac.cpp:
            * platform/graphics/chromium/IconChromiumWin.cpp:
            (WebCore::Icon::createIconForFiles):
            * platform/graphics/gtk/IconGtk.cpp:
            (WebCore::Icon::createIconForFiles):
            * platform/graphics/haiku/IconHaiku.cpp:
            * platform/graphics/mac/IconMac.mm:
            (WebCore::Icon::createIconForFiles):
            * platform/graphics/qt/IconQt.cpp:
            (WebCore::Icon::createIconForFiles):
            * platform/graphics/win/IconWin.cpp:
            (WebCore::Icon::createIconForFiles):
            * platform/graphics/wx/IconWx.cpp:
            * rendering/RenderFileUploadControl.cpp:
            (WebCore::RenderFileUploadControl::RenderFileUploadControl):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50632 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5da8631..622126e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2009-11-08  Kent Tamura  <tkent at chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Simplify Icon interface.
+        https://bugs.webkit.org/show_bug.cgi?id=31154
+
+        - Remove Icon::createIconForFile().  createIconForFiles() covers
+          createIconForFile()'s role.
+        - Remove FileChooser::chooseIcon()
+        - Change the parameter types of FileChooser constructor and the
+          factory method, String -> const Vector<String>&, in order to
+          support initialization with multiple files.
+        - Remove the icon loading code in IconChromiumWin.cpp, which
+          doesn't work because of the sandbox.
+
+        No tests because it's just a refactoring.
+
+        * platform/FileChooser.cpp:
+        (WebCore::FileChooser::FileChooser):
+        (WebCore::FileChooser::create):
+        (WebCore::FileChooser::chooseFile):
+        (WebCore::FileChooser::chooseFiles):
+        * platform/FileChooser.h:
+        * platform/graphics/Icon.h:
+        * platform/graphics/chromium/IconChromiumLinux.cpp:
+        * platform/graphics/chromium/IconChromiumMac.cpp:
+        * platform/graphics/chromium/IconChromiumWin.cpp:
+        (WebCore::Icon::createIconForFiles):
+        * platform/graphics/gtk/IconGtk.cpp:
+        (WebCore::Icon::createIconForFiles):
+        * platform/graphics/haiku/IconHaiku.cpp:
+        * platform/graphics/mac/IconMac.mm:
+        (WebCore::Icon::createIconForFiles):
+        * platform/graphics/qt/IconQt.cpp:
+        (WebCore::Icon::createIconForFiles):
+        * platform/graphics/win/IconWin.cpp:
+        (WebCore::Icon::createIconForFiles):
+        * platform/graphics/wx/IconWx.cpp:
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::RenderFileUploadControl):
+
 2009-11-08  Daniel Bates  <dbates at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/platform/FileChooser.cpp b/WebCore/platform/FileChooser.cpp
index 739181d..9fad392 100644
--- a/WebCore/platform/FileChooser.cpp
+++ b/WebCore/platform/FileChooser.cpp
@@ -37,16 +37,16 @@ FileChooserClient::~FileChooserClient()
 {
 }
 
-inline FileChooser::FileChooser(FileChooserClient* client, const String& filename)
+inline FileChooser::FileChooser(FileChooserClient* client, const Vector<String>& initialFilenames)
     : m_client(client)
-    , m_icon(chooseIcon(filename))
+    , m_icon(Icon::createIconForFiles(initialFilenames))
 {
-    m_filenames.append(filename);
+    m_filenames = initialFilenames;
 }
 
-PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const String& filename)
+PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const Vector<String>& initialFilenames)
 {
-    return adoptRef(new FileChooser(client, filename));
+    return adoptRef(new FileChooser(client, initialFilenames));
 }
 
 FileChooser::~FileChooser()
@@ -61,13 +61,9 @@ void FileChooser::clear()
 
 void FileChooser::chooseFile(const String& filename)
 {
-    if (m_filenames.size() == 1 && m_filenames[0] == filename)
-        return;
-    m_filenames.clear();
-    m_filenames.append(filename);
-    m_icon = chooseIcon(filename);
-    if (m_client)
-        m_client->valueChanged();
+    Vector<String> filenames;
+    filenames.append(filename);
+    chooseFiles(filenames);
 }
 
 void FileChooser::chooseFiles(const Vector<String>& filenames)
@@ -75,23 +71,9 @@ void FileChooser::chooseFiles(const Vector<String>& filenames)
     if (m_filenames == filenames)
         return;
     m_filenames = filenames;
-    m_icon = chooseIcon(filenames);
+    m_icon = Icon::createIconForFiles(filenames);
     if (m_client)
         m_client->valueChanged();
 }
 
-PassRefPtr<Icon> FileChooser::chooseIcon(const String& filename)
-{
-    return Icon::createIconForFile(filename);
-}
-
-PassRefPtr<Icon> FileChooser::chooseIcon(Vector<String> filenames)
-{
-    if (filenames.isEmpty())
-        return 0;
-    if (filenames.size() == 1)
-        return Icon::createIconForFile(filenames[0]);
-    return Icon::createIconForFiles(filenames);
-}
-
 }
diff --git a/WebCore/platform/FileChooser.h b/WebCore/platform/FileChooser.h
index 8192fe8..1d4e970 100644
--- a/WebCore/platform/FileChooser.h
+++ b/WebCore/platform/FileChooser.h
@@ -47,7 +47,7 @@ public:
 
 class FileChooser : public RefCounted<FileChooser> {
 public:
-    static PassRefPtr<FileChooser> create(FileChooserClient*, const String& initialFilename);
+    static PassRefPtr<FileChooser> create(FileChooserClient*, const Vector<String>& initialFilenames);
     ~FileChooser();
 
     void disconnectClient() { m_client = 0; }
@@ -66,9 +66,7 @@ public:
     bool allowsMultipleFiles() const { return m_client ? m_client->allowsMultipleFiles() : false; }
 
 private:
-    FileChooser(FileChooserClient*, const String& initialfilename);
-    static PassRefPtr<Icon> chooseIcon(const String& filename);
-    static PassRefPtr<Icon> chooseIcon(Vector<String> filenames);
+    FileChooser(FileChooserClient*, const Vector<String>& initialFilenames);
 
     FileChooserClient* m_client;
     Vector<String> m_filenames;
diff --git a/WebCore/platform/graphics/Icon.h b/WebCore/platform/graphics/Icon.h
index 444c67c..d7d694a 100644
--- a/WebCore/platform/graphics/Icon.h
+++ b/WebCore/platform/graphics/Icon.h
@@ -51,7 +51,6 @@ class String;
     
 class Icon : public RefCounted<Icon> {
 public:
-    static PassRefPtr<Icon> createIconForFile(const String& filename);
     static PassRefPtr<Icon> createIconForFiles(const Vector<String>& filenames);
 
     ~Icon();
diff --git a/WebCore/platform/graphics/chromium/IconChromiumLinux.cpp b/WebCore/platform/graphics/chromium/IconChromiumLinux.cpp
index a5a6e1f..1386163 100644
--- a/WebCore/platform/graphics/chromium/IconChromiumLinux.cpp
+++ b/WebCore/platform/graphics/chromium/IconChromiumLinux.cpp
@@ -46,12 +46,6 @@ Icon::~Icon()
 {
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String&)
-{
-    notImplemented();
-    return 0;
-}
-
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
 {
     notImplemented();
diff --git a/WebCore/platform/graphics/chromium/IconChromiumMac.cpp b/WebCore/platform/graphics/chromium/IconChromiumMac.cpp
index 93e36ba..23ca698 100644
--- a/WebCore/platform/graphics/chromium/IconChromiumMac.cpp
+++ b/WebCore/platform/graphics/chromium/IconChromiumMac.cpp
@@ -39,11 +39,6 @@
  
 namespace WebCore {
 
-PassRefPtr<Icon> Icon::createIconForFile(const String&)
-{
-    return 0;
-}
-
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
 {
     return 0;
diff --git a/WebCore/platform/graphics/chromium/IconChromiumWin.cpp b/WebCore/platform/graphics/chromium/IconChromiumWin.cpp
index b419e6f..b0145f8 100644
--- a/WebCore/platform/graphics/chromium/IconChromiumWin.cpp
+++ b/WebCore/platform/graphics/chromium/IconChromiumWin.cpp
@@ -52,26 +52,11 @@ Icon::~Icon()
         DestroyIcon(m_icon);
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
-    SHFILEINFO sfi;
-    memset(&sfi, 0, sizeof(sfi));
-
-    String tmpFilename = filename;
-    if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
-        return 0;
-
-    return adoptRef(new Icon(sfi.hIcon));
-}
-
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
-    // FIXME: support multiple files.
+    // FIXME: We can't access icons directly from renderer processes.
     // http://code.google.com/p/chromium/issues/detail?id=4092
-    if (!filenames.size())
-        return 0;
-
-    return createIconForFile(filenames[0]);
+    return 0;
 }
 
 void Icon::paint(GraphicsContext* context, const IntRect& rect)
diff --git a/WebCore/platform/graphics/gtk/IconGtk.cpp b/WebCore/platform/graphics/gtk/IconGtk.cpp
index e08c1ab..3563a59 100644
--- a/WebCore/platform/graphics/gtk/IconGtk.cpp
+++ b/WebCore/platform/graphics/gtk/IconGtk.cpp
@@ -87,23 +87,25 @@ static String lookupIconName(String MIMEType)
     return GTK_STOCK_FILE;
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
+PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
-    if (!g_path_skip_root(filename.utf8().data()))
+    if (filenames.isEmpty())
         return 0;
 
-    String MIMEType = MIMETypeRegistry::getMIMETypeForPath(filename);
-    String iconName = lookupIconName(MIMEType);
+    if (filenames.size() == 1) {
+        if (!g_path_skip_root(filenames[0].utf8().data()))
+            return 0;
 
-    RefPtr<Icon> icon = adoptRef(new Icon);
-    icon->m_icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), iconName.utf8().data(), 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
-    if (!icon->m_icon)
-        return 0;
-    return icon.release();
-}
+        String MIMEType = MIMETypeRegistry::getMIMETypeForPath(filenames[0]);
+        String iconName = lookupIconName(MIMEType);
+
+        RefPtr<Icon> icon = adoptRef(new Icon);
+        icon->m_icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), iconName.utf8().data(), 16, GTK_ICON_LOOKUP_USE_BUILTIN, 0);
+        if (!icon->m_icon)
+            return 0;
+        return icon.release();
+    }
 
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
     //FIXME: Implement this
     return 0;
 }
diff --git a/WebCore/platform/graphics/haiku/IconHaiku.cpp b/WebCore/platform/graphics/haiku/IconHaiku.cpp
index dccac4a..3663ee2 100644
--- a/WebCore/platform/graphics/haiku/IconHaiku.cpp
+++ b/WebCore/platform/graphics/haiku/IconHaiku.cpp
@@ -36,12 +36,6 @@ Icon::~Icon()
     notImplemented();
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
-    notImplemented();
-    return 0;
-}
-
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
     notImplemented();
diff --git a/WebCore/platform/graphics/mac/IconMac.mm b/WebCore/platform/graphics/mac/IconMac.mm
index 63abe59..aee7234 100644
--- a/WebCore/platform/graphics/mac/IconMac.mm
+++ b/WebCore/platform/graphics/mac/IconMac.mm
@@ -39,27 +39,32 @@ Icon::~Icon()
 {
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
+PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
-    // Don't pass relative filenames -- we don't want a result that depends on the current directory.
-    // Need 0U here to disambiguate String::operator[] from operator(NSString*, int)[]
-    if (filename.isEmpty() || filename[0U] != '/')
+    if (filenames.isEmpty())
         return 0;
 
-    NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile:filename];
-    if (!image)
-        return 0;
+    bool useIconFromFirstFile;
+#ifdef BUILDING_ON_TIGER
+    // FIXME: find a better image for multiple files to use on Tiger.
+    useIconFromFirstFile = true;
+#else
+    useIconFromFirstFile = filenames.size() == 1;
+#endif
+    if (useIconFromFirstFile) {
+        // Don't pass relative filenames -- we don't want a result that depends on the current directory.
+        // Need 0U here to disambiguate String::operator[] from operator(NSString*, int)[]
+        if (filenames[0].isEmpty() || filenames[0][0U] != '/')
+            return 0;
 
-    return adoptRef(new Icon(image));
-}
+        NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile:filenames[0]];
+        if (!image)
+            return 0;
 
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
-    if (filenames.isEmpty())
-        return 0;
+        return adoptRef(new Icon(image));
+    }
 #ifdef BUILDING_ON_TIGER
-    // FIXME: find a better image to use on Tiger.
-    return createIconForFile(filenames[0]);
+    return 0;
 #else
     NSImage* image = [NSImage imageNamed:NSImageNameMultipleDocuments];
     if (!image)
diff --git a/WebCore/platform/graphics/qt/IconQt.cpp b/WebCore/platform/graphics/qt/IconQt.cpp
index 98f4606..a9870fc 100644
--- a/WebCore/platform/graphics/qt/IconQt.cpp
+++ b/WebCore/platform/graphics/qt/IconQt.cpp
@@ -40,15 +40,17 @@ Icon::~Icon()
 {
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
+PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
-    RefPtr<Icon> i = adoptRef(new Icon);
-    i->m_icon = QIcon(filename);
-    return i.release();
-}
+    if (filenames.isEmpty())
+        return 0;
+
+    if (filenames.size() == 1) {
+        RefPtr<Icon> i = adoptRef(new Icon);
+        i->m_icon = QIcon(filenames[0]);
+        return i.release();
+    }
 
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
-{
     //FIXME: Implement this
     return 0;
 }
diff --git a/WebCore/platform/graphics/win/IconWin.cpp b/WebCore/platform/graphics/win/IconWin.cpp
index 61f1fd3..d71ca00 100644
--- a/WebCore/platform/graphics/win/IconWin.cpp
+++ b/WebCore/platform/graphics/win/IconWin.cpp
@@ -47,20 +47,22 @@ Icon::~Icon()
     DestroyIcon(m_hIcon);
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
+PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
-    SHFILEINFO sfi;
-    memset(&sfi, 0, sizeof(sfi));
-
-    String tmpFilename = filename;
-    if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
+    if (filenames.isEmpty())
         return 0;
 
-    return adoptRef(new Icon(sfi.hIcon));
-}
+    if (filenames.size() == 1) {
+        SHFILEINFO sfi;
+        memset(&sfi, 0, sizeof(sfi));
+
+        String tmpFilename = filenames[0];
+        if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
+            return 0;
+
+        return adoptRef(new Icon(sfi.hIcon));
+    }
 
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
-{
 #if PLATFORM(WINCE)
     return 0;
 #else
diff --git a/WebCore/platform/graphics/wx/IconWx.cpp b/WebCore/platform/graphics/wx/IconWx.cpp
index e82091e..d3cc961 100644
--- a/WebCore/platform/graphics/wx/IconWx.cpp
+++ b/WebCore/platform/graphics/wx/IconWx.cpp
@@ -32,12 +32,6 @@ Icon::~Icon()
 {
 }
 
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
-    notImplemented();
-    return 0;
-}
-
 PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
 {
     notImplemented();
diff --git a/WebCore/rendering/RenderFileUploadControl.cpp b/WebCore/rendering/RenderFileUploadControl.cpp
index 72623f7..262be31 100644
--- a/WebCore/rendering/RenderFileUploadControl.cpp
+++ b/WebCore/rendering/RenderFileUploadControl.cpp
@@ -63,8 +63,11 @@ private:
 RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input)
     : RenderBlock(input)
     , m_button(0)
-    , m_fileChooser(FileChooser::create(this, input->value()))
 {
+    Vector<String> filenames;
+    // FIXME: The following code passes only the first file even if the input has multiple files.
+    filenames.append(input->value());
+    m_fileChooser = FileChooser::create(this, filenames);
 }
 
 RenderFileUploadControl::~RenderFileUploadControl()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list