forked from mirrors/gecko-dev
Bug 1823763 - Convert toolkit/components/reader to ES modules. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D173183
This commit is contained in:
parent
475d4dd995
commit
07446898da
10 changed files with 22 additions and 41 deletions
|
|
@ -216,7 +216,7 @@ toolkit/components/reader/Readability-readerable.js
|
||||||
toolkit/components/reader/JSDOMParser.js
|
toolkit/components/reader/JSDOMParser.js
|
||||||
|
|
||||||
# Uses preprocessing
|
# Uses preprocessing
|
||||||
toolkit/components/reader/Readerable.jsm
|
toolkit/components/reader/Readerable.sys.mjs
|
||||||
|
|
||||||
# Generated & special files in cld2
|
# Generated & special files in cld2
|
||||||
toolkit/components/translation/cld2/
|
toolkit/components/translation/cld2/
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ const known_scripts = {
|
||||||
"resource:///actors/LinkHandlerChild.sys.mjs",
|
"resource:///actors/LinkHandlerChild.sys.mjs",
|
||||||
"resource:///actors/SearchSERPTelemetryChild.sys.mjs",
|
"resource:///actors/SearchSERPTelemetryChild.sys.mjs",
|
||||||
"resource://gre/actors/ContentMetaChild.sys.mjs",
|
"resource://gre/actors/ContentMetaChild.sys.mjs",
|
||||||
"resource://gre/modules/Readerable.jsm",
|
"resource://gre/modules/Readerable.sys.mjs",
|
||||||
|
|
||||||
// Telemetry
|
// Telemetry
|
||||||
"resource://gre/modules/TelemetryControllerBase.sys.mjs", // bug 1470339
|
"resource://gre/modules/TelemetryControllerBase.sys.mjs", // bug 1470339
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ class EventListener extends Handler {
|
||||||
!content.document.body.classList.contains("loaded")
|
!content.document.body.classList.contains("loaded")
|
||||||
) {
|
) {
|
||||||
// Don't restore the scroll position of an about:reader page at this
|
// Don't restore the scroll position of an about:reader page at this
|
||||||
// point; listen for the custom event dispatched from AboutReader.jsm.
|
// point; listen for the custom event dispatched from AboutReader.sys.mjs.
|
||||||
content.addEventListener("AboutReaderContentReady", this);
|
content.addEventListener("AboutReaderContentReady", this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,11 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["AboutReader"];
|
|
||||||
|
|
||||||
const { ReaderMode } = ChromeUtils.import(
|
const { ReaderMode } = ChromeUtils.import(
|
||||||
"resource://gre/modules/ReaderMode.jsm"
|
"resource://gre/modules/ReaderMode.jsm"
|
||||||
);
|
);
|
||||||
const { AppConstants } = ChromeUtils.importESModule(
|
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||||
"resource://gre/modules/AppConstants.sys.mjs"
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||||
);
|
|
||||||
|
|
||||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
|
||||||
);
|
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
|
|
@ -59,7 +50,7 @@ const zoomOnMeta =
|
||||||
Services.prefs.getIntPref("mousewheel.with_meta.action", 1) == 3;
|
Services.prefs.getIntPref("mousewheel.with_meta.action", 1) == 3;
|
||||||
const isAppLocaleRTL = Services.locale.isAppLocaleRTL;
|
const isAppLocaleRTL = Services.locale.isAppLocaleRTL;
|
||||||
|
|
||||||
var AboutReader = function(
|
export var AboutReader = function(
|
||||||
actor,
|
actor,
|
||||||
articlePromise,
|
articlePromise,
|
||||||
docContentType = "document",
|
docContentType = "document",
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["ReaderMode"];
|
|
||||||
|
|
||||||
// Constants for telemetry.
|
// Constants for telemetry.
|
||||||
const DOWNLOAD_SUCCESS = 0;
|
const DOWNLOAD_SUCCESS = 0;
|
||||||
|
|
@ -31,9 +28,7 @@ const CLASSES_TO_PRESERVE = [
|
||||||
"wp-smiley",
|
"wp-smiley",
|
||||||
];
|
];
|
||||||
|
|
||||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
|
||||||
);
|
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
|
|
@ -57,7 +52,7 @@ const gIsFirefoxDesktop =
|
||||||
|
|
||||||
Services.telemetry.setEventRecordingEnabled("readermode", true);
|
Services.telemetry.setEventRecordingEnabled("readermode", true);
|
||||||
|
|
||||||
var ReaderMode = {
|
export var ReaderMode = {
|
||||||
DEBUG: 0,
|
DEBUG: 0,
|
||||||
|
|
||||||
// For time spent telemetry
|
// For time spent telemetry
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to a dedicated thread handling readability parsing.
|
* Interface to a dedicated thread handling readability parsing.
|
||||||
*/
|
*/
|
||||||
|
|
@ -12,8 +10,6 @@ const { BasePromiseWorker } = ChromeUtils.import(
|
||||||
"resource://gre/modules/PromiseWorker.jsm"
|
"resource://gre/modules/PromiseWorker.jsm"
|
||||||
);
|
);
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["ReaderWorker"];
|
export var ReaderWorker = new BasePromiseWorker(
|
||||||
|
|
||||||
var ReaderWorker = new BasePromiseWorker(
|
|
||||||
"resource://gre/modules/reader/ReaderWorker.js"
|
"resource://gre/modules/reader/ReaderWorker.js"
|
||||||
);
|
);
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// This file and Readability-readerable.js are merged together into
|
// This file and Readability-readerable.js are merged together into
|
||||||
// Readerable.jsm.
|
// Readerable.sys.mjs.
|
||||||
|
|
||||||
/* exported Readerable */
|
/* exported Readerable */
|
||||||
/* import-globals-from Readability-readerable.js */
|
/* import-globals-from Readability-readerable.js */
|
||||||
|
|
@ -14,10 +14,6 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||||
);
|
);
|
||||||
|
|
||||||
function isNodeVisible(node) {
|
|
||||||
return node.clientHeight > 0 && node.clientWidth > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
var Readerable = {
|
var Readerable = {
|
||||||
get isEnabledForParseOnLoad() {
|
get isEnabledForParseOnLoad() {
|
||||||
return this.isEnabled;
|
return this.isEnabled;
|
||||||
|
|
@ -43,7 +39,11 @@ var Readerable = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isProbablyReaderable(doc, isNodeVisible);
|
return isProbablyReaderable(doc, this._isNodeVisible);
|
||||||
|
},
|
||||||
|
|
||||||
|
_isNodeVisible(node) {
|
||||||
|
return node.clientHeight > 0 && node.clientWidth > 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
_blockedHosts: [
|
_blockedHosts: [
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["Readerable"];
|
|
||||||
|
|
||||||
#include Readability-readerable.js
|
#include Readability-readerable.js
|
||||||
#include Readerable.js
|
#include Readerable.js
|
||||||
|
|
||||||
|
export { Readerable };
|
||||||
|
|
@ -7,19 +7,19 @@
|
||||||
JAR_MANIFESTS += ["jar.mn"]
|
JAR_MANIFESTS += ["jar.mn"]
|
||||||
|
|
||||||
EXTRA_JS_MODULES += [
|
EXTRA_JS_MODULES += [
|
||||||
"AboutReader.jsm",
|
"AboutReader.sys.mjs",
|
||||||
"ReaderMode.jsm",
|
"ReaderMode.sys.mjs",
|
||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_PP_JS_MODULES += [
|
EXTRA_PP_JS_MODULES += [
|
||||||
"Readerable.jsm",
|
"Readerable.sys.mjs",
|
||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_JS_MODULES.reader = [
|
EXTRA_JS_MODULES.reader = [
|
||||||
"JSDOMParser.js",
|
"JSDOMParser.js",
|
||||||
"Readability.js",
|
"Readability.js",
|
||||||
"ReaderWorker.js",
|
"ReaderWorker.js",
|
||||||
"ReaderWorker.jsm",
|
"ReaderWorker.sys.mjs",
|
||||||
]
|
]
|
||||||
|
|
||||||
BROWSER_CHROME_MANIFESTS += ["test/browser.ini"]
|
BROWSER_CHROME_MANIFESTS += ["test/browser.ini"]
|
||||||
|
|
|
||||||
|
|
@ -703,7 +703,7 @@ body.hcm .color-scheme-buttons {
|
||||||
/* Article content */
|
/* Article content */
|
||||||
|
|
||||||
/* Note that any class names from the original article that we want to match on
|
/* Note that any class names from the original article that we want to match on
|
||||||
* must be added to CLASSES_TO_PRESERVE in ReaderMode.jsm, so that
|
* must be added to CLASSES_TO_PRESERVE in ReaderMode.sys.mjs, so that
|
||||||
* Readability.js doesn't strip them out */
|
* Readability.js doesn't strip them out */
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue