mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
Integrate AccumulatedVisualContext with display list recording and playback. This is the main commit of the refactoring that delivers the architectural improvements enabled by AccumulatedVisualContext. Recording changes: Each display list command now stores a single RefPtr<AccumulatedVisualContext> instead of separate scroll_frame_id and ClipFrame. The recorder simply captures the current accumulated context when appending commands. The before_paint()/after_paint() hooks that pushed/popped scroll frame IDs are replaced by directly setting accumulated_visual_context on the recorder before painting each element. Playback changes: The display list player now uses LCA (Lowest Common Ancestor) based traversal to switch between visual contexts efficiently. When transitioning from context A to context B: 1. Find the LCA of A and B in the context tree 2. Pop (restore) states back to the LCA depth 3. Push (save + apply) states from LCA down to B This approach minimizes redundant save/restore operations. For example, when rendering siblings that share a common scroll container, the player keeps that scroll state applied and only switches the divergent parts of their context chains. Key deletions: - Remove translate_by() from all 45 display list commands - commands are now immutable - Remove transform/perspective fields from PushStackingContext - transforms are tracked via AccumulatedVisualContext - Remove push_scroll_frame_id()/pop_scroll_frame_id() from DisplayListRecorder - Remove before_paint()/after_paint() hooks from Paintable - Merge ApplyOpacity, ApplyCompositeAndBlendingOperator, ApplyFilter into single ApplyEffects command Stacking context painting changes: The StackingContext::paint() method is significantly simplified. Instead of building a PushStackingContextParams struct with transform matrices and pushing/popping stacking contexts, it now: 1. Sets the accumulated visual context (which already contains transforms) 2. Applies effects (opacity, blend mode, filters) if needed 3. Applies clip path if needed 4. Paints the content 5. Restores state The visual state management that was interleaved throughout the painting code is now handled uniformly by the context tree.
32 lines
813 B
HTML
32 lines
813 B
HTML
<!DOCTYPE html>
|
|
<link rel="match" href="../expected/scrollable-contains-box-with-gradient-background-ref.html" />
|
|
<meta name="fuzzy" content="maxDifference=0-1;totalPixels=0-50">
|
|
<style type="text/css">
|
|
* {
|
|
scrollbar-width: none;
|
|
}
|
|
|
|
.box {
|
|
width: 180px;
|
|
height: 64px;
|
|
background: linear-gradient(rgb(109, 152, 204), rgb(138, 100, 229));
|
|
border-radius: 100px;
|
|
}
|
|
|
|
#scrollable {
|
|
width: 200px;
|
|
height: 200px;
|
|
overflow: scroll;
|
|
border: 10px solid orchid;
|
|
}
|
|
</style>
|
|
<div id="scrollable">
|
|
<div style="height: 100px"></div>
|
|
<div class="box"></div>
|
|
<div style="height: 200px"></div>
|
|
</div>
|
|
<script>
|
|
const scrollContainer = document.getElementById("scrollable");
|
|
scrollContainer.scrollTop = 100;
|
|
</script>
|