diff --git a/src/core/annotation.js b/src/core/annotation.js index e52c69a51..7abd2213f 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -66,6 +66,8 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { /** * @param {XRef} xref * @param {Object} ref + * @param {string} uniquePrefix + * @param {Object} idCounters * @returns {Annotation} */ create: function AnnotationFactory_create(xref, ref, @@ -717,20 +719,19 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { return Annotation.prototype.getOperatorList.call(this, evaluator, task); } - var opList = new OperatorList(); - var data = this.data; + var operatorList = new OperatorList(); // Even if there is an appearance stream, ignore it. This is the // behaviour used by Adobe Reader. - if (!data.defaultAppearance) { - return Promise.resolve(opList); + if (!this.data.defaultAppearance) { + return Promise.resolve(operatorList); } - var stream = new Stream(stringToBytes(data.defaultAppearance)); - return evaluator.getOperatorList(stream, task, - this.fieldResources, opList). + var stream = new Stream(stringToBytes(this.data.defaultAppearance)); + return evaluator.getOperatorList(stream, task, this.fieldResources, + operatorList). then(function () { - return opList; + return operatorList; }); } }); diff --git a/test/annotation_layer_test.css b/test/annotation_layer_test.css index f99ff1fad..ae5881c62 100644 --- a/test/annotation_layer_test.css +++ b/test/annotation_layer_test.css @@ -43,7 +43,8 @@ position: absolute; } -.annotationLayer .textWidgetAnnotation input { +.annotationLayer .textWidgetAnnotation input, +.annotationLayer .textWidgetAnnotation textarea { background-color: rgba(0, 54, 255, 0.13); border: 1px solid transparent; box-sizing: border-box; @@ -54,6 +55,18 @@ width: 100%; } +.annotationLayer .textWidgetAnnotation textarea { + font: message-box; + font-size: 9px; + resize: none; +} + +.annotationLayer .textWidgetAnnotation input[disabled], +.annotationLayer .textWidgetAnnotation textarea[disabled] { + background: none; + border: 1px solid transparent; +} + .annotationLayer .popupAnnotation { display: block !important; } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 546382bea..588d08aa5 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -249,4 +249,5 @@ !annotation-squiggly.pdf !annotation-highlight.pdf !annotation-fileattachment.pdf +!annotation-text-widget.pdf !zero_descent.pdf diff --git a/test/pdfs/annotation-text-widget.pdf b/test/pdfs/annotation-text-widget.pdf new file mode 100644 index 000000000..d6c959c1a Binary files /dev/null and b/test/pdfs/annotation-text-widget.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index bc8b0412c..821a4cb1e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3137,6 +3137,13 @@ "type": "eq", "annotations": true }, + { "id": "annotation-text-widget-forms", + "file": "pdfs/annotation-text-widget.pdf", + "md5": "cc9672539ad5b837152a9c6961e5f106", + "rounds": 1, + "type": "eq", + "forms": true + }, { "id": "issue6108", "file": "pdfs/issue6108.pdf", "md5": "8961cb55149495989a80bf0487e0f076", diff --git a/test/unit/annotation_layer_spec.js b/test/unit/annotation_layer_spec.js index 6971e6fca..267b6e8a9 100644 --- a/test/unit/annotation_layer_spec.js +++ b/test/unit/annotation_layer_spec.js @@ -469,7 +469,8 @@ describe('Annotation layer', function() { textWidgetDict = null; }); - it('should handle unknown text alignment and maximum length', function() { + it('should handle unknown text alignment, maximum length and flags', + function() { var textWidgetRef = new Ref(124, 0); var xref = new XRefMock([ { ref: textWidgetRef, data: textWidgetDict, } @@ -478,11 +479,15 @@ describe('Annotation layer', function() { var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); expect(textWidgetAnnotation.data.textAlignment).toEqual(null); expect(textWidgetAnnotation.data.maxLen).toEqual(null); + expect(textWidgetAnnotation.data.readOnly).toEqual(false); + expect(textWidgetAnnotation.data.multiLine).toEqual(false); }); - it('should not set invalid text alignment and maximum length', function() { + it('should not set invalid text alignment, maximum length and flags', + function() { textWidgetDict.set('Q', 'center'); textWidgetDict.set('MaxLen', 'five'); + textWidgetDict.set('Ff', 'readonly'); var textWidgetRef = new Ref(43, 0); var xref = new XRefMock([ @@ -492,11 +497,15 @@ describe('Annotation layer', function() { var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); expect(textWidgetAnnotation.data.textAlignment).toEqual(null); expect(textWidgetAnnotation.data.maxLen).toEqual(null); + expect(textWidgetAnnotation.data.readOnly).toEqual(false); + expect(textWidgetAnnotation.data.multiLine).toEqual(false); }); - it('should set valid text alignment and maximum length', function() { + it('should set valid text alignment, maximum length and flags', + function() { textWidgetDict.set('Q', 1); textWidgetDict.set('MaxLen', 20); + textWidgetDict.set('Ff', 4097); var textWidgetRef = new Ref(84, 0); var xref = new XRefMock([ @@ -506,6 +515,8 @@ describe('Annotation layer', function() { var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); expect(textWidgetAnnotation.data.textAlignment).toEqual(1); expect(textWidgetAnnotation.data.maxLen).toEqual(20); + expect(textWidgetAnnotation.data.readOnly).toEqual(true); + expect(textWidgetAnnotation.data.multiLine).toEqual(true); }); });