Commit graph

5 commits

Author SHA1 Message Date
Subramanya Sastry f3da8462dd DOMUtils: Get rid of isElt, isText, isComment helpers
* Most of these are remnants from the Parsoid/JS codebase.
* This change follows the pattern we've been using everywhere
  since the port from JS->PHP.
* Also reduces instruction count by about 0.2%.

Change-Id: Ibf21104f6722c34299f03e303dc3401bf053a751
2021-09-20 22:39:38 +00:00
C. Scott Ananian 9fc6abf7ce Add class alias file to allow swapping in Dodo for DOMDocument
Change-Id: I56c10d2f4283e9e7b57bf722208fefab007cdf45
2021-07-23 12:20:06 -04:00
Arlo Breault f22474a3f6 One document to rule them all
The description in T179082 suggests that by using one document for the
entire parse, we'd probably see some performance gains from not having
to import nodes when we get to the top level pipeline and we'd avoid the
validation errors from 19a9c3c.

However, the spec seems to suggest creating a new document when parsing
an HTML fragment,
https://html.spec.whatwg.org/#html-fragment-parsing-algorithm

And, indeed, domino implements it that way,
12a5f67136/lib/htmlelts.js (L84-L96)

So, the request in T217705 may be a little misguided.

What then is this patch good for?  In T221790 the ask is that
sub-pipelines produce DocumentFragment which make for cleaner interfaces
and less confusion when migrating children.

The general outline here is that a document is created when the
environment is constructed that gives us the 1-1 correspondence.
Sub-pipelines do create their own documents for the purpose of tree
building, as in the fragment parsing algorithm, but are then immediately
imported to DocumentFragments to be used for the rest of the
post-processing passes.

Bug: T221790
Bug: T179082
Bug: T217705
Change-Id: Idf856d4e071d742ca38486c8ab402e39b3c8949f
2020-09-29 22:36:33 +00:00
C. Scott Ananian 8a2414e881 Use DOMUtils::hasTypeOf/matchTypeOf/addTypeOf consistently
The `typeof` attribute is a space-separated list.  Use consistent methods
to test for membership in that list.

Try to set a good example by using ::addTypeOf() in general to set the
value of the 'typeof' attribute, except when we are transferring values
from one node to another.

Move the *TypeOf method to DOMUtils from DOMDataUtils, eliminating some
duplication.  Create Wikimedia\Parsoid\Ext\DOMUtils so that extensions
can use these methods as well.

Change-Id: Ib2ef827ef1cf5e31a1ef0a5034cdd3d9a0212bdb
2020-05-26 23:57:18 -04:00
C. Scott Ananian 4f16aee1b5 All extension DOM processors should extend Ext\DOMProcessor
Change-Id: Ide9700747b3ecea9da59911c6eb342569be4c9b8
2020-05-03 21:15:41 +00:00