mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
Instead, compute them on demand. This affects ReplacedBox and its subclasses. This commit is centered around a new Box::auto_content_box_size method. It returns a SizeWithAspectRatio representing the natural size of a replaced element, or the size derived from attributes for text input and textarea. These values are used when the corresponding axis is auto or indefinite. Although introducing this API choke-point for sizing replaced and replaced-like elements was the main goal, it's notable that layout becomes more robust in the face of dynamic changes due to reduced potential for stale size values (at the cost of extra calculations and allocations).
30 lines
801 B
C++
30 lines
801 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class CanvasBox final : public ReplacedBox {
|
|
GC_CELL(CanvasBox, ReplacedBox);
|
|
GC_DECLARE_ALLOCATOR(CanvasBox);
|
|
|
|
public:
|
|
CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, GC::Ref<CSS::ComputedProperties>);
|
|
virtual ~CanvasBox() override;
|
|
|
|
HTML::HTMLCanvasElement const& dom_node() const { return static_cast<HTML::HTMLCanvasElement const&>(*ReplacedBox::dom_node()); }
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
private:
|
|
virtual CSS::SizeWithAspectRatio compute_auto_content_box_size() const override;
|
|
};
|
|
|
|
}
|