1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 22:07:35 +00:00

LibWeb: Support <svg> elements with display: block

There are a couple of things that went into this:

- We now calculate the intrinsic width/height and aspect ratio of <svg>
  elements based on the spec algorithm instead of our previous ad-hoc
  guesswork solution.

- Replaced elements with automatic size and intrinsic aspect ratio but
  no intrinsic dimensions are now sized with the stretch-fit width
  formula.

- We take care to assign both used width and used height to <svg>
  elements before running their SVG formatting contexts. This ensures
  that the inside SVG content is laid out with knowledge of its
  viewport geometry.

- We avoid infinite recursion in tentative_height_for_replaced_element()
  by using the already-calculated used width instead of calling the
  function that calculates the used width (since that may call us right
  back again).
This commit is contained in:
Andreas Kling 2023-05-19 18:14:37 +02:00
parent 28d2e26678
commit f0560fd087
11 changed files with 107 additions and 74 deletions

View file

@ -0,0 +1,7 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x170 [BFC] children: not-inline
BlockContainer <body> at (8,8) content-size 784x154 children: not-inline
SVGSVGBox <svg> at (9,9) content-size 100x50 [SVG] children: not-inline
SVGGeometryBox <rect> at (21.5,21.5) content-size 75x25 children: not-inline
SVGSVGBox <svg> at (9,61) content-size 200x100 [SVG] children: not-inline
SVGGeometryBox <rect> at (34,86) content-size 150x50 children: not-inline