Text widget annotations: improve unit and reference tests
This patch improves the unit tests by testing the support for read-only and multiline fields. Moreover, we add a reference test to ensure that the text widgets are not only rendered, but also that their contents are styled properly. Finally, we perform minor improvements in `src/core/annotation.js`, for example adding missing comments.
This commit is contained in:
parent
f6965fadc0
commit
adf0972ca5
@ -66,6 +66,8 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
|
|||||||
/**
|
/**
|
||||||
* @param {XRef} xref
|
* @param {XRef} xref
|
||||||
* @param {Object} ref
|
* @param {Object} ref
|
||||||
|
* @param {string} uniquePrefix
|
||||||
|
* @param {Object} idCounters
|
||||||
* @returns {Annotation}
|
* @returns {Annotation}
|
||||||
*/
|
*/
|
||||||
create: function AnnotationFactory_create(xref, ref,
|
create: function AnnotationFactory_create(xref, ref,
|
||||||
@ -717,20 +719,19 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
|||||||
return Annotation.prototype.getOperatorList.call(this, evaluator, task);
|
return Annotation.prototype.getOperatorList.call(this, evaluator, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
var opList = new OperatorList();
|
var operatorList = new OperatorList();
|
||||||
var data = this.data;
|
|
||||||
|
|
||||||
// Even if there is an appearance stream, ignore it. This is the
|
// Even if there is an appearance stream, ignore it. This is the
|
||||||
// behaviour used by Adobe Reader.
|
// behaviour used by Adobe Reader.
|
||||||
if (!data.defaultAppearance) {
|
if (!this.data.defaultAppearance) {
|
||||||
return Promise.resolve(opList);
|
return Promise.resolve(operatorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
var stream = new Stream(stringToBytes(data.defaultAppearance));
|
var stream = new Stream(stringToBytes(this.data.defaultAppearance));
|
||||||
return evaluator.getOperatorList(stream, task,
|
return evaluator.getOperatorList(stream, task, this.fieldResources,
|
||||||
this.fieldResources, opList).
|
operatorList).
|
||||||
then(function () {
|
then(function () {
|
||||||
return opList;
|
return operatorList;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.annotationLayer .textWidgetAnnotation input {
|
.annotationLayer .textWidgetAnnotation input,
|
||||||
|
.annotationLayer .textWidgetAnnotation textarea {
|
||||||
background-color: rgba(0, 54, 255, 0.13);
|
background-color: rgba(0, 54, 255, 0.13);
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -54,6 +55,18 @@
|
|||||||
width: 100%;
|
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 {
|
.annotationLayer .popupAnnotation {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -249,4 +249,5 @@
|
|||||||
!annotation-squiggly.pdf
|
!annotation-squiggly.pdf
|
||||||
!annotation-highlight.pdf
|
!annotation-highlight.pdf
|
||||||
!annotation-fileattachment.pdf
|
!annotation-fileattachment.pdf
|
||||||
|
!annotation-text-widget.pdf
|
||||||
!zero_descent.pdf
|
!zero_descent.pdf
|
||||||
|
BIN
test/pdfs/annotation-text-widget.pdf
Normal file
BIN
test/pdfs/annotation-text-widget.pdf
Normal file
Binary file not shown.
@ -3137,6 +3137,13 @@
|
|||||||
"type": "eq",
|
"type": "eq",
|
||||||
"annotations": true
|
"annotations": true
|
||||||
},
|
},
|
||||||
|
{ "id": "annotation-text-widget-forms",
|
||||||
|
"file": "pdfs/annotation-text-widget.pdf",
|
||||||
|
"md5": "cc9672539ad5b837152a9c6961e5f106",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"forms": true
|
||||||
|
},
|
||||||
{ "id": "issue6108",
|
{ "id": "issue6108",
|
||||||
"file": "pdfs/issue6108.pdf",
|
"file": "pdfs/issue6108.pdf",
|
||||||
"md5": "8961cb55149495989a80bf0487e0f076",
|
"md5": "8961cb55149495989a80bf0487e0f076",
|
||||||
|
@ -469,7 +469,8 @@ describe('Annotation layer', function() {
|
|||||||
textWidgetDict = null;
|
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 textWidgetRef = new Ref(124, 0);
|
||||||
var xref = new XRefMock([
|
var xref = new XRefMock([
|
||||||
{ ref: textWidgetRef, data: textWidgetDict, }
|
{ ref: textWidgetRef, data: textWidgetDict, }
|
||||||
@ -478,11 +479,15 @@ describe('Annotation layer', function() {
|
|||||||
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
||||||
expect(textWidgetAnnotation.data.textAlignment).toEqual(null);
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null);
|
||||||
expect(textWidgetAnnotation.data.maxLen).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('Q', 'center');
|
||||||
textWidgetDict.set('MaxLen', 'five');
|
textWidgetDict.set('MaxLen', 'five');
|
||||||
|
textWidgetDict.set('Ff', 'readonly');
|
||||||
|
|
||||||
var textWidgetRef = new Ref(43, 0);
|
var textWidgetRef = new Ref(43, 0);
|
||||||
var xref = new XRefMock([
|
var xref = new XRefMock([
|
||||||
@ -492,11 +497,15 @@ describe('Annotation layer', function() {
|
|||||||
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
||||||
expect(textWidgetAnnotation.data.textAlignment).toEqual(null);
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null);
|
||||||
expect(textWidgetAnnotation.data.maxLen).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('Q', 1);
|
||||||
textWidgetDict.set('MaxLen', 20);
|
textWidgetDict.set('MaxLen', 20);
|
||||||
|
textWidgetDict.set('Ff', 4097);
|
||||||
|
|
||||||
var textWidgetRef = new Ref(84, 0);
|
var textWidgetRef = new Ref(84, 0);
|
||||||
var xref = new XRefMock([
|
var xref = new XRefMock([
|
||||||
@ -506,6 +515,8 @@ describe('Annotation layer', function() {
|
|||||||
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef);
|
||||||
expect(textWidgetAnnotation.data.textAlignment).toEqual(1);
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(1);
|
||||||
expect(textWidgetAnnotation.data.maxLen).toEqual(20);
|
expect(textWidgetAnnotation.data.maxLen).toEqual(20);
|
||||||
|
expect(textWidgetAnnotation.data.readOnly).toEqual(true);
|
||||||
|
expect(textWidgetAnnotation.data.multiLine).toEqual(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user