Bug 622423 - More delay loaded JS scripts and less via <script> includes [r=mbrubeck r=vingtetun]

This commit is contained in:
Mark Finkle 2011-01-04 14:22:30 -05:00
Родитель 079833692e
Коммит bbe35dc89a
4 изменённых файлов: 107 добавлений и 31 удалений

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

@ -0,0 +1,103 @@
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Mobile Browser.
*
* The Initial Developer of the Original Code is
* Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mark Finkle <mfinkle@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
/**
* Delay load some JS modules
*/
XPCOMUtils.defineLazyGetter(this, "PluralForm", function() {
Cu.import("resource://gre/modules/PluralForm.jsm");
return PluralForm;
});
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Cu.import("resource://gre/modules/PlacesUtils.jsm");
return PlacesUtils;
});
/**
* Delay load some browser scripts
*/
[
["Sanitizer", "chrome://browser/content/sanitize.js"],
["ExtensionsView", "chrome://browser/content/extensions.js"],
["DownloadsView", "chrome://browser/content/downloads.js"],
["PreferencesView", "chrome://browser/content/preferences.js"],
["ConsoleView", "chrome://browser/content/console.js"],
["AnimatedZoom", "chrome://browser/content/AnimatedZoom.js"],
["CommandUpdater", "chrome://browser/content/commandUtil.js"],
#ifdef MOZ_SERVICES_SYNC
["WeaveGlue", "chrome://browser/content/sync.js"],
#endif
["SSLExceptions", "chrome://browser/content/exceptions.js"]
].forEach(function (aScript) {
let [name, script] = aScript;
XPCOMUtils.defineLazyGetter(window, name, function() {
let sandbox = {};
Services.scriptloader.loadSubScript(script, sandbox);
return sandbox[name];
});
});
/**
* Delay load some global scripts using a custom namespace
*/
XPCOMUtils.defineLazyGetter(this, "GlobalOverlay", function() {
let GlobalOverlay = {};
Services.scriptloader.loadSubScript("chrome://global/content/globalOverlay.js", GlobalOverlay);
return GlobalOverlay;
});
XPCOMUtils.defineLazyGetter(this, "ContentAreaUtils", function() {
let ContentAreaUtils = {};
Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils);
return ContentAreaUtils;
});
XPCOMUtils.defineLazyGetter(this, "ZoomManager", function() {
let sandbox = {};
Services.scriptloader.loadSubScript("chrome://global/content/viewZoomOverlay.js", sandbox);
return sandbox.ZoomManager;
});
XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", "@mozilla.org/browser/nav-history-service;1", "nsINavHistoryService", "nsIBrowserHistory");
XPCOMUtils.defineLazyServiceGetter(window, "gURIFixup", "@mozilla.org/docshell/urifixup;1", "nsIURIFixup");
XPCOMUtils.defineLazyServiceGetter(window, "gFaviconService", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
XPCOMUtils.defineLazyServiceGetter(window, "gFocusManager", "@mozilla.org/focus-manager;1", "nsIFocusManager");

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

@ -40,21 +40,6 @@
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "PluralForm", function() {
Cu.import("resource://gre/modules/PluralForm.jsm");
return PluralForm;
});
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Cu.import("resource://gre/modules/PlacesUtils.jsm");
return PlacesUtils;
});
XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", "@mozilla.org/browser/nav-history-service;1", "nsINavHistoryService", "nsIBrowserHistory");
XPCOMUtils.defineLazyServiceGetter(window, "gURIFixup", "@mozilla.org/docshell/urifixup;1", "nsIURIFixup");
XPCOMUtils.defineLazyServiceGetter(window, "gFaviconService", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
XPCOMUtils.defineLazyServiceGetter(window, "gFocusManager", "@mozilla.org/focus-manager;1", "nsIFocusManager");
[
["AllPagesList", "popup_autocomplete", "cmd_openLocation"],
["HistoryList", "history-items", "cmd_history"],
@ -1105,7 +1090,7 @@ var BrowserUI = {
this.activePanel = RemoteTabsList;
break;
case "cmd_quit":
goQuitApplication();
GlobalOverlay.goQuitApplication();
break;
case "cmd_close":
this._closeOrQuit();
@ -1375,7 +1360,7 @@ var PageActions = {
savePageAsPDF: function saveAsPDF() {
let browser = Browser.selectedBrowser;
let fileName = getDefaultFileName(browser.contentTitle, browser.documentURI, null, null);
let fileName = ContentAreaUtils.getDefaultFileName(browser.contentTitle, browser.documentURI, null, null);
fileName = fileName.trim() + ".pdf";
let displayName = fileName;
#ifdef MOZ_PLATFORM_MAEMO

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

@ -75,24 +75,11 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/commandUtil.js"/>
<script type="application/javascript" src="chrome://browser/content/exceptions.js"/>
<script type="application/javascript" src="chrome://browser/content/browser.js"/>
<script type="application/javascript" src="chrome://browser/content/browser-ui.js"/>
<script type="application/javascript" src="chrome://browser/content/sanitize.js"/>
<script type="application/javascript" src="chrome://browser/content/preferences.js"/>
<script type="application/javascript" src="chrome://browser/content/extensions.js"/>
<script type="application/javascript" src="chrome://browser/content/downloads.js"/>
<script type="application/javascript" src="chrome://browser/content/console.js"/>
<script type="application/javascript" src="chrome://browser/content/browser-scripts.js"/>
<script type="application/javascript" src="chrome://browser/content/Util.js"/>
<script type="application/javascript" src="chrome://browser/content/input.js"/>
<script type="application/javascript" src="chrome://browser/content/AnimatedZoom.js"/>
#ifdef MOZ_SERVICES_SYNC
<script type="application/javascript" src="chrome://browser/content/sync.js"/>
#endif
<broadcasterset id="broadcasterset">
<broadcaster id="bcast_contentShowing"/>

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

@ -20,6 +20,7 @@ chrome.jar:
* content/browser.xul (content/browser.xul)
* content/browser.js (content/browser.js)
* content/browser-ui.js (content/browser-ui.js)
* content/browser-scripts.js (content/browser-scripts.js)
content/content.js (content/content.js)
content/commandUtil.js (content/commandUtil.js)
* content/bindings.xml (content/bindings.xml)