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

LibWeb: Move CSS classes into the Web::CSS namespace

This commit is contained in:
Andreas Kling 2020-07-26 20:01:35 +02:00
parent 3e389f4cdc
commit 1f008c95b6
100 changed files with 358 additions and 366 deletions

View file

@ -38,7 +38,7 @@ HTMLBRElement::~HTMLBRElement()
{
}
RefPtr<LayoutNode> HTMLBRElement::create_layout_node(const StyleProperties*)
RefPtr<LayoutNode> HTMLBRElement::create_layout_node(const CSS::StyleProperties*)
{
return adopt(*new LayoutBreak(document(), *this));
}

View file

@ -35,7 +35,7 @@ public:
HTMLBRElement(DOM::Document&, const FlyString& local_name);
virtual ~HTMLBRElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
};
}

View file

@ -40,17 +40,17 @@ HTMLBodyElement::~HTMLBodyElement()
{
}
void HTMLBodyElement::apply_presentational_hints(StyleProperties& style) const
void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("bgcolor")) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, ColorStyleValue::create(color.value()));
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
} else if (name.equals_ignoring_case("text")) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::Color, ColorStyleValue::create(color.value()));
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
} else if (name.equals_ignoring_case("background")) {
ASSERT(m_background_style_value);
style.set_property(CSS::PropertyID::BackgroundImage, *m_background_style_value);
@ -74,7 +74,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value
if (color.has_value())
document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_case("background")) {
m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast<DOM::Document&>(document()));
m_background_style_value = CSS::ImageStyleValue::create(document().complete_url(value), const_cast<DOM::Document&>(document()));
}
}

View file

@ -36,10 +36,10 @@ public:
virtual ~HTMLBodyElement() override;
virtual void parse_attribute(const FlyString&, const String&) override;
virtual void apply_presentational_hints(StyleProperties&) const override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
private:
RefPtr<ImageStyleValue> m_background_style_value;
RefPtr<CSS::ImageStyleValue> m_background_style_value;
};
}

View file

@ -55,7 +55,7 @@ unsigned HTMLCanvasElement::height() const
return attribute(HTML::AttributeNames::height).to_uint().value_or(150);
}
RefPtr<LayoutNode> HTMLCanvasElement::create_layout_node(const StyleProperties* parent_style)
RefPtr<LayoutNode> HTMLCanvasElement::create_layout_node(const CSS::StyleProperties* parent_style)
{
auto style = document().style_resolver().resolve_style(*this, parent_style);
if (style->display() == CSS::Display::None)

View file

@ -51,7 +51,7 @@ public:
unsigned height() const;
private:
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
RefPtr<Gfx::Bitmap> m_bitmap;
RefPtr<CanvasRenderingContext2D> m_context;

View file

@ -39,13 +39,13 @@ HTMLFontElement::~HTMLFontElement()
{
}
void HTMLFontElement::apply_presentational_hints(StyleProperties& style) const
void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_case("color")) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::Color, ColorStyleValue::create(color.value()));
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
}
});
}

View file

@ -35,7 +35,7 @@ public:
HTMLFontElement(DOM::Document&, const FlyString& local_name);
virtual ~HTMLFontElement() override;
virtual void apply_presentational_hints(StyleProperties&) const override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
};
}

View file

@ -50,7 +50,7 @@ HTMLIFrameElement::~HTMLIFrameElement()
{
}
RefPtr<LayoutNode> HTMLIFrameElement::create_layout_node(const StyleProperties* parent_style)
RefPtr<LayoutNode> HTMLIFrameElement::create_layout_node(const CSS::StyleProperties* parent_style)
{
auto style = document().style_resolver().resolve_style(*this, parent_style);
return adopt(*new LayoutFrame(document(), *this, move(style)));

View file

@ -35,7 +35,7 @@ public:
HTMLIFrameElement(DOM::Document&, const FlyString& local_name);
virtual ~HTMLIFrameElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
Frame* hosted_frame() { return m_hosted_frame; }
const Frame* hosted_frame() const { return m_hosted_frame; }

View file

@ -61,7 +61,7 @@ HTMLImageElement::~HTMLImageElement()
{
}
void HTMLImageElement::apply_presentational_hints(StyleProperties& style) const
void HTMLImageElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::width) {
@ -84,7 +84,7 @@ void HTMLImageElement::parse_attribute(const FlyString& name, const String& valu
m_image_loader.load(document().complete_url(value));
}
RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const StyleProperties* parent_style)
RefPtr<LayoutNode> HTMLImageElement::create_layout_node(const CSS::StyleProperties* parent_style)
{
auto style = document().style_resolver().resolve_style(*this, parent_style);
if (style->display() == CSS::Display::None)

View file

@ -51,11 +51,11 @@ public:
const Gfx::Bitmap* bitmap() const;
private:
virtual void apply_presentational_hints(StyleProperties&) const override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
void animate();
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
ImageLoader m_image_loader;
};

View file

@ -46,7 +46,7 @@ HTMLInputElement::~HTMLInputElement()
{
}
RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties* parent_style)
RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const CSS::StyleProperties* parent_style)
{
ASSERT(document().frame());
auto& frame = *document().frame();

View file

@ -35,7 +35,7 @@ public:
HTMLInputElement(DOM::Document&, const FlyString& local_name);
virtual ~HTMLInputElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
String type() const { return attribute(HTML::AttributeNames::type); }
String value() const { return attribute(HTML::AttributeNames::value); }

View file

@ -79,7 +79,7 @@ void HTMLLinkElement::load_stylesheet(const URL& url)
{
// First insert an empty style sheet in the document sheet list.
// There's probably a nicer way to do this, but this ensures that sheets are in document order.
m_style_sheet = StyleSheet::create({});
m_style_sheet = CSS::StyleSheet::create({});
document().style_sheets().add_sheet(*m_style_sheet);
LoadRequest request;

View file

@ -61,7 +61,7 @@ private:
};
unsigned m_relationship { 0 };
RefPtr<StyleSheet> m_style_sheet;
RefPtr<CSS::StyleSheet> m_style_sheet;
};
}

View file

@ -61,7 +61,7 @@ void HTMLObjectElement::parse_attribute(const FlyString& name, const String& val
m_image_loader.load(document().complete_url(value));
}
RefPtr<LayoutNode> HTMLObjectElement::create_layout_node(const StyleProperties* parent_style)
RefPtr<LayoutNode> HTMLObjectElement::create_layout_node(const CSS::StyleProperties* parent_style)
{
if (m_should_show_fallback_content)
return HTMLElement::create_layout_node(parent_style);

View file

@ -46,7 +46,7 @@ public:
String type() const { return attribute(HTML::AttributeNames::type); }
private:
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
ImageLoader m_image_loader;
bool m_should_show_fallback_content { false };

View file

@ -52,7 +52,7 @@ void HTMLStyleElement::children_changed()
if (m_stylesheet)
document().style_sheets().add_sheet(*m_stylesheet);
else
document().style_sheets().add_sheet(StyleSheet::create({}));
document().style_sheets().add_sheet(CSS::StyleSheet::create({}));
HTMLElement::children_changed();
}

View file

@ -30,8 +30,6 @@
namespace Web {
class StyleSheet;
class HTMLStyleElement : public HTMLElement {
public:
HTMLStyleElement(DOM::Document&, const FlyString& local_name);
@ -41,7 +39,7 @@ public:
virtual void removed_from(Node&) override;
private:
RefPtr<StyleSheet> m_stylesheet;
RefPtr<CSS::StyleSheet> m_stylesheet;
};
}

View file

@ -38,13 +38,13 @@ HTMLTableCellElement::~HTMLTableCellElement()
{
}
void HTMLTableCellElement::apply_presentational_hints(StyleProperties& style) const
void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::bgcolor) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, ColorStyleValue::create(color.value()));
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
return;
}
if (name == HTML::AttributeNames::align) {

View file

@ -36,7 +36,7 @@ public:
virtual ~HTMLTableCellElement() override;
private:
virtual void apply_presentational_hints(StyleProperties&) const override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
};
}

View file

@ -38,7 +38,7 @@ HTMLTableElement::~HTMLTableElement()
{
}
void HTMLTableElement::apply_presentational_hints(StyleProperties& style) const
void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::width) {
@ -49,7 +49,7 @@ void HTMLTableElement::apply_presentational_hints(StyleProperties& style) const
if (name == HTML::AttributeNames::bgcolor) {
auto color = Color::from_string(value);
if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, ColorStyleValue::create(color.value()));
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
return;
}
});

View file

@ -36,7 +36,7 @@ public:
virtual ~HTMLTableElement() override;
private:
virtual void apply_presentational_hints(StyleProperties&) const override;
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
};
}