Resolve page size using standard length utils. (#46163)
Calculating the page area size is very similar to how the content box
size of a regular non-replaced CSS box is calculated.
content box + padding + border + margin = size of containing block
The only differences:
-
percentage-based padding/margins in a given dimension are resolved
against the containing block size in that dimension (i.e. a
percentage-based margin-top is resolved against the containing block
height), not unconditionally against the inline-size of the containing
block (regular CSS boxes) -
Overconstrainedness is resolved differently. Rather than adjusting
margins to fix the equation, the containing block size is adjusted.
Auto @page margins are also handled correctly now. Tests included.
Clean up pagination stuff in Document, and move the logic of
GetPageDescription() into pagination utils in layout, and only call it
from external APIs (we used to need it during layout as well, but not
anymore). The end goal here is to be able to implement this by examining
the physical fragments, but we're not quite there yet, since Blink still
doesn't control the margin area of the page.
Improve detection of unusable page sizes (if margins+border+padding are
larger than the containing block). We'll now recalculate computed style
for such page containers, and just ignore all author styles.
Bug: 40286153
Change-Id: Id660b7e60d71256f32cb56db1cf419ad8ac91c2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5522379
Reviewed-by: Ian Kilpatrick ikilpatrick@chromium.org
Commit-Queue: Morten Stenshorne mstensho@chromium.org
Cr-Commit-Position: refs/heads/main@{#1299921}
Co-authored-by: Morten Stenshorne mstensho@chromium.org