From 0759f54bd33f3900c094f27d81481da76b9b4a03 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 13 Mar 2021 20:11:33 +0100 Subject: LibWeb: Rename StyleDeclaration => CSSStyleDeclaration to match CSSOM --- Userland/Libraries/LibWeb/CMakeLists.txt | 2 +- Userland/Libraries/LibWeb/CSS/CSSRule.h | 2 +- .../Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp | 40 +++++++++++++++ .../Libraries/LibWeb/CSS/CSSStyleDeclaration.h | 58 ++++++++++++++++++++++ Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp | 2 +- Userland/Libraries/LibWeb/CSS/CSSStyleRule.h | 10 ++-- .../LibWeb/CSS/Parser/DeprecatedCSSParser.cpp | 10 ++-- .../LibWeb/CSS/Parser/DeprecatedCSSParser.h | 2 +- Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp | 40 --------------- Userland/Libraries/LibWeb/CSS/StyleDeclaration.h | 58 ---------------------- Userland/Libraries/LibWeb/DOM/Element.h | 4 +- Userland/Libraries/LibWeb/Forward.h | 2 +- 12 files changed, 115 insertions(+), 115 deletions(-) create mode 100644 Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp create mode 100644 Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h delete mode 100644 Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp delete mode 100644 Userland/Libraries/LibWeb/CSS/StyleDeclaration.h diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 7e219dc4a8..ea774a9bc7 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -11,6 +11,7 @@ set(SOURCES Bindings/Wrappable.cpp CSS/CSSImportRule.cpp CSS/CSSRule.cpp + CSS/CSSStyleDeclaration.cpp CSS/CSSStyleRule.cpp CSS/CSSStyleSheet.cpp CSS/DefaultStyleSheetSource.cpp @@ -24,7 +25,6 @@ set(SOURCES CSS/QuirksModeStyleSheetSource.cpp CSS/Selector.cpp CSS/SelectorEngine.cpp - CSS/StyleDeclaration.cpp CSS/StyleInvalidator.cpp CSS/StyleProperties.cpp CSS/StyleResolver.cpp diff --git a/Userland/Libraries/LibWeb/CSS/CSSRule.h b/Userland/Libraries/LibWeb/CSS/CSSRule.h index de2a365252..63fa5c1868 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSRule.h @@ -28,8 +28,8 @@ #include #include +#include #include -#include namespace Web::CSS { diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp new file mode 100644 index 0000000000..04b291298a --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018-2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +namespace Web::CSS { + +CSSStyleDeclaration::CSSStyleDeclaration(Vector&& properties) + : m_properties(move(properties)) +{ +} + +CSSStyleDeclaration::~CSSStyleDeclaration() +{ +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h new file mode 100644 index 0000000000..b81b08dcdc --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018-2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include +#include + +namespace Web::CSS { + +struct StyleProperty { + CSS::PropertyID property_id; + NonnullRefPtr value; + bool important { false }; +}; + +class CSSStyleDeclaration : public RefCounted { +public: + static NonnullRefPtr create(Vector&& properties) + { + return adopt(*new CSSStyleDeclaration(move(properties))); + } + + ~CSSStyleDeclaration(); + + const Vector& properties() const { return m_properties; } + +private: + explicit CSSStyleDeclaration(Vector&&); + + Vector m_properties; +}; + +} diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index daaf83d467..72e3791deb 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -28,7 +28,7 @@ namespace Web::CSS { -CSSStyleRule::CSSStyleRule(Vector&& selectors, NonnullRefPtr&& declaration) +CSSStyleRule::CSSStyleRule(Vector&& selectors, NonnullRefPtr&& declaration) : m_selectors(move(selectors)) , m_declaration(move(declaration)) { diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h index bfee3c0b6d..e8db816f6c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.h @@ -29,8 +29,8 @@ #include #include +#include #include -#include namespace Web::CSS { @@ -39,7 +39,7 @@ class CSSStyleRule : public CSSRule { AK_MAKE_NONMOVABLE(CSSStyleRule); public: - static NonnullRefPtr create(Vector&& selectors, NonnullRefPtr&& declaration) + static NonnullRefPtr create(Vector&& selectors, NonnullRefPtr&& declaration) { return adopt(*new CSSStyleRule(move(selectors), move(declaration))); } @@ -47,16 +47,16 @@ public: ~CSSStyleRule(); const Vector& selectors() const { return m_selectors; } - const StyleDeclaration& declaration() const { return m_declaration; } + const CSSStyleDeclaration& declaration() const { return m_declaration; } virtual StringView class_name() const { return "CSSStyleRule"; }; virtual Type type() const { return Type::Style; }; private: - CSSStyleRule(Vector&&, NonnullRefPtr&&); + CSSStyleRule(Vector&&, NonnullRefPtr&&); Vector m_selectors; - NonnullRefPtr m_declaration; + NonnullRefPtr m_declaration; }; } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp index f565186ef2..3c6b0e15f3 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.cpp @@ -808,7 +808,7 @@ public: return; } - rules.append(CSS::CSSStyleRule::create(move(current_rule.selectors), CSS::StyleDeclaration::create(move(current_rule.properties)))); + rules.append(CSS::CSSStyleRule::create(move(current_rule.selectors), CSS::CSSStyleDeclaration::create(move(current_rule.properties)))); } Optional parse_string() @@ -947,7 +947,7 @@ public: return CSS::CSSStyleSheet::create(move(rules)); } - RefPtr parse_standalone_declaration() + RefPtr parse_standalone_declaration() { consume_whitespace_or_comments(); for (;;) { @@ -958,7 +958,7 @@ public: if (!peek()) break; } - return CSS::StyleDeclaration::create(move(current_rule.properties)); + return CSS::CSSStyleDeclaration::create(move(current_rule.properties)); } private: @@ -993,10 +993,10 @@ RefPtr parse_css(const CSS::ParsingContext& context, const S return parser.parse_sheet(); } -RefPtr parse_css_declaration(const CSS::ParsingContext& context, const StringView& css) +RefPtr parse_css_declaration(const CSS::ParsingContext& context, const StringView& css) { if (css.is_empty()) - return CSS::StyleDeclaration::create({}); + return CSS::CSSStyleDeclaration::create({}); CSSParser parser(context, css); return parser.parse_standalone_declaration(); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.h b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.h index bf1da4229e..e03c83ba59 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/DeprecatedCSSParser.h @@ -49,7 +49,7 @@ private: namespace Web { RefPtr parse_css(const CSS::ParsingContext&, const StringView&); -RefPtr parse_css_declaration(const CSS::ParsingContext&, const StringView&); +RefPtr parse_css_declaration(const CSS::ParsingContext&, const StringView&); RefPtr parse_css_value(const CSS::ParsingContext&, const StringView&, CSS::PropertyID property_id = CSS::PropertyID::Invalid); Optional parse_selector(const CSS::ParsingContext&, const StringView&); diff --git a/Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp deleted file mode 100644 index eb56b94625..0000000000 --- a/Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -namespace Web::CSS { - -StyleDeclaration::StyleDeclaration(Vector&& properties) - : m_properties(move(properties)) -{ -} - -StyleDeclaration::~StyleDeclaration() -{ -} - -} diff --git a/Userland/Libraries/LibWeb/CSS/StyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/StyleDeclaration.h deleted file mode 100644 index 787429eb15..0000000000 --- a/Userland/Libraries/LibWeb/CSS/StyleDeclaration.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include -#include - -namespace Web::CSS { - -struct StyleProperty { - CSS::PropertyID property_id; - NonnullRefPtr value; - bool important { false }; -}; - -class StyleDeclaration : public RefCounted { -public: - static NonnullRefPtr create(Vector&& properties) - { - return adopt(*new StyleDeclaration(move(properties))); - } - - ~StyleDeclaration(); - - const Vector& properties() const { return m_properties; } - -private: - explicit StyleDeclaration(Vector&&); - - Vector m_properties; -}; - -} diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h index a9462caf5b..fdafd19fd8 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.h +++ b/Userland/Libraries/LibWeb/DOM/Element.h @@ -90,7 +90,7 @@ public: const CSS::StyleProperties* specified_css_values() const { return m_specified_css_values.ptr(); } NonnullRefPtr computed_style(); - const CSS::StyleDeclaration* inline_style() const { return m_inline_style; } + const CSS::CSSStyleDeclaration* inline_style() const { return m_inline_style; } // FIXME: innerHTML also appears on shadow roots. https://w3c.github.io/DOM-Parsing/#dom-innerhtml String inner_html() const; @@ -116,7 +116,7 @@ private: QualifiedName m_qualified_name; Vector m_attributes; - RefPtr m_inline_style; + RefPtr m_inline_style; RefPtr m_specified_css_values; diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 5a90a41bb0..3b8e4c4222 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -30,11 +30,11 @@ namespace Web::CSS { class CSSRule; class CSSImportRule; +class CSSStyleDeclaration; class CSSStyleRule; class CSSStyleSheet; class Length; class Selector; -class StyleDeclaration; class StyleProperties; class StyleResolver; class StyleSheet; -- cgit v1.2.3