-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Text widget annotations: implement comb support #7649
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: implement comb support #7649
Conversation
dc691f9
to
90a2107
Compare
@@ -715,6 +715,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { | |||
// Process field flags for the display layer. | |||
this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY); | |||
this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE); | |||
this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && | |||
this.data.maxLen !== null && !this.data.multiLine; |
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 you're missing a number of field checks here, please see the specification text:
(PDF 1.5) May be set only if the MaxLen entry is present in the text field dictionary (see Table 229) and _if the Multiline, Password, and FileSelect flags are clear_. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs.
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.
Good point. I thought we didn't need it because we do not support the Password
and FileSelect
flags anyway, but it makes sense to add these checks anyway to prevent any issues. I'll update the patch.
@@ -77,6 +77,22 @@ | |||
border: 1px solid transparent; | |||
} | |||
|
|||
.annotationLayer .textWidgetAnnotation input.comb { |
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.
Don't you want to add these rules to the corresponding file in /test
as well, to enable testing of comb
fields once we have better tests?
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.
Yes, I'll do that.
90a2107
to
5b1f510
Compare
I have addressed the comments and managed to adjust the reference test for text widget annotations to include a field that uses combs. |
/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/434cf638d7a1547/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/434cf638d7a1547/output.txt Total script time: 1.02 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/7de759130fe7a06/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/ad6cc3caae12396/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/ad6cc3caae12396/output.txt Total script time: 24.78 mins
Image differences available at: http://107.22.172.223:8877/ad6cc3caae12396/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/7de759130fe7a06/output.txt Total script time: 29.39 mins
Image differences available at: http://107.21.233.14:8877/7de759130fe7a06/reftest-analyzer.html#web=eq.log |
5b1f510
to
6100ab4
Compare
I pushed a new commit to fix an issue in the a unit test. No other changes have been made. /botio unittest |
From: Bot.io (Linux)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/d258015cb323cbb/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/913c5d457a4bf41/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/d258015cb323cbb/output.txt Total script time: 1.72 mins
|
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/913c5d457a4bf41/output.txt Total script time: 2.08 mins
|
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.
Looks mostly fine, but I think that the format of AnnotationFieldFlag
is making things more difficult to follow. Please see inline comments.
}); | ||
|
||
it('should set valid text alignment, maximum length and flags', | ||
function() { | ||
var flags = 0; | ||
flags |= 1 << (AnnotationFieldFlag.READONLY - 1); | ||
flags |= 1 << (AnnotationFieldFlag.MULTILINE - 1); |
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.
As far as I'm concerted, the current way that the AnnotationFieldFlag
are defined makes the unit-tests unnecessarily convoluted and difficult to understand.
What would be a lot clearer is if you changed AnnotationFieldFlag
to the same form as AnnotationFlag
, since that means you could change the hasFieldFlags
method in src/core/annotation.js
to just:
return !!(this.data.fieldFlags & flag);
and specifying the flags in the unit-tests would be so much more straightforward:
var flags = AnnotationFieldFlag.READONLY + AnnotationFieldFlag.MULTILINE;
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.
Really good point. I'll definitely look into that.
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 pushed a new commit that fixes this.
* area, causing horizontal scrolling. We avoid this by extending the width | ||
* when the element has focus and revert this when it loses focus. | ||
*/ | ||
width: 115%; |
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.
It's unfortunate that this sort of hack is necessary, but I'm also not able to come up with a better solution :-(
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 agree, but after searching for a couple of hours there really isn't another way with CSS only. The real problem is that letter spacing is always applied on the right side of a character, whereas we would want to tune that or turn it off for the last character. Since that's not possible, we need this workaround. There are JS-based solutions, but they are even uglier and require much more code, so this is the cleanest solution IMO.
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 just want to make it absolutely clear that I didn't mean to complain about your solution here, but rather about the (missing) features of the web platform that made the workaround necessary!
expect(textWidgetAnnotation.data.comb).toEqual(true); | ||
}); | ||
|
||
it('should only accept comb fields when the flags are valid', function() { |
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.
It might be possible to simplify this particular test a bit, so I'd like to see an updated version based on the AnnotationFieldFlag
comment above.
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'll try that. I'm not sure how much simpler it will become though as we still need the loops to remove the flags one-by-one, but we'll see.
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 pushed a new commit that fixes this.
Directly use the hexadecimal representation, just like the `AnnotationFlags`, to avoid calculations and to improve readability. This allows us to simplify the unit tests for text widget annotations as well.
d38d0f8
to
375229d
Compare
/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/6ed923ea3044355/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/6ed923ea3044355/output.txt Total script time: 1.00 mins Published |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/48fa394f3e9134e/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/ac30c3c5b18469c/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/48fa394f3e9134e/output.txt Total script time: 24.63 mins
Image differences available at: http://107.22.172.223:8877/48fa394f3e9134e/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/ac30c3c5b18469c/output.txt Total script time: 29.08 mins
Image differences available at: http://107.21.233.14:8877/ac30c3c5b18469c/reftest-analyzer.html#web=eq.log |
Much better, thank you! With the changes to /botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/6841f4c21ab4c77/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/81cb41574c520d9/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/6841f4c21ab4c77/output.txt Total script time: 24.88 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/81cb41574c520d9/output.txt Total script time: 28.37 mins
|
…tx-comb Text widget annotations: implement comb support
This is another part of #7613.