mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibWeb: Replace FlexFlowStyleValue with ShorthandStyleValue
This commit is contained in:
parent
aa45b3dfe3
commit
1ae515c0b7
10 changed files with 5 additions and 79 deletions
|
@ -17,7 +17,6 @@ source_set("StyleValues") {
|
||||||
"EasingStyleValue.cpp",
|
"EasingStyleValue.cpp",
|
||||||
"EdgeStyleValue.cpp",
|
"EdgeStyleValue.cpp",
|
||||||
"FilterValueListStyleValue.cpp",
|
"FilterValueListStyleValue.cpp",
|
||||||
"FlexFlowStyleValue.cpp",
|
|
||||||
"FontStyleValue.cpp",
|
"FontStyleValue.cpp",
|
||||||
"GridAreaShorthandStyleValue.cpp",
|
"GridAreaShorthandStyleValue.cpp",
|
||||||
"GridAutoFlowStyleValue.cpp",
|
"GridAutoFlowStyleValue.cpp",
|
||||||
|
|
|
@ -94,7 +94,6 @@ set(SOURCES
|
||||||
CSS/StyleValues/EasingStyleValue.cpp
|
CSS/StyleValues/EasingStyleValue.cpp
|
||||||
CSS/StyleValues/EdgeStyleValue.cpp
|
CSS/StyleValues/EdgeStyleValue.cpp
|
||||||
CSS/StyleValues/FilterValueListStyleValue.cpp
|
CSS/StyleValues/FilterValueListStyleValue.cpp
|
||||||
CSS/StyleValues/FlexFlowStyleValue.cpp
|
|
||||||
CSS/StyleValues/FontStyleValue.cpp
|
CSS/StyleValues/FontStyleValue.cpp
|
||||||
CSS/StyleValues/GridAreaShorthandStyleValue.cpp
|
CSS/StyleValues/GridAreaShorthandStyleValue.cpp
|
||||||
CSS/StyleValues/GridAutoFlowStyleValue.cpp
|
CSS/StyleValues/GridAutoFlowStyleValue.cpp
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
||||||
|
@ -3973,7 +3972,9 @@ RefPtr<StyleValue> Parser::parse_flex_flow_value(Vector<ComponentValue> const& c
|
||||||
if (!flex_wrap)
|
if (!flex_wrap)
|
||||||
flex_wrap = property_initial_value(m_context.realm(), PropertyID::FlexWrap);
|
flex_wrap = property_initial_value(m_context.realm(), PropertyID::FlexWrap);
|
||||||
|
|
||||||
return FlexFlowStyleValue::create(flex_direction.release_nonnull(), flex_wrap.release_nonnull());
|
return ShorthandStyleValue::create(PropertyID::FlexFlow,
|
||||||
|
{ PropertyID::FlexDirection, PropertyID::FlexWrap },
|
||||||
|
{ flex_direction.release_nonnull(), flex_wrap.release_nonnull() });
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_generic_font_family(ValueID identifier)
|
static bool is_generic_font_family(ValueID identifier)
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementShorthandStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridTrackPlacementShorthandStyleValue.h>
|
||||||
|
@ -806,13 +805,6 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_id == CSS::PropertyID::FlexFlow) {
|
if (property_id == CSS::PropertyID::FlexFlow) {
|
||||||
if (value.is_flex_flow()) {
|
|
||||||
auto const& flex_flow = value.as_flex_flow();
|
|
||||||
set_longhand_property(CSS::PropertyID::FlexDirection, flex_flow.flex_direction());
|
|
||||||
set_longhand_property(CSS::PropertyID::FlexWrap, flex_flow.flex_wrap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
set_longhand_property(CSS::PropertyID::FlexDirection, value);
|
set_longhand_property(CSS::PropertyID::FlexDirection, value);
|
||||||
set_longhand_property(CSS::PropertyID::FlexWrap, value);
|
set_longhand_property(CSS::PropertyID::FlexWrap, value);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FlexFlowStyleValue.h>
|
|
||||||
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
||||||
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
|
||||||
|
|
|
@ -99,7 +99,6 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(Easing, easing) \
|
__ENUMERATE_STYLE_VALUE_TYPE(Easing, easing) \
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(Edge, edge) \
|
__ENUMERATE_STYLE_VALUE_TYPE(Edge, edge) \
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(FilterValueList, filter_value_list) \
|
__ENUMERATE_STYLE_VALUE_TYPE(FilterValueList, filter_value_list) \
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(FlexFlow, flex_flow) \
|
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(Font, font) \
|
__ENUMERATE_STYLE_VALUE_TYPE(Font, font) \
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(Frequency, frequency) \
|
__ENUMERATE_STYLE_VALUE_TYPE(Frequency, frequency) \
|
||||||
__ENUMERATE_STYLE_VALUE_TYPE(GridAreaShorthand, grid_area_shorthand) \
|
__ENUMERATE_STYLE_VALUE_TYPE(GridAreaShorthand, grid_area_shorthand) \
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
||||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
||||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
||||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FlexFlowStyleValue.h"
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
|
||||||
|
|
||||||
String FlexFlowStyleValue::to_string() const
|
|
||||||
{
|
|
||||||
return MUST(String::formatted("{} {}", m_properties.flex_direction->to_string(), m_properties.flex_wrap->to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
||||||
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
||||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
||||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <LibWeb/CSS/StyleValue.h>
|
|
||||||
|
|
||||||
namespace Web::CSS {
|
|
||||||
|
|
||||||
class FlexFlowStyleValue final : public StyleValueWithDefaultOperators<FlexFlowStyleValue> {
|
|
||||||
public:
|
|
||||||
static ValueComparingNonnullRefPtr<FlexFlowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
|
|
||||||
{
|
|
||||||
return adopt_ref(*new (nothrow) FlexFlowStyleValue(move(flex_direction), move(flex_wrap)));
|
|
||||||
}
|
|
||||||
virtual ~FlexFlowStyleValue() override = default;
|
|
||||||
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> flex_direction() const { return m_properties.flex_direction; }
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> flex_wrap() const { return m_properties.flex_wrap; }
|
|
||||||
|
|
||||||
virtual String to_string() const override;
|
|
||||||
|
|
||||||
bool properties_equal(FlexFlowStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
FlexFlowStyleValue(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
|
|
||||||
: StyleValueWithDefaultOperators(Type::FlexFlow)
|
|
||||||
, m_properties { .flex_direction = move(flex_direction), .flex_wrap = move(flex_wrap) }
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Properties {
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> flex_direction;
|
|
||||||
ValueComparingNonnullRefPtr<StyleValue> flex_wrap;
|
|
||||||
bool operator==(Properties const&) const = default;
|
|
||||||
} m_properties;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -37,6 +37,8 @@ String ShorthandStyleValue::to_string() const
|
||||||
switch (m_properties.shorthand_property) {
|
switch (m_properties.shorthand_property) {
|
||||||
case PropertyID::Flex:
|
case PropertyID::Flex:
|
||||||
return MUST(String::formatted("{} {} {}", longhand(PropertyID::FlexGrow)->to_string(), longhand(PropertyID::FlexShrink)->to_string(), longhand(PropertyID::FlexBasis)->to_string()));
|
return MUST(String::formatted("{} {} {}", longhand(PropertyID::FlexGrow)->to_string(), longhand(PropertyID::FlexShrink)->to_string(), longhand(PropertyID::FlexBasis)->to_string()));
|
||||||
|
case PropertyID::FlexFlow:
|
||||||
|
return MUST(String::formatted("{} {}", longhand(PropertyID::FlexDirection)->to_string(), longhand(PropertyID::FlexWrap)->to_string()));
|
||||||
default:
|
default:
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
auto first = true;
|
auto first = true;
|
||||||
|
|
|
@ -104,7 +104,6 @@ class EdgeStyleValue;
|
||||||
class ElementInlineCSSStyleDeclaration;
|
class ElementInlineCSSStyleDeclaration;
|
||||||
class ExplicitGridTrack;
|
class ExplicitGridTrack;
|
||||||
class FilterValueListStyleValue;
|
class FilterValueListStyleValue;
|
||||||
class FlexFlowStyleValue;
|
|
||||||
class FontFace;
|
class FontFace;
|
||||||
class FontStyleValue;
|
class FontStyleValue;
|
||||||
class Frequency;
|
class Frequency;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue