Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor frame metadata into tags #4212

Merged
merged 2 commits into from
May 22, 2024
Merged

Refactor frame metadata into tags #4212

merged 2 commits into from
May 22, 2024

Conversation

laurmaedje
Copy link
Member

@laurmaedje laurmaedje commented May 21, 2024

This replaces the MetaElem with a new TagElem that fills a similar role, but works a bit differently. The purpose of both is to hold elements that will become available through introspection. However, the MetaElem did this via the style chain, by attaching a style to the full subtree of content resulting from a locatable element, which resulted in lots of redundant FrameItem::Meta(Meta::Elem(_), ..) in the frames.

The new TagElem is generated exactly once per locatable element and holds the element directly. The challenge here is that the tag still needs to stick to the element so that if e.g. a heading moves to another page, the page number in the outline is still correct. To that extent, the flow layouter has gained a new pending_tags array and the tags are only flushed into the frames when something proper is layouted. Overall, the new mechanism is much more efficient. The old thing was actually so bad that the famous thesis benchmark improves by ~14% with this PR.

The old FrameItem::Meta was also used for hiding and links. These usages have been replaced by a completely internal mechanism for hiding and a new top-level FrameItem::Link for links.

This PR is only a first small step in an incremental refactor of realization and flow layout. The TagElem and pending_tags aren't necessarily the best way to implement tags in realization and layout, rather they are the least intrusive ones in the current setup. Things will change further as the refactoring progresses. The exact semantics of how tags will stick to elements are also still somewhat in-flux and will likely a change a bit in later refactor phases. These rules affect the results of .page() and .position() calls on locations. With this PR, things should mostly be the same as on main, though there will be edge cases where things changed a bit. They might change again with further refactoring.

@laurmaedje laurmaedje added this pull request to the merge queue May 22, 2024
@laurmaedje laurmaedje removed this pull request from the merge queue due to a manual request May 22, 2024
@laurmaedje laurmaedje enabled auto-merge May 22, 2024 09:25
@laurmaedje laurmaedje added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit a52987a May 22, 2024
12 checks passed
@laurmaedje laurmaedje deleted the tags branch May 22, 2024 09:35
@MDLC01 MDLC01 mentioned this pull request May 22, 2024
PgBiel added a commit to tulio240/typst that referenced this pull request May 30, 2024
Refactor frame metadata into tags (typst#4212)


Require `Send` and `Sync` for worlds (typst#4219)


Optimize counters and state (typst#4223)


Add `windows` method to array (typst#4136)

Improve `CITATION.cff` file (typst#4201)


Fix equation resizing when adding the equation number (typst#4179)


`layout` documentation improvements (typst#4196)

Allow somewhat arbitrary characters as `mat`, `vec` and `cases` `delim` (typst#4211)


Do layout short-circuit in flow instead of realization (typst#4231)


Split `BitSet` into two types and make it a bit nicer (typst#4249)


Set default value of `raw.theme` to `auto`, and allow setting `raw.theme` to `auto` (typst#4186)


Extended cargo installation instructions (typst#4168)

Hint for language-region pair on `text.lang` (typst#4183)


Improve macro docs (+ Native*Data docs) (typst#4240)


Rephrase the sentence on variable scope in Scripting documentation (typst#4250)


Refactor `Capable::vtable` to return `Option<NonNull<()>>` (typst#4252)


Nicer test helper CSS (typst#4269)


Trim weak spacing at line start/end in paragraph layout (typst#4087)


Add ability to choose between minified and pretty-printed JSON (typst#4161)


Refactor PDF export (typst#4154)

Reorder syntax kinds (typst#4287)


Fix figure centering (typst#4276)

Fix `Default` impls for AST nodes (typst#4288)


Bump libc to v0.2.155 (typst#4268)


Bump time dependency (typst#4294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant