1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:38:11 +00:00

LibWeb: Don't tolerate unit-less lengths (except 0) in standards mode

"width: 500" is not a valid CSS property in standards mode and should
be ignored.

To plumb the quirks-mode flag into CSS parsing, this patch adds a new
CSS::ParsingContext object that must be passed to the CSS parser.
Currently it only allows you to check the quirks-mode flag. In the
future it will be a good place to put additional information needed
for things like relative URL resolution, etc.

This narrows <div class=parser> on ACID2 to the correct width. :^)
This commit is contained in:
Andreas Kling 2020-06-28 12:43:22 +02:00
parent c1acf67715
commit 9e642827fc
7 changed files with 221 additions and 112 deletions

View file

@ -31,13 +31,26 @@
namespace Web {
RefPtr<StyleSheet> parse_css(const StringView&);
RefPtr<StyleDeclaration> parse_css_declaration(const StringView&);
NonnullRefPtr<StyleValue> parse_css_value(const StringView&);
Optional<Selector> parse_selector(const StringView&);
namespace CSS {
class ParsingContext {
public:
ParsingContext();
explicit ParsingContext(const Document&);
RefPtr<LengthStyleValue> parse_line_width(const StringView&);
RefPtr<ColorStyleValue> parse_color(const StringView&);
RefPtr<StringStyleValue> parse_line_style(const StringView&);
bool in_quirks_mode() const;
private:
const Document* m_document { nullptr };
};
}
RefPtr<StyleSheet> parse_css(const CSS::ParsingContext&, const StringView&);
RefPtr<StyleDeclaration> parse_css_declaration(const CSS::ParsingContext&, const StringView&);
RefPtr<StyleValue> parse_css_value(const CSS::ParsingContext&, const StringView&);
Optional<Selector> parse_selector(const CSS::ParsingContext&, const StringView&);
RefPtr<LengthStyleValue> parse_line_width(const CSS::ParsingContext&, const StringView&);
RefPtr<ColorStyleValue> parse_color(const CSS::ParsingContext&, const StringView&);
RefPtr<StringStyleValue> parse_line_style(const CSS::ParsingContext&, const StringView&);
}