mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb: Draw floating replaced elements more correctly
Previously floating replaced elements were drawn incorrectly and also twice.
This commit is contained in:
parent
80b2c11c81
commit
5f1a146afd
Notes:
github-actions[bot]
2025-03-03 20:50:39 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 5f1a146afd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3430
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/kalenikaliaksandr
3 changed files with 73 additions and 2 deletions
|
@ -129,14 +129,27 @@ void StackingContext::paint_descendants(PaintContext& context, Paintable const&
|
|||
// "For each one of these, treat the element as if it created a new stacking context, but any positioned
|
||||
// descendants and descendants which actually create a new stacking context should be considered part of
|
||||
// the parent stacking context, not this new one."
|
||||
auto should_be_treated_as_stacking_context = child.layout_node().is_grid_item() && !z_index.has_value();
|
||||
if (should_be_treated_as_stacking_context) {
|
||||
auto grid_item_should_be_treated_as_stacking_context = child.layout_node().is_grid_item() && !z_index.has_value();
|
||||
if (grid_item_should_be_treated_as_stacking_context) {
|
||||
// FIXME: This may not be fully correct with respect to the paint phases.
|
||||
if (phase == StackingContextPaintPhase::Foreground)
|
||||
paint_node_as_stacking_context(child, context);
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css2/#painting-order
|
||||
// All non-positioned floating descendants, in tree order. For each one of these, treat the
|
||||
// element as if it created a new stacking context, but any positioned descendants and
|
||||
// descendants which actually create a new stacking context should be considered part of the
|
||||
// parent stacking context, not this new one.
|
||||
auto floating_item_should_be_treated_as_stacking_context = child.is_floating() && !child.is_positioned() && !z_index.has_value();
|
||||
if (floating_item_should_be_treated_as_stacking_context) {
|
||||
if (phase == StackingContextPaintPhase::Floats) {
|
||||
paint_node_as_stacking_context(child, context);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
}
|
||||
|
||||
if (child.is_positioned() && z_index.value_or(0) == 0)
|
||||
return IterationDecision::Continue;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue