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
|
||||
|
||||
# Uses preprocessing
|
||||
toolkit/components/reader/Readerable.jsm
|
||||
toolkit/components/reader/Readerable.sys.mjs
|
||||
|
||||
# Generated & special files in cld2
|
||||
toolkit/components/translation/cld2/
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ const known_scripts = {
|
|||
"resource:///actors/LinkHandlerChild.sys.mjs",
|
||||
"resource:///actors/SearchSERPTelemetryChild.sys.mjs",
|
||||
"resource://gre/actors/ContentMetaChild.sys.mjs",
|
||||
"resource://gre/modules/Readerable.jsm",
|
||||
"resource://gre/modules/Readerable.sys.mjs",
|
||||
|
||||
// Telemetry
|
||||
"resource://gre/modules/TelemetryControllerBase.sys.mjs", // bug 1470339
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class EventListener extends Handler {
|
|||
!content.document.body.classList.contains("loaded")
|
||||
) {
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,11 @@
|
|||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["AboutReader"];
|
||||
|
||||
const { ReaderMode } = ChromeUtils.import(
|
||||
"resource://gre/modules/ReaderMode.jsm"
|
||||
);
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
|
|
@ -59,7 +50,7 @@ const zoomOnMeta =
|
|||
Services.prefs.getIntPref("mousewheel.with_meta.action", 1) == 3;
|
||||
const isAppLocaleRTL = Services.locale.isAppLocaleRTL;
|
||||
|
||||
var AboutReader = function(
|
||||
export var AboutReader = function(
|
||||
actor,
|
||||
articlePromise,
|
||||
docContentType = "document",
|
||||
|
|
@ -2,9 +2,6 @@
|
|||
/* 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,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["ReaderMode"];
|
||||
|
||||
// Constants for telemetry.
|
||||
const DOWNLOAD_SUCCESS = 0;
|
||||
|
|
@ -31,9 +28,7 @@ const CLASSES_TO_PRESERVE = [
|
|||
"wp-smiley",
|
||||
];
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||
|
||||
const lazy = {};
|
||||
|
||||
|
|
@ -57,7 +52,7 @@ const gIsFirefoxDesktop =
|
|||
|
||||
Services.telemetry.setEventRecordingEnabled("readermode", true);
|
||||
|
||||
var ReaderMode = {
|
||||
export var ReaderMode = {
|
||||
DEBUG: 0,
|
||||
|
||||
// For time spent telemetry
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Interface to a dedicated thread handling readability parsing.
|
||||
*/
|
||||
|
|
@ -12,8 +10,6 @@ const { BasePromiseWorker } = ChromeUtils.import(
|
|||
"resource://gre/modules/PromiseWorker.jsm"
|
||||
);
|
||||
|
||||
var EXPORTED_SYMBOLS = ["ReaderWorker"];
|
||||
|
||||
var ReaderWorker = new BasePromiseWorker(
|
||||
export var ReaderWorker = new BasePromiseWorker(
|
||||
"resource://gre/modules/reader/ReaderWorker.js"
|
||||
);
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
"use strict";
|
||||
|
||||
// This file and Readability-readerable.js are merged together into
|
||||
// Readerable.jsm.
|
||||
// Readerable.sys.mjs.
|
||||
|
||||
/* exported Readerable */
|
||||
/* import-globals-from Readability-readerable.js */
|
||||
|
|
@ -14,10 +14,6 @@ const { XPCOMUtils } = ChromeUtils.importESModule(
|
|||
"resource://gre/modules/XPCOMUtils.sys.mjs"
|
||||
);
|
||||
|
||||
function isNodeVisible(node) {
|
||||
return node.clientHeight > 0 && node.clientWidth > 0;
|
||||
}
|
||||
|
||||
var Readerable = {
|
||||
get isEnabledForParseOnLoad() {
|
||||
return this.isEnabled;
|
||||
|
|
@ -43,7 +39,11 @@ var Readerable = {
|
|||
return false;
|
||||
}
|
||||
|
||||
return isProbablyReaderable(doc, isNodeVisible);
|
||||
return isProbablyReaderable(doc, this._isNodeVisible);
|
||||
},
|
||||
|
||||
_isNodeVisible(node) {
|
||||
return node.clientHeight > 0 && node.clientWidth > 0;
|
||||
},
|
||||
|
||||
_blockedHosts: [
|
||||
|
|
|
|||
|
|
@ -2,9 +2,8 @@
|
|||
/* 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,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Readerable"];
|
||||
|
||||
#include Readability-readerable.js
|
||||
#include Readerable.js
|
||||
|
||||
export { Readerable };
|
||||
|
|
@ -7,19 +7,19 @@
|
|||
JAR_MANIFESTS += ["jar.mn"]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"AboutReader.jsm",
|
||||
"ReaderMode.jsm",
|
||||
"AboutReader.sys.mjs",
|
||||
"ReaderMode.sys.mjs",
|
||||
]
|
||||
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
"Readerable.jsm",
|
||||
"Readerable.sys.mjs",
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES.reader = [
|
||||
"JSDOMParser.js",
|
||||
"Readability.js",
|
||||
"ReaderWorker.js",
|
||||
"ReaderWorker.jsm",
|
||||
"ReaderWorker.sys.mjs",
|
||||
]
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ["test/browser.ini"]
|
||||
|
|
|
|||
|
|
@ -703,7 +703,7 @@ body.hcm .color-scheme-buttons {
|
|||
/* Article content */
|
||||
|
||||
/* 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 */
|
||||
|
||||
.container {
|
||||
|
|
|
|||
Loading…
Reference in a new issue