From 120cd44011f15bb101a94d181822b1de8eb82d73 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 22 May 2020 21:45:00 +0200 Subject: [PATCH] LibWeb: Move Attribute to its own header file This will allow us to use it without including Element.h --- Libraries/LibWeb/DOM/Attribute.h | 51 ++++++++++++++++++++++++++++++++ Libraries/LibWeb/DOM/Element.h | 21 ++----------- 2 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 Libraries/LibWeb/DOM/Attribute.h diff --git a/Libraries/LibWeb/DOM/Attribute.h b/Libraries/LibWeb/DOM/Attribute.h new file mode 100644 index 0000000000..32ca3d11b4 --- /dev/null +++ b/Libraries/LibWeb/DOM/Attribute.h @@ -0,0 +1,51 @@ +/* + * 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 + +namespace Web { + +class Attribute { +public: + Attribute(const FlyString& name, const String& value) + : m_name(name) + , m_value(value) + { + } + + const FlyString& name() const { return m_name; } + const String& value() const { return m_value; } + + void set_value(const String& value) { m_value = value; } + +private: + FlyString m_name; + String m_value; +}; + +} diff --git a/Libraries/LibWeb/DOM/Element.h b/Libraries/LibWeb/DOM/Element.h index f1602d4b07..70c9d83f6b 100644 --- a/Libraries/LibWeb/DOM/Element.h +++ b/Libraries/LibWeb/DOM/Element.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -35,24 +36,6 @@ namespace Web { class LayoutNodeWithStyle; -class Attribute { -public: - Attribute(const FlyString& name, const String& value) - : m_name(name) - , m_value(value) - { - } - - const FlyString& name() const { return m_name; } - const String& value() const { return m_value; } - - void set_value(const String& value) { m_value = value; } - -private: - FlyString m_name; - String m_value; -}; - class Element : public ParentNode { public: using WrapperType = Bindings::ElementWrapper; @@ -77,7 +60,7 @@ public: bool has_class(const StringView&) const; - virtual void apply_presentational_hints(StyleProperties&) const {} + virtual void apply_presentational_hints(StyleProperties&) const { } virtual void parse_attribute(const FlyString& name, const String& value); void recompute_style();