mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 09:07:44 +00:00
LibWeb: Move viewport subscriptions from BrowsingContext to Document
With this change, elements that want to receive viewport rect updates will need to register on document instead of the browsing context. This change solves the problem where a browsing context for a document is guaranteed to exist only while the document is active so browsing context might not exit by the time DOM node that want to register is constructed. This is a part of preparation work before switching to navigables where this issue becomes more visible.
This commit is contained in:
parent
48e9097aa4
commit
5ff7448fee
10 changed files with 66 additions and 61 deletions
|
@ -13,16 +13,16 @@ namespace Web::Layout {
|
|||
VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
browsing_context().register_viewport_client(*this);
|
||||
document.register_viewport_client(*this);
|
||||
}
|
||||
|
||||
void VideoBox::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
|
||||
// NOTE: We unregister from the browsing context in finalize() to avoid trouble
|
||||
// in the scenario where our BrowsingContext has already been swept by GC.
|
||||
browsing_context().unregister_viewport_client(*this);
|
||||
// NOTE: We unregister from the document in finalize() to avoid trouble
|
||||
// in the scenario where our Document has already been swept by GC.
|
||||
document().unregister_viewport_client(*this);
|
||||
}
|
||||
|
||||
HTML::HTMLVideoElement& VideoBox::dom_node()
|
||||
|
@ -49,7 +49,7 @@ void VideoBox::prepare_for_replaced_layout()
|
|||
set_natural_aspect_ratio({});
|
||||
}
|
||||
|
||||
void VideoBox::browsing_context_did_set_viewport_rect(CSSPixelRect const&)
|
||||
void VideoBox::did_set_viewport_rect(CSSPixelRect const&)
|
||||
{
|
||||
// FIXME: Several steps in HTMLMediaElement indicate we may optionally handle whether the media object
|
||||
// is in view. Implement those steps.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue