]> git.parisson.com Git - pdf.js.git/commitdiff
use array index instead of array.shift()
authorAdil Allawi <adil@diwan.com>
Thu, 15 Dec 2011 10:08:50 +0000 (10:08 +0000)
committerAdil Allawi <adil@diwan.com>
Thu, 15 Dec 2011 10:08:50 +0000 (10:08 +0000)
src/canvas.js

index fbebc0aa22a97c420bb8ab748c224c69b0e6945d..38b33d19d8f7900e0b0da843f70784686e61a685 100644 (file)
@@ -328,11 +328,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
         return;
 
       var self = this;
+      var textDivIndex = 0;
       var renderTextLayer = function canvasRenderTextLayer() {
-        var finished = true;
+        var finished = false;
         var textDivs = self.textDivs;
-        if (textDivs.length > 0) {
-          var textDiv = textDivs.shift();
+        if (textDivIndex < textDivs.length) {
+          var textDiv = textDivs[textDivIndex++];
           if (textDiv.dataset.textLength > 1) { // avoid div by zero
             textLayer.appendChild(textDiv);
             // Adjust div width (via letterSpacing) to match canvas text
@@ -341,8 +342,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
               ((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
                (textDiv.dataset.textLength - 1)) + 'px';
           }
-          finished = false;
         }
+        else
+          finished = true;
         return finished;
       }
       var textLayerQueue = this.textLayerQueue;