mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibWeb: Stop using NonnullRefPtrVector for StyleValueVector
This commit is contained in:
parent
8a48246ed1
commit
4c75d4af28
4 changed files with 33 additions and 25 deletions
|
@ -1247,10 +1247,10 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
|
||||||
if (family_value->is_value_list()) {
|
if (family_value->is_value_list()) {
|
||||||
auto const& family_list = static_cast<StyleValueList const&>(*family_value).values();
|
auto const& family_list = static_cast<StyleValueList const&>(*family_value).values();
|
||||||
for (auto const& family : family_list) {
|
for (auto const& family : family_list) {
|
||||||
if (family.is_identifier()) {
|
if (family->is_identifier()) {
|
||||||
found_font = find_generic_font(family.to_identifier());
|
found_font = find_generic_font(family->to_identifier());
|
||||||
} else if (family.is_string()) {
|
} else if (family->is_string()) {
|
||||||
found_font = find_font(family.to_string().release_value_but_fixme_should_propagate_errors());
|
found_font = find_font(family->to_string().release_value_but_fixme_should_propagate_errors());
|
||||||
}
|
}
|
||||||
if (found_font)
|
if (found_font)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -296,21 +296,21 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
||||||
Vector<CSS::Transformation> transformations;
|
Vector<CSS::Transformation> transformations;
|
||||||
|
|
||||||
for (auto& it : list.values()) {
|
for (auto& it : list.values()) {
|
||||||
if (!it.is_transformation())
|
if (!it->is_transformation())
|
||||||
return {};
|
return {};
|
||||||
auto& transformation_style_value = it.as_transformation();
|
auto& transformation_style_value = it->as_transformation();
|
||||||
CSS::Transformation transformation;
|
CSS::Transformation transformation;
|
||||||
transformation.function = transformation_style_value.transform_function();
|
transformation.function = transformation_style_value.transform_function();
|
||||||
Vector<TransformValue> values;
|
Vector<TransformValue> values;
|
||||||
for (auto& transformation_value : transformation_style_value.values()) {
|
for (auto& transformation_value : transformation_style_value.values()) {
|
||||||
if (transformation_value.is_length()) {
|
if (transformation_value->is_length()) {
|
||||||
values.append({ transformation_value.to_length() });
|
values.append({ transformation_value->to_length() });
|
||||||
} else if (transformation_value.is_percentage()) {
|
} else if (transformation_value->is_percentage()) {
|
||||||
values.append({ transformation_value.as_percentage().percentage() });
|
values.append({ transformation_value->as_percentage().percentage() });
|
||||||
} else if (transformation_value.is_numeric()) {
|
} else if (transformation_value->is_numeric()) {
|
||||||
values.append({ transformation_value.to_number() });
|
values.append({ transformation_value->to_number() });
|
||||||
} else if (transformation_value.is_angle()) {
|
} else if (transformation_value->is_angle()) {
|
||||||
values.append({ transformation_value.as_angle().angle() });
|
values.append({ transformation_value->as_angle().angle() });
|
||||||
} else {
|
} else {
|
||||||
dbgln("FIXME: Unsupported value in transform!");
|
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.
|
// For now, we'll just assume strings since that is easiest.
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
for (auto const& item : content_style_value.content().values()) {
|
for (auto const& item : content_style_value.content().values()) {
|
||||||
if (item.is_string()) {
|
if (item->is_string()) {
|
||||||
builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
|
builder.append(item->to_string().release_value_but_fixme_should_propagate_errors());
|
||||||
} else {
|
} else {
|
||||||
// TODO: Implement quotes, counters, images, and other things.
|
// TODO: Implement quotes, counters, images, and other things.
|
||||||
}
|
}
|
||||||
|
@ -499,8 +499,8 @@ CSS::ContentData StyleProperties::content() const
|
||||||
if (content_style_value.has_alt_text()) {
|
if (content_style_value.has_alt_text()) {
|
||||||
StringBuilder alt_text_builder;
|
StringBuilder alt_text_builder;
|
||||||
for (auto const& item : content_style_value.alt_text()->values()) {
|
for (auto const& item : content_style_value.alt_text()->values()) {
|
||||||
if (item.is_string()) {
|
if (item->is_string()) {
|
||||||
alt_text_builder.append(item.to_string().release_value_but_fixme_should_propagate_errors());
|
alt_text_builder.append(item->to_string().release_value_but_fixme_should_propagate_errors());
|
||||||
} else {
|
} else {
|
||||||
// TODO: Implement counters
|
// TODO: Implement counters
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ Vector<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const
|
||||||
Vector<CSS::TextDecorationLine> lines;
|
Vector<CSS::TextDecorationLine> lines;
|
||||||
auto& values = value->as_value_list().values();
|
auto& values = value->as_value_list().values();
|
||||||
for (auto const& item : 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;
|
return lines;
|
||||||
}
|
}
|
||||||
|
@ -652,7 +652,7 @@ Vector<ShadowData> StyleProperties::shadow(PropertyID property_id) const
|
||||||
Vector<ShadowData> shadow_data;
|
Vector<ShadowData> shadow_data;
|
||||||
shadow_data.ensure_capacity(value_list.size());
|
shadow_data.ensure_capacity(value_list.size());
|
||||||
for (auto const& layer_value : value_list.values())
|
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;
|
return shadow_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2112,7 +2112,11 @@ ErrorOr<String> TransformationStyleValue::to_string() const
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
TRY(builder.try_append(CSS::to_string(m_properties.transform_function)));
|
TRY(builder.try_append(CSS::to_string(m_properties.transform_function)));
|
||||||
TRY(builder.try_append('('));
|
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(')'));
|
TRY(builder.try_append(')'));
|
||||||
|
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
|
@ -2158,7 +2162,13 @@ ErrorOr<String> StyleValueList::to_string() const
|
||||||
VERIFY_NOT_REACHED();
|
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)
|
ValueComparingNonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
|
||||||
|
|
|
@ -267,9 +267,7 @@ private:
|
||||||
using RefPtr<T>::operator==;
|
using RefPtr<T>::operator==;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
|
||||||
using ValueComparingNonnullRefPtrVector = AK::NonnullPtrVector<ValueComparingNonnullRefPtr<T>>;
|
|
||||||
using StyleValueVector = ValueComparingNonnullRefPtrVector<StyleValue const>;
|
|
||||||
|
|
||||||
class StyleValue : public RefCounted<StyleValue> {
|
class StyleValue : public RefCounted<StyleValue> {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue