mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Make LineBoxFragment store non-const Layout::Node&
This is more honest, since we actually const_cast these layout nodes during inline layout anyway.
This commit is contained in:
parent
6a83475ec5
commit
88ca932fac
Notes:
sideshowbarker
2024-07-19 01:03:48 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/88ca932fac8
4 changed files with 8 additions and 8 deletions
|
@ -135,8 +135,8 @@ void InlineFormattingContext::run(LayoutMode layout_mode)
|
|||
}
|
||||
}
|
||||
|
||||
if (fragment.layout_node().is_box())
|
||||
dimension_box_on_line(const_cast<Box&>(downcast<Box>(fragment.layout_node())), layout_mode);
|
||||
if (is<Box>(fragment.layout_node()))
|
||||
dimension_box_on_line(downcast<Box>(fragment.layout_node()), layout_mode);
|
||||
|
||||
float final_line_box_width = 0;
|
||||
for (auto& fragment : line_box.fragments())
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
void LineBox::add_fragment(const Node& layout_node, int start, int length, int width, int height, LineBoxFragment::Type fragment_type)
|
||||
void LineBox::add_fragment(Node& layout_node, int start, int length, int width, int height, LineBoxFragment::Type fragment_type)
|
||||
{
|
||||
bool text_align_is_justify = layout_node.style().text_align() == CSS::TextAlign::Justify;
|
||||
if (!text_align_is_justify && !m_fragments.is_empty() && &m_fragments.last().layout_node() == &layout_node) {
|
||||
|
@ -47,7 +47,7 @@ void LineBox::add_fragment(const Node& layout_node, int start, int length, int w
|
|||
m_width += width;
|
||||
|
||||
if (is<Box>(layout_node))
|
||||
const_cast<Box&>(downcast<Box>(layout_node)).set_containing_line_box_fragment(m_fragments.last());
|
||||
downcast<Box>(layout_node).set_containing_line_box_fragment(m_fragments.last());
|
||||
}
|
||||
|
||||
void LineBox::trim_trailing_whitespace()
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
float width() const { return m_width; }
|
||||
|
||||
void add_fragment(const Node& layout_node, int start, int length, int width, int height, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
|
||||
void add_fragment(Node& layout_node, int start, int length, int width, int height, LineBoxFragment::Type = LineBoxFragment::Type::Normal);
|
||||
|
||||
const NonnullOwnPtrVector<LineBoxFragment>& fragments() const { return m_fragments; }
|
||||
NonnullOwnPtrVector<LineBoxFragment>& fragments() { return m_fragments; }
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
Trailing,
|
||||
};
|
||||
|
||||
LineBoxFragment(const Node& layout_node, int start, int length, const Gfx::FloatPoint& offset, const Gfx::FloatSize& size, Type type)
|
||||
LineBoxFragment(Node& layout_node, int start, int length, const Gfx::FloatPoint& offset, const Gfx::FloatSize& size, Type type)
|
||||
: m_layout_node(layout_node)
|
||||
, m_start(start)
|
||||
, m_length(length)
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
const Node& layout_node() const { return m_layout_node; }
|
||||
Node& layout_node() const { return m_layout_node; }
|
||||
int start() const { return m_start; }
|
||||
int length() const { return m_length; }
|
||||
const Gfx::FloatRect absolute_rect() const;
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
Gfx::FloatRect selection_rect(const Gfx::Font&) const;
|
||||
|
||||
private:
|
||||
const Node& m_layout_node;
|
||||
Node& m_layout_node;
|
||||
int m_start { 0 };
|
||||
int m_length { 0 };
|
||||
Gfx::FloatPoint m_offset;
|
||||
|
|
Loading…
Reference in a new issue