Skip to content

layout: Ensure that background-repeat: round size calculation rounds to nearest natural number#41158

Merged
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:round-to-natural-number
Dec 10, 2025
Merged

layout: Ensure that background-repeat: round size calculation rounds to nearest natural number#41158
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:round-to-natural-number

Conversation

@mrobinson
Copy link
Copy Markdown
Member

The previous code was just rounding to the nearest integrer, while the
specification says to round to the nearest natural number. The prevents
inf and NaN values from creeping to the results. This was leading to
a crash in WebRender.

Testing: This change adds a crash test.
Fixes: #41130.

@mrobinson mrobinson requested a review from Loirooriol as a code owner December 9, 2025 14:54
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 9, 2025
]
},
"background-repeat": {
"background-repeat-image-larger-than-positioning-area-crash.html": [
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.

You forgot to include this file in the PR

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.

This is added now.

@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#56595) with upstreamable changes.

@@ -0,0 +1,5 @@
<!DOCTYPE html>
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.

Add <link rel="help" href="https://github.com/servo/servo/issues/41130"> for reference.

@@ -0,0 +1,5 @@
<!DOCTYPE html>
<style>
#span {background-repeat: round; background-image: url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wDGhYvCNVA1EIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAjklEQVR42u3QIQEAMAgAsHNNVspTgARY1BZh0ZWP3VcgSJAgQYIECRKEIEGCBAkSJEgQggQJEiRIkCBBCBIkSJAgQYIECUKQIEGCBAkSJAhBggQJEiRIkCAECRIkSJAgQYIEIUiQIEGCBAkShCBBggQJEiRIEIIECRIkSJAgQYIQJEiQIEGCBAlCkCBBdwaeugIthHvZ+AAAAABJRU5E) }
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.

You can use background-image: url("../../support/60x60-green.png"), it's shorter.

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Dec 10, 2025
…s to nearest natural number

The previous code was just rounding to the nearest integrer, while the
specification says to round to the nearest natural number. The prevents
`inf` and `NaN` values from creeping to the results. This was leading to
a crash in WebRender.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson force-pushed the round-to-natural-number branch from 4a94d27 to c375278 Compare December 10, 2025 13:43
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 10, 2025
@mrobinson
Copy link
Copy Markdown
Member Author

@Loirooriol Thanks for the review!

@mrobinson mrobinson enabled auto-merge December 10, 2025 13:43
@servo-wpt-sync
Copy link
Copy Markdown
Collaborator

📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#56595).

@mrobinson mrobinson added this pull request to the merge queue Dec 10, 2025
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 10, 2025
Merged via the queue into servo:main with commit 949ce55 Dec 10, 2025
32 checks passed
@mrobinson mrobinson deleted the round-to-natural-number branch December 10, 2025 14:39
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

4 participants