Arlolra has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/381497 )
Change subject: T96923: Remove further access to src when not in selserMode
......................................................................
T96923: Remove further access to src when not in selserMode
Change-Id: I00680855219fccc7f37df6e4127f474b6cced32f
---
M lib/html2wt/separators.js
1 file changed, 8 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/97/381497/1
diff --git a/lib/html2wt/separators.js b/lib/html2wt/separators.js
index 098ce94..5d82287 100644
--- a/lib/html2wt/separators.js
+++ b/lib/html2wt/separators.js
@@ -489,13 +489,11 @@
var buildSep = function(node) {
var state = this.state;
var origNode = node;
- var src = state.env.page.src;
var prevNode = state.sep.lastSourceNode;
var sep, dsrA, dsrB;
/*
----------------------------------------------------------------------
* Assuming we have access to the original source, we can use it only
if:
- * - If we are in rt-testing mode (NO edits in that scenario) OR
* - If we are in selser mode AND
* . this node is not part of a subtree that has been marked
'modified'
* (massively edited, either in actuality or because DOMDiff is not
smart enough).
@@ -506,12 +504,12 @@
* may not reflect deleted content between them.
*
---------------------------------------------------------------------- */
var origSepUsable = node && prevNode && node !== prevNode &&
- src && (state.rtTestMode ||
- (state.selserMode && !state.inModifiedContent &&
+ state.selserMode && !state.inModifiedContent &&
!DU.nextToDeletedBlockNodeInWT(state.env, prevNode,
true) &&
!DU.nextToDeletedBlockNodeInWT(state.env, node, false)
&&
WTSUtils.origSrcValidInEditedContext(state.env,
prevNode) &&
- WTSUtils.origSrcValidInEditedContext(state.env, node)));
+ WTSUtils.origSrcValidInEditedContext(state.env, node);
+
if (origSepUsable) {
if (!DU.isElt(prevNode)) {
// Check if this is the last child of a zero-width
element, and use
@@ -529,10 +527,7 @@
// Should be fixed.
DU.getDataParsoid(prevNode.previousSibling).dsr &&
// Don't extrapolate if the string was
potentially changed
- // or we didn't diff (selser disabled)
- (state.rtTestMode || // no changes in
rt testing
- // diffed and no change here
- (state.selserMode &&
!DU.directChildrenChanged(node.parentNode, this.env)))
+
!DU.directChildrenChanged(node.parentNode, this.env)
) {
var endDsr =
DU.getDataParsoid(prevNode.previousSibling).dsr[1];
var correction;
@@ -608,19 +603,19 @@
sep = '';
} else if (dsrA[2] !== null) {
// B in A, from parent to child
- sep = src.substring(dsrA[0] +
dsrA[2], dsrB[0]);
+ sep = state.getOrigSrc(dsrA[0]
+ dsrA[2], dsrB[0]);
}
} else if (dsrA[1] <= dsrB[0]) {
// B following A (siblingish)
- sep = src.substring(dsrA[1], dsrB[0]);
+ sep = state.getOrigSrc(dsrA[1],
dsrB[0]);
} else if (dsrB[3] !== null) {
// A in B, from child to parent
- sep = src.substring(dsrA[1], dsrB[1] -
dsrB[3]);
+ sep = state.getOrigSrc(dsrA[1], dsrB[1]
- dsrB[3]);
}
} else if (dsrA[1] <= dsrB[1]) {
if (dsrB[3] !== null) {
// A in B, from child to parent
- sep = src.substring(dsrA[1], dsrB[1] -
dsrB[3]);
+ sep = state.getOrigSrc(dsrA[1], dsrB[1]
- dsrB[3]);
}
} else {
this.env.log("info/html2wt", "dsr backwards:
should not happen!");
--
To view, visit https://gerrit.wikimedia.org/r/381497
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I00680855219fccc7f37df6e4127f474b6cced32f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits