1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

LibWeb+WebContent: Convert BrowsingContext to new pixel units

This fixes a few glitches. We no longer give the page double the width
it should have, and we mark the correct area of the page as needing
repainting.
This commit is contained in:
Sam Atkins 2022-11-03 12:49:54 +00:00 committed by Linus Groh
parent 8fb7c32ec3
commit affc8a22ca
23 changed files with 68 additions and 70 deletions

View file

@ -676,7 +676,7 @@ static void measure_scrollable_overflow(LayoutState const& state, Box const& box
void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_mode, AvailableSpace const& available_space)
{
auto viewport_rect = root().browsing_context().viewport_rect();
auto viewport_rect = root().browsing_context().viewport_rect().to_type<float>();
auto& icb = verify_cast<Layout::InitialContainingBlock>(root());
auto& icb_state = m_state.get_mutable(icb);

View file

@ -31,9 +31,8 @@ Box::~Box()
void Box::set_needs_display()
{
// FIXME: Make `set_needs_display` take CSSPixels
if (paint_box())
browsing_context().set_needs_display(enclosing_int_rect(paint_box()->absolute_rect().to_type<float>()));
browsing_context().set_needs_display(paint_box()->absolute_rect());
}
bool Box::is_body() const

View file

@ -33,8 +33,7 @@ void FrameBox::did_set_rect()
ReplacedBox::did_set_rect();
VERIFY(dom_node().nested_browsing_context());
// FIXME: Pass CSSPixels here instead of int.
dom_node().nested_browsing_context()->set_size(paint_box()->content_size().to_type<float>().to_type<int>());
dom_node().nested_browsing_context()->set_size(paint_box()->content_size());
}
RefPtr<Painting::Paintable> FrameBox::create_paintable() const

View file

@ -92,9 +92,9 @@ bool ImageBox::renders_as_alt_text() const
return false;
}
void ImageBox::browsing_context_did_set_viewport_rect(Gfx::IntRect const& viewport_rect)
void ImageBox::browsing_context_did_set_viewport_rect(CSSPixelRect const& viewport_rect)
{
m_image_loader.set_visible_in_viewport(paint_box() && viewport_rect.to_type<CSSPixels>().intersects(paint_box()->absolute_rect()));
m_image_loader.set_visible_in_viewport(paint_box() && viewport_rect.intersects(paint_box()->absolute_rect()));
}
RefPtr<Painting::Paintable> ImageBox::create_paintable() const

View file

@ -35,7 +35,7 @@ public:
private:
// ^BrowsingContext::ViewportClient
virtual void browsing_context_did_set_viewport_rect(Gfx::IntRect const&) final;
virtual void browsing_context_did_set_viewport_rect(CSSPixelRect const&) final;
// ^JS::Cell
virtual void finalize() override;

View file

@ -158,7 +158,7 @@ void Node::set_needs_display()
return;
containing_block->paint_box()->for_each_fragment([&](auto& fragment) {
if (&fragment.layout_node() == this || is_ancestor_of(fragment.layout_node())) {
browsing_context().set_needs_display(fragment.absolute_rect().template to_type<float>().template to_type<int>());
browsing_context().set_needs_display(fragment.absolute_rect());
}
return IterationDecision::Continue;
});