mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb/CSS: Remove an unnecessary ParsingContext constructor
Anywhere we have a Node, we have a Document. So just use that.
This commit is contained in:
parent
0ac133d73b
commit
ca5dee4c55
Notes:
github-actions[bot]
2025-02-06 16:49:02 +00:00
Author: https://github.com/AtkinsSJ
Commit: ca5dee4c55
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3464
Reviewed-by: https://github.com/ADKaster
4 changed files with 3 additions and 12 deletions
|
@ -47,14 +47,6 @@ ParsingContext::ParsingContext(DOM::Document const& document, Mode mode)
|
|||
{
|
||||
}
|
||||
|
||||
ParsingContext::ParsingContext(DOM::ParentNode& parent_node, Mode mode)
|
||||
: m_realm(parent_node.realm())
|
||||
, m_document(&parent_node.document())
|
||||
, m_url(parent_node.document().url())
|
||||
, m_mode(mode)
|
||||
{
|
||||
}
|
||||
|
||||
bool ParsingContext::in_quirks_mode() const
|
||||
{
|
||||
return m_document ? m_document->in_quirks_mode() : false;
|
||||
|
|
|
@ -24,7 +24,6 @@ public:
|
|||
explicit ParsingContext(JS::Realm&, URL::URL, Mode = Mode::Normal);
|
||||
explicit ParsingContext(DOM::Document const&, Mode = Mode::Normal);
|
||||
explicit ParsingContext(DOM::Document const&, URL::URL, Mode = Mode::Normal);
|
||||
explicit ParsingContext(DOM::ParentNode&, Mode = Mode::Normal);
|
||||
|
||||
Mode mode() const { return m_mode; }
|
||||
bool is_parsing_svg_presentation_attribute() const { return m_mode == Mode::SVGPresentationAttribute; }
|
||||
|
|
|
@ -744,7 +744,7 @@ GC::Ptr<ShadowRoot> Element::shadow_root_for_bindings() const
|
|||
WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
|
||||
{
|
||||
// 1. Let s be the result of parse a selector from selectors.
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(document()), selectors);
|
||||
|
||||
// 2. If s is failure, then throw a "SyntaxError" DOMException.
|
||||
if (!maybe_selectors.has_value())
|
||||
|
@ -764,7 +764,7 @@ WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
|
|||
WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors) const
|
||||
{
|
||||
// 1. Let s be the result of parse a selector from selectors.
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(static_cast<ParentNode&>(const_cast<Element&>(*this))), selectors);
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext(document()), selectors);
|
||||
|
||||
// 2. If s is failure, then throw a "SyntaxError" DOMException.
|
||||
if (!maybe_selectors.has_value())
|
||||
|
|
|
@ -52,7 +52,7 @@ static WebIDL::ExceptionOr<Variant<GC::Ptr<Element>, GC::Ref<NodeList>>> scope_m
|
|||
{
|
||||
// To scope-match a selectors string selectors against a node, run these steps:
|
||||
// 1. Let s be the result of parse a selector selectors.
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext { node }, selector_text);
|
||||
auto maybe_selectors = parse_selector(CSS::Parser::ParsingContext { node.document() }, selector_text);
|
||||
|
||||
// 2. If s is failure, then throw a "SyntaxError" DOMException.
|
||||
if (!maybe_selectors.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue