mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibWeb: Stop using NonnullRefPtrVector for StyleValueVector
This commit is contained in:
parent
8a48246ed1
commit
4c75d4af28
Notes:
sideshowbarker
2024-07-17 06:51:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4c75d4af28
@ -1247,10 +1247,10 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
|
||||
if (family_value->is_value_list()) {
|
||||
auto const& family_list = static_cast<StyleValueList const&>(*family_value).values();
|
||||
for (auto const& family : family_list) {
|
||||
if (family.is_identifier()) {
|
||||
found_font = find_generic_font(family.to_identifier());
|
||||
} else if (family.is_string()) {
|
||||
found_font = find_font(family.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
if (family->is_identifier()) {
|
||||
found_font = find_generic_font(family->to_identifier());
|
||||
} else if (family->is_string()) {
|
||||
found_font = find_font(family->to_string().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
if (found_font)
|
||||
break;
|
||||
|
@ -296,21 +296,21 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
||||
Vector<CSS::Transformation> transformations;
|
||||
|
||||
for (auto& it : list.values()) {
|
||||
if (!it.is_transformation())
|
||||
if (!it->is_transformation())
|
||||
return {};
|
||||
auto& transformation_style_value = it.as_transformation();
|
||||
auto& transformation_style_value = it->as_transformation();
|
||||
CSS::Transformation transformation;
|
||||
transformation.function = transformation_style_value.transform_function();
|
||||
Vector<TransformValue> values;
|
||||
for (auto& transformation_value : transformation_style_value.values()) {
|
||||
if (transformation_value.is_length()) {
|
||||
values.append({ transformation_value.to_length() });
|
||||
} else if (transformation_value.is_percentage()) {
|
||||
values.append({ transformation_value.as_percentage().percentage() });
|
||||
} else if (transformation_value.is_numeric()) {
|
||||
values.append({ transformation_value.to_number() });
|
||||
} else if (transformation_value.is_angle()) {
|
||||
values.append({ transformation_value.as_angle().angle() });
|
||||
if (transformation_value->is_length()) {
|
||||
values.append({ transformation_value->to_length() });
|
||||
} else if (transformation_value->is_percentage()) {
|
||||
values.append({ transformation_value->as_percentage().percentage() });
|
||||
} else if (transformation_value->is_numeric()) {
|
||||
values.append({ transformation_value->to_number() });
|
||||
} else if (transformation_value->is_angle()) {
|
||||
values.append({ transformation_value->as_angle().angle() });
|
||||
} else {
|
||||
dbgln("FIXME: Unsupported value in transform!");
|
||||
}
|
||||
@ -487,8 +487,8 @@ CSS::ContentData StyleProperties::content() const
|
||||
// For now, we'll just assume strings since that is easiest.
|
||||
StringBuilder builder;
|
||||
for (auto const& item : content_style_value.content().values()) {
|
||||
if (item.is_string()) {
|
||||
builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
if (item->is_string()) {
|
||||
builder.append(item->to_string().release_value_but_fixme_should_propagate_errors());
|
||||
} else {
|
||||
// TODO: Implement quotes, counters, images, and other things.
|
||||
}
|
||||
@ -499,8 +499,8 @@ CSS::ContentData StyleProperties::content() const
|
||||
if (content_style_value.has_alt_text()) {
|
||||
StringBuilder alt_text_builder;
|
||||
for (auto const& item : content_style_value.alt_text()->values()) {
|
||||
if (item.is_string()) {
|
||||
alt_text_builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
|
||||
if (item->is_string()) {
|
||||
alt_text_builder.append(item->to_string().release_value_but_fixme_should_propagate_errors());
|
||||
} else {
|
||||
// TODO: Implement counters
|
||||
}
|
||||
@ -592,7 +592,7 @@ Vector<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const
|
||||
Vector<CSS::TextDecorationLine> lines;
|
||||
auto& values = value->as_value_list().values();
|
||||
for (auto const& item : values) {
|
||||
lines.append(value_id_to_text_decoration_line(item.to_identifier()).value());
|
||||
lines.append(value_id_to_text_decoration_line(item->to_identifier()).value());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@ -652,7 +652,7 @@ Vector<ShadowData> StyleProperties::shadow(PropertyID property_id) const
|
||||
Vector<ShadowData> shadow_data;
|
||||
shadow_data.ensure_capacity(value_list.size());
|
||||
for (auto const& layer_value : value_list.values())
|
||||
shadow_data.append(make_shadow_data(layer_value.as_shadow()));
|
||||
shadow_data.append(make_shadow_data(layer_value->as_shadow()));
|
||||
|
||||
return shadow_data;
|
||||
}
|
||||
|
@ -2112,7 +2112,11 @@ ErrorOr<String> TransformationStyleValue::to_string() const
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_append(CSS::to_string(m_properties.transform_function)));
|
||||
TRY(builder.try_append('('));
|
||||
TRY(builder.try_join(", "sv, m_properties.values));
|
||||
for (size_t i = 0; i < m_properties.values.size(); ++i) {
|
||||
TRY(builder.try_append(TRY(m_properties.values[i]->to_string())));
|
||||
if (i != m_properties.values.size() - 1)
|
||||
TRY(builder.try_append(", "sv));
|
||||
}
|
||||
TRY(builder.try_append(')'));
|
||||
|
||||
return builder.to_string();
|
||||
@ -2158,7 +2162,13 @@ ErrorOr<String> StyleValueList::to_string() const
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return String::from_deprecated_string(DeprecatedString::join(separator, m_properties.values));
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < m_properties.values.size(); ++i) {
|
||||
TRY(builder.try_append(TRY(m_properties.values[i]->to_string())));
|
||||
if (i != m_properties.values.size() - 1)
|
||||
TRY(builder.try_append(separator));
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
||||
|
@ -267,9 +267,7 @@ private:
|
||||
using RefPtr<T>::operator==;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using ValueComparingNonnullRefPtrVector = AK::NonnullPtrVector<ValueComparingNonnullRefPtr<T>>;
|
||||
using StyleValueVector = ValueComparingNonnullRefPtrVector<StyleValue const>;
|
||||
using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
|
||||
|
||||
class StyleValue : public RefCounted<StyleValue> {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user