r63796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63795‎ | r63796 | r63797 >
Date:01:53, 16 March 2010
Author:nimishg
Status:ok
Tags:
Comment:
undoes most of r63579, slows down template parsing considerably but stops the issue of dirty diffs on page load
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -73,7 +73,7 @@
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ),
7575 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 27 ),
7676 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 172 ),
77 - array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 43 ),
 77+ array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 44 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 52 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 21 ),
8080 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 97 ),
@@ -82,10 +82,10 @@
8383 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 3 ),
8484 ),
8585 'combined' => array(
86 - array( 'src' => 'js/plugins.combined.js', 'version' => 341 ),
 86+ array( 'src' => 'js/plugins.combined.js', 'version' => 342 ),
8787 ),
8888 'minified' => array(
89 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 341 ),
 89+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 342 ),
9090 ),
9191 ),
9292 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.highlight.js
@@ -202,40 +202,10 @@
203203 // Split off the prefix
204204 // This leaves the prefix in the current node and puts
205205 // the rest in a new node which is our start node
206 - var newStartNode = startNode.splitText( s.offset < s.node.nodeValue.length ?
 206+ startNode = startNode.splitText( s.offset < s.node.nodeValue.length ?
207207 s.offset : s.node.nodeValue.length - 1
208208 );
209 - var oldStartNode = startNode;
210 - startNode = newStartNode;
211 -
212 - // Update offset objects. We don't need purgeOffsets(), simply
213 - // manipulating the existing offset objects will suffice
214 - // FIXME: This manipulates context.offsets directly, which is ugly,
215 - // but the performance improvement vs. purgeOffsets() is worth it
216 - // This code doesn't set lastTextNode to newStartNode for offset objects
217 - // with lastTextNode == oldStartNode, but that doesn't really matter
218 - var subtracted = s.offset;
219 - var oldLength = s.length;
220 -
221 - var j, o;
222 - // Update offset objects referring to oldStartNode
223 - for ( j = start - subtracted; j < start; j++ ) {
224 - if ( j in context.offsets ) {
225 - o = context.offsets[j];
226 - o.node = oldStartNode;
227 - o.length = subtracted;
228 - }
229 - }
230 - // Update offset objects referring to newStartNode
231 - for ( j = start; j < start - subtracted + oldLength; j++ ) {
232 - if ( j in context.offsets ) {
233 - o = context.offsets[j];
234 - o.node = newStartNode;
235 - o.offset -= subtracted;
236 - o.length -= subtracted;
237 - o.lastTextNode = oldStartNode;
238 - }
239 - }
 209+ context.fn.purgeOffsets();
240210 }
241211
242212 var end = markers[i].end;
@@ -249,32 +219,10 @@
250220 var endNode = e.node;
251221 if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) {
252222 // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode
253 - var newEndNode = endNode;
254 - var oldEndNode = endNode.splitText( e.offset + 1 );
 223+ var endNode = endNode.splitText( e.offset + 1 );
255224
256225 // Update offset objects
257 - var subtracted = e.offset + 1;
258 - var oldLength = e.length;
259 -
260 -
261 - var j, o;
262 - // Update offset objects referring to oldEndNode
263 - for ( j = end - subtracted; j < end; j++ ) {
264 - if ( j in context.offsets ) {
265 - o = context.offsets[j];
266 - o.node = oldEndNode;
267 - o.length = subtracted;
268 - }
269 - }
270 - for ( j = end; j < end - subtracted + oldLength; j++ ) {
271 - if ( j in context.offsets ) {
272 - o = context.offsets[j];
273 - o.node = newEndNode;
274 - o.offset -= subtracted;
275 - o.length -= subtracted;
276 - o.lastTextNode = oldEndNode;
277 - }
278 - }
 226+ context.fn.purgeOffsets();
279227 }
280228
281229 // Don't wrap trailing BRs, doing that causes weird issues
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -8736,40 +8736,10 @@
87378737 // Split off the prefix
87388738 // This leaves the prefix in the current node and puts
87398739 // the rest in a new node which is our start node
8740 - var newStartNode = startNode.splitText( s.offset < s.node.nodeValue.length ?
 8740+ startNode = startNode.splitText( s.offset < s.node.nodeValue.length ?
87418741 s.offset : s.node.nodeValue.length - 1
87428742 );
8743 - var oldStartNode = startNode;
8744 - startNode = newStartNode;
8745 -
8746 - // Update offset objects. We don't need purgeOffsets(), simply
8747 - // manipulating the existing offset objects will suffice
8748 - // FIXME: This manipulates context.offsets directly, which is ugly,
8749 - // but the performance improvement vs. purgeOffsets() is worth it
8750 - // This code doesn't set lastTextNode to newStartNode for offset objects
8751 - // with lastTextNode == oldStartNode, but that doesn't really matter
8752 - var subtracted = s.offset;
8753 - var oldLength = s.length;
8754 -
8755 - var j, o;
8756 - // Update offset objects referring to oldStartNode
8757 - for ( j = start - subtracted; j < start; j++ ) {
8758 - if ( j in context.offsets ) {
8759 - o = context.offsets[j];
8760 - o.node = oldStartNode;
8761 - o.length = subtracted;
8762 - }
8763 - }
8764 - // Update offset objects referring to newStartNode
8765 - for ( j = start; j < start - subtracted + oldLength; j++ ) {
8766 - if ( j in context.offsets ) {
8767 - o = context.offsets[j];
8768 - o.node = newStartNode;
8769 - o.offset -= subtracted;
8770 - o.length -= subtracted;
8771 - o.lastTextNode = oldStartNode;
8772 - }
8773 - }
 8743+ context.fn.purgeOffsets();
87748744 }
87758745
87768746 var end = markers[i].end;
@@ -8783,32 +8753,10 @@
87848754 var endNode = e.node;
87858755 if ( e.offset + 1 < e.length - 1 && endNode.nodeName == '#text' ) {
87868756 // Split off the suffix. This puts the suffix in a new node and leaves the rest in endNode
8787 - var newEndNode = endNode;
8788 - var oldEndNode = endNode.splitText( e.offset + 1 );
 8757+ var endNode = endNode.splitText( e.offset + 1 );
87898758
87908759 // Update offset objects
8791 - var subtracted = e.offset + 1;
8792 - var oldLength = e.length;
8793 -
8794 -
8795 - var j, o;
8796 - // Update offset objects referring to oldEndNode
8797 - for ( j = end - subtracted; j < end; j++ ) {
8798 - if ( j in context.offsets ) {
8799 - o = context.offsets[j];
8800 - o.node = oldEndNode;
8801 - o.length = subtracted;
8802 - }
8803 - }
8804 - for ( j = end; j < end - subtracted + oldLength; j++ ) {
8805 - if ( j in context.offsets ) {
8806 - o = context.offsets[j];
8807 - o.node = newEndNode;
8808 - o.offset -= subtracted;
8809 - o.length -= subtracted;
8810 - o.lastTextNode = oldEndNode;
8811 - }
8812 - }
 8760+ context.fn.purgeOffsets();
88138761 }
88148762
88158763 // Don't wrap trailing BRs, doing that causes weird issues
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -593,11 +593,9 @@
594594 context.modules.highlight.markersStr=markersStr;var oldStarts=[];if(!context.modules.highlight.markersOldStarts){context.modules.highlight.markersOldStarts=[];}
595595 var visited=[],v=0;for(var i=0;i<markers.length;i++){var start=markers[i].start;var s=context.fn.getOffset(start);if(!s){continue;}
596596 var startNode=s.node;while(startNode.nodeName=='BR'||s.offset==startNode.nodeValue.length){start++;s=context.fn.getOffset(start);startNode=s.node;}
597 -if(s.offset>0&&s.node.nodeName=='#text'){var newStartNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);var oldStartNode=startNode;startNode=newStartNode;var subtracted=s.offset;var oldLength=s.length;var j,o;for(j=start-subtracted;j<start;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldStartNode;o.length=subtracted;}}
598 -for(j=start;j<start-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newStartNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldStartNode;}}}
 597+if(s.offset>0&&s.node.nodeName=='#text'){startNode=startNode.splitText(s.offset<s.node.nodeValue.length?s.offset:s.node.nodeValue.length-1);context.fn.purgeOffsets();}
599598 var end=markers[i].end;var e=context.fn.getOffset(end-1);if(!e){continue;}
600 -var endNode=e.node;if(e.offset+1<e.length-1&&endNode.nodeName=='#text'){var newEndNode=endNode;var oldEndNode=endNode.splitText(e.offset+1);var subtracted=e.offset+1;var oldLength=e.length;var j,o;for(j=end-subtracted;j<end;j++){if(j in context.offsets){o=context.offsets[j];o.node=oldEndNode;o.length=subtracted;}}
601 -for(j=end;j<end-subtracted+oldLength;j++){if(j in context.offsets){o=context.offsets[j];o.node=newEndNode;o.offset-=subtracted;o.length-=subtracted;o.lastTextNode=oldEndNode;}}}
 599+var endNode=e.node;if(e.offset+1<e.length-1&&endNode.nodeName=='#text'){var endNode=endNode.splitText(e.offset+1);context.fn.purgeOffsets();}
602600 if(endNode.nodeName=='BR'){endNode=e.lastTextNode;}
603601 if(startNode.parentNode!=endNode.parentNode){var startP=$(startNode).closest('p').get(0);var t=new context.fn.rawTraverser(startNode,startP,context.$content.get(0),false);var afterStart=startNode.nextSibling;var lastP=startP;var nextT=t.next();while(nextT&&t.node!=endNode){t=nextT;nextT=t.next();if(t.node.parentNode!=startNode.parentNode){var oldParent=t.node.parentNode;if(afterStart){if(lastP!=t.inP){startNode.parentNode.insertBefore(startNode.ownerDocument.createElement('br'),afterStart);}
604602 if(!(oldParent.childNodes.length==1&&oldParent.firstChild.nodeName=='BR')){while(oldParent.firstChild){startNode.parentNode.insertBefore(oldParent.firstChild,afterStart);}}}else{if(lastP!=t.inP){startNode.parentNode.appendChild(startNode.ownerDocument.createElement('br'));}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r63579UsabilityInitiative: Some performance improvements for the highlighter...catrope22:04, 10 March 2010

Status & tagging log