[Pkg-javascript-commits] [pdf.js] 108/115: Implement annotation layer rendering and updating in src/display/annotation_layer.js
David Prévot
taffit at moszumanska.debian.org
Wed Dec 16 20:03:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit edce8daeac6f619b7be3adf68069ba4af808768f
Author: Tim van der Meij <timvandermeij at gmail.com>
Date: Tue Dec 15 16:48:55 2015 +0100
Implement annotation layer rendering and updating in src/display/annotation_layer.js
---
src/display/annotation_layer.js | 28 +++++++++++++++++++++++++++-
web/annotations_layer_builder.js | 33 +++++++--------------------------
2 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js
index 50b54b7..f24db67 100644
--- a/src/display/annotation_layer.js
+++ b/src/display/annotation_layer.js
@@ -324,8 +324,34 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
}
}
+ function render(viewport, div, annotations, page, linkService) {
+ for (var i = 0, ii = annotations.length; i < ii; i++) {
+ var data = annotations[i];
+ if (!data || !data.hasHtml) {
+ continue;
+ }
+
+ var element = getHtmlElement(data, page, viewport, linkService);
+ div.appendChild(element);
+ }
+ }
+
+ function update(viewport, div, annotations) {
+ for (var i = 0, ii = annotations.length; i < ii; i++) {
+ var data = annotations[i];
+ var element = div.querySelector(
+ '[data-annotation-id="' + data.id + '"]');
+ if (element) {
+ CustomStyle.setProp('transform', element,
+ 'matrix(' + viewport.transform.join(',') + ')');
+ }
+ }
+ div.removeAttribute('hidden');
+ }
+
return {
- getHtmlElement: getHtmlElement
+ render: render,
+ update: update
};
})();
diff --git a/web/annotations_layer_builder.js b/web/annotations_layer_builder.js
index 37e23d8..e9b0fbd 100644
--- a/web/annotations_layer_builder.js
+++ b/web/annotations_layer_builder.js
@@ -27,8 +27,6 @@
* @class
*/
var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
- var CustomStyle = PDFJS.CustomStyle;
-
/**
* @param {AnnotationsLayerBuilderOptions} options
* @constructs AnnotationsLayerBuilder
@@ -56,22 +54,14 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
this.pdfPage.getAnnotations(parameters).then(function (annotations) {
viewport = viewport.clone({ dontFlip: true });
- var data, element, i, ii;
if (self.div) {
// If an annotationLayer already exists, refresh its children's
// transformation matrices.
- for (i = 0, ii = annotations.length; i < ii; i++) {
- data = annotations[i];
- element = self.div.querySelector(
- '[data-annotation-id="' + data.id + '"]');
- if (element) {
- CustomStyle.setProp('transform', element,
- 'matrix(' + viewport.transform.join(',') + ')');
- }
- }
- self.div.removeAttribute('hidden');
+ PDFJS.AnnotationLayer.update(viewport, self.div, annotations);
} else {
+ // Create an annotation layer div and render the annotations
+ // if there is at least one annotation.
if (annotations.length === 0) {
return;
}
@@ -80,19 +70,10 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() {
self.div.className = 'annotationLayer';
self.pageDiv.appendChild(self.div);
- for (i = 0, ii = annotations.length; i < ii; i++) {
- data = annotations[i];
- if (!data || !data.hasHtml) {
- continue;
- }
-
- element = PDFJS.AnnotationLayer.getHtmlElement(data, self.pdfPage,
- viewport,
- self.linkService);
- if (typeof mozL10n !== 'undefined') {
- mozL10n.translate(element);
- }
- self.div.appendChild(element);
+ PDFJS.AnnotationLayer.render(viewport, self.div, annotations,
+ self.pdfPage, self.linkService);
+ if (typeof mozL10n !== 'undefined') {
+ mozL10n.translate(self.div);
}
}
});
--
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