Repository navigation
Fix PR #1149 - #1177
Open
100pah wants to merge 5 commits into
Open
Fix PR #1149#1177100pah wants to merge 5 commits into
100pah wants to merge 5 commits into
Conversation
… usage of `this` in callback function (https://github.com/ecomfe/zrender/blob/349111033fba0fa08cee745b72dd2ea66dc6fcaa/src/canvas/Painter.ts#L1254). And the corresponding TS error. (1.2) `PathProxy#setScale` was called before `PathProxy#setDPR`, but `PathProxy#setScale` used DPR. Fix that: remove `setDPR` method and add DPR as a parameter of `setScale`. (2). Fix and clarify width/height parameters processing in `constructor` and `resize` method in `singleCanvas` case - align them with `non-singleCanvas` case. (3). Remove attaching `dpr` to `CanvasRenderingContext2D` - not necessary and error-prone.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved canvas resizing and export-scaling regressions can produce incorrectly sized or clipped output.
4 open findings
What changed in this PR
Addresses rendering issues introduced by #1158 by making device pixel ratio (DPR) explicit and revising canvas sizing.
Changes:
- Passes DPR through brush scopes and path scaling instead of attaching it to rendering contexts.
- Refactors single-canvas sizing and fixes the resize callback’s
thisusage. - Consolidates shared sizing and rendering option types.
| File | Description |
|---|---|
| src/zrender.ts | Uses shared options and clarifies resize documentation. |
| src/PainterBase.ts | Reuses shared resize parameter types. |
| src/graphic/Displayable.ts | Adds DPR to brush parameters. |
| src/graphic/CompoundPath.ts | Passes DPR to child path scaling. |
| src/core/types.ts | Defines shared options and dimension constants. |
| src/core/PathProxy.ts | Accepts DPR directly in setScale. |
| src/core/BoundingRect.ts | Reuses shared dimension constants. |
| src/canvas/Painter.ts | Revises sizing, resizing, and DPR propagation. |
| src/canvas/Layer.ts | Removes context DPR markers and centralizes bitmap sizing. |
| src/canvas/helper.ts | Adds single-canvas size resolution. |
| src/canvas/graphic.ts | Uses brush-scope DPR throughout rendering. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ovilia
approved these changes
Oct 18, 2026
This branch has not been deployed
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.

thisin callback function (zrender/src/canvas/Painter.ts
Line 1254 in 3491110
PathProxy#setScalewas called beforePathProxy#setDPR, butPathProxy#setScaleused DPR. Fix that: removesetDPRmethod and add DPR as a parameter ofsetScale.constructorandresizemethod insingleCanvascase - align them withnon-singleCanvascase.dprtoCanvasRenderingContext2D- not necessary and error-prone.Painter#toDataURLandPainter#renderToString- add the missing escaping on attribute values.