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

dglazkov at chromium.org dglazkov at chromium.org
Thu Apr 8 00:52:21 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 2073f30ba2812b6822bd911ea2eb50aa4a9d5262
Author: dglazkov at chromium.org <dglazkov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 30 16:49:43 2009 +0000

    2009-12-30  Dimitri Glazkov  <dglazkov at chromium.org>
    
            Reviewed by Adam Barth.
    
            [V8] Generate configuring of all indexers.
            https://bugs.webkit.org/show_bug.cgi?id=33031
    
            Refactorig, covered by existing tests.
    
            * bindings/scripts/CodeGeneratorV8.pm: Added generation of indexers for
                special cases.
            * bindings/v8/V8DOMWrapper.cpp:
            (WebCore::V8DOMWrapper::getTemplate): Removed custom tempalte configuration of
                indexers.
            * bindings/v8/custom/V8CustomBinding.h: Added decls for Applet, Embed, and Object
                elements (these will be generated, too -- later.)
            * bindings/v8/custom/V8HTMLPlugInElementCustom.cpp:
            (WebCore::npObjectIndexedGetter): Moved common code to a separate method.
            (WebCore::npObjectIndexedSetter): Ditto.
            (WebCore::INDEXED_PROPERTY_GETTER): Added custom handlers for Applet, Embed, and Object
              all calling the common method.
            (WebCore::INDEXED_PROPERTY_SETTER): Ditto.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52663 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9b187d3..eab23ab 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -19,6 +19,29 @@
 
         Reviewed by Adam Barth.
 
+        [V8] Generate configuring of all indexers.
+        https://bugs.webkit.org/show_bug.cgi?id=33031
+
+        Refactorig, covered by existing tests.
+
+        * bindings/scripts/CodeGeneratorV8.pm: Added generation of indexers for
+            special cases.
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::getTemplate): Removed custom tempalte configuration of
+            indexers.
+        * bindings/v8/custom/V8CustomBinding.h: Added decls for Applet, Embed, and Object
+            elements (these will be generated, too -- later.)
+        * bindings/v8/custom/V8HTMLPlugInElementCustom.cpp:
+        (WebCore::npObjectIndexedGetter): Moved common code to a separate method.
+        (WebCore::npObjectIndexedSetter): Ditto.
+        (WebCore::INDEXED_PROPERTY_GETTER): Added custom handlers for Applet, Embed, and Object
+          all calling the common method.
+        (WebCore::INDEXED_PROPERTY_SETTER): Ditto.
+
+2009-12-30  Dimitri Glazkov  <dglazkov at chromium.org>
+
+        Reviewed by Adam Barth.
+
         [V8] Generate configuring of all named property getters/setters/enumerators.
         https://bugs.webkit.org/show_bug.cgi?id=32996
 
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 0d44500..b5ade94 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1140,35 +1140,91 @@ sub GenerateSingleBatchedAttribute
 END
 }
 
+my %indexerSpecialCases = (
+    "Storage" => 1,
+    "HTMLAppletElement" => 1,
+    "HTMLEmbedElement" => 1,
+    "HTMLObjectElement" => 1
+);
+
 sub GenerateImplementationIndexer
 {
     my $dataNode = shift;
     my $indexer = shift;
     my $interfaceName = $dataNode->name;
 
-    if ($dataNode->extendedAttributes->{"HasIndexGetter"}) {
-        $implIncludes{"V8Collection.h"} = 1;
-        if (!$dataNode->extendedAttributes->{"HasCustomIndexGetter"}) {
-            if ($indexer->type eq "DOMString") {
-                my $conversion = $indexer->extendedAttributes->{"ConvertNullStringTo"};
-                if ($conversion && $conversion eq "Null") {
-                    push(@implContent, <<END);
+    # FIXME: Figure out what HasNumericIndexGetter is really supposed to do. Right now, it's only set on WebGL-related files.
+    my $hasCustomSetter = $dataNode->extendedAttributes->{"HasCustomIndexSetter"} && !$dataNode->extendedAttributes->{"HasNumericIndexGetter"};
+    my $hasGetter = $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"CustomGetOwnPropertySlot"};
+
+    # FIXME: Find a way to not have to special-case HTMLOptionsCollection.
+    if ($interfaceName eq "HTMLOptionsCollection") {
+        $hasGetter = 1;
+    }
+
+    # FIXME: Investigate and remove this nastinesss. In V8, named property handling and indexer handling are apparently decoupled,
+    # which means that object[X] where X is a number doesn't reach named property indexer. So we need to provide
+    # simplistic, mirrored indexer handling in addition to named property handling.
+    my $isSpecialCase = exists $indexerSpecialCases{$interfaceName};
+    if ($isSpecialCase) {
+        $hasGetter = 1;
+        $hasCustomSetter = 1;
+    }
+
+    if (!$hasGetter) {
+        return;
+    }
+
+    $implIncludes{"V8Collection.h"} = 1;
+
+    my $indexerType = $indexer ? $indexer->type : 0;
+
+    # FIXME: Remove this once toV8 helper methods are implemented (see https://bugs.webkit.org/show_bug.cgi?id=32563).
+    if ($interfaceName eq "WebKitCSSKeyframesRule") {
+        $indexerType = "WebKitCSSKeyframeRule";
+    }
+
+    if ($indexerType && !$hasCustomSetter) {
+        if ($indexerType eq "DOMString") {
+            my $conversion = $indexer->extendedAttributes->{"ConvertNullStringTo"};
+            if ($conversion && $conversion eq "Null") {
+                push(@implContent, <<END);
   setCollectionStringOrNullIndexedGetter<${interfaceName}>(desc);
 END
-                } else {
-                    push(@implContent, <<END);
-  setCollectionStringIndexedGetter<${interfaceName}>(desc);
-END
-                }
             } else {
-                my $indexerType = $indexer->type;
-                my $indexerClassIndex = uc($indexerType);
                 push(@implContent, <<END);
-  setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc, V8ClassIndex::${indexerClassIndex});
+  setCollectionStringIndexedGetter<${interfaceName}>(desc);
 END
             }
+        } else {
+            my $indexerClassIndex = uc($indexerType);
+            push(@implContent, <<END);
+  setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc, V8ClassIndex::${indexerClassIndex});
+END
         }
+
+        return;
+    }
+
+    my $hasDeleter = $dataNode->extendedAttributes->{"CustomDeleteProperty"};
+    my $hasEnumerator = !$isSpecialCase && IsNodeSubType($dataNode);
+    my $setOn = "Instance";
+
+    # V8 has access-check callback API (see ObjectTemplate::SetAccessCheckCallbacks) and it's used on DOMWindow
+    # instead of deleters or enumerators. In addition, the getter should be set on prototype template, to
+    # get implementation straight out of the DOMWindow prototype regardless of what prototype is actually set
+    # on the object.
+    if ($interfaceName eq "DOMWindow") {
+        $setOn = "Prototype";
+        $hasDeleter = 0;
     }
+
+    push(@implContent, "  desc->${setOn}Template()->SetIndexedPropertyHandler(V8Custom::v8${interfaceName}IndexedPropertyGetter");
+    push(@implContent, $hasCustomSetter ? ", V8Custom::v8${interfaceName}IndexedPropertySetter" : ", 0");
+    push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the moment.
+    push(@implContent, $hasDeleter ? ", V8Custom::v8${interfaceName}IndexedPropertyDeleter" : ", 0");
+    push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>, v8::Integer::New(V8ClassIndex::NODE)") if $hasEnumerator;
+    push(@implContent, ");\n");
 }
 
 sub GenerateImplementationNamedPropertyGetter
@@ -1516,7 +1572,7 @@ END
         push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
     }
 
-    GenerateImplementationIndexer($dataNode, $indexer) if $indexer;
+    GenerateImplementationIndexer($dataNode, $indexer);
     GenerateImplementationNamedPropertyGetter($dataNode, $namedPropertyGetter);
 
     # Define our functions with Set() or SetAccessor()
diff --git a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
index 8d7bf24..bd2bb7b 100644
--- a/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
+++ b/WebCore/bindings/v8/DerivedSourcesAllInOne.cpp
@@ -421,4 +421,3 @@
 #include "bindings/V8InspectorBackend.cpp"
 #include "bindings/V8InspectorFrontendHost.cpp"
 #endif
-
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index ba2d86f..fa08743 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -280,12 +280,8 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
         descriptor->InstanceTemplate()->SetCallAsFunctionHandler(V8HTMLCollection::callAsFunctionCallback);
         break;
     case V8ClassIndex::HTMLOPTIONSCOLLECTION:
-        descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(HTMLOptionsCollection), USE_INDEXED_PROPERTY_SETTER(HTMLOptionsCollection));
         descriptor->InstanceTemplate()->SetCallAsFunctionHandler(V8HTMLCollection::callAsFunctionCallback);
         break;
-    case V8ClassIndex::HTMLSELECTELEMENT:
-        descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(HTMLSelectElement), USE_INDEXED_PROPERTY_SETTER(HTMLSelectElement), 0, 0, nodeCollectionIndexedPropertyEnumerator<HTMLSelectElement>, v8::Integer::New(V8ClassIndex::NODE));
-        break;
     case V8ClassIndex::HTMLDOCUMENT: {
         // We add an extra internal field to all Document wrappers for
         // storing a per document DOMImplementation wrapper.
@@ -318,12 +314,8 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
         // HTMLAppletElement, HTMLEmbedElement and HTMLObjectElement are
         // inherited from HTMLPlugInElement, and they share the same property
         // handling code.
-        descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(HTMLPlugInElement), USE_INDEXED_PROPERTY_SETTER(HTMLPlugInElement));
         descriptor->InstanceTemplate()->SetCallAsFunctionHandler(V8HTMLPlugInElement::defaultCallback);
         break;
-    case V8ClassIndex::HTMLFORMELEMENT:
-        descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(HTMLFormElement), 0, 0, 0, nodeCollectionIndexedPropertyEnumerator<HTMLFormElement>, v8::Integer::New(V8ClassIndex::NODE));
-        break;
     case V8ClassIndex::STYLESHEET:  // fall through
     case V8ClassIndex::CSSSTYLESHEET: {
         // We add an extra internal field to hold a reference to
@@ -338,23 +330,13 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
         v8::Local<v8::ObjectTemplate> instanceTemplate = descriptor->InstanceTemplate();
         ASSERT(instanceTemplate->InternalFieldCount() == V8Custom::kDefaultWrapperInternalFieldCount);
         instanceTemplate->SetInternalFieldCount(V8Custom::kNamedNodeMapInternalFieldCount);
-        instanceTemplate->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(NamedNodeMap), 0, 0, 0, collectionIndexedPropertyEnumerator<NamedNodeMap>, v8::Integer::New(V8ClassIndex::NODE));
         break;
     }
     case V8ClassIndex::NODELIST:
         descriptor->InstanceTemplate()->SetCallAsFunctionHandler(V8NodeList::callAsFunctionCallback);
         break;
-#if ENABLE(DOM_STORAGE)
-    case V8ClassIndex::STORAGE:
-        descriptor->InstanceTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(Storage), USE_INDEXED_PROPERTY_SETTER(Storage), 0, USE_INDEXED_PROPERTY_DELETER(Storage));
-        break;
-#endif
     case V8ClassIndex::DOMWINDOW: {
-        v8::Local<v8::Signature> defaultSignature = v8::Signature::New(descriptor);
-
-        descriptor->PrototypeTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(DOMWindow));
         descriptor->PrototypeTemplate()->SetInternalFieldCount(V8Custom::kDOMWindowInternalFieldCount);
-
         descriptor->SetHiddenPrototype(true);
 
         // Reserve spaces for references to location, history and
diff --git a/WebCore/bindings/v8/custom/V8CustomBinding.h b/WebCore/bindings/v8/custom/V8CustomBinding.h
index ad3a0ae..d506074 100644
--- a/WebCore/bindings/v8/custom/V8CustomBinding.h
+++ b/WebCore/bindings/v8/custom/V8CustomBinding.h
@@ -367,8 +367,12 @@ namespace WebCore {
         DECLARE_NAMED_PROPERTY_SETTER(HTMLEmbedElement);
         DECLARE_NAMED_PROPERTY_GETTER(HTMLObjectElement);
         DECLARE_NAMED_PROPERTY_SETTER(HTMLObjectElement);
-        DECLARE_INDEXED_PROPERTY_GETTER(HTMLPlugInElement);
-        DECLARE_INDEXED_PROPERTY_SETTER(HTMLPlugInElement);
+        DECLARE_INDEXED_PROPERTY_GETTER(HTMLAppletElement);
+        DECLARE_INDEXED_PROPERTY_SETTER(HTMLAppletElement);
+        DECLARE_INDEXED_PROPERTY_GETTER(HTMLEmbedElement);
+        DECLARE_INDEXED_PROPERTY_SETTER(HTMLEmbedElement);
+        DECLARE_INDEXED_PROPERTY_GETTER(HTMLObjectElement);
+        DECLARE_INDEXED_PROPERTY_SETTER(HTMLObjectElement);
 
         DECLARE_NAMED_PROPERTY_GETTER(StyleSheetList);
         DECLARE_INDEXED_PROPERTY_GETTER(NamedNodeMap);
diff --git a/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
index 6acd689..e173ab9 100644
--- a/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp
@@ -114,7 +114,7 @@ v8::Handle<v8::Value> V8HTMLPlugInElement::defaultCallback(const v8::Arguments&
     return npObjectInvokeDefaultHandler(args);
 }
 
-INDEXED_PROPERTY_GETTER(HTMLPlugInElement)
+v8::Handle<v8::Value> npObjectIndexedGetter(uint32_t index, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.HTMLPlugInElement.IndexedPropertyGetter");
     HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder());
@@ -129,7 +129,7 @@ INDEXED_PROPERTY_GETTER(HTMLPlugInElement)
     return npObjectGetIndexedProperty(instance, index);
 }
 
-INDEXED_PROPERTY_SETTER(HTMLPlugInElement)
+v8::Handle<v8::Value> npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.HTMLPlugInElement.IndexedPropertySetter");
     HTMLPlugInElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLPlugInElement>(info.Holder());
@@ -144,4 +144,40 @@ INDEXED_PROPERTY_SETTER(HTMLPlugInElement)
     return npObjectSetIndexedProperty(instance, index, value);
 }
 
+INDEXED_PROPERTY_GETTER(HTMLAppletElement)
+{
+    INC_STATS("DOM.HTMLAppletElement.IndexedPropertyGetter");
+    return npObjectIndexedGetter(index, info);
+}
+
+INDEXED_PROPERTY_GETTER(HTMLEmbedElement)
+{
+    INC_STATS("DOM.HTMLEmbedElement.IndexedPropertyGetter");
+    return npObjectIndexedGetter(index, info);
+}
+
+INDEXED_PROPERTY_GETTER(HTMLObjectElement)
+{
+    INC_STATS("DOM.HTMLObjectElement.IndexedPropertyGetter");
+    return npObjectIndexedGetter(index, info);
+}
+
+INDEXED_PROPERTY_SETTER(HTMLAppletElement)
+{
+    INC_STATS("DOM.HTMLAppletElement.IndexedPropertySetter");
+    return npObjectIndexedSetter(index, value, info);
+}
+
+INDEXED_PROPERTY_SETTER(HTMLEmbedElement)
+{
+    INC_STATS("DOM.HTMLEmbedElement.IndexedPropertySetter");
+    return npObjectIndexedSetter(index, value, info);
+}
+
+INDEXED_PROPERTY_SETTER(HTMLObjectElement)
+{
+    INC_STATS("DOM.HTMLObjectElement.IndexedPropertySetter");
+    return npObjectIndexedSetter(index, value, info);
+}
+
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list