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

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:03 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 cd28dd34fe733a123443de96a2f7130b512fe70e
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Mon Dec 28 00:33:41 2015 +0100

    Implement support for Underline annotations
---
 src/core/annotation.js             |  19 +++++++++++++++++++
 src/display/annotation_layer.js    |  30 ++++++++++++++++++++++++++++++
 test/pdfs/.gitignore               |   1 +
 test/pdfs/annotation-underline.pdf | Bin 0 -> 92151 bytes
 test/test_manifest.json            |   7 +++++++
 web/annotation_layer_builder.css   |   4 ++++
 6 files changed, 61 insertions(+)

diff --git a/src/core/annotation.js b/src/core/annotation.js
index 7c94100..e33573c 100644
--- a/src/core/annotation.js
+++ b/src/core/annotation.js
@@ -96,6 +96,9 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
       case 'Popup':
         return new PopupAnnotation(parameters);
 
+      case 'Underline':
+        return new UnderlineAnnotation(parameters);
+
       default:
         warn('Unimplemented annotation type "' + subtype + '", ' +
              'falling back to base annotation');
@@ -786,6 +789,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
   return PopupAnnotation;
 })();
 
+var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
+  function UnderlineAnnotation(parameters) {
+    Annotation.call(this, parameters);
+
+    this.data.annotationType = AnnotationType.UNDERLINE;
+    this.data.hasHtml = true;
+
+    // PDF viewers completely ignore any border styles.
+    this.data.borderStyle.setWidth(0);
+  }
+
+  Util.inherit(UnderlineAnnotation, Annotation, {});
+
+  return UnderlineAnnotation;
+})();
+
 exports.Annotation = Annotation;
 exports.AnnotationBorderStyle = AnnotationBorderStyle;
 exports.AnnotationFactory = AnnotationFactory;
diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js
index 07d2003..2fe96b3 100644
--- a/src/display/annotation_layer.js
+++ b/src/display/annotation_layer.js
@@ -72,6 +72,9 @@ AnnotationElementFactory.prototype =
       case AnnotationType.POPUP:
         return new PopupAnnotationElement(parameters);
 
+      case AnnotationType.UNDERLINE:
+        return new UnderlineAnnotationElement(parameters);
+
       default:
         throw new Error('Unimplemented annotation type "' + subtype + '"');
     }
@@ -594,6 +597,33 @@ var PopupElement = (function PopupElementClosure() {
 })();
 
 /**
+ * @class
+ * @alias UnderlineAnnotationElement
+ */
+var UnderlineAnnotationElement = (
+    function UnderlineAnnotationElementClosure() {
+  function UnderlineAnnotationElement(parameters) {
+    AnnotationElement.call(this, parameters);
+  }
+
+  Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
+    /**
+     * Render the underline annotation's HTML element in the empty container.
+     *
+     * @public
+     * @memberof UnderlineAnnotationElement
+     * @returns {HTMLSectionElement}
+     */
+    render: function UnderlineAnnotationElement_render() {
+      this.container.className = 'underlineAnnotation';
+      return this.container;
+    }
+  });
+
+  return UnderlineAnnotationElement;
+})();
+
+/**
  * @typedef {Object} AnnotationLayerParameters
  * @property {PageViewport} viewport
  * @property {HTMLDivElement} div
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index d3a7680..09a811a 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -200,3 +200,4 @@
 !openoffice.pdf
 !annotation-link-text-popup.pdf
 !annotation-text-without-popup.pdf
+!annotation-underline.pdf
diff --git a/test/pdfs/annotation-underline.pdf b/test/pdfs/annotation-underline.pdf
new file mode 100644
index 0000000..8bc4c95
Binary files /dev/null and b/test/pdfs/annotation-underline.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 92d433d..ee01079 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -2631,6 +2631,13 @@
        "annotations": true,
        "about": "Text annotation without a separate Popup annotation"
     },
+    {  "id": "annotation-underline",
+       "file": "pdfs/annotation-underline.pdf",
+       "md5": "c24b3aba771de52f9bac25e854c39458",
+       "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 4e041f5..a2fe4e7 100644
--- a/web/annotation_layer_builder.css
+++ b/web/annotation_layer_builder.css
@@ -68,3 +68,7 @@
 .annotationLayer .popup p {
   padding-top: 0.2em;
 }
+
+.annotationLayer .underlineAnnotation {
+  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