mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:57:45 +00:00
LibWeb: Add a way to resolve calc() values without a layout node
Instead of a layout node, you can pass a new Length::ResolutionContext struct which contains everything needed to resolve calc() lengths.
This commit is contained in:
parent
2ade229f27
commit
df8a96ee00
5 changed files with 107 additions and 75 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
|
||||
|
@ -156,6 +157,16 @@ public:
|
|||
Type type() const { return m_type; }
|
||||
double raw_value() const { return m_value; }
|
||||
|
||||
struct ResolutionContext {
|
||||
[[nodiscard]] static Length::ResolutionContext for_layout_node(Layout::Node const&);
|
||||
|
||||
CSSPixelRect viewport_rect;
|
||||
FontMetrics font_metrics;
|
||||
FontMetrics root_font_metrics;
|
||||
};
|
||||
|
||||
[[nodiscard]] CSSPixels to_px(ResolutionContext const&) const;
|
||||
|
||||
CSSPixels to_px(Layout::Node const&) const;
|
||||
|
||||
ALWAYS_INLINE CSSPixels to_px(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue