You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5f7821c
Browse filesBrowse the repository at this point in the historyBrowse files
Let a table inside an inline element inherit its style, as a block does
Under the standard cssMode, a table opened inside open inline elements, as in
<span class="note">…<table>…</table>…</span>, sets their state aside on the
enclosing block as #653 does for a block, so it inherits their colour, font,
size and weight, and a relative font size on it is taken of theirs. The text
after the table is drawn in their style again until their end tags. A table
nested in a cell keeps the cell's open inline elements, so an end tag after it
restores what was before. Legacy is unchanged.
The set-aside and put-back helpers move from BlockTag to Tag, and the put-back
restores the block's own state when nothing was set aside, reading it through
InheritedProperties::blockTextState().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG-GRAVITYPDF.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,7 @@ Read this section before upgrading from upstream mPDF. Each entry says what chan
62
62
*`revert` and `revert-layer` give the value of the built-in defaults and the default stylesheet, such as a heading's size, a list's margin or a cell's padding, and are `unset` where those give none. An HTML attribute such as `cellpadding` counts as an author rule, so `revert` goes past it too.
63
63
* A shorthand passes the keyword to each of its longhands, so `border: inherit` takes every side's width, style and colour, and `font: initial` resets the size, family, style, weight, line height and variants.
64
64
***A table inherits from the block around it**, as in a browser, under the standard `cssMode`. It used to start from the document's defaults, so `<div style="color: red; font-family: monospace">` around a table left its cells black and in the body's font. Now a table takes every inherited property from the block, list item, header or positioned block it is in, and a nested table takes its cell's `text-align` and `line-height` too. [#543][#656]
65
+
* A table inside an inline element, as in `<span class="note">…<table>…</table>…</span>`, takes the element's style, as a block does since [#653]. The text after the table, up to the element's end tag, is drawn in that style again. Before, it lost it, and in a table cell the style ran on past the end tag.
65
66
*`table { font-size: 80% }` is taken of the block's size, not the document's.
66
67
* The built-in default style no longer gives a table `hyphens: manual` and `font-kerning: auto`, which a browser's does not, so a table inherits them. It keeps the table's `line-height: 1.2` where the block's is `normal`, as tables have always been drawn.
67
68
* A `th` in a table in a right-aligned block is aligned right, since it inherits an alignment.
Copy file name to clipboardExpand all lines: src/Tag/Tag.php
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -318,4 +318,50 @@ abstract public function open($attr, &$ahtml, &$ihtml);
318
318
319
319
abstractpublicfunctionclose(&$ahtml, &$ihtml);
320
320
321
+
/**
322
+
* Sets aside the inline elements a block or table opens inside, under CssMode::STANDARD: their saved states and the
323
+
* text state they set go on the enclosing block. The block or table inherits that text state, and
324
+
* restoreBlockTextState() puts both back when it closes, so the text after it is drawn in their style and their end tags restore what was there before them.
325
+
*
326
+
* A block opened a second time, as a kept block laid out again or a block reopened after a forced page break, finds
327
+
* them already set aside and keeps them, as by then the text state has changed
328
+
*/
329
+
protectedfunctionsetOpenInlineElementsAside()
330
+
{
331
+
$block = &$this->mpdf->blk[$this->mpdf->blklvl];
332
+
333
+
if (!isset($block['openInline']) && array_filter($this->mpdf->InlineProperties)) {
334
+
$block['openInline'] = [
335
+
'properties' => $this->mpdf->InlineProperties,
336
+
'state' => $this->mpdf->saveInlineProperties(),
337
+
];
338
+
339
+
// The line before the block or table is printed next, and its text with no colour or link of its own is drawn in the
Copy file name to clipboardExpand all lines: tests/Mpdf/TableInheritsFromBlockTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -146,6 +146,7 @@ public function fontSizes()
146
146
'ems of the block' => ['<div style="font-size: 20pt"><table style="font-size: 1.5em"><tr><td>qq</td></tr></table></div>', 30.0, 16.5],
147
147
'a percentage of the list item' => ['<ul><li style="font-size: 20pt"><table style="font-size: 50%"><tr><td>qq</td></tr></table></li></ul>', 10.0, 5.5],
148
148
'a percentage of the cell' => ['<table><tr><td style="font-size: 20pt"><table style="font-size: 50%"><tr><td>qq</td></tr></table></td></tr></table>', 10.0, 5.5],
149
+
'a percentage of a span' => ['<span style="font-size: 20pt">zz<table style="font-size: 50%"><tr><td>qq</td></tr></table></span>', 10.0, 5.5],
149
150
'the block\'s size, inherited' => ['<div style="font-size: 20pt"><table><tr><td>qq</td></tr></table></div>', 20.0, 11.0],
150
151
'rem in a cell of a sized table' => ['<table style="font-size: 20pt"><tr><td style="font-size: 1.5rem">qq</td></tr></table>', 16.5, 30.0],
151
152
'rem in a table in a sized block' => ['<div style="font-size: 20pt"><table><tr><td style="font-size: 1rem">qq</td></tr></table></div>', 11.0, 11.0],
0 commit comments