@@ -68,6 +68,10 @@ static bool _paintOutline(Frag& frag, Gfx::Color currentColor, Gfx::Outline& out
68
68
return true ;
69
69
}
70
70
71
+ static bool _needsNewStackingContext (Frag const & frag) {
72
+ return frag.style ().zIndex != Keywords::AUTO;
73
+ }
74
+
71
75
static void _paintFragBordersAndBackgrounds (Frag& frag, Scene::Stack& stack) {
72
76
auto const & cssBackground = frag.style ().backgrounds ;
73
77
@@ -84,8 +88,11 @@ static void _paintFragBordersAndBackgrounds(Frag& frag, Scene::Stack& stack) {
84
88
bool hasOutline = _paintOutline (frag, currentColor, outline );
85
89
Math::Rectf bound = frag.metrics .borderBox ().round ().cast <f64>();
86
90
87
- if (any (backgrounds) or hasBorders or hasOutline)
88
- stack.add (makeRc<Scene::Box>(bound, std::move (borders), std::move (outline ), std::move (backgrounds)));
91
+ if (any (backgrounds) or hasBorders or hasOutline) {
92
+ auto box = makeRc<Scene::Box>(bound, std::move (borders), std::move (outline ), std::move (backgrounds));
93
+ box->zIndex = _needsNewStackingContext (frag) ? Limits<isize>::MIN : 0 ;
94
+ stack.add (box);
95
+ }
89
96
}
90
97
91
98
static void _establishStackingContext (Frag& frag, Scene::Stack& stack);
@@ -111,8 +118,7 @@ static void _paintChildren(Frag& frag, Scene::Stack& stack, auto predicate) {
111
118
for (auto & c : frag.children ) {
112
119
auto & s = c.style ();
113
120
114
- auto zIndex = s.zIndex ;
115
- if (zIndex != Keywords::AUTO) {
121
+ if (_needsNewStackingContext (c)) {
116
122
if (predicate (s))
117
123
_establishStackingContext (c, stack);
118
124
continue ;
0 commit comments