mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibWeb: Support more presentational hints from the HTML spec
Specifically, this adds support for the align attribute when applied to heading, paragraph and caption elements.
This commit is contained in:
parent
25af1b33f6
commit
51f41ea997
6 changed files with 55 additions and 0 deletions
|
@ -16,4 +16,23 @@ HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, DOM::QualifiedNa
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLHeadingElement::~HTMLHeadingElement() = default;
|
HTMLHeadingElement::~HTMLHeadingElement() = default;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2
|
||||||
|
void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||||
|
{
|
||||||
|
HTMLElement::apply_presentational_hints(style);
|
||||||
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
|
if (name.equals_ignoring_case("align"sv)) {
|
||||||
|
if (value == "left"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
|
||||||
|
else if (value == "right"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
|
||||||
|
else if (value == "center"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
|
||||||
|
else if (value == "justify"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ class HTMLHeadingElement final : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
virtual ~HTMLHeadingElement() override;
|
virtual ~HTMLHeadingElement() override;
|
||||||
|
|
||||||
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLHeadingElement(DOM::Document&, DOM::QualifiedName);
|
HTMLHeadingElement(DOM::Document&, DOM::QualifiedName);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,4 +17,22 @@ HTMLParagraphElement::HTMLParagraphElement(DOM::Document& document, DOM::Qualifi
|
||||||
|
|
||||||
HTMLParagraphElement::~HTMLParagraphElement() = default;
|
HTMLParagraphElement::~HTMLParagraphElement() = default;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2
|
||||||
|
void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||||
|
{
|
||||||
|
HTMLElement::apply_presentational_hints(style);
|
||||||
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
|
if (name.equals_ignoring_case("align"sv)) {
|
||||||
|
if (value == "left"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
|
||||||
|
else if (value == "right"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
|
||||||
|
else if (value == "center"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
|
||||||
|
else if (value == "justify"sv)
|
||||||
|
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ class HTMLParagraphElement final : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
virtual ~HTMLParagraphElement() override;
|
virtual ~HTMLParagraphElement() override;
|
||||||
|
|
||||||
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLParagraphElement(DOM::Document&, DOM::QualifiedName);
|
HTMLParagraphElement(DOM::Document&, DOM::QualifiedName);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,4 +17,16 @@ HTMLTableCaptionElement::HTMLTableCaptionElement(DOM::Document& document, DOM::Q
|
||||||
|
|
||||||
HTMLTableCaptionElement::~HTMLTableCaptionElement() = default;
|
HTMLTableCaptionElement::~HTMLTableCaptionElement() = default;
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2
|
||||||
|
void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& style) const
|
||||||
|
{
|
||||||
|
HTMLElement::apply_presentational_hints(style);
|
||||||
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
|
if (name.equals_ignoring_case("align"sv)) {
|
||||||
|
if (value == "bottom"sv)
|
||||||
|
style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ class HTMLTableCaptionElement final : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
virtual ~HTMLTableCaptionElement() override;
|
virtual ~HTMLTableCaptionElement() override;
|
||||||
|
|
||||||
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName);
|
HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue