From 4399ca2d82945297ebd9239a45717616f4957036 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 8 May 2023 06:57:55 +0200 Subject: [PATCH] LibWeb: Don't include CSS/CSSStyleDeclaration.h from DOM/Element.h This required splitting out CSS::StyleProperty into its own file and out-of-lining Element::layout_node(). --- .../LibWeb/CSS/CSSStyleDeclaration.h | 13 +---------- Userland/Libraries/LibWeb/CSS/StyleProperty.h | 23 +++++++++++++++++++ Userland/Libraries/LibWeb/DOM/Element.cpp | 10 ++++++++ Userland/Libraries/LibWeb/DOM/Element.h | 6 ++--- 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 Userland/Libraries/LibWeb/CSS/StyleProperty.h diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index a04eebd38a..6bb10890ab 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -9,22 +9,11 @@ #include #include #include +#include #include namespace Web::CSS { -enum class Important { - No, - Yes, -}; - -struct StyleProperty { - Important important { Important::No }; - CSS::PropertyID property_id; - NonnullRefPtr value; - DeprecatedString custom_name {}; -}; - class CSSStyleDeclaration : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(CSSStyleDeclaration, Bindings::PlatformObject); diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperty.h b/Userland/Libraries/LibWeb/CSS/StyleProperty.h new file mode 100644 index 0000000000..8adfc386f0 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/StyleProperty.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2023, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace Web::CSS { + +enum class Important { + No, + Yes, +}; + +struct StyleProperty { + Important important { Important::No }; + CSS::PropertyID property_id; + NonnullRefPtr value; + DeprecatedString custom_name {}; +}; + +} diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index abc1bc99a0..fe2a649375 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1682,4 +1682,14 @@ void Element::for_each_attribute(Function(Node::layout_node()); +} + +Layout::NodeWithStyle const* Element::layout_node() const +{ + return static_cast(Node::layout_node()); +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index 9254b8ee47..23d4118dd8 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -132,8 +132,8 @@ public: }; NeedsRelayout recompute_style(); - Layout::NodeWithStyle* layout_node() { return static_cast(Node::layout_node()); } - Layout::NodeWithStyle const* layout_node() const { return static_cast(Node::layout_node()); } + Layout::NodeWithStyle* layout_node(); + Layout::NodeWithStyle const* layout_node() const; DeprecatedString name() const { return attribute(HTML::AttributeNames::name); }