From 916bbf591022922bb129de0458d03654ee2ff1a4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Feb 2022 10:32:00 +0100 Subject: [PATCH] LibWeb: Use Vector instead of NonnullOwnPtrVector This removes one step of indirection, but more importantly, makes it easy to copy these objects. :^) --- Userland/Libraries/LibWeb/Layout/LineBox.cpp | 4 ++-- Userland/Libraries/LibWeb/Layout/LineBox.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/LineBox.cpp b/Userland/Libraries/LibWeb/Layout/LineBox.cpp index 3a65f89155..5e5912ee51 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/LineBox.cpp @@ -24,7 +24,7 @@ void LineBox::add_fragment(Node const& layout_node, int start, int length, float m_fragments.last().m_length = (start - m_fragments.last().m_start) + length; m_fragments.last().set_width(m_fragments.last().width() + content_width); } else { - m_fragments.append(make(layout_node, start, length, Gfx::FloatPoint(m_width + leading_size, 0.0f), Gfx::FloatSize(content_width, content_height), border_box_top, border_box_bottom, fragment_type)); + m_fragments.append(LineBoxFragment { layout_node, start, length, Gfx::FloatPoint(m_width + leading_size, 0.0f), Gfx::FloatSize(content_width, content_height), border_box_top, border_box_bottom, fragment_type }); } m_width += content_width + leading_size + trailing_size; } @@ -33,7 +33,7 @@ void LineBox::trim_trailing_whitespace() { while (!m_fragments.is_empty() && m_fragments.last().is_justifiable_whitespace()) { auto fragment = m_fragments.take_last(); - m_width -= fragment->width(); + m_width -= fragment.width(); } if (m_fragments.is_empty()) diff --git a/Userland/Libraries/LibWeb/Layout/LineBox.h b/Userland/Libraries/LibWeb/Layout/LineBox.h index b478747290..90d5d10339 100644 --- a/Userland/Libraries/LibWeb/Layout/LineBox.h +++ b/Userland/Libraries/LibWeb/Layout/LineBox.h @@ -6,7 +6,6 @@ #pragma once -#include #include #include @@ -20,8 +19,8 @@ public: void add_fragment(Node const& layout_node, int start, int length, float leading_size, float trailing_size, float content_width, float content_height, float border_box_top, float border_box_bottom, LineBoxFragment::Type = LineBoxFragment::Type::Normal); - const NonnullOwnPtrVector& fragments() const { return m_fragments; } - NonnullOwnPtrVector& fragments() { return m_fragments; } + Vector const& fragments() const { return m_fragments; } + Vector& fragments() { return m_fragments; } void trim_trailing_whitespace(); @@ -33,7 +32,7 @@ private: friend class InlineFormattingContext; friend class LineBuilder; - NonnullOwnPtrVector m_fragments; + Vector m_fragments; float m_width { 0 }; };