diff --git a/Userland/Libraries/LibPDF/ColorSpace.cpp b/Userland/Libraries/LibPDF/ColorSpace.cpp index fba6b6c453..1336eb6aa7 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.cpp +++ b/Userland/Libraries/LibPDF/ColorSpace.cpp @@ -15,7 +15,7 @@ RefPtr DeviceGrayColorSpace::the() return instance; } -Color DeviceGrayColorSpace::color(const Vector& arguments) const +Color DeviceGrayColorSpace::color(Vector const& arguments) const { VERIFY(arguments.size() == 1); auto gray = static_cast(arguments[0].to_float() * 255.0f); @@ -28,7 +28,7 @@ RefPtr DeviceRGBColorSpace::the() return instance; } -Color DeviceRGBColorSpace::color(const Vector& arguments) const +Color DeviceRGBColorSpace::color(Vector const& arguments) const { VERIFY(arguments.size() == 3); auto r = static_cast(arguments[0].to_float() * 255.0f); @@ -43,7 +43,7 @@ RefPtr DeviceCMYKColorSpace::the() return instance; } -Color DeviceCMYKColorSpace::color(const Vector& arguments) const +Color DeviceCMYKColorSpace::color(Vector const& arguments) const { VERIFY(arguments.size() == 4); auto c = arguments[0].to_float(); @@ -196,7 +196,7 @@ constexpr Array convert_to_srgb(Array xyz) return matrix_multiply(conversion_matrix, xyz); } -Color CalRGBColorSpace::color(const Vector& arguments) const +Color CalRGBColorSpace::color(Vector const& arguments) const { VERIFY(arguments.size() == 3); auto a = clamp(arguments[0].to_float(), 0.0f, 1.0f); diff --git a/Userland/Libraries/LibPDF/ColorSpace.h b/Userland/Libraries/LibPDF/ColorSpace.h index 90fa479775..2a680ff5ff 100644 --- a/Userland/Libraries/LibPDF/ColorSpace.h +++ b/Userland/Libraries/LibPDF/ColorSpace.h @@ -30,7 +30,7 @@ class ColorSpace : public RefCounted { public: virtual ~ColorSpace() = default; - virtual Color color(const Vector& arguments) const = 0; + virtual Color color(Vector const& arguments) const = 0; }; class DeviceGrayColorSpace final : public ColorSpace { @@ -39,7 +39,7 @@ public: virtual ~DeviceGrayColorSpace() override = default; - virtual Color color(const Vector& arguments) const override; + virtual Color color(Vector const& arguments) const override; private: DeviceGrayColorSpace() = default; @@ -51,7 +51,7 @@ public: virtual ~DeviceRGBColorSpace() override = default; - virtual Color color(const Vector& arguments) const override; + virtual Color color(Vector const& arguments) const override; private: DeviceRGBColorSpace() = default; @@ -63,7 +63,7 @@ public: virtual ~DeviceCMYKColorSpace() override = default; - virtual Color color(const Vector& arguments) const override; + virtual Color color(Vector const& arguments) const override; private: DeviceCMYKColorSpace() = default; @@ -74,7 +74,7 @@ public: static RefPtr create(RefPtr, Vector&& parameters); virtual ~CalRGBColorSpace() override = default; - virtual Color color(const Vector& arguments) const override; + virtual Color color(Vector const& arguments) const override; private: CalRGBColorSpace() = default; diff --git a/Userland/Libraries/LibPDF/Command.h b/Userland/Libraries/LibPDF/Command.h index 539cba6d8b..c751ded5d0 100644 --- a/Userland/Libraries/LibPDF/Command.h +++ b/Userland/Libraries/LibPDF/Command.h @@ -96,7 +96,7 @@ enum class CommandType { class Command { public: - static CommandType command_type_from_symbol(const StringView& symbol_string) + static CommandType command_type_from_symbol(StringView const& symbol_string) { #define V(name, snake_name, symbol) \ if (symbol_string == #symbol) \ @@ -152,7 +152,7 @@ public: } [[nodiscard]] ALWAYS_INLINE CommandType command_type() const { return m_command_type; } - [[nodiscard]] ALWAYS_INLINE const Vector& arguments() const { return m_arguments; } + [[nodiscard]] ALWAYS_INLINE Vector const& arguments() const { return m_arguments; } private: CommandType m_command_type; @@ -165,7 +165,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::Command& command) + void format(FormatBuilder& format_builder, PDF::Command const& command) { StringBuilder builder; builder.appendff("{} ({})", diff --git a/Userland/Libraries/LibPDF/Document.cpp b/Userland/Libraries/LibPDF/Document.cpp index c545e781dd..473b5f5a20 100644 --- a/Userland/Libraries/LibPDF/Document.cpp +++ b/Userland/Libraries/LibPDF/Document.cpp @@ -34,7 +34,7 @@ String OutlineItem::to_string(int indent) const return builder.to_string(); } -RefPtr Document::create(const ReadonlyBytes& bytes) +RefPtr Document::create(ReadonlyBytes const& bytes) { auto parser = adopt_ref(*new Parser({}, bytes)); auto document = adopt_ref(*new Document(parser)); @@ -49,7 +49,7 @@ RefPtr Document::create(const ReadonlyBytes& bytes) return document; } -Document::Document(const NonnullRefPtr& parser) +Document::Document(NonnullRefPtr const& parser) : m_parser(parser) { m_parser->set_document(this); @@ -131,7 +131,7 @@ Page Document::get_page(u32 index) return page; } -Value Document::resolve(const Value& value) +Value Document::resolve(Value const& value) { if (value.is_ref()) { // FIXME: Surely indirect PDF objects can't contain another indirect PDF object, @@ -159,7 +159,7 @@ bool Document::build_page_tree() return add_page_tree_node_to_page_tree(page_tree); } -bool Document::add_page_tree_node_to_page_tree(NonnullRefPtr page_tree) +bool Document::add_page_tree_node_to_page_tree(NonnullRefPtr const& page_tree) { if (!page_tree->contains(CommonNames::Kids) || !page_tree->contains(CommonNames::Count)) return false; @@ -216,7 +216,7 @@ void Document::build_outline() m_outline->count = outline_dict->get_value(CommonNames::Count).as_int(); } -NonnullRefPtr Document::build_outline_item(NonnullRefPtr outline_item_dict) +NonnullRefPtr Document::build_outline_item(NonnullRefPtr const& outline_item_dict) { auto outline_item = adopt_ref(*new OutlineItem {}); @@ -284,7 +284,7 @@ NonnullRefPtr Document::build_outline_item(NonnullRefPtr Document::build_outline_item_chain(const Value& first_ref, const Value& last_ref) +NonnullRefPtrVector Document::build_outline_item_chain(Value const& first_ref, Value const& last_ref) { VERIFY(first_ref.is_ref()); VERIFY(last_ref.is_ref()); diff --git a/Userland/Libraries/LibPDF/Document.h b/Userland/Libraries/LibPDF/Document.h index 3cf5806634..6c885cfcf2 100644 --- a/Userland/Libraries/LibPDF/Document.h +++ b/Userland/Libraries/LibPDF/Document.h @@ -72,9 +72,9 @@ struct OutlineDict final : public RefCounted { class Document final : public RefCounted { public: - static RefPtr create(const ReadonlyBytes& bytes); + static RefPtr create(ReadonlyBytes const& bytes); - ALWAYS_INLINE const RefPtr& outline() const { return m_outline; } + ALWAYS_INLINE RefPtr const& outline() const { return m_outline; } [[nodiscard]] Value get_or_load_value(u32 index); @@ -92,12 +92,12 @@ public: // Strips away the layer of indirection by turning indirect value // refs into the value they reference, and indirect values into // the value being wrapped. - Value resolve(const Value& value); + Value resolve(Value const& value); // Like resolve, but unwraps the Value into the given type. Accepts // any object type, and the three primitive Value types. template - UnwrappedValueType resolve_to(const Value& value) + UnwrappedValueType resolve_to(Value const& value) { auto resolved = resolve(value); @@ -114,7 +114,7 @@ public: } private: - explicit Document(const NonnullRefPtr& parser); + explicit Document(NonnullRefPtr const& parser); // FIXME: Currently, to improve performance, we don't load any pages at Document // construction, rather we just load the page structure and populate @@ -123,11 +123,11 @@ private: // improve lookup time. This would reduce the initial overhead by not loading // every page tree node of, say, a 1000+ page PDF file. bool build_page_tree(); - bool add_page_tree_node_to_page_tree(NonnullRefPtr page_tree); + bool add_page_tree_node_to_page_tree(NonnullRefPtr const& page_tree); void build_outline(); - NonnullRefPtr build_outline_item(NonnullRefPtr outline_item_dict); - NonnullRefPtrVector build_outline_item_chain(const Value& first_ref, const Value& last_ref); + NonnullRefPtr build_outline_item(NonnullRefPtr const& outline_item_dict); + NonnullRefPtrVector build_outline_item_chain(Value const& first_ref, Value const& last_ref); NonnullRefPtr m_parser; RefPtr m_catalog; @@ -143,7 +143,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::Rectangle& rectangle) + void format(FormatBuilder& builder, PDF::Rectangle const& rectangle) { Formatter::format(builder, String::formatted("Rectangle {{ ll=({}, {}), ur=({}, {}) }}", @@ -156,7 +156,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::Page& page) + void format(FormatBuilder& builder, PDF::Page const& page) { constexpr auto fmt_string = "Page {{\n resources={}\n contents={}\n media_box={}\n crop_box={}\n user_unit={}\n rotate={}\n}}"; auto str = String::formatted(fmt_string, @@ -172,7 +172,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::Destination& destination) + void format(FormatBuilder& builder, PDF::Destination const& destination) { String type_str; switch (destination.type) { @@ -213,7 +213,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::OutlineItem& item) + void format(FormatBuilder& builder, PDF::OutlineItem const& item) { Formatter::format(builder, item.to_string(0)); } @@ -221,7 +221,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::OutlineDict& dict) + void format(FormatBuilder& builder, PDF::OutlineDict const& dict) { StringBuilder child_builder; child_builder.append('['); diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index 6891cb95ce..bdb8b10b82 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -11,7 +11,7 @@ namespace PDF { -Optional Filter::decode(const ReadonlyBytes& bytes, const FlyString& encoding_type) +Optional Filter::decode(ReadonlyBytes const& bytes, FlyString const& encoding_type) { if (encoding_type == CommonNames::ASCIIHexDecode) return decode_ascii_hex(bytes); @@ -37,7 +37,7 @@ Optional Filter::decode(const ReadonlyBytes& bytes, const FlyString& return {}; } -Optional Filter::decode_ascii_hex(const ReadonlyBytes& bytes) +Optional Filter::decode_ascii_hex(ReadonlyBytes const& bytes) { if (bytes.size() % 2 == 0) return decode_hex(bytes); @@ -64,7 +64,7 @@ Optional Filter::decode_ascii_hex(const ReadonlyBytes& bytes) return output; }; -Optional Filter::decode_ascii85(const ReadonlyBytes& bytes) +Optional Filter::decode_ascii85(ReadonlyBytes const& bytes) { Vector buff; buff.ensure_capacity(bytes.size()); @@ -119,13 +119,13 @@ Optional Filter::decode_ascii85(const ReadonlyBytes& bytes) return ByteBuffer::copy(buff.span()); }; -Optional Filter::decode_lzw(const ReadonlyBytes&) +Optional Filter::decode_lzw(ReadonlyBytes const&) { dbgln("LZW decoding is not supported"); VERIFY_NOT_REACHED(); }; -Optional Filter::decode_flate(const ReadonlyBytes& bytes) +Optional Filter::decode_flate(ReadonlyBytes const& bytes) { // FIXME: The spec says Flate decoding is "based on" zlib, does that mean they // aren't exactly the same? @@ -135,37 +135,37 @@ Optional Filter::decode_flate(const ReadonlyBytes& bytes) return buff.value(); }; -Optional Filter::decode_run_length(const ReadonlyBytes&) +Optional Filter::decode_run_length(ReadonlyBytes const&) { // FIXME: Support RunLength decoding TODO(); }; -Optional Filter::decode_ccitt(const ReadonlyBytes&) +Optional Filter::decode_ccitt(ReadonlyBytes const&) { // FIXME: Support CCITT decoding TODO(); }; -Optional Filter::decode_jbig2(const ReadonlyBytes&) +Optional Filter::decode_jbig2(ReadonlyBytes const&) { // FIXME: Support JBIG2 decoding TODO(); }; -Optional Filter::decode_dct(const ReadonlyBytes&) +Optional Filter::decode_dct(ReadonlyBytes const&) { // FIXME: Support dct decoding TODO(); }; -Optional Filter::decode_jpx(const ReadonlyBytes&) +Optional Filter::decode_jpx(ReadonlyBytes const&) { // FIXME: Support JPX decoding TODO(); }; -Optional Filter::decode_crypt(const ReadonlyBytes&) +Optional Filter::decode_crypt(ReadonlyBytes const&) { // FIXME: Support Crypt decoding TODO(); diff --git a/Userland/Libraries/LibPDF/Filter.h b/Userland/Libraries/LibPDF/Filter.h index 876656c38a..490005c3a2 100644 --- a/Userland/Libraries/LibPDF/Filter.h +++ b/Userland/Libraries/LibPDF/Filter.h @@ -13,19 +13,19 @@ namespace PDF { class Filter { public: - static Optional decode(const ReadonlyBytes& bytes, const FlyString& encoding_type); + static Optional decode(ReadonlyBytes const& bytes, FlyString const& encoding_type); private: - static Optional decode_ascii_hex(const ReadonlyBytes& bytes); - static Optional decode_ascii85(const ReadonlyBytes& bytes); - static Optional decode_lzw(const ReadonlyBytes& bytes); - static Optional decode_flate(const ReadonlyBytes& bytes); - static Optional decode_run_length(const ReadonlyBytes& bytes); - static Optional decode_ccitt(const ReadonlyBytes& bytes); - static Optional decode_jbig2(const ReadonlyBytes& bytes); - static Optional decode_dct(const ReadonlyBytes& bytes); - static Optional decode_jpx(const ReadonlyBytes& bytes); - static Optional decode_crypt(const ReadonlyBytes& bytes); + static Optional decode_ascii_hex(ReadonlyBytes const& bytes); + static Optional decode_ascii85(ReadonlyBytes const& bytes); + static Optional decode_lzw(ReadonlyBytes const& bytes); + static Optional decode_flate(ReadonlyBytes const& bytes); + static Optional decode_run_length(ReadonlyBytes const& bytes); + static Optional decode_ccitt(ReadonlyBytes const& bytes); + static Optional decode_jbig2(ReadonlyBytes const& bytes); + static Optional decode_dct(ReadonlyBytes const& bytes); + static Optional decode_jpx(ReadonlyBytes const& bytes); + static Optional decode_crypt(ReadonlyBytes const& bytes); }; } diff --git a/Userland/Libraries/LibPDF/Object.cpp b/Userland/Libraries/LibPDF/Object.cpp index 1b7921a092..c94f868a27 100644 --- a/Userland/Libraries/LibPDF/Object.cpp +++ b/Userland/Libraries/LibPDF/Object.cpp @@ -15,7 +15,7 @@ NonnullRefPtr ArrayObject::get_object_at(Document* document, size_t inde return document->resolve_to(m_elements[index]); } -NonnullRefPtr DictObject::get_object(Document* document, const FlyString& key) const +NonnullRefPtr DictObject::get_object(Document* document, FlyString const& key) const { return document->resolve_to(get_value(key)); } @@ -26,7 +26,7 @@ NonnullRefPtr DictObject::get_object(Document* document, const FlyString return document->resolve_to(m_elements[index]); \ } \ \ - NonnullRefPtr DictObject::get_##snake_name(Document* document, const FlyString& key) const \ + NonnullRefPtr DictObject::get_##snake_name(Document* document, FlyString const& key) const \ { \ return document->resolve_to(get(key).value()); \ } diff --git a/Userland/Libraries/LibPDF/Object.h b/Userland/Libraries/LibPDF/Object.h index c13a0e4d8d..47d0794de6 100644 --- a/Userland/Libraries/LibPDF/Object.h +++ b/Userland/Libraries/LibPDF/Object.h @@ -46,7 +46,7 @@ public: ~StringObject() override = default; - [[nodiscard]] ALWAYS_INLINE const String& string() const { return m_string; } + [[nodiscard]] ALWAYS_INLINE String const& string() const { return m_string; } [[nodiscard]] ALWAYS_INLINE bool is_binary() const { return m_is_binary; } ALWAYS_INLINE bool is_string() const override { return true; } @@ -67,7 +67,7 @@ public: ~NameObject() override = default; - [[nodiscard]] ALWAYS_INLINE const FlyString& name() const { return m_name; } + [[nodiscard]] ALWAYS_INLINE FlyString const& name() const { return m_name; } ALWAYS_INLINE bool is_name() const override { return true; } ALWAYS_INLINE const char* type_name() const override { return "name"; } @@ -92,8 +92,8 @@ public: ALWAYS_INLINE auto begin() const { return m_elements.begin(); } ALWAYS_INLINE auto end() const { return m_elements.end(); } - ALWAYS_INLINE const Value& operator[](size_t index) const { return at(index); } - ALWAYS_INLINE const Value& at(size_t index) const { return m_elements[index]; } + ALWAYS_INLINE Value const& operator[](size_t index) const { return at(index); } + ALWAYS_INLINE Value const& at(size_t index) const { return m_elements[index]; } NonnullRefPtr get_object_at(Document*, size_t index) const; @@ -122,24 +122,24 @@ public: ~DictObject() override = default; - [[nodiscard]] ALWAYS_INLINE const HashMap& map() const { return m_map; } + [[nodiscard]] ALWAYS_INLINE HashMap const& map() const { return m_map; } template bool contains(Args&&... keys) const { return (m_map.contains(keys) && ...); } - ALWAYS_INLINE Optional get(const FlyString& key) const { return m_map.get(key); } + ALWAYS_INLINE Optional get(FlyString const& key) const { return m_map.get(key); } - Value get_value(const FlyString& key) const + Value get_value(FlyString const& key) const { auto value = get(key); VERIFY(value.has_value()); return value.value(); } - NonnullRefPtr get_object(Document*, const FlyString& key) const; + NonnullRefPtr get_object(Document*, FlyString const& key) const; #define DEFINE_GETTER(class_name, snake_name) \ - NonnullRefPtr get_##snake_name(Document*, const FlyString& key) const; + NonnullRefPtr get_##snake_name(Document*, FlyString const& key) const; ENUMERATE_OBJECT_TYPES(DEFINE_GETTER) #undef DEFINE_GETTER @@ -156,7 +156,7 @@ private: class StreamObject : public Object { public: - explicit StreamObject(const NonnullRefPtr& dict) + explicit StreamObject(NonnullRefPtr const& dict) : m_dict(dict) { } @@ -176,7 +176,7 @@ private: class PlainTextStreamObject final : public StreamObject { public: - PlainTextStreamObject(const NonnullRefPtr& dict, const ReadonlyBytes& bytes) + PlainTextStreamObject(NonnullRefPtr const& dict, ReadonlyBytes const& bytes) : StreamObject(dict) , m_bytes(bytes) { @@ -192,7 +192,7 @@ private: class EncodedStreamObject final : public StreamObject { public: - EncodedStreamObject(const NonnullRefPtr& dict, ByteBuffer&& buffer) + EncodedStreamObject(NonnullRefPtr const& dict, ByteBuffer&& buffer) : StreamObject(dict) , m_buffer(buffer) { @@ -208,7 +208,7 @@ private: class IndirectValue final : public Object { public: - IndirectValue(u32 index, u32 generation_index, const Value& value) + IndirectValue(u32 index, u32 generation_index, Value const& value) : m_index(index) , m_value(value) { @@ -218,7 +218,7 @@ public: ~IndirectValue() override = default; [[nodiscard]] ALWAYS_INLINE u32 index() const { return m_index; } - [[nodiscard]] ALWAYS_INLINE const Value& value() const { return m_value; } + [[nodiscard]] ALWAYS_INLINE Value const& value() const { return m_value; } ALWAYS_INLINE bool is_indirect_value() const override { return true; } ALWAYS_INLINE const char* type_name() const override { return "indirect_object"; } @@ -257,7 +257,7 @@ namespace AK { template struct Formatter : Formatter { - void format(FormatBuilder& builder, const T& object) + void format(FormatBuilder& builder, T const& object) { Formatter::format(builder, object.to_string(0)); } @@ -265,7 +265,7 @@ struct Formatter : Formatter { template struct Formatter> : Formatter { - void format(FormatBuilder& builder, const NonnullRefPtr& object) + void format(FormatBuilder& builder, NonnullRefPtr const& object) { Formatter::format(builder, *object); } diff --git a/Userland/Libraries/LibPDF/Parser.cpp b/Userland/Libraries/LibPDF/Parser.cpp index 17f678172b..c3a66bb96b 100644 --- a/Userland/Libraries/LibPDF/Parser.cpp +++ b/Userland/Libraries/LibPDF/Parser.cpp @@ -24,18 +24,18 @@ static NonnullRefPtr make_object(Args... args) requires(IsBaseOf) return adopt_ref(*new T(forward(args)...)); } -Vector Parser::parse_graphics_commands(const ReadonlyBytes& bytes) +Vector Parser::parse_graphics_commands(ReadonlyBytes const& bytes) { auto parser = adopt_ref(*new Parser(bytes)); return parser->parse_graphics_commands(); } -Parser::Parser(Badge, const ReadonlyBytes& bytes) +Parser::Parser(Badge, ReadonlyBytes const& bytes) : m_reader(bytes) { } -Parser::Parser(const ReadonlyBytes& bytes) +Parser::Parser(ReadonlyBytes const& bytes) : m_reader(bytes) { } @@ -390,7 +390,7 @@ RefPtr Parser::parse_file_trailer() return dict; } -Optional Parser::parse_page_offset_hint_table(const ReadonlyBytes& hint_stream_bytes) +Optional Parser::parse_page_offset_hint_table(ReadonlyBytes const& hint_stream_bytes) { if (hint_stream_bytes.size() < sizeof(PageOffsetHintTable)) return {}; @@ -438,7 +438,7 @@ Optional Parser::parse_page_offset_hint_table(const return hint_table; } -Optional> Parser::parse_all_page_offset_hint_table_entries(const PageOffsetHintTable& hint_table, const ReadonlyBytes& hint_stream_bytes) +Optional> Parser::parse_all_page_offset_hint_table_entries(PageOffsetHintTable const& hint_table, ReadonlyBytes const& hint_stream_bytes) { InputMemoryStream input_stream(hint_stream_bytes); input_stream.seek(sizeof(PageOffsetHintTable)); @@ -1167,7 +1167,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::Parser::LinearizationDictionary& dict) + void format(FormatBuilder& format_builder, PDF::Parser::LinearizationDictionary const& dict) { StringBuilder builder; builder.append("{\n"); @@ -1188,7 +1188,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::Parser::PageOffsetHintTable& table) + void format(FormatBuilder& format_builder, PDF::Parser::PageOffsetHintTable const& table) { StringBuilder builder; builder.append("{\n"); @@ -1212,7 +1212,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::Parser::PageOffsetHintTableEntry& entry) + void format(FormatBuilder& format_builder, PDF::Parser::PageOffsetHintTableEntry const& entry) { StringBuilder builder; builder.append("{\n"); diff --git a/Userland/Libraries/LibPDF/Parser.h b/Userland/Libraries/LibPDF/Parser.h index e1a0912463..6dbe3b2f5f 100644 --- a/Userland/Libraries/LibPDF/Parser.h +++ b/Userland/Libraries/LibPDF/Parser.h @@ -18,12 +18,12 @@ class Document; class Parser final : public RefCounted { public: - static Vector parse_graphics_commands(const ReadonlyBytes&); + static Vector parse_graphics_commands(ReadonlyBytes const&); - Parser(Badge, const ReadonlyBytes&); + Parser(Badge, ReadonlyBytes const&); - [[nodiscard]] ALWAYS_INLINE const RefPtr& trailer() const { return m_trailer; } - void set_document(const RefPtr& document) { m_document = document; } + [[nodiscard]] ALWAYS_INLINE RefPtr const& trailer() const { return m_trailer; } + void set_document(RefPtr const& document) { m_document = document; } // Parses the header and initializes the xref table and trailer bool initialize(); @@ -80,15 +80,15 @@ private: friend struct AK::Formatter; friend struct AK::Formatter; - explicit Parser(const ReadonlyBytes&); + explicit Parser(ReadonlyBytes const&); bool parse_header(); bool initialize_linearization_dict(); bool initialize_linearized_xref_table(); bool initialize_non_linearized_xref_table(); bool initialize_hint_tables(); - Optional parse_page_offset_hint_table(const ReadonlyBytes& hint_stream_bytes); - Optional> parse_all_page_offset_hint_table_entries(const PageOffsetHintTable&, const ReadonlyBytes& hint_stream_bytes); + Optional parse_page_offset_hint_table(ReadonlyBytes const& hint_stream_bytes); + Optional> parse_all_page_offset_hint_table_entries(PageOffsetHintTable const&, ReadonlyBytes const& hint_stream_bytes); RefPtr parse_xref_table(); RefPtr parse_file_trailer(); diff --git a/Userland/Libraries/LibPDF/Reader.h b/Userland/Libraries/LibPDF/Reader.h index 9459340792..e3d7b50c65 100644 --- a/Userland/Libraries/LibPDF/Reader.h +++ b/Userland/Libraries/LibPDF/Reader.h @@ -14,12 +14,12 @@ namespace PDF { class Reader { public: - explicit Reader(const ReadonlyBytes& bytes) + explicit Reader(ReadonlyBytes const& bytes) : m_bytes(bytes) { } - ALWAYS_INLINE const ReadonlyBytes& bytes() const { return m_bytes; } + ALWAYS_INLINE ReadonlyBytes const& bytes() const { return m_bytes; } ALWAYS_INLINE size_t offset() const { return m_offset; } bool done() const diff --git a/Userland/Libraries/LibPDF/Renderer.cpp b/Userland/Libraries/LibPDF/Renderer.cpp index fe17b1d72a..cacb122f38 100644 --- a/Userland/Libraries/LibPDF/Renderer.cpp +++ b/Userland/Libraries/LibPDF/Renderer.cpp @@ -9,7 +9,7 @@ #include #define RENDERER_HANDLER(name) \ - void Renderer::handle_##name([[maybe_unused]] const Vector& args) + void Renderer::handle_##name([[maybe_unused]] Vector const& args) #define RENDERER_TODO(name) \ RENDERER_HANDLER(name) \ @@ -20,12 +20,12 @@ namespace PDF { -void Renderer::render(Document& document, const Page& page, RefPtr bitmap) +void Renderer::render(Document& document, Page const& page, RefPtr bitmap) { Renderer(document, page, bitmap).render(); } -Renderer::Renderer(RefPtr document, const Page& page, RefPtr bitmap) +Renderer::Renderer(RefPtr document, Page const& page, RefPtr bitmap) : m_document(document) , m_bitmap(bitmap) , m_page(page) @@ -83,7 +83,7 @@ void Renderer::render() handle_command(command); } -void Renderer::handle_command(const Command& command) +void Renderer::handle_command(Command const& command) { switch (command.command_type()) { #define V(name, snake_name, symbol) \ @@ -528,7 +528,7 @@ void Renderer::set_graphics_state_from_dict(NonnullRefPtr dict) handle_set_flatness_tolerance({ dict->get_value(CommonNames::FL) }); } -void Renderer::show_text(const String& string, float shift) +void Renderer::show_text(String const& string, float shift) { auto utf = Utf8View(string); @@ -566,7 +566,7 @@ void Renderer::show_text(const String& string, float shift) m_text_matrix = Gfx::AffineTransform(1, 0, 0, 1, delta_x, 0).multiply(m_text_matrix); } -RefPtr Renderer::get_color_space(const Value& value) +RefPtr Renderer::get_color_space(Value const& value) { auto name = object_cast(value.as_object())->name(); @@ -600,7 +600,7 @@ RefPtr Renderer::get_color_space(const Value& value) TODO(); } -const Gfx::AffineTransform& Renderer::calculate_text_rendering_matrix() +Gfx::AffineTransform const& Renderer::calculate_text_rendering_matrix() { if (m_text_rendering_matrix_is_dirty) { m_text_rendering_matrix = Gfx::AffineTransform( diff --git a/Userland/Libraries/LibPDF/Renderer.h b/Userland/Libraries/LibPDF/Renderer.h index 3bb67261c2..b2daebc19a 100644 --- a/Userland/Libraries/LibPDF/Renderer.h +++ b/Userland/Libraries/LibPDF/Renderer.h @@ -79,29 +79,29 @@ struct GraphicsState { class Renderer { public: - static void render(Document&, const Page&, RefPtr); + static void render(Document&, Page const&, RefPtr); private: - Renderer(RefPtr, const Page&, RefPtr); + Renderer(RefPtr, Page const&, RefPtr); void render(); - void handle_command(const Command&); + void handle_command(Command const&); #define V(name, snake_name, symbol) \ - void handle_##snake_name(const Vector& args); + void handle_##snake_name(Vector const& args); ENUMERATE_COMMANDS(V) #undef V - void handle_text_next_line_show_string(const Vector& args); - void handle_text_next_line_show_string_set_spacing(const Vector& args); + void handle_text_next_line_show_string(Vector const& args); + void handle_text_next_line_show_string_set_spacing(Vector const& args); void set_graphics_state_from_dict(NonnullRefPtr); // shift is the manual advance given in the TJ command array - void show_text(const String&, float shift = 0.0f); - RefPtr get_color_space(const Value&); + void show_text(String const&, float shift = 0.0f); + RefPtr get_color_space(Value const&); - ALWAYS_INLINE const GraphicsState& state() const { return m_graphics_state_stack.last(); } + ALWAYS_INLINE GraphicsState const& state() const { return m_graphics_state_stack.last(); } ALWAYS_INLINE GraphicsState& state() { return m_graphics_state_stack.last(); } - ALWAYS_INLINE const TextState& text_state() const { return state().text_state; } + ALWAYS_INLINE TextState const& text_state() const { return state().text_state; } ALWAYS_INLINE TextState& text_state() { return state().text_state; } template @@ -113,11 +113,11 @@ private: template ALWAYS_INLINE Gfx::Rect map(Gfx::Rect) const; - const Gfx::AffineTransform& calculate_text_rendering_matrix(); + Gfx::AffineTransform const& calculate_text_rendering_matrix(); RefPtr m_document; RefPtr m_bitmap; - const Page& m_page; + Page const& m_page; Gfx::Painter m_painter; Gfx::Path m_current_path; @@ -135,7 +135,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::LineCapStyle& style) + void format(FormatBuilder& builder, PDF::LineCapStyle const& style) { switch (style) { case PDF::LineCapStyle::ButtCap: @@ -153,7 +153,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::LineJoinStyle& style) + void format(FormatBuilder& builder, PDF::LineJoinStyle const& style) { switch (style) { case PDF::LineJoinStyle::Miter: @@ -171,7 +171,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::LineDashPattern& pattern) + void format(FormatBuilder& format_builder, PDF::LineDashPattern const& pattern) { StringBuilder builder; builder.append("["); @@ -191,7 +191,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::TextRenderingMode& style) + void format(FormatBuilder& builder, PDF::TextRenderingMode const& style) { switch (style) { case PDF::TextRenderingMode::Fill: @@ -224,7 +224,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::TextState& state) + void format(FormatBuilder& format_builder, PDF::TextState const& state) { StringBuilder builder; builder.append("TextState {\n"); @@ -245,7 +245,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::GraphicsState& state) + void format(FormatBuilder& format_builder, PDF::GraphicsState const& state) { StringBuilder builder; builder.append("GraphicsState {\n"); diff --git a/Userland/Libraries/LibPDF/Value.cpp b/Userland/Libraries/LibPDF/Value.cpp index 0248356fa6..887cda9bda 100644 --- a/Userland/Libraries/LibPDF/Value.cpp +++ b/Userland/Libraries/LibPDF/Value.cpp @@ -15,7 +15,7 @@ Value::~Value() m_as_object->unref(); } -Value& Value::operator=(const Value& other) +Value& Value::operator=(Value const& other) { m_type = other.m_type; switch (m_type) { diff --git a/Userland/Libraries/LibPDF/Value.h b/Userland/Libraries/LibPDF/Value.h index d26ac45d71..160edd68ba 100644 --- a/Userland/Libraries/LibPDF/Value.h +++ b/Userland/Libraries/LibPDF/Value.h @@ -79,14 +79,14 @@ public: m_as_object = obj; } - Value(const Value& other) + Value(Value const& other) { *this = other; } ~Value(); - Value& operator=(const Value& other); + Value& operator=(Value const& other); [[nodiscard]] ALWAYS_INLINE bool is_empty() const { return m_type == Type::Empty; } [[nodiscard]] ALWAYS_INLINE bool is_null() const { return m_type == Type::Null; } @@ -191,7 +191,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::Value& value) + void format(FormatBuilder& builder, PDF::Value const& value) { Formatter::format(builder, value.to_string()); } diff --git a/Userland/Libraries/LibPDF/XRefTable.h b/Userland/Libraries/LibPDF/XRefTable.h index 3cfb617dc8..ee70464755 100644 --- a/Userland/Libraries/LibPDF/XRefTable.h +++ b/Userland/Libraries/LibPDF/XRefTable.h @@ -52,7 +52,7 @@ public: return true; } - void add_section(const XRefSection& section) + void add_section(XRefSection const& section) { m_entries.ensure_capacity(section.starting_index + section.count); @@ -98,7 +98,7 @@ namespace AK { template<> struct Formatter : Formatter { - void format(FormatBuilder& builder, const PDF::XRefEntry& entry) + void format(FormatBuilder& builder, PDF::XRefEntry const& entry) { Formatter::format(builder, String::formatted("XRefEntry {{ offset={} generation={} used={} }}", @@ -110,7 +110,7 @@ struct Formatter : Formatter { template<> struct Formatter : Formatter { - void format(FormatBuilder& format_builder, const PDF::XRefTable& table) + void format(FormatBuilder& format_builder, PDF::XRefTable const& table) { StringBuilder builder; builder.append("XRefTable {");