Skip to content

Update width/height comment#93

Open
foolip wants to merge 1 commit into
mainfrom
width-height-coordinate-space
Open

Update width/height comment#93
foolip wants to merge 1 commit into
mainfrom
width-height-coordinate-space

Conversation

@foolip

@foolip foolip commented Mar 19, 2026

Copy link
Copy Markdown
Member

No description provided.

@foolip

foolip commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

@Kaiido FYI since you asked about this. Device pixels is wrong, or only true if you also size the canvas to match the pixel size reported by ResizeObserver, which is a good idea.

Comment thread README.md
// dimensions in device pixels
readonly attribute unsigned long width;
readonly attribute unsigned long height;
// dimensions scaled such that when drawing to canvas, the element will appear

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this "intrinsic size" and define it as a first-class concept? It's a subtle enough concept that we had a lengthy discussion about it. The definition would be something like:

"the size, in canvas coordinate space, at which an Element or ElementImage will have the same proportions when drawn into the canvas as it would have were it placed outside the canvas with the same ComputedStyle."

These attributes can then simply be described as "intrinsic size of the element", and we would refer to the "intrinsic size" concept again in the IDL for drawElementImage, because that's the size we will use if the optional destination size parameters are omitted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concept definition of "intrinsic size" could also contain polyfill code to compute it based on canvas.(width|height) and canvas.client(Width|Height) and element_style.(width|height)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Intrinsic size" is already https://drafts.csswg.org/css-sizing-3/#intrinsic-size, but I agree we could give this concept a name. Natural size is also taken, but maybe... default size?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah ok, but I think this should be direct:

// The default size of the element in canvas grid coordinates. If the width and height parameters
// to drawElementImage() are omitted, these are the values that will be used.

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.

2 participants