MarkTraceur has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/57444


Change subject: Try to speed up and chunk the DOM passes
......................................................................

Try to speed up and chunk the DOM passes

Change-Id: I17ae140e53c1aefd14a3d46292fd5af50ba11598
---
M js/lib/mediawiki.DOMPostProcessor.js
1 file changed, 10 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/44/57444/1

diff --git a/js/lib/mediawiki.DOMPostProcessor.js 
b/js/lib/mediawiki.DOMPostProcessor.js
index 1698a3b..530770d 100644
--- a/js/lib/mediawiki.DOMPostProcessor.js
+++ b/js/lib/mediawiki.DOMPostProcessor.js
@@ -404,7 +404,7 @@
  *   means the outermost table will protected).  This is no different from
  *   how it handles all other templates.
  * ------------------------------------------------------------------------ */
-function handleUnbalancedTableTags(node, env, tplIdToSkip) {
+function handleUnbalancedTableTags(node, env, options, tplIdToSkip) {
        function foundMatch(currTpl, nodeName) {
                // Did we hit a table (table/th/td/tr/tbody/th) tag
                // that is outside a template?
@@ -502,7 +502,7 @@
                        }
                } else if (c.nodeType === Node.ELEMENT_NODE) {
                        // Look at c's subtree
-                       handleUnbalancedTableTags(c, env, tplIdToSkip);
+                       handleUnbalancedTableTags(c, env, options, tplIdToSkip);
                }
 
                c = c.previousSibling;
@@ -770,17 +770,13 @@
 // This will move the start-meta closest to the content
 // that the template/extension produced and improve accuracy
 // of finding dom ranges and wrapping templates.
-function migrateStartMetas( node, env ) {
-       var c = node.firstChild;
-       while (c) {
-               var sibling = c.nextSibling;
-               if (c.childNodes.length > 0) {
-                       migrateStartMetas(c, env);
-               }
-               c = sibling;
+function migrateStartMetas( lastChild ) {
+       var node = lastChild.parentNode;
+
+       if ( lastChild !== node.lastChild ) {
+               return;
        }
 
-       var lastChild = node.lastChild;
        if (lastChild && DU.isTplStartMarkerMeta(lastChild)) {
                // console.warn("migration: " + lastChild.innerHTML);
 
@@ -2399,12 +2395,14 @@
        // DOM traverser that runs before the in-order DOM handlers.
        var firstDOMHandlerPass = new DOMTraverser();
        firstDOMHandlerPass.addHandler( null, migrateDataParsoid );
+       firstDOMHandlerPass.addHandler( 'meta', migrateStartMetas );
 
        // Common post processing
        this.processors = [
                firstDOMHandlerPass.traverse.bind( firstDOMHandlerPass ),
                handleUnbalancedTableTags,
-               migrateStartMetas,
+               // TODO: Rewrite normalizeDocument to act on nodes, not on the 
whole tree,
+               // and put it inside a traverser
                normalizeDocument,
                findBuilderCorrectedTags,
                handlePres,

-- 
To view, visit https://gerrit.wikimedia.org/r/57444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I17ae140e53c1aefd14a3d46292fd5af50ba11598
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to