-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Annotation - Use border and background colors from MK dictionary #13006
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
Conversation
calixteman
commented
Feb 20, 2021
- aims to fix PDF rendering problem: Checkboxes have black background #13003;
- pass the colors to js sandbox;
- fix checkbox color.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.67.70.0:8877/51ac9b765ebaba0/output.txt |
/botio-windows test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://3.101.106.178:8877/1aef28a4ddcac8d/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/51ac9b765ebaba0/output.txt Total script time: 23.72 mins
Image differences available at: http://54.67.70.0:8877/51ac9b765ebaba0/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/1aef28a4ddcac8d/output.txt Total script time: 29.69 mins
Image differences available at: http://3.101.106.178:8877/1aef28a4ddcac8d/reftest-analyzer.html#web=eq.log |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/a72984ad6b77272/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/a72984ad6b77272/output.txt Total script time: 4.13 mins Published |
This PR needs a rebase. I'm also not really sure what to make of some of the reference test failures, mainly |
I played with acrobat DC and the background color is used when the widget has the focus. |
f576b14
to
c7abd6d
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.67.70.0:8877/da935e061bd2bac/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://3.101.106.178:8877/293f14d24d00886/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/da935e061bd2bac/output.txt Total script time: 23.84 mins
Image differences available at: http://54.67.70.0:8877/da935e061bd2bac/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/293f14d24d00886/output.txt Total script time: 29.79 mins
Image differences available at: http://3.101.106.178:8877/293f14d24d00886/reftest-analyzer.html#web=eq.log |
Sorry to step in here, but that last version of this patch feels somewhat unfortunate in general, since:
I suppose that it might make sense to take a step back and consider how other PDF viewers (e.g. Adobe Reader and PDFium) handles fillable fields in general, since it seems that they don't necessarily always outline all fields the way that we currently do (and it rather seem to depend on the PDF file itself)!? |
In either acrobat dc or pdfium, the bg color of an unfocused rendered input has alpha or not depending if bg color of the annotation has alpha. So I don't see how avoid to have default colors in js instead of css, please tell me if it's possible. Your point is fair and I tried to figure out a solution to avoid that but I didn't manage to. |
Not sure if this is really better, but we could leave defaults in css and use getComputedStyle. @Snuffleupagus any thoughts on a better way to do this? |
When looking at how e.g. Adobe Reader handles forms, it seems (at least to me) that things like e.g. the background of form fields are generally controlled by the PDF document itself rather than the viewer. Hence my suggestion would be that we could perhaps simplify things overall by doing that in PDF.js as well, and stop setting e.g. a default |
For me the "blue" background is just added by the reader to indicate that there is a fillable form element so I think it's useful for the user. |
How about the following compromise, then:
That should hopefully reduce the overall complexity somewhat here, and also guarantee that PDF documents renders as intended (by the document author). |
I'll have a look at this once it's rebased, since then the patch will be simpler as all color function related changes have already been made in the square/circle annotation PR that was just merged, and with the comment above implemented. |
Ok so if I understand correctly:
But if bg color is white or transparent and there is no border, there is no way for the user that there is something modifiable. My goal was to have exactly the same behaviour as in either Acrobat or chrome. |
src/core/annotation.js
Outdated
*/ | ||
setBorderAndBackgroundColors(mk) { | ||
if (mk instanceof Dict) { | ||
this.borderColor = getRgbColor(mk.getArray("BC"), undefined); |
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.
Transparent is indicated by null
instead of undefined
as indicated on line 202.
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 didn't find in the spec what's the default color (transparent or whatever), so undefined
stands for "use HTML default".
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.
Wait, does that mean that we now use both undefined
and null
, but they have very slightly different meaning in the display-layer?
If so, that sounds like a recipe for confusion...
@@ -976,6 +1016,15 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement { | |||
); | |||
} | |||
|
|||
this._setBorderAndBackgroundColors(element); | |||
|
|||
const { fontColor } = this.data.defaultAppearanceData; |
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.
Why is this necessary only here and not elsewhere? Moreover, checkbox widgets don't contain text AFAIK, so what does this do?
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.
Checkboxes contains text for the on
state: most of the time one char using ZapfDingbats
font.
In that case the PDF document itself is responsible for that behaviour, so I don't really see this as a big problem.
Of course I understand that, but there's something to be said for simplicity of the overall implementation as well (in my opinion). |
Yes you're right.
|
Please keep in mind that the "default" blue background, in Adobe Reader, mentioned is actually a setting which can be toggled on/off in the options (and that the particular colour used is also customizable); hence I'm not entirely convinced by this argument. I'm mostly worried about readability/maintainability of the solution, especially since these types of changes feel like they have the potential to require additional fixes later on for various edge-cases in "weird" PDF documents. |
- aims to fix mozilla#13003; - pass the colors to js sandbox; - fix checkbox color.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.67.70.0:8877/e1f2f4022f08ef5/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://3.101.106.178:8877/2c0e3b29e6a2f95/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/e1f2f4022f08ef5/output.txt Total script time: 25.56 mins
Image differences available at: http://54.67.70.0:8877/e1f2f4022f08ef5/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/2c0e3b29e6a2f95/output.txt Total script time: 30.66 mins
Image differences available at: http://3.101.106.178:8877/2c0e3b29e6a2f95/reftest-analyzer.html#web=eq.log |
I'm closing this PR and I'll open a new one. |