1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:27:34 +00:00

LibWeb: Switch to new CSS Parser :^)

Change all the places that were including the deprecated parser, to
include the new one instead, and then delete the old parser code.

`ParentNode::query_selector[_all]()` now treat their input as a
comma-separated list of selectors, instead of just one, and return
elements that match any of the selectors in that list. This is according
to these specs:

- querySelector/querySelectorAll:
https://dom.spec.whatwg.org/#ref-for-dom-parentnode-queryselector%E2%91%A0
- selector matching algorithm:
https://www.w3.org/TR/selectors-4/#match-against-tree
This commit is contained in:
Sam Atkins 2021-07-30 19:31:46 +01:00 committed by Ali Mohammad Pur
parent 4065eb169c
commit 3bd14941c7
13 changed files with 37 additions and 2074 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
namespace Web::CSS {
class DeprecatedParsingContext {
public:
DeprecatedParsingContext();
explicit DeprecatedParsingContext(const DOM::Document&);
explicit DeprecatedParsingContext(const DOM::ParentNode&);
bool in_quirks_mode() const;
URL complete_url(const String&) const;
private:
const DOM::Document* m_document { nullptr };
};
}
namespace Web {
RefPtr<CSS::CSSStyleSheet> parse_css(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::CSSStyleDeclaration> parse_css_declaration(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::StyleValue> parse_css_value(const CSS::DeprecatedParsingContext&, const StringView&, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
RefPtr<CSS::Selector> parse_selector(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::LengthStyleValue> parse_line_width(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::ColorStyleValue> parse_color(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::IdentifierStyleValue> parse_line_style(const CSS::DeprecatedParsingContext&, const StringView&);
RefPtr<CSS::StyleValue> parse_html_length(const DOM::Document&, const StringView&);
}