Skip to content

compositor: Have viewport meta tag affect the layout viewport#40055

Merged
atbrakhi merged 1 commit into
servo:mainfrom
atbrakhi:viewport
Oct 21, 2025
Merged

compositor: Have viewport meta tag affect the layout viewport#40055
atbrakhi merged 1 commit into
servo:mainfrom
atbrakhi:viewport

Conversation

@atbrakhi
Copy link
Copy Markdown
Member

@atbrakhi atbrakhi commented Oct 21, 2025

The CSS specifications defines two viewports1, the "layout viewport" and the visual viewport. The layout viewport affects layout and the visual viewport is the result of applying pinch zoom. This changes makes it so that the initial-scale property of <meta type="viewport"> affects the layout viewport.

Testing: Added a new unit test

Footnotes

  1. https://www.w3.org/TR/css-viewport-1/#the-viewport

@atbrakhi atbrakhi marked this pull request as ready for review October 21, 2025 07:56
@atbrakhi atbrakhi requested a review from mrobinson as a code owner October 21, 2025 07:56
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 21, 2025
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 21, 2025
@mrobinson mrobinson enabled auto-merge October 21, 2025 07:57
@atbrakhi atbrakhi disabled auto-merge October 21, 2025 08:00
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 21, 2025
@atbrakhi atbrakhi enabled auto-merge October 21, 2025 08:03
@shubhamg13
Copy link
Copy Markdown
Member

shubhamg13 commented Oct 21, 2025

Isn't it what I did here : #39067 ? @mrobinson

cc: @xiaochengh

@atbrakhi atbrakhi disabled auto-merge October 21, 2025 08:37
@mrobinson
Copy link
Copy Markdown
Member

Isn't it what I did here : #39067 ? @mrobinson

cc: @xiaochengh

I left a comment asking you to reopen the PR if it was still an issue (as the original bug was closed), but didn't see any activity. We were reading the specifications and stumbled on this issue independently. We'll add you as a co-author here.

The CSS specifications defines two viewports, the "layout viewport" and the
visual viewport. The layout viewport affects layout and the visual viewport is
the result of applying pinch zoom. This changes makes it so that the
initial-scale property of <meta type="viewport"> affects the layout viewport.

Co-authored-by: Shubham Gupta <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: atbrakhi <[email protected]>
@atbrakhi
Copy link
Copy Markdown
Member Author

@shubhamg13 i have added you as co-author, sorry for the confusion.

@atbrakhi atbrakhi enabled auto-merge October 21, 2025 08:50
@atbrakhi atbrakhi added this pull request to the merge queue Oct 21, 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 Oct 21, 2025
Merged via the queue into servo:main with commit 628ba51 Oct 21, 2025
30 checks passed
@atbrakhi atbrakhi deleted the viewport branch October 21, 2025 10:19
@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 Oct 21, 2025
pull Bot pushed a commit to Haofei/servo that referenced this pull request May 5, 2026
Fixup: servo#40055

Instead of applying initial scale to page. 
- An `initial-scale` should directly affect the `visualviewport.scale`as
it is layer that manages zoom factor
w3c/csswg-drafts#9004
- `initial-scale` should be considered with `device_pixel_ratio` while
calculating `layout_viewport` as per following spec gudelines.

Specs: https://www.w3.org/TR/css-viewport-1/#the-viewport

> This specification introduces a way of overriding the size of the
viewport provided by the user agent (UA). Because of this, we need to
introduce the difference between the initial viewport and the actual
viewport.
> 
> _initial viewport_
> This refers to the viewport before any UA or author styles have
overridden the viewport given by the window or viewing area of the UA.
Note that the initial viewport size will change with the size of the
window or viewing area.
> _actual viewport_
> This is the viewport you get after processing the viewport <meta> tag.


Sample Page:
[viewport_meta_with_style_2.html](https://github.com/user-attachments/files/26271786/viewport_meta_with_style_2.html)


Testing: `tests/webview.rs`: `test_viewport_meta_tag_initial_scale`

Fixes: servo#39002

---------

Signed-off-by: Shubham Gupta <[email protected]>
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

Development

Successfully merging this pull request may close these issues.

4 participants