SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.54k stars 3.19k forks source link

LibWeb: incorrect figcaption placement #13610

Open Seirdy opened 2 years ago

Seirdy commented 2 years ago

Test site: https://seirdy.one/2020/11/23/website-best-practices.html Mirror with compatible cipher suites: https://envs.net/~seirdy/2020/11/23/website-best-practices.html

Several <blockquote> elements on that page are enclosed by <figure> elements, with <figcaption> elements at the bottom of the figures containing attribution:

<figure>
  <blockquote>
    There is only one honest measure of web performance: the time from when you click a link to when you’ve finished skipping the last ad.
  </blockquote>
  <figcaption>
    — Maciej Cegłowski, The Website Obesity Crisis
  </figcaption>
</figure>

However, the SerenityOS browser tends to render figures with the caption at the top of the figure:

SerenityOS Browser screenshot showing blockquotes with attribution above the quotes

This doesn't seem to happen for all figures, only the ones with short captions.

Source order, DOM order, and display order should generally match unless CSS alters the display order (bad practice but valid) or JS alters the display or DOM order.

krkk commented 2 years ago

looks like this has been fixed in https://github.com/SerenityOS/serenity/commit/d27136fcb07cac8573cd2d2a1f070ad02dcfcf58

this added a display: block rule to the <figure> element. It was inlined before, which confused our browser, because in the example above the blockquote was a block inside an inlined element.

however, the core issue of block elements inside inlined ones messing up the order still exist – <span>aaa <div>div</div> bbb</span> displays like aaa bbb\ndiv.