mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
Neither of these classes did anything useful as ViewportClients: - ImagePaintable called set_visible_in_viewport() which is a FIXME no-op in every ImageProvider implementation. - VideoBox had an empty did_set_viewport_rect() with a FIXME comment. More importantly, they caused a crash when a DOM node was adopted into a different document: the old ImagePaintable/VideoBox would still be registered with the old document, but their document() accessor (which goes through the DOM node) would return the new document. During GC finalization, unregister_viewport_client() would fail because it was trying to unregister from the wrong document. The only meaningful ViewportClient is HTMLImageElement (for responsive image source selection), which already handles document adoption correctly in adopted_from(). Fixes crash when loading https://msn.com/
31 lines
730 B
C++
31 lines
730 B
C++
/*
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class VideoBox final : public ReplacedBox {
|
|
GC_CELL(VideoBox, ReplacedBox);
|
|
GC_DECLARE_ALLOCATOR(VideoBox);
|
|
|
|
public:
|
|
HTML::HTMLVideoElement& dom_node();
|
|
HTML::HTMLVideoElement const& dom_node() const;
|
|
|
|
virtual bool can_have_children() const override;
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
private:
|
|
VideoBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
|
virtual CSS::SizeWithAspectRatio natural_size() const override;
|
|
};
|
|
|
|
}
|