mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 14:20:21 +00:00
LibWeb: Verify that save and restore are balanced within StackingContext
Unbalanced save and restore means that effects only relevant to a stacking context leak outside, which is never expected behavior. Having a `VERIFY()` for that makes it much easier to catch such issues.
This commit is contained in:
parent
9e3a476890
commit
8f39aa0d4a
Notes:
github-actions[bot]
2025-07-06 20:19:35 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 8f39aa0d4a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5332
2 changed files with 9 additions and 0 deletions
|
@ -417,6 +417,8 @@ void DisplayListRecorder::paint_scrollbar(int scroll_frame_id, Gfx::IntRect gutt
|
||||||
|
|
||||||
void DisplayListRecorder::apply_opacity(float opacity)
|
void DisplayListRecorder::apply_opacity(float opacity)
|
||||||
{
|
{
|
||||||
|
// Implementation of this item does saveLayer(), so we need to increment the nesting level.
|
||||||
|
++m_save_nesting_level;
|
||||||
append(ApplyOpacity { .opacity = opacity });
|
append(ApplyOpacity { .opacity = opacity });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,6 +431,8 @@ void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::Compositi
|
||||||
|
|
||||||
void DisplayListRecorder::apply_filter(Gfx::Filter filter)
|
void DisplayListRecorder::apply_filter(Gfx::Filter filter)
|
||||||
{
|
{
|
||||||
|
// Implementation of this item does saveLayer(), so we need to increment the nesting level.
|
||||||
|
++m_save_nesting_level;
|
||||||
append(ApplyFilter { .filter = move(filter) });
|
append(ApplyFilter { .filter = move(filter) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,11 @@ void StackingContext::paint(PaintContext& context) const
|
||||||
if (opacity == 0.0f)
|
if (opacity == 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
TemporaryChange save_nesting_level(context.display_list_recorder().m_save_nesting_level, 0);
|
||||||
|
ScopeGuard verify_save_and_restore_are_balanced([&] {
|
||||||
|
VERIFY(context.display_list_recorder().m_save_nesting_level == 0);
|
||||||
|
});
|
||||||
|
|
||||||
DisplayListRecorderStateSaver saver(context.display_list_recorder());
|
DisplayListRecorderStateSaver saver(context.display_list_recorder());
|
||||||
|
|
||||||
auto to_device_pixels_scale = float(context.device_pixels_per_css_pixel());
|
auto to_device_pixels_scale = float(context.device_pixels_per_css_pixel());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue