mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Delete non-const layout_node_with_style_and_box_metrics()
...from PaintableBox. It was used exclusively to go to corresponding DOM node which could be done via direct DOM node pointer owned by paintable.
This commit is contained in:
parent
0fbadba2e1
commit
72aaef5a0f
|
|
@ -27,12 +27,12 @@ void LabelablePaintable::set_being_pressed(bool being_pressed)
|
|||
|
||||
Layout::FormAssociatedLabelableNode const& LabelablePaintable::layout_box() const
|
||||
{
|
||||
return static_cast<Layout::FormAssociatedLabelableNode const&>(PaintableBox::layout_node_with_style_and_box_metrics());
|
||||
return static_cast<Layout::FormAssociatedLabelableNode const&>(layout_node());
|
||||
}
|
||||
|
||||
Layout::FormAssociatedLabelableNode& LabelablePaintable::layout_box()
|
||||
{
|
||||
return static_cast<Layout::FormAssociatedLabelableNode&>(PaintableBox::layout_node_with_style_and_box_metrics());
|
||||
return static_cast<Layout::FormAssociatedLabelableNode&>(layout_node());
|
||||
}
|
||||
|
||||
LabelablePaintable::DispatchEventOfSameName LabelablePaintable::handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned)
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge<E
|
|||
if (button != UIEvents::MouseButton::Primary)
|
||||
return DispatchEventOfSameName::Yes;
|
||||
|
||||
auto& media_element = *as<HTML::HTMLMediaElement>(layout_node_with_style_and_box_metrics().dom_node());
|
||||
auto& media_element = this->media_element();
|
||||
auto const& cached_layout_boxes = media_element.cached_layout_boxes({});
|
||||
|
||||
auto position_adjusted_by_scroll_offset = position;
|
||||
|
|
@ -305,7 +305,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge<E
|
|||
|
||||
MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mouseup(Badge<EventHandler>, CSSPixelPoint position, unsigned button, unsigned)
|
||||
{
|
||||
auto& media_element = *as<HTML::HTMLMediaElement>(layout_node_with_style_and_box_metrics().dom_node());
|
||||
auto& media_element = this->media_element();
|
||||
auto const& cached_layout_boxes = media_element.cached_layout_boxes({});
|
||||
|
||||
auto position_adjusted_by_scroll_offset = position;
|
||||
|
|
@ -356,7 +356,7 @@ MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mouseup(Badge<Eve
|
|||
|
||||
MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousemove(Badge<EventHandler>, CSSPixelPoint position, unsigned, unsigned)
|
||||
{
|
||||
auto& media_element = *as<HTML::HTMLMediaElement>(layout_node_with_style_and_box_metrics().dom_node());
|
||||
auto& media_element = this->media_element();
|
||||
auto const& cached_layout_boxes = media_element.cached_layout_boxes({});
|
||||
|
||||
auto position_adjusted_by_scroll_offset = position;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ protected:
|
|||
|
||||
void paint_media_controls(DisplayListRecordingContext&, HTML::HTMLMediaElement const&, DevicePixelRect media_rect, Optional<DevicePixelPoint> const& mouse_position) const;
|
||||
|
||||
auto& media_element() { return as<HTML::HTMLMediaElement>(*dom_node()); }
|
||||
|
||||
private:
|
||||
struct Components {
|
||||
DevicePixelRect control_box_rect;
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ CSSPixelPoint PaintableBox::scroll_offset() const
|
|||
if (auto pseudo_element = node.generated_for_pseudo_element(); pseudo_element.has_value())
|
||||
return node.pseudo_element_generator()->scroll_offset(*pseudo_element);
|
||||
|
||||
if (!(dom_node() && is<DOM::Element>(*dom_node())))
|
||||
return {};
|
||||
if (auto const* element = as_if<DOM::Element>(*dom_node()))
|
||||
return element->scroll_offset({});
|
||||
|
||||
return static_cast<DOM::Element const*>(dom_node())->scroll_offset({});
|
||||
return {};
|
||||
}
|
||||
|
||||
PaintableBox::ScrollHandled PaintableBox::set_scroll_offset(CSSPixelPoint offset)
|
||||
|
|
@ -133,7 +133,7 @@ PaintableBox::ScrollHandled PaintableBox::set_scroll_offset(CSSPixelPoint offset
|
|||
auto& node = layout_node();
|
||||
if (auto pseudo_element = node.generated_for_pseudo_element(); pseudo_element.has_value()) {
|
||||
node.pseudo_element_generator()->set_scroll_offset(*pseudo_element, offset);
|
||||
} else if (auto* element = as_if<DOM::Element>(dom_node())) {
|
||||
} else if (auto* element = as_if<DOM::Element>(*dom_node())) {
|
||||
element->set_scroll_offset({}, offset);
|
||||
} else {
|
||||
return ScrollHandled::No;
|
||||
|
|
@ -157,7 +157,7 @@ PaintableBox::ScrollHandled PaintableBox::set_scroll_offset(CSSPixelPoint offset
|
|||
return ScrollHandled::Yes;
|
||||
|
||||
// 4. Append the element to doc’s pending scroll event targets.
|
||||
document.pending_scroll_event_targets().append(*layout_node_with_style_and_box_metrics().dom_node());
|
||||
document.pending_scroll_event_targets().append(*dom_node());
|
||||
|
||||
set_needs_display(InvalidateDisplayList::No);
|
||||
return ScrollHandled::Yes;
|
||||
|
|
@ -176,9 +176,8 @@ void PaintableBox::set_offset(CSSPixelPoint offset)
|
|||
void PaintableBox::set_content_size(CSSPixelSize size)
|
||||
{
|
||||
m_content_size = size;
|
||||
if (is<Layout::Box>(Paintable::layout_node())) {
|
||||
static_cast<Layout::Box&>(layout_node_with_style_and_box_metrics()).did_set_content_size();
|
||||
}
|
||||
if (auto layout_box = as_if<Layout::Box>(layout_node()))
|
||||
layout_box->did_set_content_size();
|
||||
}
|
||||
|
||||
CSSPixelPoint PaintableBox::offset() const
|
||||
|
|
@ -534,10 +533,7 @@ void PaintableBox::paint_inspector_overlay_internal(DisplayListRecordingContext&
|
|||
auto font = Platform::FontPlugin::the().default_font(12);
|
||||
|
||||
StringBuilder builder(StringBuilder::Mode::UTF16);
|
||||
if (layout_node_with_style_and_box_metrics().dom_node())
|
||||
builder.append(layout_node_with_style_and_box_metrics().dom_node()->debug_description());
|
||||
else
|
||||
builder.append(layout_node_with_style_and_box_metrics().debug_description());
|
||||
builder.append(debug_description());
|
||||
builder.appendff(" {}x{} @ {},{}", border_rect.width(), border_rect.height(), border_rect.x(), border_rect.y());
|
||||
auto size_text = builder.to_utf16_string();
|
||||
auto size_text_rect = border_rect;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public:
|
|||
virtual Optional<Gfx::Bitmap::MaskKind> get_mask_type() const { return {}; }
|
||||
virtual RefPtr<Gfx::ImmutableBitmap> calculate_mask(DisplayListRecordingContext&, CSSPixelRect const&) const { return {}; }
|
||||
|
||||
Layout::NodeWithStyleAndBoxModelMetrics& layout_node_with_style_and_box_metrics() { return as<Layout::NodeWithStyleAndBoxModelMetrics>(layout_node()); }
|
||||
Layout::NodeWithStyleAndBoxModelMetrics const& layout_node_with_style_and_box_metrics() const { return as<Layout::NodeWithStyleAndBoxModelMetrics const>(layout_node()); }
|
||||
|
||||
auto& box_model() { return m_box_model; }
|
||||
|
|
@ -136,9 +135,6 @@ public:
|
|||
|
||||
void set_overflow_data(OverflowData data) { m_overflow_data = move(data); }
|
||||
|
||||
DOM::Node const* dom_node() const { return layout_node_with_style_and_box_metrics().dom_node(); }
|
||||
DOM::Node* dom_node() { return layout_node_with_style_and_box_metrics().dom_node(); }
|
||||
|
||||
virtual void set_needs_display(InvalidateDisplayList = InvalidateDisplayList::Yes) override;
|
||||
|
||||
void apply_scroll_offset(DisplayListRecordingContext&) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user