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 ***** */
|
* ***** 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
|
// General util/convenience tools
|
||||||
//
|
//
|
||||||
@ -71,8 +61,8 @@ let Util = {
|
|||||||
|
|
||||||
/** printf-like dump function */
|
/** printf-like dump function */
|
||||||
dumpf: function dumpf(str) {
|
dumpf: function dumpf(str) {
|
||||||
var args = arguments;
|
let args = arguments;
|
||||||
var i = 1;
|
let i = 1;
|
||||||
dump(str.replace(/%s/g, function() {
|
dump(str.replace(/%s/g, function() {
|
||||||
if (i >= args.length) {
|
if (i >= args.length) {
|
||||||
throw "dumps received too many placeholders and not enough arguments";
|
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 */
|
/** Like dump, but each arg is handled and there's an automatic newline */
|
||||||
dumpLn: function dumpLn() {
|
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");
|
dump("\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -92,9 +83,9 @@ let Util = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getScrollOffset: function getScrollOffset(aWindow) {
|
getScrollOffset: function getScrollOffset(aWindow) {
|
||||||
var cwu = Util.getWindowUtils(aWindow);
|
let cwu = Util.getWindowUtils(aWindow);
|
||||||
var scrollX = {};
|
let scrollX = {};
|
||||||
var scrollY = {};
|
let scrollY = {};
|
||||||
cwu.getScrollXY(false, scrollX, scrollY);
|
cwu.getScrollXY(false, scrollX, scrollY);
|
||||||
return new Point(scrollX.value, scrollY.value);
|
return new Point(scrollX.value, scrollY.value);
|
||||||
},
|
},
|
||||||
@ -213,11 +204,6 @@ let Util = {
|
|||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Capitalize first letter of a string. */
|
|
||||||
capitalize: function(str) {
|
|
||||||
return str.charAt(0).toUpperCase() + str.substring(1);
|
|
||||||
},
|
|
||||||
|
|
||||||
isPortrait: function isPortrait() {
|
isPortrait: function isPortrait() {
|
||||||
return (window.innerWidth < 500);
|
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;
|
return PlacesUtils;
|
||||||
});
|
});
|
||||||
|
|
||||||
const TOOLBARSTATE_LOADING = 1;
|
XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", "@mozilla.org/browser/nav-history-service;1", "nsINavHistoryService", "nsIBrowserHistory");
|
||||||
const TOOLBARSTATE_LOADED = 2;
|
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"],
|
||||||
"gHistSvc",
|
["HistoryList", "history-items", "cmd_history"],
|
||||||
"@mozilla.org/browser/nav-history-service;1",
|
["BookmarkList", "bookmarks-items", "cmd_bookmarks"],
|
||||||
[Ci.nsINavHistoryService, Ci.nsIBrowserHistory]
|
#ifdef MOZ_SERVICES_SYNC
|
||||||
],
|
["RemoteTabsList", "remotetabs-items", "cmd_remoteTabs"]
|
||||||
[
|
#endif
|
||||||
"gFaviconService",
|
].forEach(function(aPanel) {
|
||||||
"@mozilla.org/browser/favicon-service;1",
|
let [name, id, command] = aPanel;
|
||||||
[Ci.nsIFaviconService]
|
XPCOMUtils.defineLazyGetter(window, name, function() {
|
||||||
],
|
return new AwesomePanel(id, command);
|
||||||
[
|
|
||||||
"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];
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = {
|
var BrowserUI = {
|
||||||
_edit : null,
|
_edit : null,
|
||||||
_throbber : 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 HTMLIFrameElement = Ci.nsIDOMHTMLIFrameElement;
|
||||||
let HTMLFrameElement = Ci.nsIDOMHTMLFrameElement;
|
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 **/
|
/** Watches for mouse click in content and redirect them to the best found target **/
|
||||||
const ElementTouchHelper = {
|
const ElementTouchHelper = {
|
||||||
|
Loading…
Reference in New Issue
Block a user