Resolve a percentage odf margin, and give AnchorType a neutral value - #882
Merged
Conversation
…al value **A percentage `fo:margin` was dropped.** [OpenDocument] 16.2 resolves it against the same property in the parent style, which is why LibreOffice writes `fo:margin="100%"` for "whatever the parent had". Passing it to css would be wrong twice over: css reads `%` there as the containing block's width. It is resolved now, as `fo:font-size` beside it already was. The corpus renders byte for byte as before, which is the point: every `100%` in it resolves to the parent value the drop used to leave standing. What changes is the case that was silently wrong - `50%` over a parent margin now halves it. **`AnchorType` had no neutral value**, so `Frame::anchor_type()` on a frame that does not exist answered `as_char`, which a real frame also answers. It gains `none` first, as `ShapeType` has. Every ordinal after it shifts by one; `enum_ordinals_test.cpp` and apple's `ODR_SAME_ENUM` pin both mirrors, and wasm does not bind this enum. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KKFKbUVCYF2VhujdmjhhPW
andiwand
force-pushed
the
feat/anchor-none-percent-margins
branch
from
September 10, 2026 17:40
002f677 to
31d93a2
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.
The two items #881 left open.
A percentage
fo:marginwas dropped[OpenDocument] 16.2 resolves a percentage against the same property in the
parent style — which is why LibreOffice writes
fo:margin="100%"to mean"whatever the parent had", alongside explicit
fo:margin-left="0cm".So my note on #881 was wrong: passing it to css would be wrong twice over,
because css reads
%there as the containing block's width. A table ofcontents would have got a margin the width of the page. It resolves against the
parent now, as
fo:font-sizebeside it already did —Style's constructorcopies the parent's resolved style in before
resolve_style_runs, so thevalue to scale is already there.
The corpus renders byte for byte as before, and that is the point: every
100%in it resolves to exactly the parent value the drop used to leavestanding. No reference regeneration needed. What changes is the case that was
silently wrong —
50%over a parent margin now halves it instead of inheritingthe parent's full value.
AnchorTypehad no neutral valueFrame::anchor_type()on a frame that does not exist answeredas_char, whicha real frame also answers, so a caller could not tell them apart. It gains
noneas its first value, the wayShapeTypehas one.Breaking: every ordinal after it shifts by one.
enum_ordinals_test.cpppins the C++ side, apple's
ODR_SAME_ENUMpins its mirror at compile time, andjni's
AnchorType.javaresolves byordinal(); wasm does not bind this enum.Appending would have been silent but reads wrong next to
ShapeType::none, anda major is where this belongs.
Checks run
C++ 1689 passed. Reference output byte-identical in both repos, from a fresh
full run in the test directory. python 81, jni junit, apple 40 XCTest. Both
touched TUs clean under
g++-15 -Wall -Wextra -Werror -fsyntax-only.