Skip to content

[Editor] Add validation for the target element of curve endpoints #19373

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

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

Hydraulicus
Copy link
Contributor

Issue: drawing a shape may have an unwanted path element added.
Steps to reproduce:

Go to https://mozilla.github.io/pdf.js/web/viewer.html;
Select the pen tool and draw a shape on the second page;
While drawing the shape, move the cursor out of the left-hand side of the second page, then stop the action.
On the third step, the shape will be extended with a path element that starts where the cursor left the page and ends at a random position on the page. Correct this issue to ensure that the path element is not added.
Fix: Incorrect End Position of Curve on Target Page
The issue of the curve's unintended end position is caused by obtaining improper coordinates from the end-drawing event. These coordinates are derived from an element other than the intended target page.

Changes:
To resolve this, I added a check to verify the element where the drawing ends. If the drawing ends on an element other than the target page, the coordinates registration are skipped.

Notes:

@Snuffleupagus
Copy link
Collaborator

Please make sure that first line of the commit message agrees with the PR title.

@Hydraulicus Hydraulicus changed the title [Editor] Stop drawing a shape outside of the page [Editor] Add validation for the target element of curve endpoints Jan 23, 2025
@Hydraulicus
Copy link
Contributor Author

Please make sure that first line of the commit message agrees with the PR title.

Thanks for the point.
Synchronised.

@calixteman
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/08d5cd1eadb235d/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/3dd5fa05a6036bf/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/08d5cd1eadb235d/output.txt

Total script time: 10.99 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/3dd5fa05a6036bf/output.txt

Total script time: 27.15 mins

  • Integration Tests: FAILED

This patch fixes a bug that caused incorrect curve shapes when an endpoint lies beyond the page boundaries. It adds a check for the endpoint's position, and if it is outside the page, the point is excluded from the shape's coordinates.
@Snuffleupagus
Copy link
Collaborator

@Hydraulicus
Copy link
Contributor Author

Please see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits

I understand I must to squash commits. I read this guide. I trying to do it.
Sorry for inconvenience with me

@Hydraulicus Hydraulicus force-pushed the fix-drawing-beyond-page branch from 0771d73 to 104e1c3 Compare January 23, 2025 21:17
@Hydraulicus
Copy link
Contributor Author

Please see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits

I completed squash.

@calixteman
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/20805903f48370b/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/999e53e85110a5e/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/20805903f48370b/output.txt

Total script time: 10.85 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/999e53e85110a5e/output.txt

Total script time: 25.71 mins

  • Integration Tests: Passed

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you.

@calixteman calixteman merged commit 3880071 into mozilla:master Jan 23, 2025
9 checks passed
@Hydraulicus
Copy link
Contributor Author

@calixteman @Snuffleupagus Thanks for support.
Could you suggest some another issue for fix. With the aim to make me more familiar with codebase.
Thanks in advance.
I have made conclusions and my next pull request (if you don't mind) will be smoother and faster.

@Hydraulicus Hydraulicus deleted the fix-drawing-beyond-page branch January 24, 2025 07:55
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.

4 participants