Repository navigation
Lay web pages out at their own size, and let pages fill the player - #56
Merged
Merged
Conversation
A web asset's width and height are now the CSS pixel size the page is laid out at, whatever the player's size and the screen's density. The page's viewport tag is set to that width at document start and the WebView is fitted to the player as the asset's fit says, with its background colour around it. Drops setInitialScale(100), left over from a viewport injection that no longer exists. It drew one CSS pixel per screen pixel, so on a screen with a density above 1 a responsive page filled only part of the player.
Owner
Author
|
Tested in rotated players on the TV. At 90 degrees a page with no size lays out at 541x961 and fills the portrait player; the 1920x1080 page at 90 and 270 degrees is contained with bars above and below, and covers correctly. At 180 and 270 degrees Chromium reports visualViewport.height as 0, with or without this change (also with setInitialScale(100) restored), so that comes from the rotated container, not from this PR. |
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.
A page lays out at the player's size in CSS pixels, which is the player's pixels divided by the screen density. On the test TVs (1280x720 UI, density 1.33) that is 961x541, so a dashboard designed for 1920x1080 wraps or shows its mobile layout.
A web asset's
widthandheight, ignored for pages until now, are now the CSS pixel size the page lays out at. The library sets the page's viewport tag to that width at document start, in the top frame only, and keeps it there if the page changes it. With wide viewport and overview mode WebView zooms the page to the view, and the view is sized as the asset'sfitsays, withbackgroundColoraround it. Stretch lays the page out at the contained size and scales it, since a page can't be laid out distorted. The page still draws at the player's own resolution. On WebView older than 87 the width is set when the page first paints.This also drops
setInitialScale(100), left over from a viewport injection that no longer exists. It drew one CSS pixel per screen pixel, so on a screen with a density above 1 a responsive page filled only part of the player: three quarters of the width on the test TVs. Pages without a size now fill the player, which changes how every page looks on such screens.The sample app gets
web_viewport_check, a page that prints the viewport it was laid out at and draws a 1920x1080 frame, the same page asweb_viewport_1920with a size, and aviewportplaylist.Checked on both TVs: the 1920 page lays out at 1920x1080 (the visual viewport is 1920.00 x 1080.00;
clientHeightrounds to 1079) with its frame on the screen edges. Two players side by side showed Contain, Cover, Stretch and Original correctly. A recording alternating the page and a video had no black frame at any cut, cold start time is unchanged, and Wikipedia and BBC News now fill the screen.