[Pkg-javascript-commits] [pdf.js] 59/414: Implement support for Squiggly annotations

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:05 UTC 2016


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

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

commit 34918a66663f0da452288e286de0dd5496b383e2
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Wed Dec 30 15:28:26 2015 +0100

    Implement support for Squiggly annotations
---
 src/core/annotation.js            |  19 +++++++++++++++++++
 src/display/annotation_layer.js   |  29 +++++++++++++++++++++++++++++
 test/pdfs/.gitignore              |   1 +
 test/pdfs/annotation-squiggly.pdf | Bin 0 -> 93644 bytes
 test/test_manifest.json           |   7 +++++++
 web/annotation_layer_builder.css  |   6 ++----
 6 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/src/core/annotation.js b/src/core/annotation.js
index 4180584..af7fbb7 100644
--- a/src/core/annotation.js
+++ b/src/core/annotation.js
@@ -99,6 +99,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
       case 'Underline':
         return new UnderlineAnnotation(parameters);
 
+      case 'Squiggly':
+        return new SquigglyAnnotation(parameters);
+
       case 'StrikeOut':
         return new StrikeOutAnnotation(parameters);
 
@@ -808,6 +811,22 @@ var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
   return UnderlineAnnotation;
 })();
 
+var SquigglyAnnotation = (function SquigglyAnnotationClosure() {
+  function SquigglyAnnotation(parameters) {
+    Annotation.call(this, parameters);
+
+    this.data.annotationType = AnnotationType.SQUIGGLY;
+    this.data.hasHtml = true;
+
+    // PDF viewers completely ignore any border styles.
+    this.data.borderStyle.setWidth(0);
+  }
+
+  Util.inherit(SquigglyAnnotation, Annotation, {});
+
+  return SquigglyAnnotation;
+})();
+
 var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
   function StrikeOutAnnotation(parameters) {
     Annotation.call(this, parameters);
diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js
index fc974f2..bd7ae50 100644
--- a/src/display/annotation_layer.js
+++ b/src/display/annotation_layer.js
@@ -75,6 +75,9 @@ AnnotationElementFactory.prototype =
       case AnnotationType.UNDERLINE:
         return new UnderlineAnnotationElement(parameters);
 
+      case AnnotationType.SQUIGGLY:
+        return new SquigglyAnnotationElement(parameters);
+
       case AnnotationType.STRIKEOUT:
         return new StrikeOutAnnotationElement(parameters);
 
@@ -635,6 +638,32 @@ var UnderlineAnnotationElement = (
 
 /**
  * @class
+ * @alias SquigglyAnnotationElement
+ */
+var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() {
+  function SquigglyAnnotationElement(parameters) {
+    AnnotationElement.call(this, parameters);
+  }
+
+  Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
+    /**
+     * Render the squiggly annotation's HTML element in the empty container.
+     *
+     * @public
+     * @memberof SquigglyAnnotationElement
+     * @returns {HTMLSectionElement}
+     */
+    render: function SquigglyAnnotationElement_render() {
+      this.container.className = 'squigglyAnnotation';
+      return this.container;
+    }
+  });
+
+  return SquigglyAnnotationElement;
+})();
+
+/**
+ * @class
  * @alias StrikeOutAnnotationElement
  */
 var StrikeOutAnnotationElement = (
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 252702f..e5a212c 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -203,3 +203,4 @@
 !annotation-text-without-popup.pdf
 !annotation-underline.pdf
 !annotation-strikeout.pdf
+!annotation-squiggly.pdf
diff --git a/test/pdfs/annotation-squiggly.pdf b/test/pdfs/annotation-squiggly.pdf
new file mode 100644
index 0000000..3265570
Binary files /dev/null and b/test/pdfs/annotation-squiggly.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 6a0c9fc..63d537d 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -2660,6 +2660,13 @@
        "type": "eq",
        "annotations": true
     },
+    {  "id": "annotation-squiggly",
+       "file": "pdfs/annotation-squiggly.pdf",
+       "md5": "38661e731ac6c525af5894d2d20c6e71",
+       "rounds": 1,
+       "type": "eq",
+       "annotations": true
+    },
     {  "id": "issue6108",
        "file": "pdfs/issue6108.pdf",
        "md5": "8961cb55149495989a80bf0487e0f076",
diff --git a/web/annotation_layer_builder.css b/web/annotation_layer_builder.css
index b48e4c6..5d5afdf 100644
--- a/web/annotation_layer_builder.css
+++ b/web/annotation_layer_builder.css
@@ -69,10 +69,8 @@
   padding-top: 0.2em;
 }
 
-.annotationLayer .underlineAnnotation {
-  cursor: pointer;
-}
-
+.annotationLayer .underlineAnnotation,
+.annotationLayer .squigglyAnnotation,
 .annotationLayer .strikeoutAnnotation {
   cursor: pointer;
 }

-- 
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