Skip to content

Commit

Permalink
Restore AnnotationFactory, add data.hasHtml for VideoAnnotation, fix …
Browse files Browse the repository at this point in the history
…review comments
  • Loading branch information
humphd committed Dec 12, 2015
1 parent 596fdd1 commit 635c061
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
56 changes: 55 additions & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,59 @@
'use strict';

var DEFAULT_ICON_SIZE = 22; // px
var SUPPORTED_TYPES = ['Link', 'Text', 'Widget', 'Screen', 'Movie'];

/**
* @class
* @alias AnnotationFactory
*/
function AnnotationFactory() {}
AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
/**
* @param {XRef} xref
* @param {Object} ref
* @returns {Annotation}
*/
create: function AnnotationFactory_create(xref, ref) {
var dict = xref.fetchIfRef(ref);
if (!isDict(dict)) {
return;
}

// Determine the annotation's subtype.
var subtype = dict.get('Subtype');
subtype = isName(subtype) ? subtype.name : '';

// Return the right annotation object based on the subtype and field type.
var parameters = {
dict: dict,
ref: ref
};

switch (subtype) {
case 'Link':
return new LinkAnnotation(parameters);

case 'Movie':
case 'Screen':
return new VideoAnnotation(parameters);

case 'Text':
return new TextAnnotation(parameters);

case 'Widget':
var fieldType = Util.getInheritableProperty(dict, 'FT');
if (isName(fieldType) && fieldType.name === 'Tx') {
return new TextWidgetAnnotation(parameters);
}
return new WidgetAnnotation(parameters);

default:
warn('Unimplemented annotation type "' + subtype + '", ' +
'falling back to base annotation');
return new Annotation(parameters);
}
}
};

var Annotation = (function AnnotationClosure() {
// 12.5.5: Algorithm: Appearance streams
Expand Down Expand Up @@ -692,6 +744,8 @@ var VideoAnnotation = (function VideoAnnotationClosure() {
var dict = params.dict;
var data = this.data;
data.annotationType = AnnotationType.VIDEO;
data.hasHtml = true;

// Check for various annotations related to videos.
if (dict.get('Subtype').name === 'Screen') {
data.contentType = dict.get('A').get('R').get('C').get('CT') || '';
Expand Down
4 changes: 2 additions & 2 deletions src/display/annotation_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS, Util, AnnotationType, AnnotationBorderStyleType,
isExternalLinkTargetSet, LinkTargetStringMap, CustomStyle, warn */
/* globals PDFJS, Util, AnnotationType, AnnotationBorderStyleType, warn,
CustomStyle, isExternalLinkTargetSet, LinkTargetStringMap */

'use strict';

Expand Down

0 comments on commit 635c061

Please sign in to comment.