1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Tweak the new mouseState parameter, and its usage, in the viewer components and the AnnotationLayer

- Actually remove the `isDown` property when destroying the scripting-instance.

 - Mark all `mouseState` usage as "private" in the various classes.

 - Ensure that the `AnnotationLayer` actually treats the parameter as properly *optional*, the same way that the viewer components do.

 - For now remove the `mouseState` parameter from the `PDFPageView` class, and keep it only on the `BaseViewer`, since it's questionable if all of the scripting-functionality will work all that well without e.g. a full `BaseViewer`.

 - Append the `mouseState` to the JSDoc for the `AnnotationElement` class, and just move its definition into the base-`AnnotationElement` class.
This commit is contained in:
Jonas Jenwald 2020-12-17 12:55:58 +01:00
parent e6e2809825
commit 6dc39cb873
5 changed files with 11 additions and 10 deletions

View file

@ -47,6 +47,7 @@ import { ColorConverters } from "../shared/scripting_utils.js";
* @property {Object} svgFactory
* @property {boolean} [enableScripting]
* @property {boolean} [hasJSActions]
* @property {Object} [mouseState]
*/
class AnnotationElementFactory {
@ -155,6 +156,7 @@ class AnnotationElement {
this.annotationStorage = parameters.annotationStorage;
this.enableScripting = parameters.enableScripting;
this.hasJSActions = parameters.hasJSActions;
this._mouseState = parameters.mouseState;
if (isRenderable) {
this.container = this._createContainer(ignoreBorder);
@ -590,7 +592,6 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
parameters.renderInteractiveForms ||
(!parameters.data.hasAppearance && !!parameters.data.fieldValue);
super(parameters, { isRenderable });
this.mouseState = parameters.mouseState;
}
render() {
@ -734,7 +735,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
const _blurListener = blurListener;
blurListener = null;
element.addEventListener("blur", event => {
if (this.mouseState.isDown) {
if (this._mouseState.isDown) {
// Focus out using the mouse: data are committed
elementData.userValue = event.target.value;
window.dispatchEvent(
@ -1951,7 +1952,7 @@ class AnnotationLayer {
parameters.annotationStorage || new AnnotationStorage(),
enableScripting: parameters.enableScripting,
hasJSActions: parameters.hasJSActions,
mouseState: parameters.mouseState,
mouseState: parameters.mouseState || { isDown: false },
});
if (element.isRenderable) {
const rendered = element.render();