mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-23 00:19:18 +00:00
LibWeb: Implement Document.evaluate and related XPath methods
This commit is contained in:
parent
0ea519c539
commit
d2030a5377
Notes:
github-actions[bot]
2025-10-03 11:17:31 +00:00
Author: https://github.com/johannesg
Commit: d2030a5377
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6342
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
3 changed files with 29 additions and 0 deletions
|
@ -6802,6 +6802,23 @@ HashMap<FlyString, GC::Ref<Web::CSS::CSSPropertyRule>>& Document::registered_cus
|
|||
return m_registered_custom_properties;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<XPath::XPathExpression>> Document::create_expression(String const& expression, GC::Ptr<XPath::XPathNSResolver> resolver)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
return XPath::create_expression(realm, expression, resolver);
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<XPath::XPathResult>> Document::evaluate(String const& expression, DOM::Node const& context_node, GC::Ptr<XPath::XPathNSResolver> resolver, WebIDL::UnsignedShort type, GC::Ptr<XPath::XPathResult> result)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
return XPath::evaluate(realm, expression, context_node, resolver, type, result);
|
||||
}
|
||||
|
||||
GC::Ref<DOM::Node> Document::create_ns_resolver(GC::Ref<DOM::Node> node_resolver)
|
||||
{
|
||||
return node_resolver;
|
||||
}
|
||||
|
||||
NonnullRefPtr<CSS::StyleValue const> Document::custom_property_initial_value(FlyString const& name) const
|
||||
{
|
||||
auto maybe_custom_property = m_registered_custom_properties.get(name);
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <LibWeb/ViewTransition/ViewTransition.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/ObservableArray.h>
|
||||
#include <LibWeb/XPath/XPath.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -682,6 +683,10 @@ public:
|
|||
WebIDL::ExceptionOr<bool> query_command_supported(FlyString const& command);
|
||||
WebIDL::ExceptionOr<String> query_command_value(FlyString const& command);
|
||||
|
||||
WebIDL::ExceptionOr<GC::Ref<XPath::XPathExpression>> create_expression(String const& expression, GC::Ptr<XPath::XPathNSResolver> resolver = nullptr);
|
||||
WebIDL::ExceptionOr<GC::Ref<XPath::XPathResult>> evaluate(String const& expression, const DOM::Node& context_node, GC::Ptr<XPath::XPathNSResolver> resolver = nullptr, WebIDL::UnsignedShort type = 0, GC::Ptr<XPath::XPathResult> result = nullptr);
|
||||
GC::Ref<DOM::Node> create_ns_resolver(GC::Ref<DOM::Node> node_resolver); // legacy
|
||||
|
||||
// https://w3c.github.io/selection-api/#dfn-has-scheduled-selectionchange-event
|
||||
bool has_scheduled_selectionchange_event() const { return m_has_scheduled_selectionchange_event; }
|
||||
void set_scheduled_selectionchange_event(bool value) { m_has_scheduled_selectionchange_event = value; }
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#import <HTML/Location.idl>
|
||||
#import <Selection/Selection.idl>
|
||||
#import <ViewTransition/ViewTransition.idl>
|
||||
#import <XPath/XPathResult.idl>
|
||||
#import <XPath/XPathExpression.idl>
|
||||
|
||||
// https://dom.spec.whatwg.org/#document
|
||||
// https://html.spec.whatwg.org/multipage/dom.html#the-document-object
|
||||
|
@ -153,6 +155,11 @@ interface Document : Node {
|
|||
boolean queryCommandSupported(DOMString commandId);
|
||||
DOMString queryCommandValue(DOMString commandId);
|
||||
|
||||
// XPath
|
||||
[NewObject] XPathExpression createExpression(DOMString expression, optional XPathNSResolver? resolver = null);
|
||||
XPathResult evaluate(DOMString expression, Node contextNode, optional XPathNSResolver? resolver = null, optional unsigned short type = 0, optional XPathResult? result = null);
|
||||
Node createNSResolver(Node nodeResolver); // legacy
|
||||
|
||||
// special event handler IDL attributes that only apply to Document objects
|
||||
[LegacyLenientThis] attribute EventHandler onreadystatechange;
|
||||
attribute EventHandler onvisibilitychange;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue