Closed
Bug 1250090
Opened 9 years ago
Closed 8 years ago
Add width and height to CanvasRenderingContext2D
Categories
(Core :: Graphics: Canvas2D, defect)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
INVALID
People
(Reporter: xidorn, Assigned: fatseng)
References
(Blocks 1 open bug)
Details
(Whiteboard: [gfx-noted])
The HTML spec includes "width" and "height" attribute for CanvasRenderingContext2D to get the dimensions of the canvas. [1]
This would be useful because otherwise there is no efficient way to get the geometry inside the rAF loop. Some apps use clientWidth and clientHeight to get the width and height (e.g. MDN's pointerlock demo [2]), which hurts the performance because of triggering flush.
[1] https://html.spec.whatwg.org/multipage/scripting.html#2dcontext
[2] https://github.com/mdn/pointer-lock-demo/blob/3f6cfe118e5e2b205314680c69dd94f34978b8ed/app.js#L41
Updated•9 years ago
|
Blocks: 1119470
Keywords: dev-doc-needed
Updated•9 years ago
|
Whiteboard: [gfx-noted]
This is different from the width and height that we have today? https://dxr.mozilla.org/mozilla-central/source/dom/canvas/CanvasRenderingContext2D.h#428
Reporter | ||
Comment 2•9 years ago
|
||
Probably the same. We may just need to expose it in the WebIDL file.
Comment 3•9 years ago
|
||
(In reply to Xidorn Quan [:xidorn] (UTC+8) from comment #2)
> Probably the same. We may just need to expose it in the WebIDL file.
I can take this bug for the following things based on requirement.
Assignee: nobody → vliu
Comment 4•8 years ago
|
||
I will assign this bug to Farmer because he is interested in looking into it
Assignee: vliu → fatseng
Assignee | ||
Comment 5•8 years ago
|
||
I can't find width and height attributes in CanvasRenderingContext2D spec. [1]
But found they are in htmlcanvaselement. [2]
Do ctx.canvas.width and ctx.canvas.height also hurt performance?
[1] https://html.spec.whatwg.org/multipage/scripting.html#2dcontext
[2] https://html.spec.whatwg.org/multipage/scripting.html#htmlcanvaselement
Flags: needinfo?(bugzilla)
Reporter | ||
Comment 6•8 years ago
|
||
It seems it is removed a while ago: https://github.com/whatwg/html/pull/1074
And yes, canvas.width / canvas.height should be the right way to go, which I wasn't aware of.
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(bugzilla)
Resolution: --- → INVALID
Updated•8 years ago
|
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•