[Pkg-javascript-commits] [pdf.js] 24/246: Added endPath, endText. fixes extra <g> elements

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:21 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 6e4dd83a4d1729bf0af0470d29746a12f6ece3b7
Author: pramodhkp <prmdh1 at gmail.com>
Date:   Fri Jul 25 17:59:10 2014 +0530

    Added endPath, endText. fixes extra <g> elements
---
 src/display/svg.js | 43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/display/svg.js b/src/display/svg.js
index b5878e1..6431ebf 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -192,7 +192,6 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
       this.tgrp = document.createElementNS(NS, 'svg:g');
       this.tgrp.setAttributeNS(null, 'transform',
         'matrix(' + this.transformMatrix + ')');
-      this.pgrp.appendChild(this.tgrp);
     },
 
     beginDrawing: function SVGGraphics_beginDrawing(viewport, pageNum,
@@ -266,7 +265,7 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
             this.showText(args[0]);
             break;
           case OPS.endText:
-            this.endText(args);
+            this.endText();
             break;
           case OPS.moveText:
             this.moveText(args[0], args[1]);
@@ -351,6 +350,9 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
           case OPS.constructPath:
             this.constructPath(args[0], args[1]);
             break;
+          case OPS.endPath:
+            this.endPath();
+            break;
           case 92:
             this.group(opTree[x].items);
             break;
@@ -477,7 +479,7 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
       this.tgrp.appendChild(current.txtElement);
 
     },
-    
+
     setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
       this.setLeading(-y);
       this.moveText(x, y);
@@ -515,7 +517,14 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
     },
 
     endText: function SVGGraphics_endText(args) {
-      // Empty for now. Not sure how to break showText into this.
+      if (this.current.pendingClip) {
+        this.pgrp.appendChild(this.cgrp);
+      } else {
+        this.pgrp.appendChild(this.tgrp);
+      }
+      this.tgrp = document.createElementNS(NS, 'svg:g');
+      this.tgrp.setAttributeNS(null, 'transform',
+         'matrix(' + this.transformMatrix + ')');
     },
 
     // Path properties
@@ -608,17 +617,33 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
       current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray);
       current.path.setAttributeNS(null, 'stroke-dashoffset',
         current.dashPhase + 'px');
+      current.path.setAttributeNS(null, 'fill', 'none');
+
+      this.tgrp.appendChild(current.path);
       if (current.pendingClip) {
         this.cgrp.appendChild(this.tgrp);
+        this.pgrp.appendChild(this.cgrp);
+      } else {
+        this.pgrp.appendChild(this.tgrp);
       }
-      current.path.setAttributeNS(null, 'fill', 'none');
-      this.tgrp.appendChild(current.path);
       // Saving a reference in current.element so that it can be addressed
       // in 'fill' and 'stroke'
       current.element = current.path;
       current.setCurrentPoint(x, y);
     },
 
+    endPath: function SVGGraphics_endPath() {
+      var current = this.current;
+      if (current.pendingClip) {
+        this.pgrp.appendChild(this.cgrp);
+      } else {
+        this.pgrp.appendChild(this.tgrp);
+      }
+      this.tgrp = document.createElementNS(NS, 'svg:g');
+      this.tgrp.setAttributeNS(null, 'transform',
+          'matrix(' + this.transformMatrix + ')');
+    },
+
     clip: function SVGGraphics_clip(type) {
       var current = this.current;
       // Add current path to clipping path
@@ -766,10 +791,14 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
        imgEl.setAttributeNS(null, 'y', -h);
        imgEl.setAttributeNS(null, 'transform', 'scale(' + 1 / w +
         ' ' + -1 / h + ')');
+
+       this.tgrp.appendChild(imgEl);
        if (current.pendingClip) {
         this.cgrp.appendChild(this.tgrp);
+        this.pgrp.appendChild(this.cgrp);
+       } else {
+        this.pgrp.appendChild(this.tgrp);
        }
-       this.tgrp.appendChild(imgEl);
     },
   };
   return SVGGraphics;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list