-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Conversation
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.
r=me, with comments addressed and passing tests; thank you!
src/core/document.js
Outdated
@@ -314,7 +314,6 @@ class Page { | |||
...newData.annotations | |||
); | |||
|
|||
this.xref.resetNewRef(); |
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.
This was already fixed in PR #15089
src/display/annotation_storage.js
Outdated
@@ -145,6 +145,7 @@ class AnnotationStorage { | |||
const val = value instanceof AnnotationEditor ? value.serialize() : value; | |||
clone.set(key, val); | |||
} | |||
|
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.
Nit: Unrelated change.
|
||
this.div.style.width = flipOrientation ? heightStr : widthStr; | ||
this.div.style.height = flipOrientation ? widthStr : heightStr; | ||
this.div.setAttribute("data-annotation-rotation", rotation); |
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.
This looks like too much copy-and-pasting, since I'm assuming that you actually mean the following :-)
this.div.setAttribute("data-annotation-rotation", rotation); | |
this.div.setAttribute("data-editor-rotation", rotation); |
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.
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
?
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.
So likely, the name
data-annotation-rotation
is bad, do you have any suggestion ? maybedata-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.
src/display/editor/editor.js
Outdated
} | ||
|
||
/** | ||
* Translate the editor position within its parent. | ||
* @param {number} x | ||
* @param {number} y | ||
* @param {boolean} isScreen. |
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.
This parameter doesn't exist below, please remove it from the JSDoc.
@@ -131,21 +127,51 @@ class AnnotationEditor { | |||
* @param {number} x | |||
* @param {number} y |
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.
Please update the JSDoc to also list the new parameters.
src/display/editor/ink.js
Outdated
case 270: | ||
return [height, 0, width, height]; | ||
} | ||
return [0, 0, width, height]; |
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.
In other switch
-statements, for example in screenToPageTranslation
, you've used the following format:
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, |
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.
This line looks identical to the one below, did you mean the following?
.annotationEditorLayer .inkEditor.disabled:focus, | |
.annotationEditorLayer .freeTextEditor.disabled:focus, |
2761f06
to
0830d4b
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/96536a0bb76291a/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/9bef82b31a7d175/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/96536a0bb76291a/output.txt Total script time: 26.30 mins
Image differences available at: http://54.241.84.105:8877/96536a0bb76291a/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/9bef82b31a7d175/output.txt Total script time: 29.02 mins
Image differences available at: http://54.193.163.58:8877/9bef82b31a7d175/reftest-analyzer.html#web=eq.log |
src/display/editor/editor.js
Outdated
@@ -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. |
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.
Typo?
* @param {number} ty - xy-translation in screen coordinates. | |
* @param {number} ty - y-translation in screen coordinates. |
src/display/editor/editor.js
Outdated
} | ||
|
||
/** | ||
* Translate the editor position within its parent. | ||
* @param {number} x - x-translation in screen coordinates. | ||
* @param {number} y - xy-translation in screen coordinates. |
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.
Typo?
* @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.
0830d4b
to
0c420f5
Compare
[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%); | ||
} | ||
|
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.
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.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/1a191ba09fbe6da/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/6c98ec426c59d97/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/1a191ba09fbe6da/output.txt Total script time: 26.30 mins
Image differences available at: http://54.241.84.105:8877/1a191ba09fbe6da/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/6c98ec426c59d97/output.txt Total script time: 28.54 mins
|
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/6b871846394b1a5/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 1 Live output at: http://54.193.163.58:8877/59a37956d8becec/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/6b871846394b1a5/output.txt Total script time: 22.80 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/59a37956d8becec/output.txt Total script time: 22.40 mins
|
angle is not zero;
when the main page is itself rotated;