mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:47:35 +00:00
LibWeb: Make Paintable::containing_block() return a PaintableBox*
Every single client of this function was immediately calling paintable() on the result anyway, so there was no need to return a layout node! This automatically leverages the cached containing block pointer we already have in Paintable, which melts away a bunch of unnecessary traversal in hit testing and painting. :^)
This commit is contained in:
parent
c3980eda9e
commit
d1b5f55f91
9 changed files with 32 additions and 36 deletions
|
@ -73,7 +73,7 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
auto& painter = context.recording_painter();
|
||||
|
||||
if (phase == PaintPhase::Background) {
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->paintable_box()->absolute_position();
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->absolute_position();
|
||||
|
||||
for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) {
|
||||
CSSPixelRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() };
|
||||
|
@ -118,7 +118,7 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
.left = computed_values().border_left(),
|
||||
};
|
||||
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->paintable_box()->absolute_position();
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->absolute_position();
|
||||
|
||||
for_each_fragment([&](auto const& fragment, bool is_first_fragment, bool is_last_fragment) {
|
||||
CSSPixelRect absolute_fragment_rect { containing_block_position_in_absolute_coordinates.translated(fragment.offset()), fragment.size() };
|
||||
|
@ -247,7 +247,7 @@ CSSPixelRect InlinePaintable::bounding_rect() const
|
|||
|
||||
if (bounding_rect.is_empty()) {
|
||||
// FIXME: This is adhoc, and we should return rect of empty fragment instead.
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->paintable_box()->absolute_position();
|
||||
auto containing_block_position_in_absolute_coordinates = containing_block()->absolute_position();
|
||||
return { containing_block_position_in_absolute_coordinates, { 0, 0 } };
|
||||
}
|
||||
return bounding_rect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue