Skip to content

layout: Use an accurately-sized clipping rectangle for box-shadow display list item properties instead of MaxRect#44457

Merged
TimvdLippe merged 2 commits into
servo:mainfrom
yezhizhen:fix-box-shadow
Apr 23, 2026
Merged

layout: Use an accurately-sized clipping rectangle for box-shadow display list item properties instead of MaxRect#44457
TimvdLippe merged 2 commits into
servo:mainfrom
yezhizhen:fix-box-shadow

Conversation

@yezhizhen

@yezhizhen yezhizhen commented Apr 23, 2026

Copy link
Copy Markdown
Member

Mobile phone runs OpenGL Embedded System. The precision is limited comparing to Desktop which runs full OpenGL. This caused a bug where box-shadow is not displayed on Android/OHOS. Instead of using an infinite clip rect, we compute a bounded one. This should save some GPU work as well.

Reference: How to gracefully handle highp/mediump switch for mobile Android browsers?

Testing: Desktop WPT unchanged. Manually tested on Android/Ohos. Now look same as Firefox/Chrome.

Before After
Screenshot_20260423_154114.jpg screenshot_20260423_154059_1776930134.jpg

Fixes: #44431
Closes: servo/webrender#4879

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@yezhizhen yezhizhen requested review from jschwe and xiaochengh April 23, 2026 10:06
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 23, 2026
Comment thread components/layout/display_list/mod.rs Outdated
clip_rect = self.border_rect;
}
let common = builder.common_properties(clip_rect, &style);
// Note: According to CSS-BACKGROUNDS, box shadows render in *reverse* order (front to back).

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.

I don't know what "NB:" is, so replaced with "Note:".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://en.wikipedia.org/wiki/Nota_bene is often used in mathematics.

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.

I received my math education in English but never saw this word before🤣

Comment thread components/layout/display_list/mod.rs
@servo-highfive servo-highfive added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 23, 2026
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Apr 23, 2026
@yezhizhen

Copy link
Copy Markdown
Member Author

Try run here

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 23, 2026
@mrobinson mrobinson changed the title layout: Enable box-shadow on Android/OHOS by replacing infinite clip rect in build_box_shadow layout: Use an accurately sized clipping rectangle for box-shadow display list item properties instead of MaxRect Apr 23, 2026
@mrobinson mrobinson changed the title layout: Use an accurately sized clipping rectangle for box-shadow display list item properties instead of MaxRect layout: Use an accurately-sized clipping rectangle for box-shadow display list item properties instead of MaxRect Apr 23, 2026
@TimvdLippe TimvdLippe added this pull request to the merge queue Apr 23, 2026
@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 Apr 23, 2026
Merged via the queue into servo:main with commit 464ae82 Apr 23, 2026
35 checks passed
@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 Apr 23, 2026
@yezhizhen yezhizhen deleted the fix-box-shadow branch April 24, 2026 05:53
@yezhizhen

Copy link
Copy Markdown
Member Author

This also seems to fix a bug on Desktop: After you zoom in 4 times, the box-shadow would completely disappear.

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.

Box-shadow only appear in Desktop but not Android/Ohos

5 participants