[Pkg-javascript-commits] [pdf.js] 48/414: Implement support for StrikeOut annotations
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:12:04 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 c5f4b9750e4641184216216fd19155f8d7f5e5a2
Author: Tim van der Meij <timvandermeij at gmail.com>
Date: Tue Dec 29 15:09:28 2015 +0100
Implement support for StrikeOut annotations
---
src/core/annotation.js | 19 +++++++++++++++++++
src/display/annotation_layer.js | 30 ++++++++++++++++++++++++++++++
test/pdfs/.gitignore | 1 +
test/pdfs/annotation-strikeout.pdf | Bin 0 -> 91804 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 e33573c..4180584 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 'StrikeOut':
+ return new StrikeOutAnnotation(parameters);
+
default:
warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation');
@@ -805,6 +808,22 @@ var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
return UnderlineAnnotation;
})();
+var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
+ function StrikeOutAnnotation(parameters) {
+ Annotation.call(this, parameters);
+
+ this.data.annotationType = AnnotationType.STRIKEOUT;
+ this.data.hasHtml = true;
+
+ // PDF viewers completely ignore any border styles.
+ this.data.borderStyle.setWidth(0);
+ }
+
+ Util.inherit(StrikeOutAnnotation, Annotation, {});
+
+ return StrikeOutAnnotation;
+})();
+
exports.Annotation = Annotation;
exports.AnnotationBorderStyle = AnnotationBorderStyle;
exports.AnnotationFactory = AnnotationFactory;
diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js
index d0b23e0..fc974f2 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.STRIKEOUT:
+ return new StrikeOutAnnotationElement(parameters);
+
default:
throw new Error('Unimplemented annotation type "' + subtype + '"');
}
@@ -631,6 +634,33 @@ var UnderlineAnnotationElement = (
})();
/**
+ * @class
+ * @alias StrikeOutAnnotationElement
+ */
+var StrikeOutAnnotationElement = (
+ function StrikeOutAnnotationElementClosure() {
+ function StrikeOutAnnotationElement(parameters) {
+ AnnotationElement.call(this, parameters);
+ }
+
+ Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
+ /**
+ * Render the strikeout annotation's HTML element in the empty container.
+ *
+ * @public
+ * @memberof StrikeOutAnnotationElement
+ * @returns {HTMLSectionElement}
+ */
+ render: function StrikeOutAnnotationElement_render() {
+ this.container.className = 'strikeoutAnnotation';
+ return this.container;
+ }
+ });
+
+ return StrikeOutAnnotationElement;
+})();
+
+/**
* @typedef {Object} AnnotationLayerParameters
* @property {PageViewport} viewport
* @property {HTMLDivElement} div
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 78943c4..252702f 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -202,3 +202,4 @@
!annotation-link-text-popup.pdf
!annotation-text-without-popup.pdf
!annotation-underline.pdf
+!annotation-strikeout.pdf
diff --git a/test/pdfs/annotation-strikeout.pdf b/test/pdfs/annotation-strikeout.pdf
new file mode 100644
index 0000000..ede8418
Binary files /dev/null and b/test/pdfs/annotation-strikeout.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 244aeed..fef94af 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -2645,6 +2645,13 @@
"type": "eq",
"annotations": true
},
+ { "id": "annotation-strikeout",
+ "file": "pdfs/annotation-strikeout.pdf",
+ "md5": "6624e6b5bedd2f2855b6ab12bbf93c57",
+ "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 a2fe4e7..b48e4c6 100644
--- a/web/annotation_layer_builder.css
+++ b/web/annotation_layer_builder.css
@@ -72,3 +72,7 @@
.annotationLayer .underlineAnnotation {
cursor: pointer;
}
+
+.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