jenkins-bot has submitted this change and it was merged.

Change subject: Renamed function name & reorder args for clarity + added docs.
......................................................................


Renamed function name & reorder args for clarity + added docs.

* Renamed buildDOMFragmentForTokenStream --> buildDOMFragmentTokens
  and made env. the first arg.

* Added documentation to buildDOMFragmentTokens and encapsulateHTML

Change-Id: I7eccfd3f4dc5b4b91d20d1d24d98ec514df6dfbc
---
M lib/ext.Cite.js
M lib/ext.core.DOMFragmentBuilder.js
M lib/ext.core.TemplateHandler.js
M lib/mediawiki.DOMUtils.js
4 files changed, 65 insertions(+), 6 deletions(-)

Approvals:
  GWicke: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 2b7c560..6c5f004 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -304,10 +304,10 @@
 
                cb({
                        async: false,
-                       tokens: DU.buildDOMFragmentForTokenStream(
+                       tokens: DU.buildDOMFragmentTokens(
+                               manager.env,
                                refsTok,
                                olHTML,
-                               manager.env,
                                olProcessor,
                                // The <ol> HTML above is just skeleton HTML 
from a string.
                                // So, it doesn't have any DSR on it. We want 
DSR added to it.
diff --git a/lib/ext.core.DOMFragmentBuilder.js 
b/lib/ext.core.DOMFragmentBuilder.js
index a1f13d1..6db5fab 100644
--- a/lib/ext.core.DOMFragmentBuilder.js
+++ b/lib/ext.core.DOMFragmentBuilder.js
@@ -93,7 +93,7 @@
 };
 
 DOMFragmentBuilder.prototype.wrapDOMFragment = function(cb, scopeToken, dom) {
-       var toks = DU.buildDOMFragmentForTokenStream(scopeToken, dom, 
this.manager.env);
+       var toks = DU.buildDOMFragmentTokens(this.manager.env, scopeToken, dom);
 
        // Nothing more to send cb after this
        cb({tokens: toks, async:false});
diff --git a/lib/ext.core.TemplateHandler.js b/lib/ext.core.TemplateHandler.js
index da9b2c8..0b37bda 100644
--- a/lib/ext.core.TemplateHandler.js
+++ b/lib/ext.core.TemplateHandler.js
@@ -727,10 +727,10 @@
                ));
        };
 
-       var toks = DU.buildDOMFragmentForTokenStream(
+       var toks = DU.buildDOMFragmentTokens(
+               this.manager.env,
                state.token,
                doc,
-               this.manager.env,
                addWrapperAttrs,
                { isForeignContent: true }
        );
diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index 183362d..94f3866 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -1441,6 +1441,49 @@
 
        },
 
+       /**
+        * Generates wrapper tokens for a HTML expansion -- the wrapper
+        * tokens are placeholders that adequately represent semantics
+        * of the HTML DOM for the purposes of additional token transformations
+        * that will be applied to them.
+        *
+        * @param {Object} env
+        *    The active environment/context.
+        *
+        * @param {Object} token
+        *    The token that generated the DOM.
+        *
+        * @param {Object} expansion
+        *    expansion.html  -- HTML of the expansion
+        *    expansion.nodes -- outermost nodes of the HTML
+        *
+        * @param {Object} addAttrsCB
+        *    Callback that adds additional attributes to the generated tokens.
+        *
+        * @param {Object} opts
+        *    aboutId   : The about-id to set on the generated tokens.
+        *
+        *    noAboutId : If true, an about-id will not be added to the tokens
+        *                if an aboutId is not provided.
+        *                Ex: <figure>
+        *
+        *    tsr       : The TSR to set on the generated tokens. This TSR is
+        *                used to compute DSR on the placeholder tokens.
+        *                The computed DSR is transferred over to the unpacked 
DOM
+        *                if setDSR is true (see below).
+        *
+        *    setDSR    : When the DOM-fragment is unpacked, this option governs
+        *                whether the DSR from the placeholder node is 
transferred
+        *                over to the unpacked DOM or not.
+        *                Ex: Cite, reused transclusions
+        *
+        *    isForeignContent :
+        *                Does the DOM come from outside the main page? This 
governs
+        *                how the encapsulation ids are assigned to the 
unpacked DOM.
+        *                Ex: transclusions, extensions -- all siblings get the 
same
+        *                about id. This is not true for <figure> HTML.
+        *
+        */
        encapsulateExpansionHTML: function(env, token, expansion, opts) {
                opts = opts || {};
 
@@ -1501,8 +1544,24 @@
         *
         * The DOMPostProcessor will unpack the fragment and insert the HTML
         * back into the DOM.
+        *
+        * @param {Object} env
+        *    The active environment/context.
+        *
+        * @param {Object} token
+        *    The token that generated the DOM.
+        *
+        * @param {Object} docOrHTML
+        *    The DOM (or HTML string) that the token expanded to.
+        *
+        * @param {Object} addAttrsCB
+        *    Callback that adds additional attributes to the generated tokens.
+        *
+        * @param {Object} opts
+        *    Options to be passed onto the encapsulation code
+        *    See encapsulateExpansionHTML's doc. for more info about these 
options.
         */
-       buildDOMFragmentForTokenStream: function(token, docOrHTML, env, 
addAttrsCB, opts) {
+       buildDOMFragmentTokens: function(env, token, docOrHTML, addAttrsCB, 
opts) {
                var doc = docOrHTML.constructor === String ? 
this.parseHTML(docOrHTML) : docOrHTML;
                var nodes = doc.body.childNodes;
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7eccfd3f4dc5b4b91d20d1d24d98ec514df6dfbc
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Marcoil <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to