1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibWeb+LibIDL: Fix (or paper over) various const-correctness issues

There's definitely stuff to iterate on here, but this takes care of
making the libraries compile with stricter RP and NNRP.
This commit is contained in:
Andreas Kling 2023-02-20 18:56:08 +01:00
parent 68b5df6bf1
commit f11899f885
22 changed files with 210 additions and 186 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
*
@ -122,14 +122,14 @@ static RefPtr<StyleValue> style_value_for_display(CSS::Display display)
TODO();
}
static NonnullRefPtr<StyleValue> value_or_default(Optional<StyleProperty> property, NonnullRefPtr<StyleValue> default_style)
static NonnullRefPtr<StyleValue const> value_or_default(Optional<StyleProperty> property, NonnullRefPtr<StyleValue> default_style)
{
if (property.has_value())
return property.value().value;
return default_style;
}
static NonnullRefPtr<StyleValue> style_value_for_length_percentage(LengthPercentage const& length_percentage)
static NonnullRefPtr<StyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
{
if (length_percentage.is_percentage())
return PercentageStyleValue::create(length_percentage.percentage());
@ -138,7 +138,7 @@ static NonnullRefPtr<StyleValue> style_value_for_length_percentage(LengthPercent
return length_percentage.calculated();
}
static NonnullRefPtr<StyleValue> style_value_for_size(CSS::Size const& size)
static NonnullRefPtr<StyleValue const> style_value_for_size(CSS::Size const& size)
{
if (size.is_none())
return IdentifierStyleValue::create(ValueID::None);
@ -156,7 +156,7 @@ static NonnullRefPtr<StyleValue> style_value_for_size(CSS::Size const& size)
TODO();
}
RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
RefPtr<StyleValue const> ResolvedCSSStyleDeclaration::style_value_for_property(Layout::NodeWithStyle const& layout_node, PropertyID property_id) const
{
switch (property_id) {
case CSS::PropertyID::Background: {
@ -222,7 +222,7 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
auto maybe_top_right_radius = property(CSS::PropertyID::BorderTopRightRadius);
auto maybe_bottom_left_radius = property(CSS::PropertyID::BorderBottomLeftRadius);
auto maybe_bottom_right_radius = property(CSS::PropertyID::BorderBottomRightRadius);
RefPtr<BorderRadiusStyleValue> top_left_radius, top_right_radius, bottom_left_radius, bottom_right_radius;
RefPtr<BorderRadiusStyleValue const> top_left_radius, top_right_radius, bottom_left_radius, bottom_right_radius;
if (maybe_top_left_radius.has_value()) {
VERIFY(maybe_top_left_radius.value().value->is_border_radius());
top_left_radius = maybe_top_left_radius.value().value->as_border_radius();
@ -337,7 +337,7 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
auto maybe_grid_column_start = property(CSS::PropertyID::GridColumnStart);
auto maybe_grid_row_end = property(CSS::PropertyID::GridRowEnd);
auto maybe_grid_column_end = property(CSS::PropertyID::GridColumnEnd);
RefPtr<GridTrackPlacementStyleValue> grid_row_start, grid_column_start, grid_row_end, grid_column_end;
RefPtr<GridTrackPlacementStyleValue const> grid_row_start, grid_column_start, grid_row_end, grid_column_end;
if (maybe_grid_row_start.has_value()) {
VERIFY(maybe_grid_row_start.value().value->is_grid_track_placement());
grid_row_start = maybe_grid_row_start.value().value->as_grid_track_placement();
@ -363,7 +363,7 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
case CSS::PropertyID::GridColumn: {
auto maybe_grid_column_end = property(CSS::PropertyID::GridColumnEnd);
auto maybe_grid_column_start = property(CSS::PropertyID::GridColumnStart);
RefPtr<GridTrackPlacementStyleValue> grid_column_start, grid_column_end;
RefPtr<GridTrackPlacementStyleValue const> grid_column_start, grid_column_end;
if (maybe_grid_column_end.has_value()) {
VERIFY(maybe_grid_column_end.value().value->is_grid_track_placement());
grid_column_end = maybe_grid_column_end.value().value->as_grid_track_placement();
@ -381,7 +381,7 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
case CSS::PropertyID::GridRow: {
auto maybe_grid_row_end = property(CSS::PropertyID::GridRowEnd);
auto maybe_grid_row_start = property(CSS::PropertyID::GridRowStart);
RefPtr<GridTrackPlacementStyleValue> grid_row_start, grid_row_end;
RefPtr<GridTrackPlacementStyleValue const> grid_row_start, grid_row_end;
if (maybe_grid_row_end.has_value()) {
VERIFY(maybe_grid_row_end.value().value->is_grid_track_placement());
grid_row_end = maybe_grid_row_end.value().value->as_grid_track_placement();