LibWeb: Rename CompositeStyleValue -> ShorthandStyleValue

It's a shorthand, so let's call it that. :^)
This commit is contained in:
Sam Atkins 2023-09-19 12:21:15 +01:00 committed by Sam Atkins
parent 69482f1f14
commit d20254f1bc
Notes: sideshowbarker 2024-07-17 09:48:50 +09:00
9 changed files with 24 additions and 24 deletions

View file

@ -11,7 +11,6 @@ source_set("StyleValues") {
"BorderStyleValue.cpp",
"CalculatedStyleValue.cpp",
"ColorStyleValue.cpp",
"CompositeStyleValue.cpp",
"ConicGradientStyleValue.cpp",
"ContentStyleValue.cpp",
"DisplayStyleValue.cpp",
@ -44,6 +43,7 @@ source_set("StyleValues") {
"RadialGradientStyleValue.cpp",
"RectStyleValue.cpp",
"ShadowStyleValue.cpp",
"ShorthandStyleValue.cpp",
"StyleValueList.cpp",
"TextDecorationStyleValue.cpp",
"TransformationStyleValue.cpp",

View file

@ -88,7 +88,6 @@ set(SOURCES
CSS/StyleValues/BorderStyleValue.cpp
CSS/StyleValues/CalculatedStyleValue.cpp
CSS/StyleValues/ColorStyleValue.cpp
CSS/StyleValues/CompositeStyleValue.cpp
CSS/StyleValues/ConicGradientStyleValue.cpp
CSS/StyleValues/ContentStyleValue.cpp
CSS/StyleValues/DisplayStyleValue.cpp
@ -121,6 +120,7 @@ set(SOURCES
CSS/StyleValues/RadialGradientStyleValue.cpp
CSS/StyleValues/RectStyleValue.cpp
CSS/StyleValues/ShadowStyleValue.cpp
CSS/StyleValues/ShorthandStyleValue.cpp
CSS/StyleValues/StyleValueList.cpp
CSS/StyleValues/TextDecorationStyleValue.cpp
CSS/StyleValues/TransformationStyleValue.cpp

View file

@ -42,7 +42,6 @@
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/CompositeStyleValue.h>
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
@ -80,6 +79,7 @@
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/RevertStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
@ -6003,7 +6003,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
longhand_values.unchecked_append(StyleValueList::create(move(it.value), StyleValueList::Separator::Space));
}
return { CompositeStyleValue::create(move(longhand_properties), move(longhand_values)) };
return { ShorthandStyleValue::create(move(longhand_properties), move(longhand_values)) };
}
RefPtr<StyleValue> Parser::parse_css_value_for_property(PropertyID property_id, TokenStream<ComponentValue>& tokens)

View file

@ -35,7 +35,6 @@
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/CompositeStyleValue.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
@ -61,6 +60,7 @@
#include <LibWeb/CSS/StyleValues/PlaceSelfStyleValue.h>
#include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>
@ -442,10 +442,10 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
return;
}
if (value.is_composite()) {
auto& composite_value = value.as_composite();
auto& properties = composite_value.sub_properties();
auto& values = composite_value.values();
if (value.is_shorthand()) {
auto& shorthand_value = value.as_shorthand();
auto& properties = shorthand_value.sub_properties();
auto& values = shorthand_value.values();
for (size_t i = 0; i < properties.size(); ++i)
set_property_expanding_shorthands(style, properties[i], values[i], document, declaration, properties_for_revert);
}

View file

@ -20,7 +20,6 @@
#include <LibWeb/CSS/StyleValues/BorderStyleValue.h>
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
#include <LibWeb/CSS/StyleValues/CompositeStyleValue.h>
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
@ -61,6 +60,7 @@
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
#include <LibWeb/CSS/StyleValues/RevertStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
#include <LibWeb/CSS/StyleValues/TextDecorationStyleValue.h>

View file

@ -92,7 +92,6 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
__ENUMERATE_STYLE_VALUE_TYPE(BorderRadiusShorthand, border_radius_shorthand) \
__ENUMERATE_STYLE_VALUE_TYPE(Calculated, calculated) \
__ENUMERATE_STYLE_VALUE_TYPE(Color, color) \
__ENUMERATE_STYLE_VALUE_TYPE(Composite, composite) \
__ENUMERATE_STYLE_VALUE_TYPE(ConicGradient, conic_gradient) \
__ENUMERATE_STYLE_VALUE_TYPE(Content, content) \
__ENUMERATE_STYLE_VALUE_TYPE(CustomIdent, custom_ident) \
@ -133,6 +132,7 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
__ENUMERATE_STYLE_VALUE_TYPE(Resolution, resolution) \
__ENUMERATE_STYLE_VALUE_TYPE(Revert, revert) \
__ENUMERATE_STYLE_VALUE_TYPE(Shadow, shadow) \
__ENUMERATE_STYLE_VALUE_TYPE(Shorthand, shorthand) \
__ENUMERATE_STYLE_VALUE_TYPE(String, string) \
__ENUMERATE_STYLE_VALUE_TYPE(TextDecoration, text_decoration) \
__ENUMERATE_STYLE_VALUE_TYPE(Time, time) \

View file

@ -4,24 +4,24 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "CompositeStyleValue.h"
#include "ShorthandStyleValue.h"
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
namespace Web::CSS {
CompositeStyleValue::CompositeStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
: StyleValueWithDefaultOperators(Type::Composite)
ShorthandStyleValue::ShorthandStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
: StyleValueWithDefaultOperators(Type::Shorthand)
, m_properties { move(sub_properties), move(values) }
{
if (m_properties.sub_properties.size() != m_properties.values.size()) {
dbgln("CompositeStyleValue: sub_properties and values must be the same size! {} != {}", m_properties.sub_properties.size(), m_properties.values.size());
dbgln("ShorthandStyleValue: sub_properties and values must be the same size! {} != {}", m_properties.sub_properties.size(), m_properties.values.size());
VERIFY_NOT_REACHED();
}
}
CompositeStyleValue::~CompositeStyleValue() = default;
ShorthandStyleValue::~ShorthandStyleValue() = default;
String CompositeStyleValue::to_string() const
String ShorthandStyleValue::to_string() const
{
StringBuilder builder;
auto first = true;

View file

@ -10,23 +10,23 @@
namespace Web::CSS {
class CompositeStyleValue final : public StyleValueWithDefaultOperators<CompositeStyleValue> {
class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> {
public:
static ValueComparingNonnullRefPtr<CompositeStyleValue> create(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
{
return adopt_ref(*new CompositeStyleValue(move(sub_properties), move(values)));
return adopt_ref(*new ShorthandStyleValue(move(sub_properties), move(values)));
}
virtual ~CompositeStyleValue() override;
virtual ~ShorthandStyleValue() override;
Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; }
Vector<ValueComparingNonnullRefPtr<StyleValue const>> const& values() const { return m_properties.values; }
virtual String to_string() const override;
bool properties_equal(CompositeStyleValue const& other) const { return m_properties == other.m_properties; }
bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; }
private:
CompositeStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
ShorthandStyleValue(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values);
struct Properties {
Vector<PropertyID> sub_properties;

View file

@ -94,7 +94,6 @@ class CSSSupportsRule;
class CalculatedStyleValue;
class Clip;
class ColorStyleValue;
class CompositeStyleValue;
class ConicGradientStyleValue;
class ContentStyleValue;
class CustomIdentStyleValue;
@ -164,6 +163,7 @@ class RevertStyleValue;
class Screen;
class Selector;
class ShadowStyleValue;
class ShorthandStyleValue;
class Size;
class StringStyleValue;
class StyleComputer;