[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:40:23 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit f5b11768128238bbe62462aeb35ad31f068f1a25
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 6 17:15:22 2009 +0000

    2009-10-06  Anton Muhin  <antonm at chromium>
    
            Reviewed by Dimitri Glazkov.
    
            Non standard, but popular exetension allows automagically
            turn a function into a namespace resolver.  Support that in
            Chromium as well.
    
            This adds new layout tests.
            https://bugs.webkit.org/show_bug.cgi?id=30128
    
            * fast/xpath/xpath-namespaces-expected.txt:
            * fast/xpath/xpath-namespaces.html:
    2009-10-06  Anton Muhin  <antonm at chromium>
    
            Reviewed by Dimitri Glazkov.
    
            Non standard, but popular exetension allows automagically
            turn a function into a namespace resolver.  Support that in
            Chromium as well.
    
            Adjust CodeGeneratorV8 to treat XPathNSResolver in a special way.
            https://bugs.webkit.org/show_bug.cgi?id=30128
    
            * bindings/scripts/CodeGeneratorV8.pm:
            * bindings/v8/V8DOMWrapper.h:
            (WebCore::V8DOMWrapper::getXPathNSResolver):
            * bindings/v8/custom/V8DocumentCustom.cpp:
            (WebCore::CALLBACK_FUNC_DECL):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49191 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index c46a4ad..1bc5f6a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2009-10-06  Anton Muhin  <antonm at chromium>
+
+        Reviewed by Dimitri Glazkov.
+
+        Non standard, but popular exetension allows automagically
+        turn a function into a namespace resolver.  Support that in
+        Chromium as well.
+
+        This adds new layout tests.
+        https://bugs.webkit.org/show_bug.cgi?id=30128
+
+        * fast/xpath/xpath-namespaces-expected.txt:
+        * fast/xpath/xpath-namespaces.html:
+
 2009-10-06  Jakub Wieczorek  <faw217 at gmail.com>
 
         Reviewed by Simon Hausmann.
diff --git a/LayoutTests/fast/xpath/xpath-namespaces-expected.txt b/LayoutTests/fast/xpath/xpath-namespaces-expected.txt
index 51f6178..49655a1 100644
--- a/LayoutTests/fast/xpath/xpath-namespaces-expected.txt
+++ b/LayoutTests/fast/xpath/xpath-namespaces-expected.txt
@@ -3,6 +3,8 @@ This tests that XPath expressions with prefixes work correctly.
 PASS /ns:foo
 PASS /ns:*
 PASS /foo:*
+PASS /xmpl:*
+PASS /xmpl:*
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/xpath/xpath-namespaces.html b/LayoutTests/fast/xpath/xpath-namespaces.html
index 992c11e..79dc6d3 100644
--- a/LayoutTests/fast/xpath/xpath-namespaces.html
+++ b/LayoutTests/fast/xpath/xpath-namespaces.html
@@ -26,6 +26,18 @@
     var result = expr.evaluate(contextNode, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
     checkSnapshot("/foo:*", result, []);
 
+    // Now try a resolver originating from the function
+    var namespaces = { xmpl: "http://www.example.org" };
+    var mapResolver = function(prefix) { return namespaces[prefix]; };
+
+    var expr = doc.createExpression("/xmpl:*", mapResolver);
+    var result = expr.evaluate(contextNode, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/xmpl:*", result, [doc.documentElement]);
+
+    var evaluator = new XPathEvaluator();
+    var result = evaluator.evaluate("/xmpl:*", doc, mapResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    checkSnapshot("/xmpl:*", result, [doc.documentElement]);
+
     var successfullyParsed = true;
 
 </script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d3b9fd0..89c752b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2009-10-06  Anton Muhin  <antonm at chromium>
+
+        Reviewed by Dimitri Glazkov.
+
+        Non standard, but popular exetension allows automagically
+        turn a function into a namespace resolver.  Support that in
+        Chromium as well.
+
+        Adjust CodeGeneratorV8 to treat XPathNSResolver in a special way.
+        https://bugs.webkit.org/show_bug.cgi?id=30128
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/V8DOMWrapper.h:
+        (WebCore::V8DOMWrapper::getXPathNSResolver):
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::CALLBACK_FUNC_DECL):
+
 2009-10-06  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 231355a..d4fdc68 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -1463,7 +1463,7 @@ sub GenerateFunctionCallString()
             $paramName = "SVGPODListItem<" . GetNativeType($paramType, 1) . ">::copy($paramName)";
         }
 
-        if ($parameter->type eq "NodeFilter") {
+        if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
             $functionString .= "$paramName.get()";
         } else {
             $functionString .= $paramName;
@@ -1745,6 +1745,9 @@ sub GetNativeType
     # temporary hack
     return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
 
+    # necessary as resolvers could be constructed on fly.
+    return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
+
     return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
 
     # Default, assume native type is a pointer with same type name as idl type
@@ -1901,6 +1904,10 @@ sub JSValueToNative
         return "V8Node::HasInstance($value) ? V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast($value)) : 0";
     }
 
+    if ($type eq "XPathNSResolver") {
+        return "V8DOMWrapper::getXPathNSResolver($value)";
+    }
+
     AddIncludesForType($type);
     # $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type);
 
@@ -1952,10 +1959,16 @@ sub CreateCustomSignature
         if ($first) { $first = 0; }
         else { $result .= ", "; }
         if (IsWrapperType($parameter->type)) {
-            my $type = $parameter->type;
-            my $header = GetV8HeaderName($type);
-            $implIncludes{$header} = 1;
-            $result .= "V8${type}::GetRawTemplate()";
+            if ($parameter->type eq "XPathNSResolver") {
+                # Special case for XPathNSResolver.  All other browsers accepts a callable,
+                # so, even though it's against IDL, accept objects here.
+                $result .= "v8::Handle<v8::FunctionTemplate>()";
+            } else {
+                my $type = $parameter->type;
+                my $header = GetV8HeaderName($type);
+                $implIncludes{$header} = 1;
+                $result .= "V8${type}::GetRawTemplate()";
+            }
         } else {
             $result .= "v8::Handle<v8::FunctionTemplate>()";
         }
diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h
index 43b7070..2257688 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.h
+++ b/WebCore/bindings/v8/V8DOMWrapper.h
@@ -37,9 +37,12 @@
 #include "NodeFilter.h"
 #include "PlatformString.h" // for WebCore::String
 #include "V8CustomBinding.h"
+#include "V8CustomXPathNSResolver.h"
 #include "V8DOMMap.h"
 #include "V8Index.h"
 #include "V8Utilities.h"
+#include "V8XPathNSResolver.h"
+#include "XPathNSResolver.h"
 #include <v8.h>
 
 namespace WebCore {
@@ -239,6 +242,17 @@ namespace WebCore {
         static PassRefPtr<EventListener> getEventListener(V8Proxy* proxy, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup);
 
 
+        // XPath-related utilities
+        static RefPtr<XPathNSResolver> getXPathNSResolver(v8::Handle<v8::Value> value)
+        {
+            RefPtr<XPathNSResolver> resolver;
+            if (V8XPathNSResolver::HasInstance(value))
+                resolver = convertToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, v8::Handle<v8::Object>::Cast(value));
+            else if (value->IsObject())
+                resolver = V8CustomXPathNSResolver::create(value->ToObject());
+            return resolver;
+        }
+
         // DOMImplementation is a singleton and it is handled in a special
         // way. A wrapper is generated per document and stored in an
         // internal field of the document.
diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
index 1bd518c..f921a80 100644
--- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp
@@ -61,12 +61,8 @@ CALLBACK_FUNC_DECL(DocumentEvaluate)
     if (V8Node::HasInstance(args[1]))
         contextNode = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[1]));
 
-    RefPtr<XPathNSResolver> resolver;
-    if (V8XPathNSResolver::HasInstance(args[2]))
-        resolver = V8DOMWrapper::convertToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, v8::Handle<v8::Object>::Cast(args[2]));
-    else if (args[2]->IsObject())
-        resolver = V8CustomXPathNSResolver::create(args[2]->ToObject());
-    else if (!args[2]->IsNull() && !args[2]->IsUndefined())
+    RefPtr<XPathNSResolver> resolver = V8DOMWrapper::getXPathNSResolver(args[2]);
+    if (!resolver && !args[2]->IsNull() && !args[2]->IsUndefined())
         return throwError(TYPE_MISMATCH_ERR);
 
     int type = toInt32(args[3]);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list