mediawiki-extensions-Cite/lib/ext
Arlo Breault 1855c046ac Add media info in a post-processing pass
The basic idea here is to generate the media structure in the token
stream using a stuffed span with a redlink, as in T169975, and
augmenting the nodes on the DOM once the media info has been fetched.

A redlink is justified as the canonical representation of the media
elements before info is fetched because it's the fallback if fetching
fails and the media type is unknown until the info is retrieved.

Most options are stored in data-mw until the media type is fetched and
it's determined that they're applicable.  This is a bit of a reversion
of how things were done before where inapplicable options were removed
post-facto.

For consistency and styling's sake, figcaptions are now always added to
block figures.

The pass has to be run before generating headings anchor, since that
depends on the text content (ie. redlinks).  This rearranges things in
the post-processor and adds another pass.

The post-processing pass to add media info is run on subpipelines as
well as the top level so that the media info is present in cases where
we embed HTML in data-mw (which is currently skipped by the top level
only passes, except for the cite extension, which has special handling,
see T214994) and to avoid an additional post-processing pass for the
gallery extension, which scales media of packed galleries.  This comes
at the cost of making additional queries for each pipeline and requires
the add media pass to be idempotent.

Filed T214241 for figuring out what to do about data-mw info being
clobbered by template annotations.

The newly failing blacklisted tests are from roundtripping media options
in galleries, which requires a general refactor for support.  See the
FIXMEs added there.

Performance should be expected to regress by the amount of work we're
able to overlap in the async phase of the pipeline while the media info
is being fetched.  Considering a lot of that work is caught up waiting
for the batch to return (other async requests are found in the same
batch), this doesn't turn out to be much in practice in the average
case.

Bug: T153080
Bug: T169975
Change-Id: I856ee962b70cef1f8d49652396ea5264e11a8ade
2019-02-01 13:30:07 -08:00
..
Cite Add media info in a post-processing pass 2019-02-01 13:30:07 -08:00