Skip to content

Commit

Permalink
Rewrites src/core/worker.js and src/core/core.js to simplify fetching…
Browse files Browse the repository at this point in the history
… annotations
  • Loading branch information
timvandermeij committed Aug 23, 2014
1 parent 0d90bd5 commit 751b9da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
isArrayBuffer, isName, isStream, isString, createPromiseCapability,
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer,
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef,
MissingDataException, Promise, Annotation, ObjectLoader, OperatorList
*/
MissingDataException, Promise, AnnotationLayer, ObjectLoader,
OperatorList */

'use strict';

Expand All @@ -29,6 +29,7 @@ var Page = (function PageClosure() {

function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
this.pdfManager = pdfManager;
this.annotationLayer = new AnnotationLayer();
this.pageIndex = pageIndex;
this.pageDict = pageDict;
this.xref = xref;
Expand Down Expand Up @@ -204,8 +205,9 @@ var Page = (function PageClosure() {
return pageOpList;
}

var annotationsReadyPromise = Annotation.appendToOperatorList(
annotations, pageOpList, pdfManager, partialEvaluator, intent);
var annotationsReadyPromise =
self.annotationLayer.appendToOperatorList(annotations, pageOpList,
partialEvaluator, intent);
return annotationsReadyPromise.then(function () {
pageOpList.flush(true);
return pageOpList;
Expand Down Expand Up @@ -246,11 +248,11 @@ var Page = (function PageClosure() {
});
},

getAnnotationsData: function Page_getAnnotationsData() {
getAnnotations: function Page_getAnnotations() {
var annotations = this.annotations;
var annotationsData = [];
for (var i = 0, n = annotations.length; i < n; ++i) {
annotationsData.push(annotations[i].getData());
annotationsData.push(annotations[i]);
}
return annotationsData;
},
Expand All @@ -259,8 +261,9 @@ var Page = (function PageClosure() {
var annotations = [];
var annotationRefs = (this.annotationRefs || []);
for (var i = 0, n = annotationRefs.length; i < n; ++i) {
var annotationRef = annotationRefs[i];
var annotation = Annotation.fromRef(this.xref, annotationRef);
var ref = annotationRefs[i];
var dict = this.xref.fetchIfRef(ref);
var annotation = this.annotationLayer.getAnnotation(dict, ref);
if (annotation) {
annotations.push(annotation);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {

handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
return pdfManager.getPage(data.pageIndex).then(function(page) {
return pdfManager.ensure(page, 'getAnnotationsData', []);
return pdfManager.ensure(page, 'getAnnotations', []);
});
});

Expand Down

0 comments on commit 751b9da

Please sign in to comment.