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

Support rotating editor layer #15088

Merged
merged 1 commit into from
Jun 25, 2022
Merged

Conversation

calixteman
Copy link
Contributor

  • As in the annotation layer, use percent instead of pixels as unit;
  • handle the rotation of the editor layer in allowing editing when rotation
    angle is not zero;
  • the different editors are rotated counterclockwise in order to be usable
    when the main page is itself rotated;
  • add support for saving/printing rotated editors.

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!

@@ -314,7 +314,6 @@ class Page {
...newData.annotations
);

this.xref.resetNewRef();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was already fixed in PR #15089

@@ -145,6 +145,7 @@ class AnnotationStorage {
const val = value instanceof AnnotationEditor ? value.serialize() : value;
clone.set(key, val);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Unrelated change.


this.div.style.width = flipOrientation ? heightStr : widthStr;
this.div.style.height = flipOrientation ? widthStr : heightStr;
this.div.setAttribute("data-annotation-rotation", rotation);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like too much copy-and-pasting, since I'm assuming that you actually mean the following :-)

Suggested change
this.div.setAttribute("data-annotation-rotation", rotation);
this.div.setAttribute("data-editor-rotation", rotation);

Copy link
Contributor Author

@calixteman calixteman Jun 24, 2022

Choose a reason for hiding this comment

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

In fact, there is nothing wrong here.
The data-annotation-rotation is a rotation followed by a translation when data-editor-rotation is just a rotation.
The latter is only applied on an editor when the former is on all the containing layer.
So likely, the name data-annotation-rotation is bad, do you have any suggestion ? maybe data-main-rotation ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So likely, the name data-annotation-rotation is bad, do you have any suggestion ? maybe data-main-rotation ?

Your suggestion works for me, since I'm assuming that you'll be changing the src/display/annotation_layer.js-code accordingly as well?

Also, if we're re-using those CSS-rules for the annotationLayer and the annotationEditorLayer we should probably place those definitions in the https://github.com/mozilla/pdf.js/blob/master/web/pdf_viewer.css file instead.

}

/**
* Translate the editor position within its parent.
* @param {number} x
* @param {number} y
* @param {boolean} isScreen.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This parameter doesn't exist below, please remove it from the JSDoc.

@@ -131,21 +127,51 @@ class AnnotationEditor {
* @param {number} x
* @param {number} y
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update the JSDoc to also list the new parameters.

Comment on lines 175 to 178
case 270:
return [height, 0, width, height];
}
return [0, 0, width, height];
Copy link
Collaborator

Choose a reason for hiding this comment

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

In other switch-statements, for example in screenToPageTranslation, you've used the following format:

Suggested change
case 270:
return [height, 0, width, height];
}
return [0, 0, width, height];
case 270:
return [height, 0, width, height];
default:
return [0, 0, width, height];

@@ -88,6 +98,7 @@
outline: var(--hover-outline);
}

.annotationEditorLayer .inkEditor.disabled:focus,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line looks identical to the one below, did you mean the following?

Suggested change
.annotationEditorLayer .inkEditor.disabled:focus,
.annotationEditorLayer .freeTextEditor.disabled:focus,

@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/96536a0bb76291a/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/9bef82b31a7d175/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/96536a0bb76291a/output.txt

Total script time: 26.30 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

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

Total script time: 29.02 mins

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

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

@@ -130,22 +126,53 @@ class AnnotationEditor {
* Set the editor position within its parent.
* @param {number} x
* @param {number} y
* @param {number} tx - x-translation in screen coordinates.
* @param {number} ty - xy-translation in screen coordinates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo?

Suggested change
* @param {number} ty - xy-translation in screen coordinates.
* @param {number} ty - y-translation in screen coordinates.

}

/**
* Translate the editor position within its parent.
* @param {number} x - x-translation in screen coordinates.
* @param {number} y - xy-translation in screen coordinates.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo?

Suggested change
* @param {number} y - xy-translation in screen coordinates.
* @param {number} y - y-translation in screen coordinates.

- As in the annotation layer, use percent instead of pixels as unit;
- handle the rotation of the editor layer in allowing editing when rotation
  angle is not zero;
- the different editors are rotated counterclockwise in order to be usable
  when the main page is itself rotated;
- add support for saving/printing rotated editors.
Comment on lines -30 to -39
[data-annotation-rotation="90"] {
transform: rotate(90deg) translateY(-100%);
}
[data-annotation-rotation="180"] {
transform: rotate(180deg) translate(-100%, -100%);
}
[data-annotation-rotation="270"] {
transform: rotate(270deg) translateX(-100%);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

To ensure that moving this code won't cause any issues now, or in the future, I've submitted PR #15101 which should help avoid any problems.

@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/1a191ba09fbe6da/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/6c98ec426c59d97/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/1a191ba09fbe6da/output.txt

Total script time: 26.30 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/6c98ec426c59d97/output.txt

Total script time: 28.54 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: Passed

@calixteman calixteman merged commit 23fcdab into mozilla:master Jun 25, 2022
@calixteman
Copy link
Contributor Author

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/6b871846394b1a5/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/59a37956d8becec/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/6b871846394b1a5/output.txt

Total script time: 22.80 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/59a37956d8becec/output.txt

Total script time: 22.40 mins

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

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