mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +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:
parent
c1acf67715
commit
9e642827fc
7 changed files with 221 additions and 112 deletions
|
@ -346,7 +346,7 @@ NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const String& ta
|
|||
|
||||
RefPtr<Element> Document::query_selector(const StringView& selector_text)
|
||||
{
|
||||
auto selector = parse_selector(selector_text);
|
||||
auto selector = parse_selector(CSS::ParsingContext(*this), selector_text);
|
||||
if (!selector.has_value())
|
||||
return {};
|
||||
|
||||
|
@ -366,7 +366,7 @@ RefPtr<Element> Document::query_selector(const StringView& selector_text)
|
|||
|
||||
NonnullRefPtrVector<Element> Document::query_selector_all(const StringView& selector_text)
|
||||
{
|
||||
auto selector = parse_selector(selector_text);
|
||||
auto selector = parse_selector(CSS::ParsingContext(*this), selector_text);
|
||||
if (!selector.has_value())
|
||||
return {};
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void HTMLLinkElement::resource_did_load()
|
|||
|
||||
dbg() << "HTMLLinkElement: Resource did load, looks good! " << href();
|
||||
|
||||
auto sheet = parse_css(resource()->encoded_data());
|
||||
auto sheet = parse_css(CSS::ParsingContext(document()), resource()->encoded_data());
|
||||
if (!sheet) {
|
||||
dbg() << "HTMLLinkElement: Failed to parse stylesheet: " << href();
|
||||
return;
|
||||
|
|
|
@ -48,7 +48,7 @@ void HTMLStyleElement::children_changed()
|
|||
if (is<Text>(child))
|
||||
builder.append(to<Text>(child).text_content());
|
||||
});
|
||||
m_stylesheet = parse_css(builder.to_string());
|
||||
m_stylesheet = parse_css(CSS::ParsingContext(document()), builder.to_string());
|
||||
if (m_stylesheet)
|
||||
document().style_sheets().add_sheet(*m_stylesheet);
|
||||
else
|
||||
|
|
|
@ -42,7 +42,8 @@ void HTMLTableElement::apply_presentational_hints(StyleProperties& style) const
|
|||
{
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name == HTML::AttributeNames::width) {
|
||||
style.set_property(CSS::PropertyID::Width, parse_css_value(value));
|
||||
if (auto parsed_value = parse_css_value(CSS::ParsingContext(document()), value))
|
||||
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
|
||||
return;
|
||||
}
|
||||
if (name == HTML::AttributeNames::bgcolor) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue