Skip to content

Z index refactor - #3

Open
celsowm wants to merge 4 commits into
mainfrom
z-index-refactor
Open

Z index refactor#3
celsowm wants to merge 4 commits into
mainfrom
z-index-refactor

Conversation

@celsowm

@celsowm celsowm commented Nov 4, 2025

Copy link
Copy Markdown
Owner

No description provided.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant