-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Support cross references by target-counter()/target-counters() #248
Merged
Conversation
This file contains 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
- `target-counter()`/`target-counters()` support for counters on elements, i.e., defined by `counter-reset`/`counter-increment` specified on elements. - Page-based counters are not yet taken into account in this implementation. - `attr()` function cannot be used inside `target-counter()`/`target-counters()` yet. - If target element is in a source document other than the current one (on which `target-counter()`/`target-counters()` is specified), the target counter cannot be retrieved and fallback to 0.
…/`target-counters()` function
…vliostyle.counters.CounterStore` - `adapt.csscasc.PageCounterResolver` interface has been removed. Its methods are merged into `adapt.csscasc.CounterResolver`. - `vivliostyle.page.PageCounterStore` class has bee removed. Its functionalities are merged into `vivliostyle.counters.CounterStore`.
…ounters - Only effective for a target ID such that the corresponding element is already laid out before the referring pseudoelement (i.e. the pseudoelement on which `target-counter()`/`target-counters()` is specified)
…a separate method
…the target element is laid out - Added `vivliostyle.counters.TargetCounterReference` class. If no element-based counter id defined on the element specified by ID in `target-counter()` and the element has not been laid out yet, a `TargetCounterReference` object is saved in `CounterStore`. - When finishing layout of a page, elements with IDs and unresolved references that appeared on the page are collected. After that, it is deteremined that whether any unresolved references appeared so far can be resolved by the elements with IDs in the page. If there are any, each page containing such references are re-laid out, calling `renderSinglePage` method recursively. - Note that in this commit only a single page is re-laid out at a time, i.e., even if the end position of the page is changed as a result of the re-layout, the next page is not re-laid out. - TODO: take unresolved element-based (non page-based) counters into account (when the referenced element is in another source document in EPUB) - TODO: support `target-counters()` too. - TODO: control visibility of the re-laid out page appropriately.
If an element with an ID does not fit in a page, the view node is removed and deferred to the next page. However, the ID and the element are registered to an `adapt.vtree.Page` object during creation of the view node and the regitration has not been removed even if the element does not fit in the page. This has been causing incorrect page references. In this commit, the registered IDs are checked after layout of the page. If the page container does not contain an element (elements) corresponding to a registered ID, the registration of the ID is removed.
…y resolutions of cross references
…e document in the EPUB
… source document in EPUB and does not have a fragment
… before the reference
… before the reference
…s reference resolution
…s reference resolution *only if the next page has been already laid out*
…rence resolution If a reference target is allowed to go back to a page earlier than one on which it was placed previously, reference resolution can lead to an infinite loop. To avoid infinite loops, a reference target is allowed to go to a page later than one on which it was placed previously, but it is not allowed to go back to an earlier page. If the target can fit in an earlier page, a page break is inserted just before the target and the target is laid out on the page on which it was placed previously. To represent the influence reference resolution has on layout, `adapt.layout.LayoutConstraint` interface is introduced. `allowLayout` method of `LayoutConstraint` receives a `NodeContext` and returns whether it can be laid out at the current position. In this case, a `NodeContext` is not allowed to be laid out at the current position if the page index of the current position is earlier than the index of the page on which the target was placed previously.
…when it has been moved to another page
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.
Spec: CSS Generated Content Module Level 3 - Cross references and the target-* functions