Closed Bug 816380 Opened 11 years ago Closed 11 years ago

Convert XPathEvaluator to WebIDL

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This way I can remove some quickstubs once we do Document.
Whiteboard: [need review]
Attachment #686391 - Flags: review?(peterv)
Comment on attachment 686391 [details] [diff] [review]
Convert XPathEvaluator to WebIDL.

Review of attachment 686391 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/xslt/src/xpath/nsXPathEvaluator.cpp
@@ +219,5 @@
> +}
> +
> +/* static */
> +already_AddRefed<nsXPathEvaluator>
> +nsXPathEvaluator::Constructor(nsISupports* aGlobal, mozilla::ErrorResult& rv)

s/mozilla:://

@@ +242,5 @@
> +                                   ErrorResult& rv)
> +{
> +  nsCOMPtr<nsIDOMNode> nodeResolver = do_QueryInterface(aNodeResolver);
> +  nsCOMPtr<nsIDOMXPathNSResolver> res;
> +  rv = CreateNSResolver(nodeResolver, getter_AddRefs(res));

I'd just do |rv = CreateNSResolver(aNodeResolver->AsDOMNode(), getter_AddRefs(res));|

@@ +253,5 @@
> +                           nsISupports* aResult, ErrorResult& rv)
> +{
> +  nsCOMPtr<nsIDOMNode> contextNode = do_QueryInterface(aContextNode);
> +  nsCOMPtr<nsISupports> res;
> +  rv = Evaluate(aExpression, contextNode, aResolver, aType,

Same here.

::: dom/webidl/XPathEvaluator.webidl
@@ +13,5 @@
> +  // Based on nsIDOMXPathEvaluator
> +  [Creator, Throws]
> +  XPathExpression createExpression(DOMString expression,
> +                                   XPathNSResolver? resolver);
> +  [Creator, Throws]

Please file a followup to remove this Throws, I think the security exception can go and the OOM too.

@@ +16,5 @@
> +                                   XPathNSResolver? resolver);
> +  [Creator, Throws]
> +  XPathNSResolver createNSResolver(Node? nodeResolver);
> +  [Throws]
> +  nsISupports evaluate(DOMString expression, Node? contextNode,

I'd make this return XPathResult and map that to nsISupports. The spec has DOMObject and specifies that it is a XPathResult for XPath 1.0. We only support 1.0 anyway.

@@ +18,5 @@
> +  XPathNSResolver createNSResolver(Node? nodeResolver);
> +  [Throws]
> +  nsISupports evaluate(DOMString expression, Node? contextNode,
> +                       XPathNSResolver? resolver, unsigned short type,
> +                       nsISupports? result);

Same here.
Attachment #686391 - Flags: review?(peterv) → review+
> s/mozilla:://

Done.

> I'd just do |rv = CreateNSResolver(aNodeResolver->AsDOMNode(), getter_AddRefs(res));|

aNodeResolver can be null as the IDL is currently written...  I'll leave this as-is for the moment until we fix that.

> Please file a followup to remove this Throws

Filed bug 821808.

> The spec has DOMObject and specifies that it is a XPathResult for XPath 1.0.

There's a spec?  I just based it on our xpidl....  Will do, in any case.
https://hg.mozilla.org/integration/mozilla-inbound/rev/3e0b4ce62d6d
Flags: in-testsuite?
Whiteboard: [need review]
Target Milestone: --- → mozilla20
https://hg.mozilla.org/mozilla-central/rev/3e0b4ce62d6d
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
>    5.35 +addExternalIface('nsISupports', nativeType='nsISupports')
>    8.11 +interface nsISupports;
Is this needed?
> Is this needed?

No, good catch.  Pushed https://hg.mozilla.org/integration/mozilla-inbound/rev/c94c3ad9317d to remove it.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.