mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWeb: Rename IdentifierStyleValue -> CSSKeywordValue
This matches the name in the CSS Typed OM spec. https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
This commit is contained in:
parent
0e3487b9ab
commit
9559f0f123
Notes:
github-actions[bot]
2024-08-15 12:59:38 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/9559f0f123f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1076
25 changed files with 137 additions and 136 deletions
|
@ -7,6 +7,7 @@ source_set("StyleValues") {
|
|||
"BackgroundSizeStyleValue.cpp",
|
||||
"BasicShapeStyleValue.cpp",
|
||||
"BorderRadiusStyleValue.cpp",
|
||||
"CSSKeywordValue.cpp",
|
||||
"CalculatedStyleValue.cpp",
|
||||
"ColorStyleValue.cpp",
|
||||
"ConicGradientStyleValue.cpp",
|
||||
|
@ -19,7 +20,6 @@ source_set("StyleValues") {
|
|||
"GridTemplateAreaStyleValue.cpp",
|
||||
"GridTrackPlacementStyleValue.cpp",
|
||||
"GridTrackSizeListStyleValue.cpp",
|
||||
"IdentifierStyleValue.cpp",
|
||||
"ImageStyleValue.cpp",
|
||||
"IntegerStyleValue.cpp",
|
||||
"LengthStyleValue.cpp",
|
||||
|
|
|
@ -113,6 +113,7 @@ set(SOURCES
|
|||
CSS/StyleValues/ContentStyleValue.cpp
|
||||
CSS/StyleValues/CounterDefinitionsStyleValue.cpp
|
||||
CSS/StyleValues/CounterStyleValue.cpp
|
||||
CSS/StyleValues/CSSKeywordValue.cpp
|
||||
CSS/StyleValues/DisplayStyleValue.cpp
|
||||
CSS/StyleValues/EasingStyleValue.cpp
|
||||
CSS/StyleValues/EdgeStyleValue.cpp
|
||||
|
@ -121,7 +122,6 @@ set(SOURCES
|
|||
CSS/StyleValues/GridTemplateAreaStyleValue.cpp
|
||||
CSS/StyleValues/GridTrackPlacementStyleValue.cpp
|
||||
CSS/StyleValues/GridTrackSizeListStyleValue.cpp
|
||||
CSS/StyleValues/IdentifierStyleValue.cpp
|
||||
CSS/StyleValues/ImageStyleValue.cpp
|
||||
CSS/StyleValues/IntegerStyleValue.cpp
|
||||
CSS/StyleValues/LengthStyleValue.cpp
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
|
||||
|
@ -33,7 +34,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/InheritStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
|
||||
|
@ -206,10 +206,10 @@ GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() cons
|
|||
return static_cast<GridTrackSizeListStyleValue const&>(*this);
|
||||
}
|
||||
|
||||
IdentifierStyleValue const& CSSStyleValue::as_identifier() const
|
||||
CSSKeywordValue const& CSSStyleValue::as_keyword() const
|
||||
{
|
||||
VERIFY(is_identifier());
|
||||
return static_cast<IdentifierStyleValue const&>(*this);
|
||||
VERIFY(is_keyword());
|
||||
return static_cast<CSSKeywordValue const&>(*this);
|
||||
}
|
||||
|
||||
ImageStyleValue const& CSSStyleValue::as_image() const
|
||||
|
@ -375,20 +375,20 @@ ValueComparingNonnullRefPtr<CSSStyleValue const> CSSStyleValue::absolutized(CSSP
|
|||
|
||||
bool CSSStyleValue::has_auto() const
|
||||
{
|
||||
return is_identifier() && as_identifier().id() == ValueID::Auto;
|
||||
return is_keyword() && as_keyword().id() == ValueID::Auto;
|
||||
}
|
||||
|
||||
ValueID CSSStyleValue::to_identifier() const
|
||||
{
|
||||
if (is_identifier())
|
||||
return as_identifier().id();
|
||||
if (is_keyword())
|
||||
return as_keyword().id();
|
||||
return ValueID::Invalid;
|
||||
}
|
||||
|
||||
int CSSStyleValue::to_font_weight() const
|
||||
{
|
||||
if (is_identifier()) {
|
||||
switch (static_cast<IdentifierStyleValue const&>(*this).id()) {
|
||||
if (is_keyword()) {
|
||||
switch (static_cast<CSSKeywordValue const&>(*this).id()) {
|
||||
case CSS::ValueID::Normal:
|
||||
return Gfx::FontWeight::Regular;
|
||||
case CSS::ValueID::Bold:
|
||||
|
@ -417,8 +417,8 @@ int CSSStyleValue::to_font_weight() const
|
|||
int CSSStyleValue::to_font_slope() const
|
||||
{
|
||||
// FIXME: Implement oblique <angle>
|
||||
if (is_identifier()) {
|
||||
switch (static_cast<IdentifierStyleValue const&>(*this).id()) {
|
||||
if (is_keyword()) {
|
||||
switch (static_cast<CSSKeywordValue const&>(*this).id()) {
|
||||
case CSS::ValueID::Italic: {
|
||||
static int italic_slope = Gfx::name_to_slope("Italic"sv);
|
||||
return italic_slope;
|
||||
|
@ -438,8 +438,8 @@ int CSSStyleValue::to_font_slope() const
|
|||
int CSSStyleValue::to_font_stretch_width() const
|
||||
{
|
||||
int width = Gfx::FontWidth::Normal;
|
||||
if (is_identifier()) {
|
||||
switch (static_cast<IdentifierStyleValue const&>(*this).id()) {
|
||||
if (is_keyword()) {
|
||||
switch (static_cast<CSSKeywordValue const&>(*this).id()) {
|
||||
case CSS::ValueID::UltraCondensed:
|
||||
width = Gfx::FontWidth::UltraCondensed;
|
||||
break;
|
||||
|
|
|
@ -110,11 +110,11 @@ public:
|
|||
GridTemplateArea,
|
||||
GridTrackPlacement,
|
||||
GridTrackSizeList,
|
||||
Identifier,
|
||||
Image,
|
||||
Inherit,
|
||||
Initial,
|
||||
Integer,
|
||||
Keyword,
|
||||
Length,
|
||||
LinearGradient,
|
||||
MathDepth,
|
||||
|
@ -236,10 +236,6 @@ public:
|
|||
GridTrackSizeListStyleValue const& as_grid_track_size_list() const;
|
||||
GridTrackSizeListStyleValue& as_grid_track_size_list() { return const_cast<GridTrackSizeListStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_grid_track_size_list()); }
|
||||
|
||||
bool is_identifier() const { return type() == Type::Identifier; }
|
||||
IdentifierStyleValue const& as_identifier() const;
|
||||
IdentifierStyleValue& as_identifier() { return const_cast<IdentifierStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_identifier()); }
|
||||
|
||||
bool is_image() const { return type() == Type::Image; }
|
||||
ImageStyleValue const& as_image() const;
|
||||
ImageStyleValue& as_image() { return const_cast<ImageStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_image()); }
|
||||
|
@ -256,6 +252,10 @@ public:
|
|||
IntegerStyleValue const& as_integer() const;
|
||||
IntegerStyleValue& as_integer() { return const_cast<IntegerStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_integer()); }
|
||||
|
||||
bool is_keyword() const { return type() == Type::Keyword; }
|
||||
CSSKeywordValue const& as_keyword() const;
|
||||
CSSKeywordValue& as_keyword() { return const_cast<CSSKeywordValue&>(const_cast<CSSStyleValue const&>(*this).as_keyword()); }
|
||||
|
||||
bool is_length() const { return type() == Type::Length; }
|
||||
LengthStyleValue const& as_length() const;
|
||||
LengthStyleValue& as_length() { return const_cast<LengthStyleValue&>(const_cast<CSSStyleValue const&>(*this).as_length()); }
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
|
||||
|
@ -57,7 +58,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/InheritStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
|
||||
|
@ -2378,7 +2378,7 @@ RefPtr<CSSStyleValue> Parser::parse_identifier_value(TokenStream<ComponentValue>
|
|||
auto value_id = value_id_from_string(peek_token.token().ident());
|
||||
if (value_id.has_value()) {
|
||||
(void)tokens.next_token(); // ident
|
||||
return IdentifierStyleValue::create(value_id.value());
|
||||
return CSSKeywordValue::create(value_id.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3231,7 +3231,7 @@ RefPtr<CSSStyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tok
|
|||
switch (*maybe_ident) {
|
||||
case ValueID::None:
|
||||
(void)tokens.next_token();
|
||||
return IdentifierStyleValue::create(*maybe_ident);
|
||||
return CSSKeywordValue::create(*maybe_ident);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -3626,7 +3626,7 @@ RefPtr<CSSStyleValue> Parser::parse_all_as_single_none_value(TokenStream<Compone
|
|||
return {};
|
||||
|
||||
transaction.commit();
|
||||
return IdentifierStyleValue::create(ValueID::None);
|
||||
return CSSKeywordValue::create(ValueID::None);
|
||||
}
|
||||
|
||||
static void remove_property(Vector<PropertyID>& properties, PropertyID property_to_remove)
|
||||
|
@ -3654,7 +3654,7 @@ RefPtr<CSSStyleValue> Parser::parse_aspect_ratio_value(TokenStream<ComponentValu
|
|||
continue;
|
||||
}
|
||||
|
||||
if (maybe_value->is_identifier() && maybe_value->as_identifier().id() == ValueID::Auto) {
|
||||
if (maybe_value->is_keyword() && maybe_value->as_keyword().id() == ValueID::Auto) {
|
||||
if (auto_value)
|
||||
return nullptr;
|
||||
auto_value = maybe_value.release_nonnull();
|
||||
|
@ -3943,7 +3943,7 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_position_x_or_y_value(Toke
|
|||
if (!value)
|
||||
return nullptr;
|
||||
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
auto identifier = value->to_identifier();
|
||||
if (identifier == ValueID::Center) {
|
||||
transaction.commit();
|
||||
|
@ -4819,9 +4819,9 @@ RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& toke
|
|||
return make_flex_shorthand(one, one, *value);
|
||||
}
|
||||
case PropertyID::Flex: {
|
||||
if (value->is_identifier() && value->to_identifier() == ValueID::None) {
|
||||
if (value->is_keyword() && value->to_identifier() == ValueID::None) {
|
||||
auto zero = NumberStyleValue::create(0);
|
||||
return make_flex_shorthand(zero, zero, IdentifierStyleValue::create(ValueID::Auto));
|
||||
return make_flex_shorthand(zero, zero, CSSKeywordValue::create(ValueID::Auto));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -5091,7 +5091,7 @@ RefPtr<CSSStyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue
|
|||
(void)tokens.next_token(); // Ident
|
||||
if (!next_is_comma_or_eof())
|
||||
return nullptr;
|
||||
font_families.append(IdentifierStyleValue::create(maybe_ident.value()));
|
||||
font_families.append(CSSKeywordValue::create(maybe_ident.value()));
|
||||
(void)tokens.next_token(); // Comma
|
||||
continue;
|
||||
}
|
||||
|
@ -5381,14 +5381,14 @@ RefPtr<CSSStyleValue> Parser::parse_list_style_value(TokenStream<ComponentValue>
|
|||
if (found_nones == 2) {
|
||||
if (list_image || list_type)
|
||||
return nullptr;
|
||||
auto none = IdentifierStyleValue::create(ValueID::None);
|
||||
auto none = CSSKeywordValue::create(ValueID::None);
|
||||
list_image = none;
|
||||
list_type = none;
|
||||
|
||||
} else if (found_nones == 1) {
|
||||
if (list_image && list_type)
|
||||
return nullptr;
|
||||
auto none = IdentifierStyleValue::create(ValueID::None);
|
||||
auto none = CSSKeywordValue::create(ValueID::None);
|
||||
if (!list_image)
|
||||
list_image = none;
|
||||
if (!list_type)
|
||||
|
@ -6011,7 +6011,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
|
|||
return AxisOffset { Axis::None, value->as_percentage() };
|
||||
if (value->is_length())
|
||||
return AxisOffset { Axis::None, value->as_length() };
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
switch (value->to_identifier()) {
|
||||
case ValueID::Top:
|
||||
return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(0)) };
|
||||
|
@ -7343,7 +7343,7 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
|
|||
if (ident.has_value()) {
|
||||
if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) {
|
||||
(void)tokens.next_token();
|
||||
return PropertyAndValue { *property, IdentifierStyleValue::create(ident.value()) };
|
||||
return PropertyAndValue { *property, CSSKeywordValue::create(ident.value()) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/InitialStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
|
@ -100,7 +100,7 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_background_property(La
|
|||
static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
|
||||
{
|
||||
if (length_percentage.is_auto())
|
||||
return IdentifierStyleValue::create(ValueID::Auto);
|
||||
return CSSKeywordValue::create(ValueID::Auto);
|
||||
if (length_percentage.is_percentage())
|
||||
return PercentageStyleValue::create(length_percentage.percentage());
|
||||
if (length_percentage.is_length())
|
||||
|
@ -111,22 +111,22 @@ static NonnullRefPtr<CSSStyleValue const> style_value_for_length_percentage(Leng
|
|||
static NonnullRefPtr<CSSStyleValue const> style_value_for_size(Size const& size)
|
||||
{
|
||||
if (size.is_none())
|
||||
return IdentifierStyleValue::create(ValueID::None);
|
||||
return CSSKeywordValue::create(ValueID::None);
|
||||
if (size.is_percentage())
|
||||
return PercentageStyleValue::create(size.percentage());
|
||||
if (size.is_length())
|
||||
return LengthStyleValue::create(size.length());
|
||||
if (size.is_auto())
|
||||
return IdentifierStyleValue::create(ValueID::Auto);
|
||||
return CSSKeywordValue::create(ValueID::Auto);
|
||||
if (size.is_calculated())
|
||||
return size.calculated();
|
||||
if (size.is_min_content())
|
||||
return IdentifierStyleValue::create(ValueID::MinContent);
|
||||
return CSSKeywordValue::create(ValueID::MinContent);
|
||||
if (size.is_max_content())
|
||||
return IdentifierStyleValue::create(ValueID::MaxContent);
|
||||
return CSSKeywordValue::create(ValueID::MaxContent);
|
||||
// FIXME: Support fit-content(<length>)
|
||||
if (size.is_fit_content())
|
||||
return IdentifierStyleValue::create(ValueID::FitContent);
|
||||
return CSSKeywordValue::create(ValueID::FitContent);
|
||||
TODO();
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ static RefPtr<CSSStyleValue const> style_value_for_length_box_logical_side(Layou
|
|||
static RefPtr<CSSStyleValue const> style_value_for_shadow(Vector<ShadowData> const& shadow_data)
|
||||
{
|
||||
if (shadow_data.is_empty())
|
||||
return IdentifierStyleValue::create(ValueID::None);
|
||||
return CSSKeywordValue::create(ValueID::None);
|
||||
|
||||
auto make_shadow_style_value = [](ShadowData const& shadow) {
|
||||
return ShadowStyleValue::create(
|
||||
|
@ -263,7 +263,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
// The resolved value is normal if the computed value is normal, or the used value otherwise.
|
||||
case PropertyID::LineHeight: {
|
||||
auto line_height = get_computed_value(property_id);
|
||||
if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal)
|
||||
if (line_height->is_keyword() && line_height->to_identifier() == ValueID::Normal)
|
||||
return line_height;
|
||||
return LengthStyleValue::create(Length::make_px(layout_node.computed_values().line_height()));
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
case PropertyID::Transform: {
|
||||
auto transformations = layout_node.computed_values().transformations();
|
||||
if (transformations.is_empty())
|
||||
return IdentifierStyleValue::create(ValueID::None);
|
||||
return CSSKeywordValue::create(ValueID::None);
|
||||
|
||||
// https://drafts.csswg.org/css-transforms-2/#serialization-of-the-computed-value
|
||||
// The transform property is a resolved value special case property. [CSSOM]
|
||||
|
@ -516,7 +516,7 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
case PropertyID::WebkitTextFillColor:
|
||||
return ColorStyleValue::create(layout_node.computed_values().webkit_text_fill_color());
|
||||
case PropertyID::Invalid:
|
||||
return IdentifierStyleValue::create(ValueID::Invalid);
|
||||
return CSSKeywordValue::create(ValueID::Invalid);
|
||||
case PropertyID::Custom:
|
||||
dbgln_if(LIBWEB_CSS_DEBUG, "Computed style for custom properties was requested (?)");
|
||||
return nullptr;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <LibWeb/CSS/StyleSheet.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||
|
@ -45,7 +46,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
|
||||
|
@ -784,10 +784,10 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
|||
if (property_id == CSS::PropertyID::Transition) {
|
||||
if (!value.is_transition()) {
|
||||
// Handle `none` as a shorthand for `all 0s ease 0s`.
|
||||
set_longhand_property(CSS::PropertyID::TransitionProperty, IdentifierStyleValue::create(CSS::ValueID::All));
|
||||
set_longhand_property(CSS::PropertyID::TransitionProperty, CSSKeywordValue::create(CSS::ValueID::All));
|
||||
set_longhand_property(CSS::PropertyID::TransitionDuration, TimeStyleValue::create(CSS::Time::make_seconds(0)));
|
||||
set_longhand_property(CSS::PropertyID::TransitionDelay, TimeStyleValue::create(CSS::Time::make_seconds(0)));
|
||||
set_longhand_property(CSS::PropertyID::TransitionTimingFunction, IdentifierStyleValue::create(CSS::ValueID::Ease));
|
||||
set_longhand_property(CSS::PropertyID::TransitionTimingFunction, CSSKeywordValue::create(CSS::ValueID::Ease));
|
||||
return;
|
||||
}
|
||||
auto const& transitions = value.as_transition().transitions();
|
||||
|
@ -812,10 +812,10 @@ void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_i
|
|||
|
||||
// FIXME: Honor writing-mode, direction and text-orientation.
|
||||
if (ident == CSS::ValueID::InlineStart) {
|
||||
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Left));
|
||||
set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(CSS::ValueID::Left));
|
||||
return;
|
||||
} else if (ident == CSS::ValueID::InlineEnd) {
|
||||
set_longhand_property(CSS::PropertyID::Float, IdentifierStyleValue::create(CSS::ValueID::Right));
|
||||
set_longhand_property(CSS::PropertyID::Float, CSSKeywordValue::create(CSS::ValueID::Right));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1307,7 +1307,7 @@ static NonnullRefPtr<CSSStyleValue const> interpolate_box_shadow(DOM::Element& e
|
|||
}
|
||||
} else if (value.is_shadow()) {
|
||||
shadows.append(value);
|
||||
} else if (!value.is_identifier() || value.as_identifier().id() != ValueID::None) {
|
||||
} else if (!value.is_keyword() || value.as_keyword().id() != ValueID::None) {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return shadows;
|
||||
|
@ -1627,7 +1627,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optional<CSS::
|
|||
} else {
|
||||
// If interpolate_property() fails, the element should not be rendered
|
||||
dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} is invalid", string_from_property_id(it.key), progress_in_keyframe, start->to_string(), end->to_string());
|
||||
style_properties.set_animated_property(PropertyID::Visibility, IdentifierStyleValue::create(ValueID::Hidden));
|
||||
style_properties.set_animated_property(PropertyID::Visibility, CSSKeywordValue::create(ValueID::Hidden));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1640,7 +1640,7 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&
|
|||
if (auto duration_value = style.maybe_null_property(PropertyID::AnimationDuration); duration_value) {
|
||||
if (duration_value->is_time()) {
|
||||
duration = duration_value->as_time().time();
|
||||
} else if (duration_value->is_identifier() && duration_value->as_identifier().id() == ValueID::Auto) {
|
||||
} else if (duration_value->is_keyword() && duration_value->as_keyword().id() == ValueID::Auto) {
|
||||
// We use empty optional to represent "auto".
|
||||
duration = {};
|
||||
}
|
||||
|
@ -1652,26 +1652,26 @@ static void apply_animation_properties(DOM::Document& document, StyleProperties&
|
|||
|
||||
double iteration_count = 1.0;
|
||||
if (auto iteration_count_value = style.maybe_null_property(PropertyID::AnimationIterationCount); iteration_count_value) {
|
||||
if (iteration_count_value->is_identifier() && iteration_count_value->to_identifier() == ValueID::Infinite)
|
||||
if (iteration_count_value->is_keyword() && iteration_count_value->to_identifier() == ValueID::Infinite)
|
||||
iteration_count = HUGE_VAL;
|
||||
else if (iteration_count_value->is_number())
|
||||
iteration_count = iteration_count_value->as_number().number();
|
||||
}
|
||||
|
||||
CSS::AnimationFillMode fill_mode { CSS::AnimationFillMode::None };
|
||||
if (auto fill_mode_property = style.maybe_null_property(PropertyID::AnimationFillMode); fill_mode_property && fill_mode_property->is_identifier()) {
|
||||
if (auto fill_mode_property = style.maybe_null_property(PropertyID::AnimationFillMode); fill_mode_property && fill_mode_property->is_keyword()) {
|
||||
if (auto fill_mode_value = value_id_to_animation_fill_mode(fill_mode_property->to_identifier()); fill_mode_value.has_value())
|
||||
fill_mode = *fill_mode_value;
|
||||
}
|
||||
|
||||
CSS::AnimationDirection direction { CSS::AnimationDirection::Normal };
|
||||
if (auto direction_property = style.maybe_null_property(PropertyID::AnimationDirection); direction_property && direction_property->is_identifier()) {
|
||||
if (auto direction_property = style.maybe_null_property(PropertyID::AnimationDirection); direction_property && direction_property->is_keyword()) {
|
||||
if (auto direction_value = value_id_to_animation_direction(direction_property->to_identifier()); direction_value.has_value())
|
||||
direction = *direction_value;
|
||||
}
|
||||
|
||||
CSS::AnimationPlayState play_state { CSS::AnimationPlayState::Running };
|
||||
if (auto play_state_property = style.maybe_null_property(PropertyID::AnimationPlayState); play_state_property && play_state_property->is_identifier()) {
|
||||
if (auto play_state_property = style.maybe_null_property(PropertyID::AnimationPlayState); play_state_property && play_state_property->is_keyword()) {
|
||||
if (auto play_state_value = value_id_to_animation_play_state(play_state_property->to_identifier()); play_state_value.has_value())
|
||||
play_state = *play_state_value;
|
||||
}
|
||||
|
@ -2071,7 +2071,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
};
|
||||
Length::FontMetrics font_metrics { parent_font_size(), font_pixel_metrics };
|
||||
|
||||
if (font_size.is_identifier()) {
|
||||
if (font_size.is_keyword()) {
|
||||
// https://w3c.github.io/csswg-drafts/css-fonts/#absolute-size-mapping
|
||||
auto get_absolute_size_mapping = [](Web::CSS::ValueID identifier) -> CSSPixelFraction {
|
||||
switch (identifier) {
|
||||
|
@ -2100,7 +2100,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
}
|
||||
};
|
||||
|
||||
auto const identifier = static_cast<IdentifierStyleValue const&>(font_size).id();
|
||||
auto const identifier = static_cast<CSSKeywordValue const&>(font_size).id();
|
||||
|
||||
if (identifier == ValueID::Math) {
|
||||
auto math_scaling_factor = [&]() {
|
||||
|
@ -2258,7 +2258,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
auto const& family_list = static_cast<StyleValueList const&>(font_family).values();
|
||||
for (auto const& family : family_list) {
|
||||
RefPtr<Gfx::FontCascadeList const> other_font_list;
|
||||
if (family->is_identifier()) {
|
||||
if (family->is_keyword()) {
|
||||
other_font_list = find_generic_font(family->to_identifier());
|
||||
} else if (family->is_string()) {
|
||||
other_font_list = find_font(family->as_string().string_value());
|
||||
|
@ -2268,7 +2268,7 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
if (other_font_list)
|
||||
font_list->extend(*other_font_list);
|
||||
}
|
||||
} else if (font_family.is_identifier()) {
|
||||
} else if (font_family.is_keyword()) {
|
||||
if (auto other_font_list = find_generic_font(font_family.to_identifier()))
|
||||
font_list->extend(*other_font_list);
|
||||
} else if (font_family.is_string()) {
|
||||
|
@ -2372,13 +2372,13 @@ void StyleComputer::resolve_effective_overflow_values(StyleProperties& style) co
|
|||
auto overflow_y_is_visible_or_clip = overflow_y == Overflow::Visible || overflow_y == Overflow::Clip;
|
||||
if (!overflow_x_is_visible_or_clip || !overflow_y_is_visible_or_clip) {
|
||||
if (overflow_x == CSS::Overflow::Visible)
|
||||
style.set_property(CSS::PropertyID::OverflowX, IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::OverflowX, CSSKeywordValue::create(CSS::ValueID::Auto));
|
||||
if (overflow_x == CSS::Overflow::Clip)
|
||||
style.set_property(CSS::PropertyID::OverflowX, IdentifierStyleValue::create(CSS::ValueID::Hidden));
|
||||
style.set_property(CSS::PropertyID::OverflowX, CSSKeywordValue::create(CSS::ValueID::Hidden));
|
||||
if (overflow_y == CSS::Overflow::Visible)
|
||||
style.set_property(CSS::PropertyID::OverflowY, IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::OverflowY, CSSKeywordValue::create(CSS::ValueID::Auto));
|
||||
if (overflow_y == CSS::Overflow::Clip)
|
||||
style.set_property(CSS::PropertyID::OverflowY, IdentifierStyleValue::create(CSS::ValueID::Hidden));
|
||||
style.set_property(CSS::PropertyID::OverflowY, CSSKeywordValue::create(CSS::ValueID::Hidden));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/CSS/Clip.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CounterStyleValue.h>
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
|
||||
|
@ -124,7 +124,7 @@ RefPtr<CSSStyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID
|
|||
CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
|
||||
{
|
||||
auto value = property(id);
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
switch (value->to_identifier()) {
|
||||
case ValueID::Auto:
|
||||
return CSS::Size::make_auto();
|
||||
|
@ -219,7 +219,7 @@ CSSPixels StyleProperties::compute_line_height(CSSPixelRect const& viewport_rect
|
|||
{
|
||||
auto line_height = property(CSS::PropertyID::LineHeight);
|
||||
|
||||
if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal)
|
||||
if (line_height->is_keyword() && line_height->to_identifier() == ValueID::Normal)
|
||||
return font_metrics.line_height;
|
||||
|
||||
if (line_height->is_length()) {
|
||||
|
@ -355,7 +355,7 @@ Optional<CSS::FlexBasis> StyleProperties::flex_basis() const
|
|||
{
|
||||
auto value = property(CSS::PropertyID::FlexBasis);
|
||||
|
||||
if (value->is_identifier() && value->to_identifier() == CSS::ValueID::Content)
|
||||
if (value->is_keyword() && value->to_identifier() == CSS::ValueID::Content)
|
||||
return CSS::FlexBasisContent {};
|
||||
|
||||
return size_value(CSS::PropertyID::FlexBasis);
|
||||
|
@ -443,7 +443,7 @@ Optional<CSS::JustifySelf> StyleProperties::justify_self() const
|
|||
|
||||
Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(CSSStyleValue const& value)
|
||||
{
|
||||
if (value.is_identifier() && value.to_identifier() == CSS::ValueID::None)
|
||||
if (value.is_keyword() && value.to_identifier() == CSS::ValueID::None)
|
||||
return {};
|
||||
|
||||
if (!value.is_value_list())
|
||||
|
@ -729,7 +729,7 @@ StyleProperties::ContentDataAndQuoteNestingLevel StyleProperties::content(DOM::E
|
|||
for (auto const& item : content_style_value.content().values()) {
|
||||
if (item->is_string()) {
|
||||
builder.append(item->as_string().string_value());
|
||||
} else if (item->is_identifier()) {
|
||||
} else if (item->is_keyword()) {
|
||||
switch (item->to_identifier()) {
|
||||
case ValueID::OpenQuote:
|
||||
builder.append(get_quote_string(true, quote_nesting_level++));
|
||||
|
@ -809,7 +809,7 @@ Optional<CSS::Cursor> StyleProperties::cursor() const
|
|||
Optional<CSS::Visibility> StyleProperties::visibility() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::Visibility);
|
||||
if (!value->is_identifier())
|
||||
if (!value->is_keyword())
|
||||
return {};
|
||||
return value_id_to_visibility(value->to_identifier());
|
||||
}
|
||||
|
@ -836,7 +836,7 @@ Vector<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const
|
|||
return lines;
|
||||
}
|
||||
|
||||
if (value->is_identifier() && value->to_identifier() == ValueID::None)
|
||||
if (value->is_keyword() && value->to_identifier() == ValueID::None)
|
||||
return {};
|
||||
|
||||
dbgln("FIXME: Unsupported value for text-decoration-line: {}", value->to_string());
|
||||
|
@ -963,7 +963,7 @@ Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_ali
|
|||
{
|
||||
auto value = property(CSS::PropertyID::VerticalAlign);
|
||||
|
||||
if (value->is_identifier())
|
||||
if (value->is_keyword())
|
||||
return value_id_to_vertical_align(value->to_identifier()).release_value();
|
||||
|
||||
if (value->is_length())
|
||||
|
@ -1100,9 +1100,9 @@ Optional<CSS::MaskType> StyleProperties::mask_type() const
|
|||
Color StyleProperties::stop_color() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::StopColor);
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
// Workaround lack of layout node to resolve current color.
|
||||
auto& ident = value->as_identifier();
|
||||
auto& ident = value->as_keyword();
|
||||
if (ident.id() == CSS::ValueID::Currentcolor)
|
||||
value = property(CSS::PropertyID::Color);
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ void StyleProperties::set_math_depth(int math_depth)
|
|||
QuotesData StyleProperties::quotes() const
|
||||
{
|
||||
auto value = property(CSS::PropertyID::Quotes);
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
switch (value->to_identifier()) {
|
||||
case ValueID::Auto:
|
||||
return QuotesData { .type = QuotesData::Type::Auto };
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* 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) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "IdentifierStyleValue.h"
|
||||
#include "CSSKeywordValue.h"
|
||||
#include <LibGfx/Palette.h>
|
||||
#include <LibWeb/CSS/SystemColor.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -16,12 +16,12 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
String IdentifierStyleValue::to_string() const
|
||||
String CSSKeywordValue::to_string() const
|
||||
{
|
||||
return MUST(String::from_utf8(CSS::string_from_value_id(m_id)));
|
||||
}
|
||||
|
||||
bool IdentifierStyleValue::is_color(ValueID value_id)
|
||||
bool CSSKeywordValue::is_color(ValueID value_id)
|
||||
{
|
||||
switch (value_id) {
|
||||
case ValueID::Accentcolor:
|
||||
|
@ -128,12 +128,12 @@ bool IdentifierStyleValue::is_color(ValueID value_id)
|
|||
}
|
||||
}
|
||||
|
||||
bool IdentifierStyleValue::has_color() const
|
||||
bool CSSKeywordValue::has_color() const
|
||||
{
|
||||
return is_color(m_id);
|
||||
}
|
||||
|
||||
Color IdentifierStyleValue::to_color(Optional<Layout::NodeWithStyle const&> node) const
|
||||
Color CSSKeywordValue::to_color(Optional<Layout::NodeWithStyle const&> node) const
|
||||
{
|
||||
if (id() == CSS::ValueID::Currentcolor) {
|
||||
if (!node.has_value() || !node->has_style())
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* 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) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -14,13 +14,14 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> {
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
|
||||
class CSSKeywordValue final : public StyleValueWithDefaultOperators<CSSKeywordValue> {
|
||||
public:
|
||||
static ValueComparingNonnullRefPtr<IdentifierStyleValue> create(ValueID id)
|
||||
static ValueComparingNonnullRefPtr<CSSKeywordValue> create(ValueID id)
|
||||
{
|
||||
return adopt_ref(*new (nothrow) IdentifierStyleValue(id));
|
||||
return adopt_ref(*new (nothrow) CSSKeywordValue(id));
|
||||
}
|
||||
virtual ~IdentifierStyleValue() override = default;
|
||||
virtual ~CSSKeywordValue() override = default;
|
||||
|
||||
ValueID id() const { return m_id; }
|
||||
|
||||
|
@ -29,11 +30,11 @@ public:
|
|||
virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override;
|
||||
virtual String to_string() const override;
|
||||
|
||||
bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; }
|
||||
bool properties_equal(CSSKeywordValue const& other) const { return m_id == other.m_id; }
|
||||
|
||||
private:
|
||||
explicit IdentifierStyleValue(ValueID id)
|
||||
: StyleValueWithDefaultOperators(Type::Identifier)
|
||||
explicit CSSKeywordValue(ValueID id)
|
||||
: StyleValueWithDefaultOperators(Type::Keyword)
|
||||
, m_id(id)
|
||||
{
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
#include <LibWeb/CSS/SelectorEngine.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
|
||||
#include <LibWeb/DOM/Attr.h>
|
||||
#include <LibWeb/DOM/DOMTokenList.h>
|
||||
|
@ -542,7 +542,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
if (is<HTML::HTMLTableElement>(*this)) {
|
||||
auto text_align = new_computed_css_values->text_align();
|
||||
if (text_align.has_value() && (text_align.value() == CSS::TextAlign::LibwebLeft || text_align.value() == CSS::TextAlign::LibwebCenter || text_align.value() == CSS::TextAlign::LibwebRight))
|
||||
new_computed_css_values->set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Start));
|
||||
new_computed_css_values->set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Start));
|
||||
}
|
||||
|
||||
CSS::RequiredInvalidationAfterStyleChange invalidation;
|
||||
|
|
|
@ -107,6 +107,7 @@ class CSSGroupingRule;
|
|||
class CSSImportRule;
|
||||
class CSSKeyframeRule;
|
||||
class CSSKeyframesRule;
|
||||
class CSSKeywordValue;
|
||||
class CSSMediaRule;
|
||||
class CSSRule;
|
||||
class CSSRuleList;
|
||||
|
@ -150,7 +151,6 @@ class GridTrackPlacement;
|
|||
class GridTrackPlacementStyleValue;
|
||||
class GridTrackSizeList;
|
||||
class GridTrackSizeListStyleValue;
|
||||
class IdentifierStyleValue;
|
||||
class ImageStyleValue;
|
||||
class InheritStyleValue;
|
||||
class InitialStyleValue;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/HTMLCanvasElementPrototype.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/RatioStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -74,7 +74,7 @@ void HTMLCanvasElement::apply_presentational_hints(CSS::StyleProperties& style)
|
|||
// then the user agent is expected to use the parsed integers as a presentational hint for the 'aspect-ratio' property of the form auto w / h.
|
||||
style.set_property(CSS::PropertyID::AspectRatio,
|
||||
CSS::StyleValueList::create(CSS::StyleValueVector {
|
||||
CSS::IdentifierStyleValue::create(CSS::ValueID::Auto),
|
||||
CSS::CSSKeywordValue::create(CSS::ValueID::Auto),
|
||||
CSS::RatioStyleValue::create(CSS::Ratio { static_cast<double>(w.value()), static_cast<double>(h.value()) }) },
|
||||
|
||||
CSS::StyleValueList::Separator::Space));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLDivElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLDivElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -27,13 +27,13 @@ void HTMLDivElement::apply_presentational_hints(CSS::StyleProperties& style) con
|
|||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (value.equals_ignoring_ascii_case("left"sv))
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebLeft));
|
||||
else if (value.equals_ignoring_ascii_case("right"sv))
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebRight));
|
||||
else if (value.equals_ignoring_ascii_case("center"sv))
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebCenter));
|
||||
else if (value.equals_ignoring_ascii_case("justify"sv))
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLHeadingElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLHeadingElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -34,13 +34,13 @@ void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style)
|
|||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (value == "left"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Left));
|
||||
else if (value == "right"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Right));
|
||||
else if (value == "center"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Center));
|
||||
else if (value == "justify"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <LibJS/Runtime/Date.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibWeb/Bindings/HTMLInputElementPrototype.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
|
@ -135,7 +135,7 @@ void HTMLInputElement::adjust_computed_style(CSS::StyleProperties& style)
|
|||
double current_line_height = style.line_height().to_double();
|
||||
|
||||
if (is_single_line() && current_line_height < normal_line_height)
|
||||
style.set_property(CSS::PropertyID::LineHeight, CSS::IdentifierStyleValue::create(CSS::ValueID::Normal));
|
||||
style.set_property(CSS::PropertyID::LineHeight, CSS::CSSKeywordValue::create(CSS::ValueID::Normal));
|
||||
}
|
||||
|
||||
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLParagraphElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLParagraphElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -34,13 +34,13 @@ void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& styl
|
|||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (value == "left"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Left));
|
||||
else if (value == "right"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Right));
|
||||
else if (value == "center"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Center));
|
||||
else if (value == "justify"sv)
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::Justify));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLPreElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLPreElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
|
||||
|
@ -34,7 +34,7 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con
|
|||
|
||||
for_each_attribute([&](auto const& name, auto const&) {
|
||||
if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
|
||||
style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap));
|
||||
style.set_property(CSS::PropertyID::WhiteSpace, CSS::CSSKeywordValue::create(CSS::ValueID::PreWrap));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLTableCaptionElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/HTML/HTMLTableCaptionElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -34,7 +34,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& s
|
|||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name.equals_ignoring_ascii_case("align"sv)) {
|
||||
if (value == "bottom"sv)
|
||||
style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom));
|
||||
style.set_property(CSS::PropertyID::CaptionSide, CSS::CSSKeywordValue::create(CSS::ValueID::Bottom));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -54,11 +54,11 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
|||
}
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) {
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebCenter));
|
||||
} else if (value.equals_ignoring_ascii_case("left"sv)) {
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebLeft));
|
||||
} else if (value.equals_ignoring_ascii_case("right"sv)) {
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight));
|
||||
style.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::ValueID::LibwebRight));
|
||||
} else {
|
||||
if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::TextAlign))
|
||||
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
|
||||
|
@ -96,7 +96,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
|
|||
if (!border)
|
||||
return;
|
||||
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
|
||||
style.set_property(style_property, CSS::IdentifierStyleValue::create(CSS::ValueID::Inset));
|
||||
style.set_property(style_property, CSS::CSSKeywordValue::create(CSS::ValueID::Inset));
|
||||
style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1)));
|
||||
style.set_property(color_property, table_element->computed_css_values()->property(color_property));
|
||||
};
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
|
@ -65,8 +65,8 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
|
|||
}
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value.equals_ignoring_ascii_case("center"sv)) {
|
||||
style.set_property(CSS::PropertyID::MarginLeft, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::MarginRight, CSS::IdentifierStyleValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::MarginLeft, CSS::CSSKeywordValue::create(CSS::ValueID::Auto));
|
||||
style.set_property(CSS::PropertyID::MarginRight, CSS::CSSKeywordValue::create(CSS::ValueID::Auto));
|
||||
} else if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value, CSS::PropertyID::Float)) {
|
||||
style.set_property(CSS::PropertyID::Float, parsed_value.release_nonnull());
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
|
|||
if (!border)
|
||||
return;
|
||||
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
|
||||
auto legacy_line_style = CSS::IdentifierStyleValue::create(CSS::ValueID::Outset);
|
||||
auto legacy_line_style = CSS::CSSKeywordValue::create(CSS::ValueID::Outset);
|
||||
style.set_property(style_property, legacy_line_style);
|
||||
style.set_property(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(border)));
|
||||
style.set_property(color_property, CSS::ColorStyleValue::create(Color(128, 128, 128)));
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/Parser/ParsingContext.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ColorStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
|
||||
|
@ -373,7 +373,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
}
|
||||
}
|
||||
|
||||
if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->is_identifier()) {
|
||||
if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->is_keyword()) {
|
||||
switch (attachment_value->to_identifier()) {
|
||||
case CSS::ValueID::Fixed:
|
||||
layer.attachment = CSS::BackgroundAttachment::Fixed;
|
||||
|
@ -404,11 +404,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
}
|
||||
};
|
||||
|
||||
if (auto origin_value = value_for_layer(origins, layer_index); origin_value && origin_value->is_identifier()) {
|
||||
if (auto origin_value = value_for_layer(origins, layer_index); origin_value && origin_value->is_keyword()) {
|
||||
layer.origin = as_box(origin_value->to_identifier());
|
||||
}
|
||||
|
||||
if (auto clip_value = value_for_layer(clips, layer_index); clip_value && clip_value->is_identifier()) {
|
||||
if (auto clip_value = value_for_layer(clips, layer_index); clip_value && clip_value->is_keyword()) {
|
||||
layer.clip = as_box(clip_value->to_identifier());
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
layer.size_type = CSS::BackgroundSize::LengthPercentage;
|
||||
layer.size_x = size.size_x();
|
||||
layer.size_y = size.size_y();
|
||||
} else if (size_value->is_identifier()) {
|
||||
} else if (size_value->is_keyword()) {
|
||||
switch (size_value->to_identifier()) {
|
||||
case CSS::ValueID::Contain:
|
||||
layer.size_type = CSS::BackgroundSize::Contain;
|
||||
|
@ -720,7 +720,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
return max(CSSPixels { 0 }, value->as_calculated().resolve_length(*this)->to_px(*this));
|
||||
if (value->is_length())
|
||||
return value->as_length().length().to_px(*this);
|
||||
if (value->is_identifier()) {
|
||||
if (value->is_keyword()) {
|
||||
// https://www.w3.org/TR/css-backgrounds-3/#valdef-line-width-thin
|
||||
switch (value->to_identifier()) {
|
||||
case CSS::ValueID::Thin:
|
||||
|
@ -843,11 +843,11 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
if (aspect_ratio->is_value_list()) {
|
||||
auto& values_list = aspect_ratio->as_value_list().values();
|
||||
if (values_list.size() == 2
|
||||
&& values_list[0]->is_identifier() && values_list[0]->as_identifier().id() == CSS::ValueID::Auto
|
||||
&& values_list[0]->is_keyword() && values_list[0]->as_keyword().id() == CSS::ValueID::Auto
|
||||
&& values_list[1]->is_ratio()) {
|
||||
computed_values.set_aspect_ratio({ true, values_list[1]->as_ratio().ratio() });
|
||||
}
|
||||
} else if (aspect_ratio->is_identifier() && aspect_ratio->as_identifier().id() == CSS::ValueID::Auto) {
|
||||
} else if (aspect_ratio->is_keyword() && aspect_ratio->as_keyword().id() == CSS::ValueID::Auto) {
|
||||
computed_values.set_aspect_ratio({ true, {} });
|
||||
} else if (aspect_ratio->is_ratio()) {
|
||||
computed_values.set_aspect_ratio({ false, aspect_ratio->as_ratio().ratio() });
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/SVGSymbolElementPrototype.h>
|
||||
#include <LibWeb/CSS/StyleProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/Layout/SVGGraphicsBox.h>
|
||||
|
|
Loading…
Reference in a new issue