Changeset 49191 in webkit


Ignore:
Timestamp:
Oct 6, 2009 10:15:22 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-10-06 Anton Muhin <antonm@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@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):
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r49189 r49191  
     12009-10-06  Anton Muhin  <antonm@chromium>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Non standard, but popular exetension allows automagically
     6        turn a function into a namespace resolver.  Support that in
     7        Chromium as well.
     8
     9        This adds new layout tests.
     10        https://bugs.webkit.org/show_bug.cgi?id=30128
     11
     12        * fast/xpath/xpath-namespaces-expected.txt:
     13        * fast/xpath/xpath-namespaces.html:
     14
    1152009-10-06  Jakub Wieczorek  <faw217@gmail.com>
    216
  • trunk/LayoutTests/fast/xpath/xpath-namespaces-expected.txt

    r20554 r49191  
    44PASS /ns:*
    55PASS /foo:*
     6PASS /xmpl:*
     7PASS /xmpl:*
    68PASS successfullyParsed is true
    79
  • trunk/LayoutTests/fast/xpath/xpath-namespaces.html

    r20554 r49191  
    2727    checkSnapshot("/foo:*", result, []);
    2828
     29    // Now try a resolver originating from the function
     30    var namespaces = { xmpl: "http://www.example.org" };
     31    var mapResolver = function(prefix) { return namespaces[prefix]; };
     32
     33    var expr = doc.createExpression("/xmpl:*", mapResolver);
     34    var result = expr.evaluate(contextNode, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
     35    checkSnapshot("/xmpl:*", result, [doc.documentElement]);
     36
     37    var evaluator = new XPathEvaluator();
     38    var result = evaluator.evaluate("/xmpl:*", doc, mapResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
     39    checkSnapshot("/xmpl:*", result, [doc.documentElement]);
     40
    2941    var successfullyParsed = true;
    3042
  • trunk/WebCore/ChangeLog

    r49190 r49191  
     12009-10-06  Anton Muhin  <antonm@chromium>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Non standard, but popular exetension allows automagically
     6        turn a function into a namespace resolver.  Support that in
     7        Chromium as well.
     8
     9        Adjust CodeGeneratorV8 to treat XPathNSResolver in a special way.
     10        https://bugs.webkit.org/show_bug.cgi?id=30128
     11
     12        * bindings/scripts/CodeGeneratorV8.pm:
     13        * bindings/v8/V8DOMWrapper.h:
     14        (WebCore::V8DOMWrapper::getXPathNSResolver):
     15        * bindings/v8/custom/V8DocumentCustom.cpp:
     16        (WebCore::CALLBACK_FUNC_DECL):
     17
    1182009-10-06  Pavel Feldman  <pfeldman@chromium.org>
    219
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r48978 r49191  
    14641464        }
    14651465
    1466         if ($parameter->type eq "NodeFilter") {
     1466        if ($parameter->type eq "NodeFilter" || $parameter->type eq "XPathNSResolver") {
    14671467            $functionString .= "$paramName.get()";
    14681468        } else {
     
    17461746    return "RefPtr<NodeFilter>" if $type eq "NodeFilter";
    17471747
     1748    # necessary as resolvers could be constructed on fly.
     1749    return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
     1750
    17481751    return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
    17491752
     
    19021905    }
    19031906
     1907    if ($type eq "XPathNSResolver") {
     1908        return "V8DOMWrapper::getXPathNSResolver($value)";
     1909    }
     1910
    19041911    AddIncludesForType($type);
    19051912    # $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type);
     
    19531960        else { $result .= ", "; }
    19541961        if (IsWrapperType($parameter->type)) {
    1955             my $type = $parameter->type;
    1956             my $header = GetV8HeaderName($type);
    1957             $implIncludes{$header} = 1;
    1958             $result .= "V8${type}::GetRawTemplate()";
     1962            if ($parameter->type eq "XPathNSResolver") {
     1963                # Special case for XPathNSResolver.  All other browsers accepts a callable,
     1964                # so, even though it's against IDL, accept objects here.
     1965                $result .= "v8::Handle<v8::FunctionTemplate>()";
     1966            } else {
     1967                my $type = $parameter->type;
     1968                my $header = GetV8HeaderName($type);
     1969                $implIncludes{$header} = 1;
     1970                $result .= "V8${type}::GetRawTemplate()";
     1971            }
    19591972        } else {
    19601973            $result .= "v8::Handle<v8::FunctionTemplate>()";
  • trunk/WebCore/bindings/v8/V8DOMWrapper.h

    r48978 r49191  
    3838#include "PlatformString.h" // for WebCore::String
    3939#include "V8CustomBinding.h"
     40#include "V8CustomXPathNSResolver.h"
    4041#include "V8DOMMap.h"
    4142#include "V8Index.h"
    4243#include "V8Utilities.h"
     44#include "V8XPathNSResolver.h"
     45#include "XPathNSResolver.h"
    4346#include <v8.h>
    4447
     
    240243
    241244
     245        // XPath-related utilities
     246        static RefPtr<XPathNSResolver> getXPathNSResolver(v8::Handle<v8::Value> value)
     247        {
     248            RefPtr<XPathNSResolver> resolver;
     249            if (V8XPathNSResolver::HasInstance(value))
     250                resolver = convertToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, v8::Handle<v8::Object>::Cast(value));
     251            else if (value->IsObject())
     252                resolver = V8CustomXPathNSResolver::create(value->ToObject());
     253            return resolver;
     254        }
     255
    242256        // DOMImplementation is a singleton and it is handled in a special
    243257        // way. A wrapper is generated per document and stored in an
  • trunk/WebCore/bindings/v8/custom/V8DocumentCustom.cpp

    r48781 r49191  
    6262        contextNode = V8DOMWrapper::convertDOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast(args[1]));
    6363
    64     RefPtr<XPathNSResolver> resolver;
    65     if (V8XPathNSResolver::HasInstance(args[2]))
    66         resolver = V8DOMWrapper::convertToNativeObject<XPathNSResolver>(V8ClassIndex::XPATHNSRESOLVER, v8::Handle<v8::Object>::Cast(args[2]));
    67     else if (args[2]->IsObject())
    68         resolver = V8CustomXPathNSResolver::create(args[2]->ToObject());
    69     else if (!args[2]->IsNull() && !args[2]->IsUndefined())
     64    RefPtr<XPathNSResolver> resolver = V8DOMWrapper::getXPathNSResolver(args[2]);
     65    if (!resolver && !args[2]->IsNull() && !args[2]->IsUndefined())
    7066        return throwError(TYPE_MISMATCH_ERR);
    7167
Note: See TracChangeset for help on using the changeset viewer.