-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Text widget annotations: support read-only/multiline fields and improve testing #7633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text widget annotations: support read-only/multiline fields and improve testing #7633
Conversation
bc96b57
to
3fb2e39
Compare
create: function AnnotationFactory_create(xref, ref, | ||
uniquePrefix, idCounters) { | ||
create: function AnnotationFactory_create(xref, ref, uniquePrefix, | ||
idCounters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since you're not making any functional changes here, please revert this to avoid unnecessarily changing the blame
of these lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commits.
@@ -3137,6 +3137,13 @@ | |||
"type": "eq", | |||
"annotations": true | |||
}, | |||
{ "id": "annotation-text-widget", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding -forms
to the end of the test name, to make it obvious what's beeing tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commits.
idCounters) { | ||
create: | ||
function AnnotationFactory_create(xref, ref, uniquePrefix, idCounters, | ||
renderInteractiveForms) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think that you could just do this instead (note the previous comment about changing the blame
):
create: function AnnotationFactory_create(xref, ref,
uniquePrefix, idCounters,
renderInteractiveForms) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commits.
intent: renderingIntent, | ||
renderInteractiveForms: | ||
(params && params.renderInteractiveForms === true ? true : | ||
/* Default */ false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that readability would be improved here if you instead defined an intermediate renderInteractiveForms
variable above, similar to the renderingIntent
. E.g.
var renderInteractiveForms = (params.renderInteractiveForms === true ?
true : /* Default */ false);
...
this.transport.messageHandler.send('RenderPageRequest', {
pageIndex: this.pageNumber - 1,
intent: renderingIntent,
renderInteractiveForms: renderInteractiveForms,
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not yet had time to actually test this, but it looks good so far :-)
I've added a few comments, based on just browsing through the code, and I will do a more thorough review/test later.
3fb2e39
to
291ac7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, with comments addressed and passing tests.
Looks great, thank you!
cursor: not-allowed; | ||
} | ||
|
||
.annotationLayer .textWidgetAnnotation textarea { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't a textarea
have the same hover
/focus
rules as a normal input
!?
Because currently the background colour isn't removed when editing its contents, and there's no outline when the cursor is over it either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in the new commit. I thought I had this, but it somehow got lost. Thanks for noticing!
As a follow-up PR, I think that we should get rid of Since we've only just added |
Moreover, this patch provides us with a framework for handling field flags in general for all types of widget annotations.
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.
If interactive forms are enabled, then the display layer takes care of rendering the form elements. There is no need to draw them on the canvas as well. This also leads to issues when values are prefilled, because the text fields are transparent, so the contents that have been rendered onto the canvas will be visible too. We address this issue by passing the `renderInteractiveForms` parameter to the render task and handling it when the page is rendered (i.e., when the canvas is rendered).
291ac7e
to
dbea302
Compare
I have added a note to the tracking issue about removing the global. |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/c6e8f5c41558f14/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/c6e8f5c41558f14/output.txt Total script time: 1.19 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/e1f58e97e0a6772/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/efe42373b55163f/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/efe42373b55163f/output.txt Total script time: 24.50 mins
Image differences available at: http://107.22.172.223:8877/efe42373b55163f/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/e1f58e97e0a6772/output.txt Total script time: 39.66 mins
Image differences available at: http://107.21.233.14:8877/e1f58e97e0a6772/reftest-analyzer.html#web=eq.log |
I verified that the test failure above is correct. This field is actually a multiline text field that is positioned one pixel below the other field next to it. Now that this is supported, we notice this. Comparing a screenshot from the Adobe Reader rendering to the new PDF.js rendering shows that it is the same now. /botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/9c4ce4251659d10/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/b098952aec45cb8/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/9c4ce4251659d10/output.txt Total script time: 24.50 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/b098952aec45cb8/output.txt Total script time: 38.45 mins
|
…tx-flags Text widget annotations: support read-only/multiline fields and improve testing
This pull request is a part of #7613 and completes the support for text widget annotations. More details are provided in the commit messages.