Fix background-position bottom/right alignment in RenderBackgroundSystem#331
Merged
Fix background-position bottom/right alignment in RenderBackgroundSystem#331
Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
… and documentation Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix background-position bottom/right alignment in RenderBackgroundSystem
Fix background-position bottom/right alignment in RenderBackgroundSystem
Sep 17, 2025
yorkie
approved these changes
Sep 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
RenderBackgroundSystemwas not aligning background images and gradients correctly when usingbackground-positionpercentage values for bottom or right alignment. This resulted in visual discrepancies where backgrounds did not reach the element's edge as expected per CSS specification.Problem
When CSS like
background-position: 100% 100%was used, the background image would not align flush with the bottom-right corner of the element, leaving gaps or offsets. This occurred because the CSS parser stores two-value percentage positions as length values, and the rendering code was treating them as pixel offsets rather than percentages.Root Cause
The issue was in the
calculateBackgroundPosition()function'sisTwoValues()case handling. When developers used:The values were being processed as:
Solution
Enhanced the
isTwoValues()case incalculateBackgroundPosition()to:position = elementStart + percentage * (elementSize - imageSize)Visual Demonstration
The screenshot shows both
background-position: right bottom(left) andbackground-position: 100% 100%(right) correctly positioning the gradient in the bottom-right corner with perfect edge alignment.Key Changes
web_content_renderer.cppThis fix ensures that
background-position: 100% 100%now correctly aligns the background image's bottom-right corner with the element's bottom-right corner, matching CSS specification behavior and eliminating gaps/offsets at element edges.Fixes #330.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
registry.npmmirror.comnpm ci(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.