Printing: Move page size calculation to Blink.

This is in preparation for mixed page sizes support (which will be added
in an upcoming CL).

We need to set the correct size for each individual page during layout.
Remove the concept of "*the* page size", since each page can have its
own size. Note, however, that we still need a uniform page size to use
as the initial containing block, which is used to resolve viewport
units, among other things. The spec defines the initial containing block
as the page area size of the first page:
https://www.w3.org/TR/css-page-3/#page-model

As a result of this change, some cleanup in PrintRenderFrameHelper
should be possible (in future CLs). For one, we no longer need to lay
out everything twice, since we lay out with the correct page sizes in
the first layout pass (rather than first using printer defaults, then
read out sizes and pargins specified in @page rules, and then lay out
again with the correct sizes). It should also be possible to untangle
some margin logic in PrintRenderFrameHelper, since Blink now only
applies CSS-specified margins when it should (e.g. not if the user has
chosen their own margins in the print preview UI). Furthermore, there
are redundant fields in WebPrintParams. We no longer need to store a
page size or content area size (since we're providing a
WebPrintPageDescription now).

PrintContext no longer stores a vector of page rectangles. They will
instead be calculated when needed. We only used the rectangles when
printing with Blink, whereas ChromePluginPrintContext was forced to
populate a page_rects_ vector, just so that we could return the correct
number of pages. Since the code for calculating the page rectangles has
been rewritten, especially when it comes to how additional pages caused
by monolithic content is calculated, I added a web test for that, since
it turned out that we didn't have a good test for that particular case.

No behavior changes intended.

Bug: 835358
Change-Id: Ic669071b3e0ac729a467321720e25d6101e7b13f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4725066
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1177868}
2 files changed
tree: 51d48acce8fd503a29b4792219cd499928a7f060
  1. .github/
  2. .well-known/
  3. accelerometer/
  4. accessibility/
  5. accname/
  6. acid/
  7. ambient-light/
  8. animation-worklet/
  9. annotation-model/
  10. annotation-protocol/
  11. annotation-vocab/
  12. apng/
  13. appmanifest/
  14. attribution-reporting/
  15. audio-output/
  16. autoplay-policy-detection/
  17. avif/
  18. background-fetch/
  19. background-sync/
  20. badging/
  21. battery-status/
  22. beacon/
  23. bluetooth/
  24. browsing-topics/
  25. captured-mouse-events/
  26. clear-site-data/
  27. client-hints/
  28. clipboard-apis/
  29. close-watcher/
  30. common/
  31. compat/
  32. compression/
  33. compute-pressure/
  34. conformance-checkers/
  35. console/
  36. contacts/
  37. content-dpr/
  38. content-index/
  39. content-security-policy/
  40. contenteditable/
  41. cookie-store/
  42. cookies/
  43. core-aam/
  44. cors/
  45. credential-management/
  46. css/
  47. custom-elements/
  48. custom-state-pseudo-class/
  49. delegated-ink/
  50. density-size-correction/
  51. deprecation-reporting/
  52. device-memory/
  53. direct-sockets/
  54. docs/
  55. document-picture-in-picture/
  56. document-policy/
  57. dom/
  58. domparsing/
  59. domxpath/
  60. dpub-aam/
  61. dpub-aria/
  62. ecmascript/
  63. editing/
  64. element-timing/
  65. encoding/
  66. encoding-detection/
  67. encrypted-media/
  68. entries-api/
  69. event-timing/
  70. eventsource/
  71. eyedropper/
  72. feature-policy/
  73. fenced-frame/
  74. fetch/
  75. file-system-access/
  76. FileAPI/
  77. fledge/
  78. focus/
  79. font-access/
  80. fonts/
  81. forced-colors-mode/
  82. fs/
  83. fullscreen/
  84. gamepad/
  85. generic-sensor/
  86. geolocation-API/
  87. geolocation-sensor/
  88. graphics-aam/
  89. graphics-aria/
  90. gyroscope/
  91. hr-time/
  92. html/
  93. html-aam/
  94. html-longdesc/
  95. html-media-capture/
  96. https-upgrades/
  97. idle-detection/
  98. imagebitmap-renderingcontext/
  99. images/
  100. import-maps/
  101. IndexedDB/
  102. inert/
  103. infrastructure/
  104. input-device-capabilities/
  105. input-events/
  106. installedapp/
  107. interfaces/
  108. intersection-observer/
  109. intervention-reporting/
  110. is-input-pending/
  111. js/
  112. js-self-profiling/
  113. keyboard-lock/
  114. keyboard-map/
  115. largest-contentful-paint/
  116. layout-instability/
  117. lifecycle/
  118. loading/
  119. long-animation-frame/
  120. longtask-timing/
  121. magnetometer/
  122. managed/
  123. mathml/
  124. measure-memory/
  125. media/
  126. media-capabilities/
  127. media-playback-quality/
  128. media-source/
  129. mediacapture-extensions/
  130. mediacapture-fromelement/
  131. mediacapture-handle/
  132. mediacapture-image/
  133. mediacapture-insertable-streams/
  134. mediacapture-record/
  135. mediacapture-region/
  136. mediacapture-streams/
  137. mediasession/
  138. merchant-validation/
  139. mimesniff/
  140. mixed-content/
  141. mst-content-hint/
  142. navigation-api/
  143. navigation-timing/
  144. netinfo/
  145. network-error-logging/
  146. notifications/
  147. old-tests/
  148. orientation-event/
  149. orientation-sensor/
  150. page-lifecycle/
  151. page-visibility/
  152. paint-timing/
  153. parakeet/
  154. payment-handler/
  155. payment-method-basic-card/
  156. payment-method-id/
  157. payment-request/
  158. pending-beacon/
  159. performance-timeline/
  160. periodic-background-sync/
  161. permissions/
  162. permissions-policy/
  163. permissions-request/
  164. permissions-revoke/
  165. picture-in-picture/
  166. png/
  167. pointerevents/
  168. pointerlock/
  169. portals/
  170. preload/
  171. presentation-api/
  172. private-aggregation/
  173. private-click-measurement/
  174. proximity/
  175. push-api/
  176. quirks/
  177. referrer-policy/
  178. remote-playback/
  179. reporting/
  180. requestidlecallback/
  181. resize-observer/
  182. resource-timing/
  183. resources/
  184. sanitizer-api/
  185. savedata/
  186. scheduler/
  187. screen-capture/
  188. screen-details/
  189. screen-orientation/
  190. screen-wake-lock/
  191. scroll-animations/
  192. scroll-to-text-fragment/
  193. secure-contexts/
  194. secure-payment-confirmation/
  195. selection/
  196. serial/
  197. server-timing/
  198. service-workers/
  199. shadow-dom/
  200. shape-detection/
  201. shared-storage/
  202. shared-storage-selecturl-limit/
  203. signed-exchange/
  204. soft-navigation-heuristics/
  205. speculation-rules/
  206. speech-api/
  207. storage/
  208. storage-access-api/
  209. streams/
  210. subapps/
  211. subresource-integrity/
  212. svg/
  213. svg-aam/
  214. timing-entrytypes-registry/
  215. tools/
  216. top-level-storage-access-api/
  217. touch-events/
  218. trust-tokens/
  219. trusted-types/
  220. ua-client-hints/
  221. uievents/
  222. upgrade-insecure-requests/
  223. url/
  224. urlpattern/
  225. user-timing/
  226. vibration/
  227. video-rvfc/
  228. virtual-keyboard/
  229. visual-viewport/
  230. wai-aria/
  231. wasm/
  232. web-animations/
  233. web-bundle/
  234. web-locks/
  235. web-nfc/
  236. web-otp/
  237. web-share/
  238. webaudio/
  239. webauthn/
  240. webcodecs/
  241. WebCryptoAPI/
  242. webdriver/
  243. webgl/
  244. webgpu/
  245. webhid/
  246. webidl/
  247. webmessaging/
  248. webmidi/
  249. webnn/
  250. webrtc/
  251. webrtc-encoded-transform/
  252. webrtc-extensions/
  253. webrtc-ice/
  254. webrtc-identity/
  255. webrtc-priority/
  256. webrtc-stats/
  257. webrtc-svc/
  258. websockets/
  259. webstorage/
  260. webtransport/
  261. webusb/
  262. webvr/
  263. webvtt/
  264. webxr/
  265. window-management/
  266. workers/
  267. worklets/
  268. x-frame-options/
  269. xhr/
  270. .azure-pipelines.yml
  271. .gitattributes
  272. .gitignore
  273. .mailmap
  274. .taskcluster.yml
  275. CODE_OF_CONDUCT.md
  276. CODEOWNERS
  277. CONTRIBUTING.md
  278. LICENSE.md
  279. lint.ignore
  280. README.md
  281. wpt
  282. wpt.py
README.md

The web-platform-tests Project

Taskcluster CI Status documentation manifest Python 3

The web-platform-tests Project is a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.

The most important sources of information and activity are:

  • github.com/web-platform-tests/wpt: the canonical location of the project's source code revision history and the discussion forum for changes to the code
  • web-platform-tests.org: the documentation website; details how to set up the project, how to write tests, how to give and receive peer review, how to serve as an administrator, and more
  • wpt.live: a public deployment of the test suite, allowing anyone to run the tests by visiting from an Internet-enabled browser of their choice
  • wpt.fyi: an archive of test results collected from an array of web browsers on a regular basis
  • Real-time chat room: the wpt:matrix.org matrix channel; includes participants located around the world, but busiest during the European working day.
  • Mailing list: a public and low-traffic discussion list
  • RFCs: a repo for requesting comments on substantial changes that would impact other stakeholders or users; people who work on WPT infra are encouraged to watch the repo.

If you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.

Setting Up the Repo

Clone or otherwise get https://github.com/web-platform-tests/wpt.

Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune (or git fetch -p && git merge).

Running the Tests

See the documentation website and in particular the system setup for running tests locally.

Command Line Tools

The wpt command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:

  • wpt serve - For starting the wpt http server
  • wpt run - For running tests in a browser
  • wpt lint - For running the lint against all tests
  • wpt manifest - For updating or generating a MANIFEST.json test manifest
  • wpt install - For installing the latest release of a browser or webdriver server on the local machine.
  • wpt serve-wave - For starting the wpt http server and the WAVE test runner. For more details on how to use the WAVE test runner see the documentation.

Windows Notes

On Windows wpt commands must be prefixed with python or the path to the python binary (if python is not in your %PATH%).

python wpt [command]

Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt commands.

Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false in your working tree.

Publication

The master branch is automatically synced to wpt.live and w3c-test.org.

Contributing

Save the Web, Write Some Tests!

Absolutely everyone is welcome to contribute to test development. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.

The way to contribute is just as usual:

  • Fork this repository (and make sure you're still relatively in sync with it if you forked a while ago).
  • Create a branch for your changes: git checkout -b topic.
  • Make your changes.
  • Run ./wpt lint as described above.
  • Commit locally and push that to your repo.
  • Create a pull request based on the above.

Issues with web-platform-tests

If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!