mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-29 04:30:24 +00:00
Add cqw/cqh/cqi/cqb/cqmin/cqmax to the unit tables and generated helpers, then thread them through the shared length resolution path. Length::ResolutionContext now carries the subject element and whether its inline axis is horizontal. Container units need that extra context: the nearest eligible query container is selected from the subject element's flat-tree ancestors, and cqi/cqb/cqmin/cqmax map logical axes through the subject's writing mode before resolving to a physical width or height. Teach Length to resolve each axis against the selected container's content box, fall back to viewport lengths when no eligible container exists, and mark size-container dependencies so post-layout recomputation can happen when layout is not up to date. Also expose the new units through Typed OM, reject them for computationally independent `@property` initial values, and add focused font-size coverage.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2025, Callum Law <callumlaw1709@outlook.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/Length.h>
|
|
#include <LibWeb/CSS/PreferredColorScheme.h>
|
|
#include <LibWeb/DOM/AbstractElement.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
struct ComputationContext {
|
|
Length::ResolutionContext length_resolution_context;
|
|
Optional<DOM::AbstractElement> abstract_element {};
|
|
Optional<PreferredColorScheme> color_scheme {};
|
|
|
|
void reset_viewport_metric_dependency_tracking() const
|
|
{
|
|
m_did_resolve_viewport_relative_length = false;
|
|
length_resolution_context.set_did_resolve_viewport_relative_length(m_did_resolve_viewport_relative_length);
|
|
}
|
|
|
|
bool depends_on_viewport_metrics() const
|
|
{
|
|
return m_did_resolve_viewport_relative_length;
|
|
}
|
|
|
|
void visit_edges(GC::Cell::Visitor& visitor)
|
|
{
|
|
length_resolution_context.visit_edges(visitor);
|
|
if (abstract_element.has_value())
|
|
abstract_element->visit(visitor);
|
|
}
|
|
|
|
mutable bool m_did_resolve_viewport_relative_length { false };
|
|
};
|
|
|
|
}
|