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

[aspect-ratio] Use continued fraction algorithm for LayoutUnit conversion #32837

Merged
merged 1 commit into from Feb 15, 2022

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Feb 14, 2022

Previously we'd directly convert the float aspect-ratio to LayoutUnit.
This wasn't correct as we'd potentially lose a lot of precision in the
process.

Instead of this use the continued fraction algorithm to find a precise
representation.

This mitigates the current problem, but likely isn't the best end
scenario. We likely want to represent aspect-ratios as either a
LayoutUnit ratio, or float ratio, depending on the source.

(Specifically the LayoutUnit ratio is far better for the replaced
element case, except for aspect-ratio only SVGs, a float ratio may be
better for aspect-ratio only elements).

Bug: 1296175
Change-Id: I1a1f62fdfdb27785eb076ccaa2d5a4e81566fd46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3459264
Reviewed-by: David Grogan <dgrogan@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#971292}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-3459264 branch 2 times, most recently from f922605 to 75a150d Compare February 15, 2022 15:41
…sion

Previously we'd directly convert the float aspect-ratio to LayoutUnit.
This wasn't correct as we'd potentially lose a lot of precision in the
process.

Instead of this use the continued fraction algorithm to find a precise
representation.

This mitigates the current problem, but likely isn't the best end
scenario. We likely want to represent aspect-ratios as either a
LayoutUnit ratio, or float ratio, depending on the source.

(Specifically the LayoutUnit ratio is far better for the replaced
element case, except for aspect-ratio only SVGs, a float ratio may be
better for aspect-ratio only elements).

Bug: 1296175
Change-Id: I1a1f62fdfdb27785eb076ccaa2d5a4e81566fd46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3459264
Reviewed-by: David Grogan <dgrogan@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#971292}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants