LibWeb: Remove unused PercentageOr classes
These are only used at used value time (since we store as `StyleValue`s before) by which time we resolve all percentages except for layout relative length percentages.
This commit is contained in:
parent
d25f86da66
commit
1e36ccad0d
9 changed files with 3 additions and 159 deletions
|
|
@ -86,13 +86,4 @@ Angle Angle::from_style_value(NonnullRefPtr<StyleValue const> const& style_value
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
Angle Angle::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Angle const& reference_value)
|
||||
{
|
||||
CalculationResolutionContext context {
|
||||
.percentage_basis = reference_value,
|
||||
.length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node),
|
||||
};
|
||||
return calculated->resolve_angle(context).value();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public:
|
|||
}
|
||||
|
||||
static Angle from_style_value(NonnullRefPtr<StyleValue const> const&, Optional<Angle> percentage_basis);
|
||||
static Angle resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Angle const& reference_value);
|
||||
|
||||
private:
|
||||
AngleUnit m_unit;
|
||||
|
|
|
|||
|
|
@ -54,13 +54,4 @@ double Frequency::to_hertz() const
|
|||
return ratio_between_units(m_unit, FrequencyUnit::Hz) * m_value;
|
||||
}
|
||||
|
||||
Frequency Frequency::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Frequency const& reference_value)
|
||||
{
|
||||
CalculationResolutionContext context {
|
||||
.percentage_basis = reference_value,
|
||||
.length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node),
|
||||
};
|
||||
return calculated->resolve_frequency(context).value();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static Frequency resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Frequency const& reference_value);
|
||||
|
||||
private:
|
||||
FrequencyUnit m_unit;
|
||||
double m_value { 0 };
|
||||
|
|
|
|||
|
|
@ -338,12 +338,6 @@ private:
|
|||
|
||||
Optional<Descriptor> convert_to_descriptor(AtRuleID, Declaration const&);
|
||||
|
||||
Optional<AnglePercentage> parse_angle_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<FrequencyPercentage> parse_frequency_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<LengthPercentage> parse_length_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<NumberPercentage> parse_number_percentage(TokenStream<ComponentValue>&);
|
||||
Optional<TimePercentage> parse_time_percentage(TokenStream<ComponentValue>&);
|
||||
|
||||
RefPtr<StyleValue const> parse_source_size_value(TokenStream<ComponentValue>&);
|
||||
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
|
||||
Optional<Gfx::UnicodeRange> parse_unicode_range(StringView);
|
||||
|
|
|
|||
|
|
@ -212,72 +212,6 @@ Optional<Vector<ComponentValue>> Parser::parse_declaration_value(TokenStream<Com
|
|||
return top_level_declaration_value;
|
||||
}
|
||||
|
||||
Optional<AnglePercentage> Parser::parse_angle_percentage(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto value = parse_angle_percentage_value(tokens)) {
|
||||
if (value->is_angle())
|
||||
return value->as_angle().angle();
|
||||
if (value->is_percentage())
|
||||
return value->as_percentage().percentage();
|
||||
if (value->is_calculated())
|
||||
return AnglePercentage { value->as_calculated() };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<FrequencyPercentage> Parser::parse_frequency_percentage(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto value = parse_frequency_percentage_value(tokens)) {
|
||||
if (value->is_frequency())
|
||||
return value->as_frequency().frequency();
|
||||
if (value->is_percentage())
|
||||
return value->as_percentage().percentage();
|
||||
if (value->is_calculated())
|
||||
return FrequencyPercentage { value->as_calculated() };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<LengthPercentage> Parser::parse_length_percentage(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto value = parse_length_percentage_value(tokens)) {
|
||||
if (value->is_length())
|
||||
return value->as_length().length();
|
||||
if (value->is_percentage())
|
||||
return value->as_percentage().percentage();
|
||||
if (value->is_calculated())
|
||||
return LengthPercentage { value->as_calculated() };
|
||||
// FIXME: Deal with ->is_anchor_size()
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<NumberPercentage> Parser::parse_number_percentage(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto value = parse_number_percentage_value(tokens)) {
|
||||
if (value->is_number())
|
||||
return Number { Number::Type::Number, value->as_number().number() };
|
||||
if (value->is_percentage())
|
||||
return value->as_percentage().percentage();
|
||||
if (value->is_calculated())
|
||||
return NumberPercentage { value->as_calculated() };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<TimePercentage> Parser::parse_time_percentage(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (auto value = parse_time_percentage_value(tokens)) {
|
||||
if (value->is_time())
|
||||
return value->as_time().time();
|
||||
if (value->is_percentage())
|
||||
return value->as_percentage().percentage();
|
||||
if (value->is_calculated())
|
||||
return TimePercentage { value->as_calculated() };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-fonts-4/#family-name-syntax
|
||||
RefPtr<StyleValue const> Parser::parse_family_name_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
|
||||
#include <LibWeb/CSS/Time.h>
|
||||
|
||||
// FIXME: LengthPercentage is the only remaining derived class of PercentageOr so we can just merge them together. It
|
||||
// should also probably instead be CSSPixelsPercentage since it is only used after computation where we resolve
|
||||
// all relative lengths.
|
||||
namespace Web::CSS {
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -185,22 +188,6 @@ bool operator==(Percentage const& percentage, PercentageOr<T> const& percentage_
|
|||
return percentage == percentage_or;
|
||||
}
|
||||
|
||||
class AnglePercentage : public PercentageOr<Angle> {
|
||||
public:
|
||||
using PercentageOr<Angle>::PercentageOr;
|
||||
|
||||
bool is_angle() const { return is_t(); }
|
||||
Angle const& angle() const { return get_t(); }
|
||||
};
|
||||
|
||||
class FrequencyPercentage : public PercentageOr<Frequency> {
|
||||
public:
|
||||
using PercentageOr<Frequency>::PercentageOr;
|
||||
|
||||
bool is_frequency() const { return is_t(); }
|
||||
Frequency const& frequency() const { return get_t(); }
|
||||
};
|
||||
|
||||
class LengthPercentage : public PercentageOr<Length> {
|
||||
public:
|
||||
using PercentageOr<Length>::PercentageOr;
|
||||
|
|
@ -300,40 +287,8 @@ private:
|
|||
Optional<LengthPercentage> m_length_percentage;
|
||||
};
|
||||
|
||||
class TimePercentage : public PercentageOr<Time> {
|
||||
public:
|
||||
using PercentageOr<Time>::PercentageOr;
|
||||
|
||||
bool is_time() const { return is_t(); }
|
||||
Time const& time() const { return get_t(); }
|
||||
};
|
||||
|
||||
struct NumberPercentage : public PercentageOr<Number> {
|
||||
public:
|
||||
using PercentageOr<Number>::PercentageOr;
|
||||
|
||||
bool is_number() const { return is_t(); }
|
||||
Number const& number() const { return get_t(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Web::CSS::AnglePercentage> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::AnglePercentage const& angle_percentage)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, angle_percentage.to_string(Web::CSS::SerializationMode::Normal));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Web::CSS::FrequencyPercentage> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::FrequencyPercentage const& frequency_percentage)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, frequency_percentage.to_string(Web::CSS::SerializationMode::Normal));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Web::CSS::LengthPercentage> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::LengthPercentage const& length_percentage)
|
||||
|
|
@ -349,11 +304,3 @@ struct AK::Formatter<Web::CSS::LengthPercentageOrAuto> : Formatter<StringView> {
|
|||
return Formatter<StringView>::format(builder, length_percentage_or_auto.to_string(Web::CSS::SerializationMode::Normal));
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Web::CSS::TimePercentage> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::TimePercentage const& time_percentage)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, time_percentage.to_string(Web::CSS::SerializationMode::Normal));
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,13 +85,4 @@ double Time::to_milliseconds() const
|
|||
return ratio_between_units(m_unit, TimeUnit::Ms) * m_value;
|
||||
}
|
||||
|
||||
Time Time::resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const& calculated, Layout::Node const& layout_node, Time const& reference_value)
|
||||
{
|
||||
CalculationResolutionContext context {
|
||||
.percentage_basis = reference_value,
|
||||
.length_resolution_context = Length::ResolutionContext::for_layout_node(layout_node),
|
||||
};
|
||||
return calculated->resolve_time(context).value();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ public:
|
|||
}
|
||||
|
||||
static Time from_style_value(NonnullRefPtr<StyleValue const> const&, Optional<Time> percentage_basis);
|
||||
static Time resolve_calculated(NonnullRefPtr<CalculatedStyleValue const> const&, Layout::Node const&, Time const& reference_value);
|
||||
|
||||
private:
|
||||
TimeUnit m_unit;
|
||||
|
|
|
|||
Loading…
Reference in a new issue