mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibHTML: Add support for <font color>
This was pleasantly trivial to implement with the new support for presentational hints. :^)
This commit is contained in:
parent
9808d35554
commit
8fb979148d
4 changed files with 39 additions and 1 deletions
23
Libraries/LibHTML/DOM/HTMLFontElement.cpp
Normal file
23
Libraries/LibHTML/DOM/HTMLFontElement.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include <LibHTML/CSS/StyleProperties.h>
|
||||||
|
#include <LibHTML/CSS/StyleValue.h>
|
||||||
|
#include <LibHTML/DOM/HTMLFontElement.h>
|
||||||
|
|
||||||
|
HTMLFontElement::HTMLFontElement(Document& document, const String& tag_name)
|
||||||
|
: HTMLElement(document, tag_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HTMLFontElement::~HTMLFontElement()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void HTMLFontElement::apply_presentational_hints(StyleProperties& style) const
|
||||||
|
{
|
||||||
|
for_each_attribute([&](auto& name, auto& value) {
|
||||||
|
if (name == "color") {
|
||||||
|
auto color = Color::from_string(value);
|
||||||
|
if (color.has_value())
|
||||||
|
style.set_property("color", ColorStyleValue::create(color.value()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
11
Libraries/LibHTML/DOM/HTMLFontElement.h
Normal file
11
Libraries/LibHTML/DOM/HTMLFontElement.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibHTML/DOM/HTMLElement.h>
|
||||||
|
|
||||||
|
class HTMLFontElement : public HTMLElement {
|
||||||
|
public:
|
||||||
|
HTMLFontElement(Document&, const String& tag_name);
|
||||||
|
virtual ~HTMLFontElement() override;
|
||||||
|
|
||||||
|
virtual void apply_presentational_hints(StyleProperties&) const override;
|
||||||
|
};
|
|
@ -11,6 +11,7 @@ LIBHTML_OBJS = \
|
||||||
DOM/HTMLStyleElement.o \
|
DOM/HTMLStyleElement.o \
|
||||||
DOM/HTMLTitleElement.o \
|
DOM/HTMLTitleElement.o \
|
||||||
DOM/HTMLBodyElement.o \
|
DOM/HTMLBodyElement.o \
|
||||||
|
DOM/HTMLFontElement.o \
|
||||||
DOM/Document.o \
|
DOM/Document.o \
|
||||||
DOM/Text.o \
|
DOM/Text.o \
|
||||||
CSS/Selector.o \
|
CSS/Selector.o \
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibHTML/DOM/Element.h>
|
#include <LibHTML/DOM/Element.h>
|
||||||
#include <LibHTML/DOM/HTMLAnchorElement.h>
|
#include <LibHTML/DOM/HTMLAnchorElement.h>
|
||||||
#include <LibHTML/DOM/HTMLHRElement.h>
|
|
||||||
#include <LibHTML/DOM/HTMLBodyElement.h>
|
#include <LibHTML/DOM/HTMLBodyElement.h>
|
||||||
|
#include <LibHTML/DOM/HTMLFontElement.h>
|
||||||
|
#include <LibHTML/DOM/HTMLHRElement.h>
|
||||||
#include <LibHTML/DOM/HTMLHeadElement.h>
|
#include <LibHTML/DOM/HTMLHeadElement.h>
|
||||||
#include <LibHTML/DOM/HTMLHeadingElement.h>
|
#include <LibHTML/DOM/HTMLHeadingElement.h>
|
||||||
#include <LibHTML/DOM/HTMLHtmlElement.h>
|
#include <LibHTML/DOM/HTMLHtmlElement.h>
|
||||||
|
@ -26,6 +27,8 @@ static NonnullRefPtr<Element> create_element(Document& document, const String& t
|
||||||
return adopt(*new HTMLHeadElement(document, tag_name));
|
return adopt(*new HTMLHeadElement(document, tag_name));
|
||||||
if (lowercase_tag_name == "body")
|
if (lowercase_tag_name == "body")
|
||||||
return adopt(*new HTMLBodyElement(document, tag_name));
|
return adopt(*new HTMLBodyElement(document, tag_name));
|
||||||
|
if (lowercase_tag_name == "font")
|
||||||
|
return adopt(*new HTMLFontElement(document, tag_name));
|
||||||
if (lowercase_tag_name == "hr")
|
if (lowercase_tag_name == "hr")
|
||||||
return adopt(*new HTMLHRElement(document, tag_name));
|
return adopt(*new HTMLHRElement(document, tag_name));
|
||||||
if (lowercase_tag_name == "style")
|
if (lowercase_tag_name == "style")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue