Bug 1111142 - (Part 2) Load AboutReader in a frame script on Fennec. r=mfinkle,bnicholson

--HG--
extra : rebase_source : 18bd3f75e7ab32a7a29e3c11708db55d8dffc124
This commit is contained in:
Margaret Leibovic 2014-12-23 15:32:15 -05:00
Родитель 7bc6c6fb9c
Коммит cbf1d77ac3
7 изменённых файлов: 54 добавлений и 19 удалений

Просмотреть файл

@ -109,9 +109,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "SharedPreferences",
XPCOMUtils.defineLazyModuleGetter(this, "Notifications",
"resource://gre/modules/Notifications.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutReader",
"resource://gre/modules/AboutReader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
"resource://gre/modules/ReaderMode.jsm");
@ -502,6 +499,8 @@ var BrowserApp = {
// Tiles reporting is disabled.
}
window.messageManager.loadFrameScript("chrome://browser/content/content.js", true);
// Notify Java that Gecko has loaded.
Messaging.sendRequest({ type: "Gecko:Ready" });
},
@ -3963,14 +3962,6 @@ Tab.prototype = {
}
if (docURI.startsWith("about:reader")) {
// During browser restart / recovery, duplicate "DOMContentLoaded" messages are received here
// For the visible tab ... where more than one tab is being reloaded, the inital "DOMContentLoaded"
// Message can be received before the document body is available ... so we avoid instantiating an
// AboutReader object, expecting that an eventual valid message will follow.
let contentDocument = this.browser.contentDocument;
if (contentDocument.body) {
new AboutReader(contentDocument, this.browser.contentWindow);
}
// Update the page action to show the "reader active" icon.
Reader.updatePageAction(this);
}

Просмотреть файл

@ -0,0 +1,38 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* 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/. */
let { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AboutReader", "resource://gre/modules/AboutReader.jsm");
let dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.d.bind(null, "Content");
let AboutReaderListener = {
init: function(chromeGlobal) {
chromeGlobal.addEventListener("AboutReaderContentLoaded", this, false, true);
},
handleEvent: function(event) {
if (!event.originalTarget.documentURI.startsWith("about:reader")) {
return;
}
switch (event.type) {
case "AboutReaderContentLoaded":
// If we are restoring multiple reader mode tabs during session restore, duplicate "DOMContentLoaded"
// events may be fired for the visible tab. The inital "DOMContentLoaded" may be received before the
// document body is available, so we avoid instantiating an AboutReader object, expecting that a
// valid message will follow. See bug 925983.
if (content.document.body) {
new AboutReader(content.document, content);
}
break;
}
}
};
AboutReaderListener.init(this);

Просмотреть файл

@ -10,6 +10,7 @@ chrome.jar:
* content/about.xhtml (content/about.xhtml)
content/config.xhtml (content/config.xhtml)
content/config.js (content/config.js)
content/content.js (content/content.js)
content/aboutAddons.xhtml (content/aboutAddons.xhtml)
content/aboutAddons.js (content/aboutAddons.js)
content/aboutCertError.xhtml (content/aboutCertError.xhtml)

Просмотреть файл

@ -16,14 +16,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode", "resource://gre/modules/Re
XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry", "resource://gre/modules/UITelemetry.jsm");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", function ()
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow)
.QueryInterface(Ci.nsIDOMChromeWindow));
XPCOMUtils.defineLazyGetter(this, "gChromeWin", () => Services.wm.getMostRecentWindow("navigator:browser"));
function dump(s) {
Services.console.logStringMessage("AboutReader: " + s);

Просмотреть файл

@ -6,6 +6,8 @@
<meta name="viewport" content="width=device-width; user-scalable=0" />
<link rel="stylesheet" href="chrome://global/skin/aboutReader.css" type="text/css"/>
<script type="text/javascript;version=1.8" src="chrome://global/content/reader/aboutReader.js"></script>
</head>
<body>

Просмотреть файл

@ -0,0 +1,9 @@
/* 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";
window.addEventListener("DOMContentLoaded", function () {
document.dispatchEvent(new CustomEvent("AboutReaderContentLoaded", { bubbles: true }));
});

Просмотреть файл

@ -4,6 +4,7 @@
toolkit.jar:
content/global/reader/aboutReader.html (content/aboutReader.html)
content/global/reader/aboutReader.js (content/aboutReader.js)
content/global/reader/Readability.js (content/Readability.js)
content/global/reader/JSDOMParser.js (content/JSDOMParser.js)
content/global/reader/readerWorker.js (content/readerWorker.js)