mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02: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).
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
/*
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
|
#include <LibWeb/SVG/SVGSVGElement.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class SVGSVGBox final : public ReplacedBox {
|
|
GC_CELL(SVGSVGBox, ReplacedBox);
|
|
GC_DECLARE_ALLOCATOR(SVGSVGBox);
|
|
|
|
public:
|
|
SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, GC::Ref<CSS::ComputedProperties>);
|
|
virtual ~SVGSVGBox() override = default;
|
|
|
|
SVG::SVGSVGElement& dom_node() { return as<SVG::SVGSVGElement>(*ReplacedBox::dom_node()); }
|
|
SVG::SVGSVGElement const& dom_node() const { return as<SVG::SVGSVGElement>(*ReplacedBox::dom_node()); }
|
|
|
|
virtual bool can_have_children() const override { return true; }
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
private:
|
|
virtual CSS::SizeWithAspectRatio natural_size() const override;
|
|
virtual bool is_svg_svg_box() const final { return true; }
|
|
};
|
|
|
|
template<>
|
|
inline bool Node::fast_is<SVGSVGBox>() const { return is_svg_svg_box(); }
|
|
|
|
}
|