mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:27:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -11,13 +11,13 @@
|
|||
#include <LibGUI/Window.h>
|
||||
#include <errno_codes.h>
|
||||
|
||||
Presentation::Presentation(Gfx::IntSize normative_size, HashMap<DeprecatedString, DeprecatedString> metadata)
|
||||
Presentation::Presentation(Gfx::IntSize normative_size, HashMap<ByteString, ByteString> metadata)
|
||||
: m_normative_size(normative_size)
|
||||
, m_metadata(move(metadata))
|
||||
{
|
||||
}
|
||||
|
||||
NonnullOwnPtr<Presentation> Presentation::construct(Gfx::IntSize normative_size, HashMap<DeprecatedString, DeprecatedString> metadata)
|
||||
NonnullOwnPtr<Presentation> Presentation::construct(Gfx::IntSize normative_size, HashMap<ByteString, ByteString> metadata)
|
||||
{
|
||||
return NonnullOwnPtr<Presentation>(NonnullOwnPtr<Presentation>::Adopt, *new Presentation(normative_size, move(metadata)));
|
||||
}
|
||||
|
@ -128,12 +128,12 @@ ErrorOr<NonnullOwnPtr<Presentation>> Presentation::load_from_file(StringView fil
|
|||
return presentation;
|
||||
}
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString> Presentation::parse_metadata(JsonObject const& metadata_object)
|
||||
HashMap<ByteString, ByteString> Presentation::parse_metadata(JsonObject const& metadata_object)
|
||||
{
|
||||
HashMap<DeprecatedString, DeprecatedString> metadata;
|
||||
HashMap<ByteString, ByteString> metadata;
|
||||
|
||||
metadata_object.for_each_member([&](auto const& key, auto const& value) {
|
||||
metadata.set(key, value.to_deprecated_string());
|
||||
metadata.set(key, value.to_byte_string());
|
||||
});
|
||||
|
||||
return metadata;
|
||||
|
@ -142,7 +142,7 @@ HashMap<DeprecatedString, DeprecatedString> Presentation::parse_metadata(JsonObj
|
|||
ErrorOr<Gfx::IntSize> Presentation::parse_presentation_size(JsonObject const& metadata_object)
|
||||
{
|
||||
auto const& maybe_width = metadata_object.get("width"sv);
|
||||
auto const& maybe_aspect = metadata_object.get_deprecated_string("aspect"sv);
|
||||
auto const& maybe_aspect = metadata_object.get_byte_string("aspect"sv);
|
||||
|
||||
if (!maybe_width.has_value() || !maybe_width->is_number() || !maybe_aspect.has_value())
|
||||
return Error::from_string_view("Width or aspect in incorrect format"sv);
|
||||
|
@ -164,14 +164,14 @@ ErrorOr<Gfx::IntSize> Presentation::parse_presentation_size(JsonObject const& me
|
|||
};
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Presentation::render()
|
||||
ErrorOr<ByteString> Presentation::render()
|
||||
{
|
||||
HTMLElement main_element;
|
||||
main_element.tag_name = "main"sv;
|
||||
for (size_t i = 0; i < m_slides.size(); ++i) {
|
||||
HTMLElement slide_div;
|
||||
slide_div.tag_name = "div"sv;
|
||||
TRY(slide_div.attributes.try_set("id"sv, DeprecatedString::formatted("slide{}", i)));
|
||||
TRY(slide_div.attributes.try_set("id"sv, ByteString::formatted("slide{}", i)));
|
||||
TRY(slide_div.attributes.try_set("class"sv, "slide hidden"sv));
|
||||
auto& slide = m_slides[i];
|
||||
TRY(slide_div.children.try_append(TRY(slide.render(*this))));
|
||||
|
@ -214,5 +214,5 @@ ErrorOr<DeprecatedString> Presentation::render()
|
|||
)"sv));
|
||||
TRY(main_element.serialize(builder));
|
||||
TRY(builder.try_append("</body></html>"sv));
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Slide.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -38,21 +38,21 @@ public:
|
|||
void previous_frame();
|
||||
void go_to_first_slide();
|
||||
|
||||
ErrorOr<DeprecatedString> render();
|
||||
ErrorOr<ByteString> render();
|
||||
|
||||
private:
|
||||
static HashMap<DeprecatedString, DeprecatedString> parse_metadata(JsonObject const& metadata_object);
|
||||
static HashMap<ByteString, ByteString> parse_metadata(JsonObject const& metadata_object);
|
||||
static ErrorOr<Gfx::IntSize> parse_presentation_size(JsonObject const& metadata_object);
|
||||
|
||||
Presentation(Gfx::IntSize normative_size, HashMap<DeprecatedString, DeprecatedString> metadata);
|
||||
static NonnullOwnPtr<Presentation> construct(Gfx::IntSize normative_size, HashMap<DeprecatedString, DeprecatedString> metadata);
|
||||
Presentation(Gfx::IntSize normative_size, HashMap<ByteString, ByteString> metadata);
|
||||
static NonnullOwnPtr<Presentation> construct(Gfx::IntSize normative_size, HashMap<ByteString, ByteString> metadata);
|
||||
|
||||
void append_slide(Slide slide);
|
||||
|
||||
Vector<Slide> m_slides {};
|
||||
// This is not a pixel size, but an abstract size used by the slide objects for relative positioning.
|
||||
Gfx::IntSize m_normative_size;
|
||||
HashMap<DeprecatedString, DeprecatedString> m_metadata;
|
||||
HashMap<ByteString, ByteString> m_metadata;
|
||||
|
||||
Checked<unsigned> m_current_slide { 0 };
|
||||
Checked<unsigned> m_current_frame_in_slide { 0 };
|
||||
|
|
|
@ -125,7 +125,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
|
||||
void PresenterWidget::update_web_view()
|
||||
{
|
||||
m_web_view->run_javascript(DeprecatedString::formatted("goto({}, {})", m_current_presentation->current_slide_number(), m_current_presentation->current_frame_in_slide_number()));
|
||||
m_web_view->run_javascript(ByteString::formatted("goto({}, {})", m_current_presentation->current_slide_number(), m_current_presentation->current_frame_in_slide_number()));
|
||||
}
|
||||
|
||||
void PresenterWidget::update_slides_actions()
|
||||
|
@ -147,10 +147,10 @@ void PresenterWidget::set_file(StringView file_name)
|
|||
{
|
||||
auto presentation = Presentation::load_from_file(file_name);
|
||||
if (presentation.is_error()) {
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("The presentation \"{}\" could not be loaded.\n{}", file_name, presentation.error()));
|
||||
GUI::MessageBox::show_error(window(), ByteString::formatted("The presentation \"{}\" could not be loaded.\n{}", file_name, presentation.error()));
|
||||
} else {
|
||||
m_current_presentation = presentation.release_value();
|
||||
window()->set_title(DeprecatedString::formatted(title_template, m_current_presentation->title(), m_current_presentation->author()));
|
||||
window()->set_title(ByteString::formatted(title_template, m_current_presentation->title(), m_current_presentation->author()));
|
||||
set_min_size(m_current_presentation->normative_size());
|
||||
m_web_view->load_html(MUST(m_current_presentation->render()));
|
||||
update_slides_actions();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "Presentation.h"
|
||||
#include <AK/JsonObject.h>
|
||||
|
||||
Slide::Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title)
|
||||
Slide::Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_objects, ByteString title)
|
||||
: m_frame_count(move(frame_count))
|
||||
, m_slide_objects(move(slide_objects))
|
||||
, m_title(move(title))
|
||||
|
@ -19,7 +19,7 @@ Slide::Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_obje
|
|||
ErrorOr<Slide> Slide::parse_slide(JsonObject const& slide_json, unsigned slide_index)
|
||||
{
|
||||
// FIXME: Use the text with the "title" role for a title, if there is no title given.
|
||||
auto title = slide_json.get_deprecated_string("title"sv).value_or("Untitled slide");
|
||||
auto title = slide_json.get_byte_string("title"sv).value_or("Untitled slide");
|
||||
auto frame_count = slide_json.get_u32("frame_count"sv).value_or(1);
|
||||
auto maybe_slide_objects = slide_json.get_array("objects"sv);
|
||||
if (!maybe_slide_objects.has_value())
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "SlideObject.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
|
||||
// A single slide of a presentation.
|
||||
|
@ -22,9 +22,9 @@ public:
|
|||
ErrorOr<HTMLElement> render(Presentation const&) const;
|
||||
|
||||
private:
|
||||
Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_objects, DeprecatedString title);
|
||||
Slide(unsigned frame_count, Vector<NonnullRefPtr<SlideObject>> slide_objects, ByteString title);
|
||||
|
||||
unsigned m_frame_count;
|
||||
Vector<NonnullRefPtr<SlideObject>> m_slide_objects;
|
||||
DeprecatedString m_title;
|
||||
ByteString m_title;
|
||||
};
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
#include <LibGfx/Font/FontStyleMapping.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
||||
static DeprecatedString to_css_length(float design_value, Presentation const& presentation)
|
||||
static ByteString to_css_length(float design_value, Presentation const& presentation)
|
||||
{
|
||||
float length_in_vw = design_value / static_cast<float>(presentation.normative_size().width()) * 100.0f;
|
||||
return DeprecatedString::formatted("{}vw", length_in_vw);
|
||||
return ByteString::formatted("{}vw", length_in_vw);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<SlideObject>> SlideObject::parse_slide_object(JsonObject const& slide_object_json, unsigned slide_index)
|
||||
{
|
||||
auto frame = slide_object_json.get_u32("frame"sv).value_or(0);
|
||||
auto maybe_type = slide_object_json.get_deprecated_string("type"sv);
|
||||
auto maybe_type = slide_object_json.get_byte_string("type"sv);
|
||||
if (!maybe_type.has_value())
|
||||
return Error::from_string_view("Slide object must have a type"sv);
|
||||
|
||||
|
@ -58,7 +58,7 @@ void SlideObject::set_property(StringView name, JsonValue value)
|
|||
void GraphicsObject::set_property(StringView name, JsonValue value)
|
||||
{
|
||||
if (name == "color"sv) {
|
||||
if (auto color = Gfx::Color::from_string(value.to_deprecated_string()); color.has_value()) {
|
||||
if (auto color = Gfx::Color::from_string(value.to_byte_string()); color.has_value()) {
|
||||
m_color = color.release_value();
|
||||
}
|
||||
}
|
||||
|
@ -68,15 +68,15 @@ void GraphicsObject::set_property(StringView name, JsonValue value)
|
|||
void Text::set_property(StringView name, JsonValue value)
|
||||
{
|
||||
if (name == "text"sv) {
|
||||
m_text = value.to_deprecated_string();
|
||||
m_text = value.to_byte_string();
|
||||
} else if (name == "font"sv) {
|
||||
m_font_family = value.to_deprecated_string();
|
||||
m_font_family = value.to_byte_string();
|
||||
} else if (name == "font-weight"sv) {
|
||||
m_font_weight = Gfx::name_to_weight(value.to_deprecated_string());
|
||||
m_font_weight = Gfx::name_to_weight(value.to_byte_string());
|
||||
} else if (name == "font-size"sv) {
|
||||
m_font_size_in_pt = value.to_float();
|
||||
} else if (name == "text-alignment"sv) {
|
||||
m_text_align = value.to_deprecated_string();
|
||||
m_text_align = value.to_byte_string();
|
||||
}
|
||||
GraphicsObject::set_property(name, move(value));
|
||||
}
|
||||
|
@ -84,11 +84,11 @@ void Text::set_property(StringView name, JsonValue value)
|
|||
void Image::set_property(StringView name, JsonValue value)
|
||||
{
|
||||
if (name == "path"sv) {
|
||||
m_src = value.to_deprecated_string();
|
||||
m_src = value.to_byte_string();
|
||||
} else if (name == "scaling-mode"sv) {
|
||||
if (value.to_deprecated_string() == "nearest-neighbor"sv)
|
||||
if (value.to_byte_string() == "nearest-neighbor"sv)
|
||||
m_image_rendering = "crisp-edges"sv;
|
||||
else if (value.to_deprecated_string() == "smooth-pixels"sv)
|
||||
else if (value.to_byte_string() == "smooth-pixels"sv)
|
||||
m_image_rendering = "pixelated"sv;
|
||||
}
|
||||
SlideObject::set_property(name, move(value));
|
||||
|
@ -98,11 +98,11 @@ ErrorOr<HTMLElement> Text::render(Presentation const& presentation) const
|
|||
{
|
||||
HTMLElement div;
|
||||
div.tag_name = "div"sv;
|
||||
TRY(div.attributes.try_set("class"sv, DeprecatedString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index)));
|
||||
div.style.set("color"sv, m_color.to_deprecated_string());
|
||||
div.style.set("font-family"sv, DeprecatedString::formatted("'{}'", m_font_family));
|
||||
TRY(div.attributes.try_set("class"sv, ByteString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index)));
|
||||
div.style.set("color"sv, m_color.to_byte_string());
|
||||
div.style.set("font-family"sv, ByteString::formatted("'{}'", m_font_family));
|
||||
div.style.set("font-size"sv, to_css_length(m_font_size_in_pt * 1.33333333f, presentation));
|
||||
div.style.set("font-weight"sv, DeprecatedString::number(m_font_weight));
|
||||
div.style.set("font-weight"sv, ByteString::number(m_font_weight));
|
||||
div.style.set("text-align"sv, m_text_align);
|
||||
div.style.set("white-space"sv, "pre-wrap"sv);
|
||||
div.style.set("width"sv, to_css_length(m_rect.width(), presentation));
|
||||
|
@ -118,7 +118,7 @@ ErrorOr<HTMLElement> Image::render(Presentation const& presentation) const
|
|||
{
|
||||
HTMLElement img;
|
||||
img.tag_name = "img"sv;
|
||||
img.attributes.set("src"sv, URL::create_with_file_scheme(m_src).to_deprecated_string());
|
||||
img.attributes.set("src"sv, URL::create_with_file_scheme(m_src).to_byte_string());
|
||||
img.style.set("image-rendering"sv, m_image_rendering);
|
||||
if (m_rect.width() > m_rect.height())
|
||||
img.style.set("height"sv, "100%"sv);
|
||||
|
@ -127,7 +127,7 @@ ErrorOr<HTMLElement> Image::render(Presentation const& presentation) const
|
|||
|
||||
HTMLElement image_wrapper;
|
||||
image_wrapper.tag_name = "div"sv;
|
||||
TRY(image_wrapper.attributes.try_set("class"sv, DeprecatedString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index)));
|
||||
TRY(image_wrapper.attributes.try_set("class"sv, ByteString::formatted("frame slide{}-frame{}", m_slide_index, m_frame_index)));
|
||||
image_wrapper.children.append(move(img));
|
||||
image_wrapper.style.set("position"sv, "absolute"sv);
|
||||
image_wrapper.style.set("left"sv, to_css_length(m_rect.left(), presentation));
|
||||
|
|
|
@ -14,9 +14,9 @@ class Presentation;
|
|||
|
||||
struct HTMLElement {
|
||||
StringView tag_name;
|
||||
HashMap<StringView, DeprecatedString> attributes;
|
||||
HashMap<StringView, DeprecatedString> style;
|
||||
DeprecatedString inner_text;
|
||||
HashMap<StringView, ByteString> attributes;
|
||||
HashMap<StringView, ByteString> style;
|
||||
ByteString inner_text;
|
||||
Vector<HTMLElement> children;
|
||||
|
||||
ErrorOr<void> serialize(StringBuilder&) const;
|
||||
|
@ -44,7 +44,7 @@ protected:
|
|||
|
||||
unsigned m_frame_index;
|
||||
unsigned m_slide_index;
|
||||
HashMap<DeprecatedString, JsonValue> m_properties;
|
||||
HashMap<ByteString, JsonValue> m_properties;
|
||||
Gfx::IntRect m_rect;
|
||||
};
|
||||
|
||||
|
@ -76,9 +76,9 @@ private:
|
|||
virtual ErrorOr<HTMLElement> render(Presentation const&) const override;
|
||||
virtual void set_property(StringView name, JsonValue) override;
|
||||
|
||||
DeprecatedString m_text;
|
||||
DeprecatedString m_font_family;
|
||||
DeprecatedString m_text_align;
|
||||
ByteString m_text;
|
||||
ByteString m_font_family;
|
||||
ByteString m_text_align;
|
||||
float m_font_size_in_pt { 18 };
|
||||
unsigned m_font_weight { Gfx::FontWeight::Regular };
|
||||
};
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
virtual ~Image() = default;
|
||||
|
||||
private:
|
||||
DeprecatedString m_src;
|
||||
ByteString m_src;
|
||||
StringView m_image_rendering;
|
||||
|
||||
virtual ErrorOr<HTMLElement> render(Presentation const&) const override;
|
||||
|
|
|
@ -18,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// rpath is required to load .presenter files, unix, sendfd and recvfd are required to talk to WindowServer and WebContent.
|
||||
TRY(Core::System::pledge("stdio rpath unix sendfd recvfd"));
|
||||
|
||||
DeprecatedString file_to_load;
|
||||
ByteString file_to_load;
|
||||
Core::ArgsParser argument_parser;
|
||||
argument_parser.add_positional_argument(file_to_load, "Presentation to load", "file", Core::ArgsParser::Required::No);
|
||||
argument_parser.parse(arguments);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue