mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Use xpath ns resolver to resolve namespace prefixes (#39321)
The xpath resolver is a function provided by the user to resolve namespace prefixes. Previously, we were ignoring the argument. Testing: New web platform tests start to pass Part of https://github.com/servo/servo/issues/34527 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
f3d5617349
commit
1898a740a8
9 changed files with 164 additions and 132 deletions
|
@ -2,10 +2,13 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::HandleObject;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::XPathExpressionBinding::XPathExpressionMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::XPathNSResolverBinding::XPathNSResolver;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{DomGlobal, Reflector, reflect_dom_object_with_proto};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
|
@ -45,15 +48,13 @@ impl XPathExpression {
|
|||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl XPathExpressionMethods<crate::DomTypeHolder> for XPathExpression {
|
||||
/// <https://dom.spec.whatwg.org/#dom-xpathexpression-evaluate>
|
||||
fn Evaluate(
|
||||
pub(crate) fn evaluate_internal(
|
||||
&self,
|
||||
context_node: &Node,
|
||||
result_type_num: u16,
|
||||
_result: Option<&XPathResult>,
|
||||
resolver: Option<Rc<XPathNSResolver>>,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<XPathResult>> {
|
||||
let result_type = XPathResultType::try_from(result_type_num)
|
||||
|
@ -62,8 +63,7 @@ impl XPathExpressionMethods<crate::DomTypeHolder> for XPathExpression {
|
|||
let global = self.global();
|
||||
let window = global.as_window();
|
||||
|
||||
let result_value = evaluate_parsed_xpath(&self.parsed_expression, context_node)
|
||||
.map_err(|_e| Error::Operation)?;
|
||||
let result_value = evaluate_parsed_xpath(&self.parsed_expression, context_node, resolver)?;
|
||||
|
||||
// TODO(vlindhol): support putting results into mutable `_result` as per the spec
|
||||
Ok(XPathResult::new(
|
||||
|
@ -75,3 +75,16 @@ impl XPathExpressionMethods<crate::DomTypeHolder> for XPathExpression {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl XPathExpressionMethods<crate::DomTypeHolder> for XPathExpression {
|
||||
/// <https://dom.spec.whatwg.org/#dom-xpathexpression-evaluate>
|
||||
fn Evaluate(
|
||||
&self,
|
||||
context_node: &Node,
|
||||
result_type_num: u16,
|
||||
result: Option<&XPathResult>,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<XPathResult>> {
|
||||
self.evaluate_internal(context_node, result_type_num, result, None, can_gc)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue