Repository navigation
Inherit from the parent element's computed values in the standard CSS mode - #683
Merged
Merged
Conversation
jakejackson1
pushed a commit
that referenced
this pull request
Oct 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
… mode Under the standard cssMode every element inherits from its parent's computed values, as in a browser. Each frame on the stack of open elements holds its element's computed values of the inherited properties: font-size made absolute, font-weight a number, a line-height length or percentage made a length, and every other em, ex, ch or rem length made absolute. Blocks, tables, row groups, rows, cells, nested tables and positioned blocks all start from their parent's frame, which replaces the saved text state, base_table_properties, the row and row group merges and the properties put on a positioned block's stand-in div. The frames also carry the link and the decorations an element's content is drawn in. The legacy cascade is unchanged. The letter and word spacing of the text state live in TextSpacing, and the font autoLangToFont chooses for a language in Mpdf::fontForLanguage(), which setCSS(), Table and the computed values share. Fixes #547. Part of #520. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
jakejackson1
force-pushed
the
feature/547-computed-values
branch
from
October 6, 2026 01:24
a3e044b to
a42c233
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 26 of #520. Under the standard
cssMode, every element now inherits from its parent's computed values, as in a browser. The legacy cascade is unchanged.What was wrong
mPDF passed inherited values along several separate channels:
base_table_propertiesandPARENTCELL, to a table's cells;WriteFixedPosHTML()puts on the<div>that stands in for a positioned block.Each channel carried its own set of properties in its own form. So:
emlength was read again at the child's size. Withletter-spacing: 0.1emon a 20pt block, a 10pt paragraph inside it spaced its letters 1pt apart, not 2pt.inheriton a length had the same problem.line-height: normalas the number 1.33. That content was drawn with different spacing from the rest of the document.The change
inherit,initial,unsetandrevert#546) apply.ComputedValues::compute()then turns the result into computed values:font-sizebecomes absolute, through the size converter's existingconvertFontSize();font-weightbecomes a number;line-heightlength or percentage becomes a length, and a number ornormalstays as written;em/ex/ch/remlength becomes the absolute length.inheriton a property that is not inherited reads the same frame, so a row written straight into a table reads the implied tbody's values.text-decorationis inherited instead of propagated #544) that an element's content is drawn in.Css\TextSpacing, whichrestoreInlineProperties()andprintbuffer()both use. The fontautoLangToFontchooses for a language isMpdf::fontForLanguage(), shared bysetCSS(), the table handler and the computed values. The thead and tfoot handlers shareTag::keepLegacyRowGroupFont().Behaviour changes, standard mode only
em/ex/ch/remlength is inherited as the length it came to, andinherittakes that length.line-height: normalthe same way the flow does. Before, it was a fixed 1.33, which with DejaVu Sans or Times sets lines slightly further apart. To keep the old spacing, addline-height: 1.33to the positioned block.The changelog entry is under Breaking Changes, next to #543 and #544.
Snapshots
line-height: 1.33on their positioned blocks.css-wide-keywords,inherited-channelsandunicode-zero-width-space. Text moves by hundredths of a point becauseemlengths are now computed once on the parent, and one font is renumbered.TableInheritsFromBlockTestno longer special-cases a table in a positioned block. That table now drawsnormal.Tests
InheritanceMatrixTest: the matrix from Inherit from the parent element's computed values under the opt-in cascade #547, run under both cascades, through the sharedDrawnStylestrait.ComputedValueInheritanceTest:emlengths andinherit;OpenElementStackTest: what a frame carries.TextSpacingTest: the spacing helper.computed-valuesandcomputed-values-brochure-{standard,legacy}.Found along the way
letter-spacing: normalon an inline element is ignored when its text starts a block. That is pre-existing, in both modes, and is #684.Gates
composer cs: clean.php -lon PHP 5.6: clean.Fixes #547. Part of #520.
🤖 Generated with Claude Code