1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 19:37:35 +00:00

LibWeb: Rename "Computed" CSSStyleDeclaration => "Resolved"

The original name was based on the window.getComputedStyle() API.
However, "Computed" in "getComputedStyle" is actually a misnomer that
the platform is stuck with due to backwards compatibility.

What getComputedStyle() returns is actually a mix of computed and used
values. The spec calls it the "resolved" values. So let's call this
declaration subclass "ResolvedCSSStyleDeclaration" to match.
This commit is contained in:
Andreas Kling 2021-09-23 12:35:56 +02:00
parent 058d44dcae
commit 3d36e4d944
5 changed files with 18 additions and 18 deletions

View file

@ -17,7 +17,7 @@ set(SOURCES
CSS/CSSStyleDeclaration.cpp CSS/CSSStyleDeclaration.cpp
CSS/CSSStyleRule.cpp CSS/CSSStyleRule.cpp
CSS/CSSStyleSheet.cpp CSS/CSSStyleSheet.cpp
CSS/ComputedCSSStyleDeclaration.cpp CSS/ResolvedCSSStyleDeclaration.cpp
CSS/DefaultStyleSheetSource.cpp CSS/DefaultStyleSheetSource.cpp
CSS/Length.cpp CSS/Length.cpp
CSS/MediaQueryList.cpp CSS/MediaQueryList.cpp

View file

@ -6,28 +6,28 @@
*/ */
#include <AK/NonnullRefPtr.h> #include <AK/NonnullRefPtr.h>
#include <LibWeb/CSS/ComputedCSSStyleDeclaration.h> #include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
#include <LibWeb/CSS/StyleResolver.h> #include <LibWeb/CSS/StyleResolver.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Element.h>
namespace Web::CSS { namespace Web::CSS {
ComputedCSSStyleDeclaration::ComputedCSSStyleDeclaration(DOM::Element& element) ResolvedCSSStyleDeclaration::ResolvedCSSStyleDeclaration(DOM::Element& element)
: m_element(element) : m_element(element)
{ {
} }
ComputedCSSStyleDeclaration::~ComputedCSSStyleDeclaration() ResolvedCSSStyleDeclaration::~ResolvedCSSStyleDeclaration()
{ {
} }
size_t ComputedCSSStyleDeclaration::length() const size_t ResolvedCSSStyleDeclaration::length() const
{ {
return 0; return 0;
} }
String ComputedCSSStyleDeclaration::item(size_t index) const String ResolvedCSSStyleDeclaration::item(size_t index) const
{ {
(void)index; (void)index;
return {}; return {};
@ -379,7 +379,7 @@ static NonnullRefPtr<StyleValue> value_or_default(Optional<StyleProperty> proper
return default_style; return default_style;
} }
RefPtr<StyleValue> ComputedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
{ {
switch (property_id) { switch (property_id) {
case CSS::PropertyID::Float: case CSS::PropertyID::Float:
@ -550,7 +550,7 @@ RefPtr<StyleValue> ComputedCSSStyleDeclaration::style_value_for_property(Layout:
} }
} }
Optional<StyleProperty> ComputedCSSStyleDeclaration::property(PropertyID property_id) const Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID property_id) const
{ {
const_cast<DOM::Document&>(m_element->document()).ensure_layout(); const_cast<DOM::Document&>(m_element->document()).ensure_layout();
@ -575,7 +575,7 @@ Optional<StyleProperty> ComputedCSSStyleDeclaration::property(PropertyID propert
}; };
} }
bool ComputedCSSStyleDeclaration::set_property(PropertyID, StringView) bool ResolvedCSSStyleDeclaration::set_property(PropertyID, StringView)
{ {
return false; return false;
} }

View file

@ -10,14 +10,14 @@
namespace Web::CSS { namespace Web::CSS {
class ComputedCSSStyleDeclaration final : public CSSStyleDeclaration { class ResolvedCSSStyleDeclaration final : public CSSStyleDeclaration {
public: public:
static NonnullRefPtr<ComputedCSSStyleDeclaration> create(DOM::Element& element) static NonnullRefPtr<ResolvedCSSStyleDeclaration> create(DOM::Element& element)
{ {
return adopt_ref(*new ComputedCSSStyleDeclaration(element)); return adopt_ref(*new ResolvedCSSStyleDeclaration(element));
} }
virtual ~ComputedCSSStyleDeclaration() override; virtual ~ResolvedCSSStyleDeclaration() override;
virtual size_t length() const override; virtual size_t length() const override;
virtual String item(size_t index) const override; virtual String item(size_t index) const override;
@ -25,7 +25,7 @@ public:
virtual bool set_property(PropertyID, StringView css_text) override; virtual bool set_property(PropertyID, StringView css_text) override;
private: private:
explicit ComputedCSSStyleDeclaration(DOM::Element&); explicit ResolvedCSSStyleDeclaration(DOM::Element&);
RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const; RefPtr<StyleValue> style_value_for_property(Layout::NodeWithStyle const&, PropertyID) const;

View file

@ -6,9 +6,9 @@
#include <AK/AnyOf.h> #include <AK/AnyOf.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <LibWeb/CSS/ComputedCSSStyleDeclaration.h>
#include <LibWeb/CSS/Parser/Parser.h> #include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h> #include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
#include <LibWeb/CSS/StyleInvalidator.h> #include <LibWeb/CSS/StyleInvalidator.h>
#include <LibWeb/DOM/DOMException.h> #include <LibWeb/DOM/DOMException.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
@ -231,7 +231,7 @@ void Element::recompute_style()
NonnullRefPtr<CSS::StyleProperties> Element::computed_style() NonnullRefPtr<CSS::StyleProperties> Element::computed_style()
{ {
auto element_computed_style = CSS::ComputedCSSStyleDeclaration::create(*this); auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this);
auto properties = CSS::StyleProperties::create(); auto properties = CSS::StyleProperties::create();
for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) { for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {

View file

@ -6,7 +6,7 @@
#include <LibGUI/DisplayLink.h> #include <LibGUI/DisplayLink.h>
#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/FunctionObject.h>
#include <LibWeb/CSS/ComputedCSSStyleDeclaration.h> #include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/EventDispatcher.h> #include <LibWeb/DOM/EventDispatcher.h>
@ -252,7 +252,7 @@ Page const* Window::page() const
NonnullRefPtr<CSS::CSSStyleDeclaration> Window::get_computed_style(DOM::Element& element) const NonnullRefPtr<CSS::CSSStyleDeclaration> Window::get_computed_style(DOM::Element& element) const
{ {
return CSS::ComputedCSSStyleDeclaration::create(element); return CSS::ResolvedCSSStyleDeclaration::create(element);
} }
NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media) NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media)