Skip to content

Do not convert hsl/hwb to RGB at parse time to not loose precision #326

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

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

tiaanl
Copy link
Collaborator

@tiaanl tiaanl commented Feb 26, 2023

Parsing is not done in 2 forms as per the spec. Legacy and new syntax. For rgb and hsl where both are valid, first one is tried and if it fails, we try the other.

We also store hsl and hwb values directly without converting them to rgba at parse time. The conversion only happens how before serializing.

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

So would there be any chance of getting more context on why the color component parsing changes are an improvement? At a glance, it makes parsing potentially slower for non-legacy colors, and the extra heap allocation during rgb color parsing seems unfortunate, we should be able to do better there.

Can we split that from the hsl/hwb changes? I assume the split you're doing makes sense when we start parsing none, but as is I fail to see why it's an improvement.

@tiaanl
Copy link
Collaborator Author

tiaanl commented Mar 9, 2023

@emilio I rewrote the parsing changes into another PR: #328

All the issues here are addressed there and once that one is in I'll change this PR to only deal with adding HSL and HWB types.

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #328) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Looks good, let's fix the PR title?

@emilio
Copy link
Member

emilio commented Mar 9, 2023

@bors-servo delegate+

@bors-servo
Copy link
Contributor

✌️ @tiaanl can now approve this pull request

@tiaanl tiaanl changed the title Add HSL/HWB as valid parsed colors and improve component parsing Do not convert hsl/hwb to RGB at parse time to not loose precision Mar 9, 2023
@emilio
Copy link
Member

emilio commented Mar 9, 2023

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 2f56d1c has been approved by emilio

@bors-servo
Copy link
Contributor

⌛ Testing commit 2f56d1c with merge af78ba0...

@bors-servo
Copy link
Contributor

☀️ Test successful - checks-github
Approved by: emilio
Pushing af78ba0 to master...

@bors-servo bors-servo merged commit af78ba0 into servo:master Mar 9, 2023
@tiaanl tiaanl deleted the add-hsl-hwb branch March 9, 2023 11:54
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.

3 participants