Skip to content

Commit

Permalink
LibWeb: Use Vector<LineBoxFragment> instead of NonnullOwnPtrVector
Browse files Browse the repository at this point in the history
This removes one step of indirection, but more importantly, makes it
easy to copy these objects. :^)
  • Loading branch information
awesomekling committed Feb 28, 2022
1 parent 16a4716 commit 916bbf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/Layout/LineBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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_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;
}
Expand All @@ -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())
Expand Down
7 changes: 3 additions & 4 deletions Userland/Libraries/LibWeb/Layout/LineBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#pragma once

#include <AK/NonnullOwnPtrVector.h>
#include <AK/Vector.h>
#include <LibWeb/Layout/LineBoxFragment.h>

Expand All @@ -20,8 +19,8 @@ class LineBox {

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<LineBoxFragment>& fragments() const { return m_fragments; }
NonnullOwnPtrVector<LineBoxFragment>& fragments() { return m_fragments; }
Vector<LineBoxFragment> const& fragments() const { return m_fragments; }
Vector<LineBoxFragment>& fragments() { return m_fragments; }

void trim_trailing_whitespace();

Expand All @@ -33,7 +32,7 @@ class LineBox {
friend class InlineFormattingContext;
friend class LineBuilder;

NonnullOwnPtrVector<LineBoxFragment> m_fragments;
Vector<LineBoxFragment> m_fragments;
float m_width { 0 };
};

Expand Down

0 comments on commit 916bbf5

Please sign in to comment.