Z index refactor - #3
Open
celsowm wants to merge 4 commits into
Open
Conversation
This commit introduces a major refactoring of the rendering pipeline to correctly handle `z-index` and stacking contexts. The previous implementation had a fixed paint order, which caused elements to be rendered incorrectly when `z-index` was used. The new implementation introduces a sorting step that orders the `RenderBox` objects based on CSS stacking context rules before painting them. This ensures that elements are rendered in the correct order, respecting their `z-index`, `position`, and `opacity`. The key changes in this commit are: - A new `sortBoxesByZIndex` function in `src/pdf/renderer/sort-by-z-index.ts` that implements the stacking context sorting logic. - A refactored `paintLayoutPage` function in `src/pdf/renderer/page-paint.ts` that uses the new sorting logic to paint the `RenderBox` objects in the correct order. - Updates to `src/pdf/layout-tree-builder.ts` to correctly propagate `z-index`, `opacity`, and stacking context information to the render tree. - Updates to `src/css/style.ts` and `src/pdf/types.ts` to support the new `opacity` property and the `root` property in the `LayoutPageTree`.
This commit introduces a major refactoring of the rendering pipeline to correctly handle `z-index` and stacking contexts. The previous implementation had a fixed paint order, which caused elements to be rendered incorrectly when `z-index` was used. The new implementation introduces a sorting step that orders the `RenderBox` objects based on CSS stacking context rules before painting them. This ensures that elements are rendered in the correct order, respecting their `z-index`, `position`, and `opacity`. The key changes in this commit are: - A new `sortBoxesByZIndex` function in `src/pdf/renderer/sort-by-z-index.ts` that implements the stacking context sorting logic. - A refactored `paintLayoutPage` function in `src/pdf/renderer/page-paint.ts` that uses the new sorting logic to paint the `RenderBox` objects in the correct order. - Updates to `src/pdf/layout-tree-builder.ts` to correctly propagate `z-index`, `opacity`, and stacking context information to the render tree. - Updates to `src/css/style.ts` and `src/pdf/types.ts` to support the new `opacity` property and the `root` property in the `LayoutPageTree`.
This commit introduces a major refactoring of the rendering pipeline to correctly handle `z-index` and stacking contexts. The previous implementation had a fixed paint order, which caused elements to be rendered incorrectly when `z-index` was used. The new implementation introduces a sorting step that orders the `RenderBox` objects based on CSS stacking context rules before painting them. This ensures that elements are rendered in the correct order, respecting their `z-index`, `position`, and `opacity`. The key changes in this commit are: - A new `sortBoxesByZIndex` function in `src/pdf/renderer/sort-by-z-index.ts` that implements the stacking context sorting logic. - A refactored `paintLayoutPage` function in `src/pdf/renderer/page-paint.ts` that uses the new sorting logic to paint the `RenderBox` objects in the correct order. - Updates to `src/pdf/layout-tree-builder.ts` to correctly propagate `z-index`, `opacity`, and stacking context information to the render tree. - Updates to `src/css/style.ts` and `src/pdf/types.ts` to support the new `opacity` property and the `root` property in the `LayoutPageTree`.
This commit introduces a major refactoring of the rendering pipeline to correctly support the `z-index` CSS property and stacking contexts. The key changes include: - A new sorting algorithm (`sortBoxesByZIndex`) that orders renderable elements according to CSS stacking context rules, considering `position`, `z-index`, and `opacity`. - The page painting logic in `page-paint.ts` has been updated to use the sorted list of elements, ensuring that elements are painted in the correct order. - The `layout-tree-builder.ts` module now correctly identifies elements that establish a new stacking context and propagates the necessary properties to the render tree. - The `opacity` property is now correctly handled as part of the stacking context calculation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.