Add TextAlign::WebkitCenter variant that centers both inline text and block-level children narrower than their container. The UA stylesheet now uses -webkit-center for <center>, matching real browser behavior where block children (like tables) are centered, not just inline text. The core mechanism is a post-layout shift in layout_block_children_vertical that repositions block children by (container_width - child_width) / 2. The shift_subtree_x helper recursively adjusts content origins, inline line boxes/fragments, and collapsed border segments. Guards prevent double-centering (auto-margin children), shifting table internals, and incorrectly shifting absolutely/fixed-positioned descendants. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 lines
123 B
HTML
4 lines
123 B
HTML
<center style="width: 400px">
|
|
<div style="width: 200px; height: 50px; background: red;">Centered block</div>
|
|
</center>
|