mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 593237 - Use defineLazyGetter/defineLazyGetterService [r=mbrubeck]
This commit is contained in:
parent
0caf1af992
commit
e7f53e95ae
@ -39,16 +39,6 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
let Ci = Components.interfaces;
|
||||
|
||||
// Blindly copied from Safari documentation for now.
|
||||
const kViewportMinScale = 0;
|
||||
const kViewportMaxScale = 10;
|
||||
const kViewportMinWidth = 200;
|
||||
const kViewportMaxWidth = 10000;
|
||||
const kViewportMinHeight = 223;
|
||||
const kViewportMaxHeight = 10000;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// General util/convenience tools
|
||||
//
|
||||
@ -71,8 +61,8 @@ let Util = {
|
||||
|
||||
/** printf-like dump function */
|
||||
dumpf: function dumpf(str) {
|
||||
var args = arguments;
|
||||
var i = 1;
|
||||
let args = arguments;
|
||||
let i = 1;
|
||||
dump(str.replace(/%s/g, function() {
|
||||
if (i >= args.length) {
|
||||
throw "dumps received too many placeholders and not enough arguments";
|
||||
@ -83,7 +73,8 @@ let Util = {
|
||||
|
||||
/** Like dump, but each arg is handled and there's an automatic newline */
|
||||
dumpLn: function dumpLn() {
|
||||
for (var i = 0; i < arguments.length; i++) { dump(arguments[i] + " "); }
|
||||
for (let i = 0; i < arguments.length; i++)
|
||||
dump(arguments[i] + " ");
|
||||
dump("\n");
|
||||
},
|
||||
|
||||
@ -92,9 +83,9 @@ let Util = {
|
||||
},
|
||||
|
||||
getScrollOffset: function getScrollOffset(aWindow) {
|
||||
var cwu = Util.getWindowUtils(aWindow);
|
||||
var scrollX = {};
|
||||
var scrollY = {};
|
||||
let cwu = Util.getWindowUtils(aWindow);
|
||||
let scrollX = {};
|
||||
let scrollY = {};
|
||||
cwu.getScrollXY(false, scrollX, scrollY);
|
||||
return new Point(scrollX.value, scrollY.value);
|
||||
},
|
||||
@ -213,11 +204,6 @@ let Util = {
|
||||
#endif
|
||||
},
|
||||
|
||||
/** Capitalize first letter of a string. */
|
||||
capitalize: function(str) {
|
||||
return str.charAt(0).toUpperCase() + str.substring(1);
|
||||
},
|
||||
|
||||
isPortrait: function isPortrait() {
|
||||
return (window.innerWidth < 500);
|
||||
}
|
||||
@ -290,30 +276,3 @@ Util.Timeout.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cache of commonly used elements.
|
||||
*/
|
||||
let Elements = {};
|
||||
|
||||
[
|
||||
["browserBundle", "bundle_browser"],
|
||||
["contentShowing", "bcast_contentShowing"],
|
||||
["urlbarState", "bcast_urlbarState"],
|
||||
["stack", "stack"],
|
||||
["tabs", "tabs-container"],
|
||||
["controls", "browser-controls"],
|
||||
["panelUI", "panel-container"],
|
||||
["viewBuffer", "view-buffer"],
|
||||
["toolbarContainer", "toolbar-container"],
|
||||
].forEach(function (elementGlobal) {
|
||||
let [name, id] = elementGlobal;
|
||||
Elements.__defineGetter__(name, function () {
|
||||
let element = document.getElementById(id);
|
||||
if (!element)
|
||||
return null;
|
||||
delete Elements[name];
|
||||
return Elements[name] = element;
|
||||
});
|
||||
});
|
||||
|
@ -49,41 +49,50 @@ XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
|
||||
return PlacesUtils;
|
||||
});
|
||||
|
||||
const TOOLBARSTATE_LOADING = 1;
|
||||
const TOOLBARSTATE_LOADED = 2;
|
||||
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");
|
||||
|
||||
[
|
||||
[
|
||||
"gHistSvc",
|
||||
"@mozilla.org/browser/nav-history-service;1",
|
||||
[Ci.nsINavHistoryService, Ci.nsIBrowserHistory]
|
||||
],
|
||||
[
|
||||
"gFaviconService",
|
||||
"@mozilla.org/browser/favicon-service;1",
|
||||
[Ci.nsIFaviconService]
|
||||
],
|
||||
[
|
||||
"gURIFixup",
|
||||
"@mozilla.org/docshell/urifixup;1",
|
||||
[Ci.nsIURIFixup]
|
||||
],
|
||||
[
|
||||
"gFocusManager",
|
||||
"@mozilla.org/focus-manager;1",
|
||||
[Ci.nsIFocusManager]
|
||||
]
|
||||
].forEach(function (service) {
|
||||
let [name, contract, ifaces] = service;
|
||||
window.__defineGetter__(name, function () {
|
||||
delete window[name];
|
||||
window[name] = Cc[contract].getService(ifaces.splice(0, 1)[0]);
|
||||
if (ifaces.length)
|
||||
ifaces.forEach(function (i) { return window[name].QueryInterface(i); });
|
||||
return window[name];
|
||||
["AllPagesList", "popup_autocomplete", "cmd_openLocation"],
|
||||
["HistoryList", "history-items", "cmd_history"],
|
||||
["BookmarkList", "bookmarks-items", "cmd_bookmarks"],
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
["RemoteTabsList", "remotetabs-items", "cmd_remoteTabs"]
|
||||
#endif
|
||||
].forEach(function(aPanel) {
|
||||
let [name, id, command] = aPanel;
|
||||
XPCOMUtils.defineLazyGetter(window, name, function() {
|
||||
return new AwesomePanel(id, command);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Cache of commonly used elements.
|
||||
*/
|
||||
let Elements = {};
|
||||
|
||||
[
|
||||
["browserBundle", "bundle_browser"],
|
||||
["contentShowing", "bcast_contentShowing"],
|
||||
["urlbarState", "bcast_urlbarState"],
|
||||
["stack", "stack"],
|
||||
["tabs", "tabs-container"],
|
||||
["controls", "browser-controls"],
|
||||
["panelUI", "panel-container"],
|
||||
["viewBuffer", "view-buffer"],
|
||||
["toolbarContainer", "toolbar-container"],
|
||||
].forEach(function (aElementGlobal) {
|
||||
let [name, id] = aElementGlobal;
|
||||
XPCOMUtils.defineLazyGetter(Elements, name, function() {
|
||||
return document.getElementById(id);
|
||||
});
|
||||
});
|
||||
|
||||
const TOOLBARSTATE_LOADING = 1;
|
||||
const TOOLBARSTATE_LOADED = 2;
|
||||
|
||||
var BrowserUI = {
|
||||
_edit : null,
|
||||
_throbber : null,
|
||||
@ -2483,22 +2492,3 @@ var SharingUI = {
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "HistoryList", function() {
|
||||
return new AwesomePanel("history-items", "cmd_history");
|
||||
});
|
||||
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
XPCOMUtils.defineLazyGetter(this, "RemoteTabsList", function() {
|
||||
return new AwesomePanel("remotetabs-items", "cmd_remoteTabs");
|
||||
});
|
||||
#endif
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "AllPagesList", function() {
|
||||
return new AwesomePanel("popup_autocomplete", "cmd_openLocation");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "BookmarkList", function() {
|
||||
return new AwesomePanel("bookmarks-items", "cmd_bookmarks");
|
||||
});
|
||||
|
||||
|
@ -18,6 +18,13 @@ let HTMLHtmlElement = Ci.nsIDOMHTMLHtmlElement;
|
||||
let HTMLIFrameElement = Ci.nsIDOMHTMLIFrameElement;
|
||||
let HTMLFrameElement = Ci.nsIDOMHTMLFrameElement;
|
||||
|
||||
// Blindly copied from Safari documentation for now.
|
||||
const kViewportMinScale = 0;
|
||||
const kViewportMaxScale = 10;
|
||||
const kViewportMinWidth = 200;
|
||||
const kViewportMaxWidth = 10000;
|
||||
const kViewportMinHeight = 223;
|
||||
const kViewportMaxHeight = 10000;
|
||||
|
||||
/** Watches for mouse click in content and redirect them to the best found target **/
|
||||
const ElementTouchHelper = {
|
||||
|
Loading…
Reference in New Issue
Block a user