[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

eric at webkit.org eric at webkit.org
Thu Oct 29 20:52:14 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 7891f87cb51770bcb31c52b780a72bacc11a7389
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 26 17:35:16 2009 +0000

    2009-10-26  Anton Muhin  <antonm at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            Unbreak Chromium build: that requires adding custom implementations
            for HTMLOptionsCollection's item and namedItem.  Keep v8 binding
            close to JSC bindings as well.
            https://bugs.webkit.org/show_bug.cgi?id=30780
    
            * bindings/v8/V8Collection.h:
            (WebCore::getNamedItemsFromCollection):
            (WebCore::getItemFromCollection):
            * bindings/v8/custom/V8CustomBinding.h:
            * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp:
            (WebCore::NAMED_PROPERTY_GETTER):
            (WebCore::CALLBACK_FUNC_DECL):
            * bindings/v8/custom/V8HTMLCollectionCustom.cpp:
            (WebCore::NAMED_PROPERTY_GETTER):
            (WebCore::CALLBACK_FUNC_DECL):
            * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
            (WebCore::CALLBACK_FUNC_DECL):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50073 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 44452c0..0f31297 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2009-10-26  Anton Muhin  <antonm at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Unbreak Chromium build: that requires adding custom implementations
+        for HTMLOptionsCollection's item and namedItem.  Keep v8 binding
+        close to JSC bindings as well.
+        https://bugs.webkit.org/show_bug.cgi?id=30780
+
+        * bindings/v8/V8Collection.h:
+        (WebCore::getNamedItemsFromCollection):
+        (WebCore::getItemFromCollection):
+        * bindings/v8/custom/V8CustomBinding.h:
+        * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp:
+        (WebCore::NAMED_PROPERTY_GETTER):
+        (WebCore::CALLBACK_FUNC_DECL):
+        * bindings/v8/custom/V8HTMLCollectionCustom.cpp:
+        (WebCore::NAMED_PROPERTY_GETTER):
+        (WebCore::CALLBACK_FUNC_DECL):
+        * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+
 2009-10-23  Alexey Proskuryakov  <ap at apple.com>
 
         Reviewed by Adam Barth and Darin Adler.
diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h
index cbfe921..8eae2a2 100644
--- a/WebCore/bindings/v8/V8Collection.h
+++ b/WebCore/bindings/v8/V8Collection.h
@@ -34,6 +34,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLSelectElement.h"
 #include "V8Binding.h"
+#include "V8NamedNodesCollection.h"
 #include "V8Proxy.h"
 #include <v8.h>
 
@@ -210,6 +211,38 @@ namespace WebCore {
 
     v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*);
 
+    template<class Collection>
+    v8::Handle<v8::Value> getNamedItemsFromCollection(Collection* collection, AtomicString name)
+    {
+        Vector<RefPtr<Node> > namedItems;
+        collection->namedItems(name, namedItems);
+
+        if (!namedItems.size())
+            return v8::Handle<v8::Value>();
+
+        if (namedItems.size() == 1)
+            return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
+
+        NodeList* list = new V8NamedNodesCollection(namedItems);
+        return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
+    }
+
+    template<class Collection>
+    v8::Handle<v8::Value> getItemFromCollection(Collection* collection, v8::Handle<v8::Value> argument)
+    {
+        v8::Local<v8::Uint32> index = argument->ToArrayIndex();
+        if (index.IsEmpty()) {
+            v8::Handle<v8::Value> result = getNamedItemsFromCollection(collection, toWebCoreString(argument->ToString()));
+
+            if (result.IsEmpty())
+                return v8::Undefined();
+
+            return result;
+        }
+
+        RefPtr<Node> result = collection->item(index->Uint32Value());
+        return V8DOMWrapper::convertNodeToV8Object(result.release());
+    }
 } // namespace WebCore
 
 #endif // V8Collection_h
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index d9f9344..1971c96 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -280,6 +280,8 @@ namespace WebCore {
 
         DECLARE_PROPERTY_ACCESSOR_SETTER(AttrValue);
 
+        DECLARE_CALLBACK(HTMLOptionsCollectionItem);
+        DECLARE_CALLBACK(HTMLOptionsCollectionNamedItem);
         DECLARE_PROPERTY_ACCESSOR(HTMLOptionsCollectionLength);
 
         DECLARE_CALLBACK(HTMLInputElementSetSelectionRange);
diff --git a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
index 419f374..fb387ea 100644
--- a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp
@@ -32,43 +32,12 @@
 #include "HTMLAllCollection.h"
 
 #include "V8Binding.h"
+#include "V8Collection.h"
 #include "V8CustomBinding.h"
-#include "V8NamedNodesCollection.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name)
-{
-    Vector<RefPtr<Node> > namedItems;
-    collection->namedItems(name, namedItems);
-
-    if (!namedItems.size())
-        return v8::Handle<v8::Value>();
-
-    if (namedItems.size() == 1)
-        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
-
-    NodeList* list = new V8NamedNodesCollection(namedItems);
-    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
-}
-
-static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument)
-{
-    v8::Local<v8::Uint32> index = argument->ToArrayIndex();
-    if (index.IsEmpty()) {
-        v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString()));
-
-        if (result.IsEmpty())
-            return v8::Undefined();
-
-        return result;
-    }
-
-    RefPtr<Node> result = collection->item(index->Uint32Value());
-    return V8DOMWrapper::convertNodeToV8Object(result.release());
-}
-
 NAMED_PROPERTY_GETTER(HTMLAllCollection)
 {
     INC_STATS("DOM.HTMLAllCollection.NamedPropertyGetter");
@@ -85,21 +54,21 @@ NAMED_PROPERTY_GETTER(HTMLAllCollection)
 
     // Finally, search the DOM structure.
     HTMLAllCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLAllCollection>(V8ClassIndex::HTMLALLCOLLECTION, info.Holder());
-    return getNamedItems(imp, v8StringToAtomicWebCoreString(name));
+    return getNamedItemsFromCollection(imp, v8StringToAtomicWebCoreString(name));
 }
 
 CALLBACK_FUNC_DECL(HTMLAllCollectionItem)
 {
     INC_STATS("DOM.HTMLAllCollection.item()");
     HTMLAllCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLAllCollection>(V8ClassIndex::HTMLALLCOLLECTION, args.Holder());
-    return getItem(imp, args[0]);
+    return getItemFromCollection(imp, args[0]);
 }
 
 CALLBACK_FUNC_DECL(HTMLAllCollectionNamedItem)
 {
     INC_STATS("DOM.HTMLAllCollection.namedItem()");
     HTMLAllCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLAllCollection>(V8ClassIndex::HTMLALLCOLLECTION, args.Holder());
-    v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0]));
+    v8::Handle<v8::Value> result = getNamedItemsFromCollection(imp, toWebCoreString(args[0]));
 
     if (result.IsEmpty())
         return v8::Undefined();
@@ -116,7 +85,7 @@ CALLBACK_FUNC_DECL(HTMLAllCollectionCallAsFunction)
     HTMLAllCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLAllCollection>(V8ClassIndex::HTMLALLCOLLECTION, args.Holder());
 
     if (args.Length() == 1)
-        return getItem(imp, args[0]);
+        return getItemFromCollection(imp, args[0]);
 
     // If there is a second argument it is the index of the item we want.
     String name = toWebCoreString(args[0]);
diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
index 7c9b40f..c45c41b 100644
--- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp
@@ -32,43 +32,12 @@
 #include "HTMLCollection.h"
 
 #include "V8Binding.h"
+#include "V8Collection.h"
 #include "V8CustomBinding.h"
-#include "V8NamedNodesCollection.h"
 #include "V8Proxy.h"
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicString name)
-{
-    Vector<RefPtr<Node> > namedItems;
-    collection->namedItems(name, namedItems);
-
-    if (!namedItems.size())
-        return v8::Handle<v8::Value>();
-
-    if (namedItems.size() == 1)
-        return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release());
-
-    NodeList* list = new V8NamedNodesCollection(namedItems);
-    return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list);
-}
-
-static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument)
-{
-    v8::Local<v8::Uint32> index = argument->ToArrayIndex();
-    if (index.IsEmpty()) {
-        v8::Handle<v8::Value> result = getNamedItems(collection, toWebCoreString(argument->ToString()));
-
-        if (result.IsEmpty())
-            return v8::Undefined();
-
-        return result;
-    }
-
-    RefPtr<Node> result = collection->item(index->Uint32Value());
-    return V8DOMWrapper::convertNodeToV8Object(result.release());
-}
-
 NAMED_PROPERTY_GETTER(HTMLCollection)
 {
     INC_STATS("DOM.HTMLCollection.NamedPropertyGetter");
@@ -85,21 +54,21 @@ NAMED_PROPERTY_GETTER(HTMLCollection)
 
     // Finally, search the DOM structure.
     HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, info.Holder());
-    return getNamedItems(imp, v8StringToAtomicWebCoreString(name));
+    return getNamedItemsFromCollection(imp, v8StringToAtomicWebCoreString(name));
 }
 
 CALLBACK_FUNC_DECL(HTMLCollectionItem)
 {
     INC_STATS("DOM.HTMLCollection.item()");
     HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder());
-    return getItem(imp, args[0]);
+    return getItemFromCollection(imp, args[0]);
 }
 
 CALLBACK_FUNC_DECL(HTMLCollectionNamedItem)
 {
     INC_STATS("DOM.HTMLCollection.namedItem()");
     HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder());
-    v8::Handle<v8::Value> result = getNamedItems(imp, toWebCoreString(args[0]));
+    v8::Handle<v8::Value> result = getNamedItemsFromCollection(imp, toWebCoreString(args[0]));
 
     if (result.IsEmpty())
         return v8::Undefined();
@@ -116,7 +85,7 @@ CALLBACK_FUNC_DECL(HTMLCollectionCallAsFunction)
     HTMLCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLCollection>(V8ClassIndex::HTMLCOLLECTION, args.Holder());
 
     if (args.Length() == 1)
-        return getItem(imp, args[0]);
+        return getItemFromCollection(imp, args[0]);
 
     // If there is a second argument it is the index of the item we want.
     String name = toWebCoreString(args[0]);
diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
index 02c3499..15015b4 100644
--- a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp
@@ -133,4 +133,23 @@ INDEXED_PROPERTY_SETTER(HTMLOptionsCollection)
     return toOptionsCollectionSetter(index, value, base);
 }
 
+CALLBACK_FUNC_DECL(HTMLOptionsCollectionItem)
+{
+    INC_STATS("DOM.HTMLOptionsCollection.item()");
+    HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder());
+    return getItemFromCollection(imp, args[0]);
+}
+
+CALLBACK_FUNC_DECL(HTMLOptionsCollectionNamedItem)
+{
+    INC_STATS("DOM.HTMLOptionsCollection.namedItem()");
+    HTMLOptionsCollection* imp = V8DOMWrapper::convertToNativeObject<HTMLOptionsCollection>(V8ClassIndex::HTMLOPTIONSCOLLECTION, args.Holder());
+    v8::Handle<v8::Value> result = getNamedItemsFromCollection(imp, toWebCoreString(args[0]));
+
+    if (result.IsEmpty())
+        return v8::Undefined();
+
+    return result;
+}
+
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list