A form XObject with a /StructParents entry has its own marked content ids,
referenced from the struct tree with a MCR having a /Stm entry: this is what
Chrome generates when printing a tagged page.
So the text layer could contain the same id several times, and the struct
tree didn't reference any content because only the page /StructParents was
used to look into the parent tree.
Now ids of marked content in such XObjects are prefixed by the XObject ref,
and the XObjects /StructParents are used when parsing the page struct tree.
Since the resources can be shared between pages, only the parents having
some content on the current page are added.
When saving, a new annotation can now be anchored to some content in a form
XObject: its parent is found in the XObject parent array.
Preserve `RowSpan`, `ColSpan`, `Headers`, `Scope`, `Short` and `Summary`
when serializing the structure tree, and map them to the corresponding
ARIA attributes in the viewer.
The attributes are now collected from both the `A` and the `C` entries,
which may be arrays interleaving dictionaries and revision numbers: this
also fixes the bounding box and the MS Office MathML lookups, which only
handled a single direct dictionary.
Fixes#18090.
This commit fixes a number of missing cleanup steps in the unit tests
that kept state alive for longer than necessary:
- the loading tasks were not all being destroyed;
- the find controllers were not being reset;
- the state set in `beforeAll`/`beforeEach` was not all being nulled in
the correspoding `afterAll`/`afterEach` blocks.
Combined this resulted in a steady increase in memory usage of the test
process as the tests ran, climbing up to ~1.5 GB. After this patch the
memory usage remains stable at ~800 MB.
It'll help to make math equations "visible" for screen readers.
MS Office has a specific way to add some MathML code to struc tree leaf
and this patch handles it.
The idea is to insert a span in the text layer with an aria-role set to img
and use the bounding box provided by the attribute field in the tag dict in
order to have non-null dimensions for the image to make it "visible".
When a PDF is "marked" we now generate a separate DOM that represents
the structure tree from the PDF. This DOM is inserted into the <canvas>
element and allows screen readers to walk the tree and have more
information about headings, images, links, etc. To link the structure
tree DOM (which is empty) to the text layer aria-owns is used. This
required modifying the text layer creation so that marked items are
now tracked.