Skip to content

Commit 74b9764

Browse files
LuneMerciersleepy-monax
authored andcommitted
vaev-layout: Fix zindex on parent children case.
1 parent 0e8727b commit 74b9764

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/web/vaev-layout/paint.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ static bool _paintOutline(Frag& frag, Gfx::Color currentColor, Gfx::Outline& out
6868
return true;
6969
}
7070

71+
static bool _needsNewStackingContext(Frag const& frag) {
72+
return frag.style().zIndex != Keywords::AUTO;
73+
}
74+
7175
static void _paintFragBordersAndBackgrounds(Frag& frag, Scene::Stack& stack) {
7276
auto const& cssBackground = frag.style().backgrounds;
7377

@@ -84,8 +88,11 @@ static void _paintFragBordersAndBackgrounds(Frag& frag, Scene::Stack& stack) {
8488
bool hasOutline = _paintOutline(frag, currentColor, outline);
8589
Math::Rectf bound = frag.metrics.borderBox().round().cast<f64>();
8690

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+
}
8996
}
9097

9198
static void _establishStackingContext(Frag& frag, Scene::Stack& stack);
@@ -111,8 +118,7 @@ static void _paintChildren(Frag& frag, Scene::Stack& stack, auto predicate) {
111118
for (auto& c : frag.children) {
112119
auto& s = c.style();
113120

114-
auto zIndex = s.zIndex;
115-
if (zIndex != Keywords::AUTO) {
121+
if (_needsNewStackingContext(c)) {
116122
if (predicate(s))
117123
_establishStackingContext(c, stack);
118124
continue;

0 commit comments

Comments
 (0)