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

[Editor] Handle correctly colors when saving a document in HCM #15115

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

calixteman
Copy link
Contributor

  • for example in Dusk theme (Windows 11), black appears to be white, so
    the user will draw something in white. But if they want to print or
    save the used color must be black.
  • fix a bug with the color input which only accepts hex string colors;
  • adjust outline color of the selected/hovered editors in HCM.

]);

get _colors() {
if (typeof document !== "undefined") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this check, since I don't believe this code is expected to run outside of browsers?
Also, in the method just below you're accessing window directly without checking if it's available first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this check to fix gulp unittestcli which was unhappy with that (likely because a static property is using it)... so I chose the easiest solution.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jun 29, 2022

Choose a reason for hiding this comment

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

Ah, that explains things. In that case, since this doesn't matter in browsers, please see the suggestion below (which is based on what we do in the viewer-code in a couple of spots).

if (!rgb) {
return name;
}
return "#" + rgb.map(x => x.toString(16).padStart(2, "0")).join("");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, isn't this identical to the existing Util.makeHexColor method?
Please use that one instead, rather than reinventing the wheel here :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Especially when I created this wheel myself...

src/display/display_utils.js Show resolved Hide resolved
Comment on lines 290 to 299
if (typeof document !== "undefined") {
const colors = new Map([
["CanvasText", null],
["Canvas", null],
]);
getColorValues(colors);
return shadow(this, "_colors", colors);
}

return shadow(this, "_colors", ColorManager._colorsMapping);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (typeof document !== "undefined") {
const colors = new Map([
["CanvasText", null],
["Canvas", null],
]);
getColorValues(colors);
return shadow(this, "_colors", colors);
}
return shadow(this, "_colors", ColorManager._colorsMapping);
if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("LIB") &&
typeof document === "undefined"
) {
return shadow(this, "_colors", ColorManager._colorsMapping);
}
const colors = new Map([
["CanvasText", null],
["Canvas", null],
]);
getColorValues(colors);
return shadow(this, "_colors", colors);
}

@calixteman calixteman force-pushed the editing_a11y_bis branch 2 times, most recently from b01273d to 9899d58 Compare June 29, 2022 15:18
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.

r=me, with comments addressed and passing tests; thank you!

src/pdf.js Outdated
@@ -123,6 +124,7 @@ export {
getDocument,
getFilenameFromUrl,
getPdfFilenameFromUrl,
getRGB,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this necessary, since I'm not finding anything that depends on this?
As a general rule, please let's not expose things in the API unless it's actually needed e.g. in the viewer.

@calixteman
Copy link
Contributor Author

/botio test

1 similar comment
@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/6690445c2358ce2/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/21adb5d52137d3f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/6690445c2358ce2/output.txt

Total script time: 21.20 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: FAILED
  • Regression tests: FAILED
  errors: 1754

Image differences available at: http://54.241.84.105:8877/6690445c2358ce2/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/21adb5d52137d3f/output.txt

Total script time: 23.61 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  errors: 877

Image differences available at: http://54.193.163.58:8877/21adb5d52137d3f/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor Author

/botio browsertest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/932885268a25887/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/8270b401e61a3fd/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/932885268a25887/output.txt

Total script time: 3.95 mins

  • Regression tests: FAILED
  errors: 1754

Image differences available at: http://54.241.84.105:8877/932885268a25887/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/8270b401e61a3fd/output.txt

Total script time: 5.19 mins

  • Regression tests: FAILED
  errors: 877

Image differences available at: http://54.193.163.58:8877/8270b401e61a3fd/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor Author

/botio-windows browsertest

@calixteman
Copy link
Contributor Author

So it's my fault:
image

- for example in Dusk theme (Windows 11), black appears to be white, so
  the user will draw something in white. But if they want to print or
  save the used color must be black.
- fix a bug with the color input which only accepts hex string colors;
- adjust outline color of the selected/hovered editors in HCM.
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/2c6b6e4d01dee2c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/9bf75ff6f00489c/output.txt

@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@mozilla mozilla deleted a comment from pdfjsbot Jun 30, 2022
@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/2c6b6e4d01dee2c/output.txt

Total script time: 25.90 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 28

Image differences available at: http://54.241.84.105:8877/2c6b6e4d01dee2c/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/9bf75ff6f00489c/output.txt

Total script time: 28.36 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.193.163.58:8877/9bf75ff6f00489c/reftest-analyzer.html#web=eq.log

@calixteman
Copy link
Contributor Author

calixteman commented Jun 30, 2022

To fix the issue, I lazily get the static values computed thanks to document:
https://github.com/mozilla/pdf.js/pull/15115/files#diff-8ba8badc29ff13ad2d4b61ad2b7df503933c69c028150d1ba24188deb7f11493R61-R68

@Snuffleupagus does that work for you ?

@Snuffleupagus Snuffleupagus merged commit 13c01b6 into mozilla:master Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants