Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update letterSpacing and wordSpacing to accept String #7378

Merged
merged 9 commits into from
Jan 28, 2022
Merged

Update letterSpacing and wordSpacing to accept String #7378

merged 9 commits into from
Jan 28, 2022

Conversation

yiyix
Copy link
Contributor

@yiyix yiyix commented Nov 29, 2021

@annevk
Copy link
Member

annevk commented Nov 30, 2021

Thanks for creating this PR @yiyix.

As far as I know @Kaiido does not speak for Mozilla or Firefox. @jdashg or I do (at times).

Also, this change isn't sufficient. You need to invoke the CSS parser as we do for other canvas members. And we also need to serialize the value in some manner for the getters.

@annevk
Copy link
Member

annevk commented Nov 30, 2021

cc @whatwg/canvas

Copy link
Member

@Kaiido Kaiido left a comment

Choose a reason for hiding this comment

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

Yes, I always speak (maybe too much) only for myself as a web-author, I don't have any affiliation with any vendor.

Regarding the changes I still find the discrepancy between font being converted to px and these values kept as relative <length> a bit surprising ("2vw" may represent two different values entirely just by resizing the window), but overall I don't have strong opinions.

@yiyix
Copy link
Contributor Author

yiyix commented Dec 14, 2021

Thanks for creating this PR @yiyix.

As far as I know @Kaiido does not speak for Mozilla or Firefox. @jdashg or I do (at times).

Thank you for the clarification. What do you think about this change, Define letterSpacing and wordSpacing in terms of String? Or do you think it's better to keep as it is or accept doubles and strings?

Also, this change isn't sufficient. You need to invoke the CSS parser as we do for other canvas members. And we also need to serialize the value in some manner for the getters.

I will re-write this part. Thank you

Copy link
Member

@Kaiido Kaiido left a comment

Choose a reason for hiding this comment

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

Sorry for this quite sketchy review, I am not sure about all my proposed changes and a review of the review is required.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@domenic
Copy link
Member

domenic commented Dec 16, 2021

@Kaiido, it'd be best if you left review to the editors :). I worry that you might end up giving advice which conflicts with our preferences, or applies to a section the editors request be done in a different way entirely, etc. This makes it harder for contributors to understand what is required for merging, and can generate unnecessary work.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Overall it looks like you have the right idea to me, and have found the most relevant algorithms for parsing and serializing. We just need to tighten up the language.

Note that this parse/serialize architecture means that

ctx.letterSpacing = "5PX";
console.assert(ctx.letterSpacing === "5px"); // lowercased!!

will hold. That seems consistent with what we've specified elsewhere, but is worth writing web platform tests for.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@yiyix
Copy link
Contributor Author

yiyix commented Jan 10, 2022

Overall it looks like you have the right idea to me, and have found the most relevant algorithms for parsing and serializing. We just need to tighten up the language.

Note that this parse/serialize architecture means that

ctx.letterSpacing = "5PX";
console.assert(ctx.letterSpacing === "5px"); // lowercased!!

will hold. That seems consistent with what we've specified elsewhere, but is worth writing web platform tests for.

Good point! Tests and Changes are now made.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

This looks great. A few style issues and one more substantial issue about the initial value, but after that this is about ready to merge. (I can do a final formatting pass.)

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

OK, this all looks good! But I realized we forgot to update a couple other parts of the spec which currently refer to letterSpacing/wordSpacing to instead refer to "letter spacing"/"word spacing" (i.e., to refer to the underlying <span data-x="concept-CanvasTextDrawingStyles-letter-spacing">letter spacing</span> private field).

I think the following two places need updating:

After that I think we should be good!

@yiyix
Copy link
Contributor Author

yiyix commented Jan 28, 2022

OK, this all looks good! But I realized we forgot to update a couple other parts of the spec which currently refer to letterSpacing/wordSpacing to instead refer to "letter spacing"/"word spacing" (i.e., to refer to the underlying <span data-x="concept-CanvasTextDrawingStyles-letter-spacing">letter spacing</span> private field).

I think the following two places need updating:

After that I think we should be good!

This version definitely looks much better than the previous ones. Thank you so much! This should conclude our spec changes for Canvas new API

@Kaiido
Copy link
Member

Kaiido commented Jan 28, 2022

I think the following two places need updating:

Is it so? This section gets the "attributes" values, linking to the IDL attributes' getters sounds correct, no? Otherwise I guess this should be moved in a later item like it's done for "The current dash list".
And if this is indeed the correct action, then should we also update strokeStyle, fillStyle, globalCompositeOperation, and filter (maybe in an other PR)?

@domenic
Copy link
Member

domenic commented Jan 28, 2022

Yes @Kaiido, this is part of a general program to update the spec to stop relying on JavaScript-modifiable getters and instead get their backing values.

@domenic domenic merged commit 4d93c06 into whatwg:main Jan 28, 2022
Kaiido added a commit to Kaiido/html that referenced this pull request Jan 29, 2022
… getters

This is a follow-up on whatwg#7378.
It fixes a couple of typos, and adds the current filter and the current composition operator in the list of saved values from CanvasState, since these already have their own internal value being defined.
domenic pushed a commit that referenced this pull request Jan 31, 2022
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44.

Use the current filter and current composition operator in the canvas state section, instead of the public getters, per #7378 (comment).
asankah pushed a commit to asankah/html that referenced this pull request Feb 7, 2022
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44.

Use the current filter and current composition operator in the canvas state section, instead of the public getters, per whatwg#7378 (comment).
mfreed7 pushed a commit to mfreed7/html that referenced this pull request Jun 3, 2022
Fix some typos in the canvas text styles section that were introduced in4d93c06fa604021b7c582940e1a419378237bf44.

Use the current filter and current composition operator in the canvas state section, instead of the public getters, per whatwg#7378 (comment).
@yiyix yiyix deleted the letter-spacing-type branch January 4, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants