mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibWeb: Implement CSS 'contain' property
This commit is contained in:
parent
c53c781745
commit
67ed676831
Notes:
github-actions[bot]
2025-01-28 11:25:39 +00:00
Author: https://github.com/Psychpsyo
Commit: 67ed676831
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3296
Reviewed-by: https://github.com/AtkinsSJ ✅
154 changed files with 4200 additions and 117 deletions
|
@ -28,6 +28,37 @@ Box::~Box()
|
|||
{
|
||||
}
|
||||
|
||||
Optional<CSSPixels> Box::natural_width() const
|
||||
{
|
||||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
return 0;
|
||||
|
||||
return m_natural_width;
|
||||
}
|
||||
Optional<CSSPixels> Box::natural_height() const
|
||||
{
|
||||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
return 0;
|
||||
|
||||
return m_natural_height;
|
||||
}
|
||||
Optional<CSSPixelFraction> Box::natural_aspect_ratio() const
|
||||
{
|
||||
// https://drafts.csswg.org/css-contain-2/#containment-size
|
||||
// Replaced elements must be treated as having a natural width and height of 0 and no natural aspect
|
||||
// ratio.
|
||||
if (dom_node() && dom_node()->is_element() && as<DOM::Element>(dom_node())->has_size_containment())
|
||||
return {};
|
||||
|
||||
return m_natural_aspect_ratio;
|
||||
}
|
||||
|
||||
void Box::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue