mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibWeb: Rename Layout::Node::paintable() to first_paintable()
Layout node is allowed to have multiple corresponding paintables, so first_paintable() is more explicit name for getter that returns first paintable.
This commit is contained in:
parent
7d22b1c5c8
commit
c690fb9df3
Notes:
github-actions[bot]
2024-10-16 18:26:47 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: c690fb9df3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1829
15 changed files with 42 additions and 42 deletions
|
@ -127,7 +127,7 @@ RefPtr<CSSStyleValue const> interpolate_transform(DOM::Element& element, CSSStyl
|
|||
return {};
|
||||
Optional<Painting::PaintableBox const&> paintable_box;
|
||||
if (auto layout_node = element.layout_node()) {
|
||||
if (auto paintable = layout_node->paintable(); paintable && is<Painting::PaintableBox>(paintable))
|
||||
if (auto paintable = layout_node->first_paintable(); paintable && is<Painting::PaintableBox>(paintable))
|
||||
paintable_box = *static_cast<Painting::PaintableBox*>(paintable);
|
||||
}
|
||||
if (auto matrix = transformation->to_matrix(paintable_box); !matrix.is_error())
|
||||
|
|
|
@ -198,9 +198,9 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
{
|
||||
auto used_value_for_property = [&layout_node, property_id](Function<CSSPixels(Painting::PaintableBox const&)>&& used_value_getter) -> Optional<CSSPixels> {
|
||||
auto const& display = layout_node.computed_values().display();
|
||||
if (!display.is_none() && !display.is_contents() && layout_node.paintable()) {
|
||||
if (layout_node.paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = static_cast<Painting::PaintableBox const&>(*layout_node.paintable());
|
||||
if (!display.is_none() && !display.is_contents() && layout_node.first_paintable()) {
|
||||
if (layout_node.first_paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = static_cast<Painting::PaintableBox const&>(*layout_node.first_paintable());
|
||||
return used_value_getter(paintable_box);
|
||||
}
|
||||
dbgln("FIXME: Support getting used value for property `{}` on {}", string_from_property_id(property_id), layout_node.debug_description());
|
||||
|
@ -379,8 +379,8 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
auto transform = FloatMatrix4x4::identity();
|
||||
|
||||
// 2. Post-multiply all <transform-function>s in <transform-list> to transform.
|
||||
VERIFY(layout_node.paintable());
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.paintable());
|
||||
VERIFY(layout_node.first_paintable());
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
for (auto transformation : transformations) {
|
||||
transform = transform * transformation.to_matrix(paintable_box).release_value();
|
||||
}
|
||||
|
@ -523,15 +523,15 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
// For grid-template-columns and grid-template-rows the resolved value is the used value.
|
||||
// https://www.w3.org/TR/css-grid-2/#resolved-track-list-standalone
|
||||
if (property_id == PropertyID::GridTemplateColumns) {
|
||||
if (layout_node.paintable() && layout_node.paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.paintable());
|
||||
if (layout_node.first_paintable() && layout_node.first_paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
if (auto used_values_for_grid_template_columns = paintable_box.used_values_for_grid_template_columns()) {
|
||||
return used_values_for_grid_template_columns;
|
||||
}
|
||||
}
|
||||
} else if (property_id == PropertyID::GridTemplateRows) {
|
||||
if (layout_node.paintable() && layout_node.paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.paintable());
|
||||
if (layout_node.first_paintable() && layout_node.first_paintable()->is_paintable_box()) {
|
||||
auto const& paintable_box = verify_cast<Painting::PaintableBox const>(*layout_node.first_paintable());
|
||||
if (auto used_values_for_grid_template_rows = paintable_box.used_values_for_grid_template_rows()) {
|
||||
return used_values_for_grid_template_rows;
|
||||
}
|
||||
|
|
|
@ -1389,14 +1389,14 @@ void Document::set_inspected_node(Node* node, Optional<CSS::Selector::PseudoElem
|
|||
if (m_inspected_node.ptr() == node && m_inspected_pseudo_element == pseudo_element)
|
||||
return;
|
||||
|
||||
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->paintable())
|
||||
layout_node->paintable()->set_needs_display();
|
||||
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->first_paintable())
|
||||
layout_node->first_paintable()->set_needs_display();
|
||||
|
||||
m_inspected_node = node;
|
||||
m_inspected_pseudo_element = pseudo_element;
|
||||
|
||||
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->paintable())
|
||||
layout_node->paintable()->set_needs_display();
|
||||
if (auto layout_node = inspected_layout_node(); layout_node && layout_node->first_paintable())
|
||||
layout_node->first_paintable()->set_needs_display();
|
||||
}
|
||||
|
||||
Layout::Node* Document::inspected_layout_node()
|
||||
|
|
|
@ -601,8 +601,8 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
|
||||
if (auto* node_with_style = dynamic_cast<Layout::NodeWithStyle*>(pseudo_element->layout_node.ptr())) {
|
||||
node_with_style->apply_style(*pseudo_element_style);
|
||||
if (invalidation.repaint && node_with_style->paintable())
|
||||
node_with_style->paintable()->set_needs_display();
|
||||
if (invalidation.repaint && node_with_style->first_paintable())
|
||||
node_with_style->first_paintable()->set_needs_display();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -381,9 +381,9 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
|||
}
|
||||
}
|
||||
|
||||
if (is<Layout::InlineNode>(layout_node) && layout_node.paintable()) {
|
||||
if (is<Layout::InlineNode>(layout_node) && layout_node.first_paintable()) {
|
||||
auto const& inline_node = static_cast<Layout::InlineNode const&>(layout_node);
|
||||
auto const& inline_paintable = static_cast<Painting::InlinePaintable const&>(*inline_node.paintable());
|
||||
auto const& inline_paintable = static_cast<Painting::InlinePaintable const&>(*inline_node.first_paintable());
|
||||
auto const& fragments = inline_paintable.fragments();
|
||||
for (size_t fragment_index = 0; fragment_index < fragments.size(); ++fragment_index) {
|
||||
auto const& fragment = fragments[fragment_index];
|
||||
|
|
|
@ -72,12 +72,12 @@ JS::GCPtr<Painting::Paintable> Box::create_paintable() const
|
|||
|
||||
Painting::PaintableBox* Box::paintable_box()
|
||||
{
|
||||
return static_cast<Painting::PaintableBox*>(Node::paintable());
|
||||
return static_cast<Painting::PaintableBox*>(Node::first_paintable());
|
||||
}
|
||||
|
||||
Painting::PaintableBox const* Box::paintable_box() const
|
||||
{
|
||||
return static_cast<Painting::PaintableBox const*>(Node::paintable());
|
||||
return static_cast<Painting::PaintableBox const*>(Node::first_paintable());
|
||||
}
|
||||
|
||||
Optional<CSSPixelFraction> Box::preferred_aspect_ratio() const
|
||||
|
|
|
@ -11,12 +11,12 @@ namespace Web::Layout {
|
|||
|
||||
Painting::LabelablePaintable* LabelableNode::paintable()
|
||||
{
|
||||
return static_cast<Painting::LabelablePaintable*>(ReplacedBox::paintable());
|
||||
return static_cast<Painting::LabelablePaintable*>(ReplacedBox::first_paintable());
|
||||
}
|
||||
|
||||
Painting::LabelablePaintable const* LabelableNode::paintable() const
|
||||
{
|
||||
return static_cast<Painting::LabelablePaintable const*>(ReplacedBox::paintable());
|
||||
return static_cast<Painting::LabelablePaintable const*>(ReplacedBox::first_paintable());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box)
|
|||
auto scrollable_overflow_rect = paintable_box.absolute_padding_box_rect();
|
||||
|
||||
// - All line boxes directly contained by the scroll container.
|
||||
if (is<Painting::PaintableWithLines>(box.paintable())) {
|
||||
for (auto const& fragment : static_cast<Painting::PaintableWithLines const&>(*box.paintable()).fragments()) {
|
||||
if (is<Painting::PaintableWithLines>(box.first_paintable())) {
|
||||
for (auto const& fragment : static_cast<Painting::PaintableWithLines const&>(*box.first_paintable()).fragments()) {
|
||||
scrollable_overflow_rect = scrollable_overflow_rect.united(fragment.absolute_rect());
|
||||
}
|
||||
}
|
||||
|
@ -129,8 +129,8 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box)
|
|||
});
|
||||
} else {
|
||||
box.for_each_child([&scrollable_overflow_rect, &content_overflow_rect](Node const& child) {
|
||||
if (child.paintable() && child.paintable()->is_inline_paintable()) {
|
||||
for (auto const& fragment : static_cast<Painting::InlinePaintable const&>(*child.paintable()).fragments()) {
|
||||
if (child.first_paintable() && child.first_paintable()->is_inline_paintable()) {
|
||||
for (auto const& fragment : static_cast<Painting::InlinePaintable const&>(*child.first_paintable()).fragments()) {
|
||||
scrollable_overflow_rect = scrollable_overflow_rect.united(fragment.absolute_rect());
|
||||
content_overflow_rect = content_overflow_rect.united(fragment.absolute_rect());
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ void LayoutState::resolve_relative_positions()
|
|||
auto& used_values = *it.value;
|
||||
auto& node = const_cast<NodeWithStyle&>(used_values.node());
|
||||
|
||||
auto* paintable = node.paintable();
|
||||
auto* paintable = node.first_paintable();
|
||||
if (!paintable)
|
||||
continue;
|
||||
if (!is<Painting::InlinePaintable>(*paintable))
|
||||
|
@ -197,8 +197,8 @@ void LayoutState::resolve_relative_positions()
|
|||
static void build_paint_tree(Node& node, Painting::Paintable* parent_paintable = nullptr)
|
||||
{
|
||||
Painting::Paintable* paintable = nullptr;
|
||||
if (node.paintable()) {
|
||||
paintable = const_cast<Painting::Paintable*>(node.paintable());
|
||||
if (node.first_paintable()) {
|
||||
paintable = const_cast<Painting::Paintable*>(node.first_paintable());
|
||||
if (parent_paintable && !paintable->forms_unconnected_subtree()) {
|
||||
VERIFY(!paintable->parent());
|
||||
parent_paintable->append_child(*paintable);
|
||||
|
@ -298,7 +298,7 @@ void LayoutState::commit(Box& root)
|
|||
if (!node.is_box())
|
||||
continue;
|
||||
|
||||
auto& paintable = static_cast<Painting::PaintableBox&>(*node.paintable());
|
||||
auto& paintable = static_cast<Painting::PaintableBox&>(*node.first_paintable());
|
||||
CSSPixelPoint offset;
|
||||
|
||||
if (used_values.containing_line_box_fragment.has_value()) {
|
||||
|
@ -336,7 +336,7 @@ void LayoutState::commit(Box& root)
|
|||
auto find_closest_inline_paintable = [&](auto& fragment) -> Painting::InlinePaintable const* {
|
||||
for (auto const* parent = fragment.layout_node().parent(); parent; parent = parent->parent()) {
|
||||
if (is<InlineNode>(*parent))
|
||||
return static_cast<Painting::InlinePaintable const*>(parent->paintable());
|
||||
return static_cast<Painting::InlinePaintable const*>(parent->first_paintable());
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
@ -352,7 +352,7 @@ void LayoutState::commit(Box& root)
|
|||
|
||||
for (auto* text_node : text_nodes) {
|
||||
text_node->add_paintable(text_node->create_paintable());
|
||||
auto* paintable = text_node->paintable();
|
||||
auto* paintable = text_node->first_paintable();
|
||||
auto const& font = text_node->first_available_font();
|
||||
auto const glyph_height = CSSPixels::nearest_value_for(font.pixel_size());
|
||||
auto const css_line_thickness = [&] {
|
||||
|
|
|
@ -67,8 +67,8 @@ public:
|
|||
|
||||
using PaintableList = IntrusiveList<&Painting::Paintable::m_list_node>;
|
||||
|
||||
Painting::Paintable* paintable() { return m_paintable.first(); }
|
||||
Painting::Paintable const* paintable() const { return m_paintable.first(); }
|
||||
Painting::Paintable* first_paintable() { return m_paintable.first(); }
|
||||
Painting::Paintable const* first_paintable() const { return m_paintable.first(); }
|
||||
void add_paintable(JS::GCPtr<Painting::Paintable>);
|
||||
void clear_paintables();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ void Viewport::update_text_blocks()
|
|||
Vector<TextPosition> text_positions;
|
||||
Vector<TextBlock> text_blocks;
|
||||
for_each_in_inclusive_subtree([&](auto const& layout_node) {
|
||||
if (layout_node.display().is_none() || !layout_node.paintable() || !layout_node.paintable()->is_visible())
|
||||
if (layout_node.display().is_none() || !layout_node.first_paintable() || !layout_node.first_paintable()->is_visible())
|
||||
return TraversalDecision::Continue;
|
||||
|
||||
if (layout_node.is_box() || layout_node.is_generated()) {
|
||||
|
|
|
@ -136,7 +136,7 @@ static Gfx::StandardCursor cursor_css_to_gfx(Optional<CSS::Cursor> cursor)
|
|||
|
||||
static CSSPixelPoint compute_mouse_event_offset(CSSPixelPoint position, Layout::Node const& layout_node)
|
||||
{
|
||||
auto top_left_of_layout_node = layout_node.paintable()->box_type_agnostic_position();
|
||||
auto top_left_of_layout_node = layout_node.first_paintable()->box_type_agnostic_position();
|
||||
return {
|
||||
position.x() - top_left_of_layout_node.x(),
|
||||
position.y() - top_left_of_layout_node.y()
|
||||
|
|
|
@ -82,7 +82,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||
|
||||
DisplayListRecorderStateSaver state { display_list_recorder };
|
||||
if (resolved_background.needs_text_clip) {
|
||||
auto display_list = compute_text_clip_paths(context, *layout_node.paintable(), resolved_background.background_rect.location());
|
||||
auto display_list = compute_text_clip_paths(context, *layout_node.first_paintable(), resolved_background.background_rect.location());
|
||||
auto rect = context.rounded_device_rect(resolved_background.background_rect);
|
||||
display_list_recorder.add_mask(move(display_list), rect.to_type<int>());
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
explicit PaintableFragment(Layout::LineBoxFragment const&);
|
||||
|
||||
Layout::Node const& layout_node() const { return m_layout_node; }
|
||||
Paintable const& paintable() const { return *m_layout_node->paintable(); }
|
||||
Paintable const& paintable() const { return *m_layout_node->first_paintable(); }
|
||||
|
||||
int start() const { return m_start; }
|
||||
int length() const { return m_length; }
|
||||
|
|
|
@ -96,11 +96,11 @@ RefPtr<Gfx::Bitmap> SVGMaskable::calculate_mask_of_svg(PaintContext& context, CS
|
|||
};
|
||||
RefPtr<Gfx::Bitmap> mask_bitmap = {};
|
||||
if (auto* mask_box = get_mask_box(graphics_element)) {
|
||||
auto& mask_paintable = static_cast<PaintableBox const&>(*mask_box->paintable());
|
||||
auto& mask_paintable = static_cast<PaintableBox const&>(*mask_box->first_paintable());
|
||||
mask_bitmap = paint_mask_or_clip(mask_paintable);
|
||||
}
|
||||
if (auto* clip_box = get_clip_box(graphics_element)) {
|
||||
auto& clip_paintable = static_cast<PaintableBox const&>(*clip_box->paintable());
|
||||
auto& clip_paintable = static_cast<PaintableBox const&>(*clip_box->first_paintable());
|
||||
auto clip_bitmap = paint_mask_or_clip(clip_paintable);
|
||||
// Combine the clip-path with the mask (if present).
|
||||
if (mask_bitmap && clip_bitmap)
|
||||
|
|
|
@ -890,12 +890,12 @@ static void append_paint_tree(Web::Page& page, StringBuilder& builder)
|
|||
builder.append("(no layout tree)"sv);
|
||||
return;
|
||||
}
|
||||
if (!layout_root->paintable()) {
|
||||
if (!layout_root->first_paintable()) {
|
||||
builder.append("(no paint tree)"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
Web::dump_tree(builder, *layout_root->paintable());
|
||||
Web::dump_tree(builder, *layout_root->first_paintable());
|
||||
}
|
||||
|
||||
static void append_gc_graph(StringBuilder& builder)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue