Skip to content
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

Interactive forms: render button widget annotations (checkboxes and radio buttons) #7898

Merged

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Dec 15, 2016

Replaces #7664.
Fixes a part of #7613.

The reference tests do not display selection marks in fields only when checkbox/radio button styling is supported by the browser because the rasterizer cannot handle that. This is not a problem for landing this patch, but we will add it to the tracking issue when this is merged.

Copy link
Contributor

@yurydelendik yurydelendik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

}
this.container.appendChild(inputElement);

var labelElement = document.createElement('label');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment that will say that label will be visible as CSS styling will take care of it?

Copy link
Contributor Author

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.

return Promise.resolve(operatorList);
}

if (this.appearance) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO since we need to select AS based on value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already taken care of by the getDefaultAppearance function based on the AS dictionary entry. Refactoring this is already part of the tracking issue.

@timvandermeij timvandermeij force-pushed the acroforms-checkbox-radiobutton branch from 418123c to e3d7ac3 Compare December 16, 2016 00:28
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that https://bugzilla.mozilla.org/show_bug.cgi?id=418833 has now (finally) landed, most modern browsers should now support proper styling of Checkboxes and Radio buttons.
With that in mind: Would it be possible to use normal HTML elements, instead of the label hacks used here, since I believe that that would simplify the HTML, CSS and JavaScript a great deal here?

Yes this would mean that these elements wouldn't look as nice in browsers without support for styling them, but given the simplicity of that implementation I'd greatly prefer the approach with proper form elements!

@@ -97,6 +99,66 @@
width: 115%;
}

.annotationLayer .buttonWidgetAnnotation.checkBox label,
.annotationLayer .buttonWidgetAnnotation.radioButton label {
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, most of these rules are the same as those used above in

.annotationLayer .textWidgetAnnotation input,
, hence moving these rules there instead (with possible necessary overrides here) might make the code more readable and maintainable!?

Copy link
Contributor Author

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.

@@ -75,6 +77,26 @@
padding-right: 0;
}

.annotationLayer .buttonWidgetAnnotation.checkBox label,
.annotationLayer .buttonWidgetAnnotation.radioButton label {
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, most of these rules are the same as those used above in https://github.com/timvandermeij/pdf.js/blob/e3d7ac3595cf4a0832ba60835a0302e9e117d6df/test/annotation_layer_test.css#L46, hence moving these rules there instead (with possible necessary overrides here) might make the code more readable and maintainable!?

Copy link
Contributor Author

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.

@timvandermeij timvandermeij force-pushed the acroforms-checkbox-radiobutton branch 6 times, most recently from 66b0baa to bc5eac0 Compare December 16, 2016 21:52
@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/961fde53b838aef/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/961fde53b838aef/output.txt

Total script time: 2.20 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/a1d9b662179c431/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/d08f4fd63603922/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/d08f4fd63603922/output.txt

Total script time: 25.85 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.22.172.223:8877/d08f4fd63603922/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux)


Failed

Full output at http://107.21.233.14:8877/a1d9b662179c431/output.txt

Total script time: 26.41 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://107.21.233.14:8877/a1d9b662179c431/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor Author

Do you mind reviewing this PR again @Snuffleupagus, in particular the last commit, to check if it's better this way?

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Yury has already reviewed most of this, I've mainly skimmed through the total diff.

[...] in particular the last commit, to check if it's better this way?

Yes, I think it's much better this way! By directly using the proper elements, the code becomes a lot cleaner and easier to follow!

I've got just one remaining question, and please keep in mind that "no" is a perfectly valid answer:
I've not looked too closely at the individual commits (besides the last one). but would it be possible/useful to fold some the smaller commits together before landing?


Also, when landing this, don't forget to add a note in the tracking issue about the flags that this PR doesn't implement; i.e. NoToggleToOff and RadiosInUnison, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2201104.

benweet and others added 2 commits December 17, 2016 20:31
@timvandermeij timvandermeij force-pushed the acroforms-checkbox-radiobutton branch from bc5eac0 to 050dc6c Compare December 17, 2016 19:34
@timvandermeij timvandermeij force-pushed the acroforms-checkbox-radiobutton branch from 050dc6c to d5412e1 Compare December 17, 2016 19:37
…ve labels

Modern browsers support styling radio buttons and checkboxes with CSS.
This makes the implementation much easier, and the fallback for older
browsers is still decent.
@timvandermeij timvandermeij force-pushed the acroforms-checkbox-radiobutton branch from d5412e1 to a428899 Compare December 17, 2016 19:42
@timvandermeij
Copy link
Contributor Author

Thank you. I managed to reduce the commits I added from five to three.

@timvandermeij
Copy link
Contributor Author

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://107.22.172.223:8877/59636db25c5db62/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_makeref from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/eb3ae5292f21648/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/eb3ae5292f21648/output.txt

Total script time: 25.42 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/59636db25c5db62/output.txt

Total script time: 25.46 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@timvandermeij timvandermeij merged commit 017e9b9 into mozilla:master Dec 17, 2016
@timvandermeij timvandermeij deleted the acroforms-checkbox-radiobutton branch December 17, 2016 20:22
@timvandermeij
Copy link
Contributor Author

I have updated the tracking issue with the remaining points.

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…-radiobutton

Interactive forms: render button widget annotations (checkboxes and radio buttons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants