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

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:06 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 6ef7120a0454ed766821a8649920edcf3e367f59
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Fri Jan 1 15:31:46 2016 +0100

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

diff --git a/src/core/annotation.js b/src/core/annotation.js
index af7fbb7..1efabe4 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 'Highlight':
+        return new HighlightAnnotation(parameters);
+
       case 'Underline':
         return new UnderlineAnnotation(parameters);
 
@@ -795,6 +798,22 @@ var PopupAnnotation = (function PopupAnnotationClosure() {
   return PopupAnnotation;
 })();
 
+var HighlightAnnotation = (function HighlightAnnotationClosure() {
+  function HighlightAnnotation(parameters) {
+    Annotation.call(this, parameters);
+
+    this.data.annotationType = AnnotationType.HIGHLIGHT;
+    this.data.hasHtml = true;
+
+    // PDF viewers completely ignore any border styles.
+    this.data.borderStyle.setWidth(0);
+  }
+
+  Util.inherit(HighlightAnnotation, Annotation, {});
+
+  return HighlightAnnotation;
+})();
+
 var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
   function UnderlineAnnotation(parameters) {
     Annotation.call(this, parameters);
diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js
index bd7ae50..196a0e3 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.HIGHLIGHT:
+        return new HighlightAnnotationElement(parameters);
+
       case AnnotationType.UNDERLINE:
         return new UnderlineAnnotationElement(parameters);
 
@@ -611,6 +614,33 @@ var PopupElement = (function PopupElementClosure() {
 
 /**
  * @class
+ * @alias HighlightAnnotationElement
+ */
+var HighlightAnnotationElement = (
+    function HighlightAnnotationElementClosure() {
+  function HighlightAnnotationElement(parameters) {
+    AnnotationElement.call(this, parameters);
+  }
+
+  Util.inherit(HighlightAnnotationElement, AnnotationElement, {
+    /**
+     * Render the highlight annotation's HTML element in the empty container.
+     *
+     * @public
+     * @memberof HighlightAnnotationElement
+     * @returns {HTMLSectionElement}
+     */
+    render: function HighlightAnnotationElement_render() {
+      this.container.className = 'highlightAnnotation';
+      return this.container;
+    }
+  });
+
+  return HighlightAnnotationElement;
+})();
+
+/**
+ * @class
  * @alias UnderlineAnnotationElement
  */
 var UnderlineAnnotationElement = (
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index e5a212c..6237b25 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -204,3 +204,4 @@
 !annotation-underline.pdf
 !annotation-strikeout.pdf
 !annotation-squiggly.pdf
+!annotation-highlight.pdf
diff --git a/test/pdfs/annotation-highlight.pdf b/test/pdfs/annotation-highlight.pdf
new file mode 100644
index 0000000..ab2ef6e
Binary files /dev/null and b/test/pdfs/annotation-highlight.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 63d537d..cbd1300 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -2667,6 +2667,13 @@
        "type": "eq",
        "annotations": true
     },
+    {  "id": "annotation-highlight",
+       "file": "pdfs/annotation-highlight.pdf",
+       "md5": "e13e198e3a69c32dc9ebdc704d3105e1",
+       "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 5d5afdf..3c6b4e4 100644
--- a/web/annotation_layer_builder.css
+++ b/web/annotation_layer_builder.css
@@ -69,6 +69,7 @@
   padding-top: 0.2em;
 }
 
+.annotationLayer .highlightAnnotation,
 .annotationLayer .underlineAnnotation,
 .annotationLayer .squigglyAnnotation,
 .annotationLayer .strikeoutAnnotation {

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