summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authormartinfalisse <martinmotteditfalisse@gmail.com>2023-01-16 17:29:15 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-21 14:35:00 +0100
commit9d99bd8258f2d27de67a8f0339e8fccb28e8b82b (patch)
treeda742ed2526de7f45e34e6e88432d4031cdcca54 /Userland
parentaec2dadfddf106fa06c10814ae6f2d0d5a56ea0c (diff)
downloadserenity-9d99bd8258f2d27de67a8f0339e8fccb28e8b82b.zip
LibWeb: Use String class in certain CSS Grid classes
Converts the remaining instances of DeprecatedString to String in the CSS Grid classes.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h9
-rw-r--r--Userland/Libraries/LibWeb/CSS/GridTrackSize.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/GridTrackSize.h6
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp37
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/GridFormattingContext.h2
7 files changed, 38 insertions, 26 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp b/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
index 451eb79eaf..485a66b0d1 100644
--- a/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
+++ b/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.cpp
@@ -5,7 +5,7 @@
*/
#include "GridTrackPlacement.h"
-#include <AK/DeprecatedString.h>
+#include <AK/StringBuilder.h>
namespace Web::CSS {
@@ -15,14 +15,14 @@ GridTrackPlacement::GridTrackPlacement(int span_count_or_position, bool has_span
{
}
-GridTrackPlacement::GridTrackPlacement(DeprecatedString line_name, int span_count_or_position, bool has_span)
+GridTrackPlacement::GridTrackPlacement(String line_name, int span_count_or_position, bool has_span)
: m_type(has_span ? Type::Span : Type::Position)
, m_span_count_or_position(span_count_or_position)
, m_line_name(line_name)
{
}
-GridTrackPlacement::GridTrackPlacement(DeprecatedString line_name, bool has_span)
+GridTrackPlacement::GridTrackPlacement(String line_name, bool has_span)
: m_type(has_span ? Type::Span : Type::Position)
, m_line_name(line_name)
{
diff --git a/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h b/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
index c25147f4ac..071b1c081f 100644
--- a/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
+++ b/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
@@ -6,7 +6,6 @@
#pragma once
-#include <AK/DeprecatedString.h>
#include <AK/String.h>
namespace Web::CSS {
@@ -19,9 +18,9 @@ public:
Auto
};
- GridTrackPlacement(DeprecatedString line_name, int span_count_or_position, bool has_span = false);
+ GridTrackPlacement(String line_name, int span_count_or_position, bool has_span = false);
GridTrackPlacement(int span_count_or_position, bool has_span = false);
- GridTrackPlacement(DeprecatedString line_name, bool has_span = false);
+ GridTrackPlacement(String line_name, bool has_span = false);
GridTrackPlacement();
static GridTrackPlacement make_auto() { return GridTrackPlacement(); };
@@ -35,7 +34,7 @@ public:
int raw_value() const { return m_span_count_or_position; }
Type type() const { return m_type; }
- DeprecatedString line_name() const { return m_line_name; }
+ String line_name() const { return m_line_name; }
ErrorOr<String> to_string() const;
bool operator==(GridTrackPlacement const& other) const
@@ -46,7 +45,7 @@ public:
private:
Type m_type;
int m_span_count_or_position { 0 };
- DeprecatedString m_line_name;
+ String m_line_name;
};
}
diff --git a/Userland/Libraries/LibWeb/CSS/GridTrackSize.cpp b/Userland/Libraries/LibWeb/CSS/GridTrackSize.cpp
index 9f40c4a79d..5df3bbb188 100644
--- a/Userland/Libraries/LibWeb/CSS/GridTrackSize.cpp
+++ b/Userland/Libraries/LibWeb/CSS/GridTrackSize.cpp
@@ -152,7 +152,7 @@ ErrorOr<String> ExplicitGridTrack::to_string() const
}
}
-GridTrackSizeList::GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<DeprecatedString>> line_names)
+GridTrackSizeList::GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<String>> line_names)
: m_track_list(track_list)
, m_line_names(line_names)
{
diff --git a/Userland/Libraries/LibWeb/CSS/GridTrackSize.h b/Userland/Libraries/LibWeb/CSS/GridTrackSize.h
index 0722ee1426..3f6bb4500c 100644
--- a/Userland/Libraries/LibWeb/CSS/GridTrackSize.h
+++ b/Userland/Libraries/LibWeb/CSS/GridTrackSize.h
@@ -92,13 +92,13 @@ private:
class GridTrackSizeList {
public:
- GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<DeprecatedString>> line_names);
+ GridTrackSizeList(Vector<CSS::ExplicitGridTrack> track_list, Vector<Vector<String>> line_names);
GridTrackSizeList();
static GridTrackSizeList make_auto();
Vector<CSS::ExplicitGridTrack> track_list() const { return m_track_list; }
- Vector<Vector<DeprecatedString>> line_names() const { return m_line_names; }
+ Vector<Vector<String>> line_names() const { return m_line_names; }
ErrorOr<String> to_string() const;
bool operator==(GridTrackSizeList const& other) const
@@ -108,7 +108,7 @@ public:
private:
Vector<CSS::ExplicitGridTrack> m_track_list;
- Vector<Vector<DeprecatedString>> m_line_names;
+ Vector<Vector<String>> m_line_names;
};
class GridRepeat {
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index d7397821da..daf3e4e157 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -6014,11 +6014,11 @@ Optional<CSS::GridRepeat> Parser::parse_repeat(Vector<ComponentValue> const& com
return {};
Vector<CSS::ExplicitGridTrack> repeat_params;
- Vector<Vector<DeprecatedString>> line_names_list;
+ Vector<Vector<String>> line_names_list;
auto last_object_was_line_names = false;
while (part_two_tokens.has_next_token()) {
auto token = part_two_tokens.next_token();
- Vector<DeprecatedString> line_names;
+ Vector<String> line_names;
if (token.is_block()) {
if (last_object_was_line_names)
return {};
@@ -6028,7 +6028,10 @@ Optional<CSS::GridRepeat> Parser::parse_repeat(Vector<ComponentValue> const& com
TokenStream block_tokens { token.block().values() };
while (block_tokens.has_next_token()) {
auto current_block_token = block_tokens.next_token();
- line_names.append(current_block_token.token().ident());
+ auto maybe_string = String::from_utf8(current_block_token.token().ident());
+ if (maybe_string.is_error())
+ return {};
+ line_names.append(maybe_string.value());
block_tokens.skip_whitespace();
}
line_names_list.append(line_names);
@@ -6112,7 +6115,7 @@ Optional<CSS::ExplicitGridTrack> Parser::parse_track_sizing_function(ComponentVa
RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const& component_values)
{
Vector<CSS::ExplicitGridTrack> track_list;
- Vector<Vector<DeprecatedString>> line_names_list;
+ Vector<Vector<String>> line_names_list;
auto last_object_was_line_names = false;
TokenStream tokens { component_values };
while (tokens.has_next_token()) {
@@ -6121,13 +6124,16 @@ RefPtr<StyleValue> Parser::parse_grid_track_sizes(Vector<ComponentValue> const&
if (last_object_was_line_names)
return GridTrackSizeStyleValue::make_auto();
last_object_was_line_names = true;
- Vector<DeprecatedString> line_names;
+ Vector<String> line_names;
if (!token.block().is_square())
return GridTrackSizeStyleValue::make_auto();
TokenStream block_tokens { token.block().values() };
while (block_tokens.has_next_token()) {
auto current_block_token = block_tokens.next_token();
- line_names.append(current_block_token.token().ident());
+ auto maybe_string = String::from_utf8(current_block_token.token().ident());
+ if (maybe_string.is_error())
+ return {};
+ line_names.append(maybe_string.value());
block_tokens.skip_whitespace();
}
line_names_list.append(line_names);
@@ -6189,14 +6195,17 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement(Vector<ComponentValue> con
return GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement(1, true));
if (is_valid_integer(current_token))
return GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement(static_cast<int>(current_token.number_value())));
- if (is_line_name(current_token))
- return GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement(current_token.ident()));
+ if (is_line_name(current_token)) {
+ auto maybe_string = String::from_utf8(current_token.ident());
+ if (!maybe_string.is_error())
+ return GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement(maybe_string.value()));
+ }
return {};
}
auto span_value = false;
auto span_or_position_value = 0;
- DeprecatedString line_name_value;
+ String line_name_value;
while (true) {
if (is_auto(current_token))
return {};
@@ -6213,10 +6222,14 @@ RefPtr<StyleValue> Parser::parse_grid_track_placement(Vector<ComponentValue> con
return {};
}
if (is_line_name(current_token)) {
- if (line_name_value.is_empty())
- line_name_value = current_token.ident();
- else
+ if (line_name_value.is_empty()) {
+ auto maybe_string = String::from_utf8(current_token.ident());
+ if (maybe_string.is_error())
+ return {};
+ line_name_value = maybe_string.release_value();
+ } else {
return {};
+ }
}
tokens.skip_whitespace();
if (tokens.has_next_token())
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
index 2d777c435b..44b593f44c 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
@@ -1820,7 +1820,7 @@ CSSPixels GridFormattingContext::get_free_space_y(Box const& box)
return -1;
}
-int GridFormattingContext::get_line_index_by_line_name(DeprecatedString const& needle, CSS::GridTrackSizeList grid_track_size_list)
+int GridFormattingContext::get_line_index_by_line_name(String const& needle, CSS::GridTrackSizeList grid_track_size_list)
{
if (grid_track_size_list.track_list().size() == 0)
return -1;
diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
index 01f21ab7af..a79264f9cb 100644
--- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
@@ -99,7 +99,7 @@ private:
CSSPixels get_free_space_x(AvailableSpace const& available_space);
CSSPixels get_free_space_y(Box const&);
- int get_line_index_by_line_name(DeprecatedString const& line_name, CSS::GridTrackSizeList);
+ int get_line_index_by_line_name(String const& line_name, CSS::GridTrackSizeList);
CSSPixels resolve_definite_track_size(CSS::GridSize const&, AvailableSpace const&, Box const&);
size_t count_of_gap_columns();
size_t count_of_gap_rows();