mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:47:58 +01:00
Fix some CPOW issues. Everything is still terrible, though.
This commit is contained in:
@@ -696,7 +696,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
keyword, true);
|
||||
|
||||
let item = keywords[keyword];
|
||||
if (item && item.url.contains("%s"))
|
||||
if (item && item.url.includes("%s"))
|
||||
context.fork("keyword/" + keyword, keyword.length + space.length, null, context => {
|
||||
context.format = history.format;
|
||||
context.title = [/*L*/keyword + " Quick Search"];
|
||||
@@ -709,7 +709,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
return history.get({ uri: util.newURI(begin), uriIsPrefix: true }).map(function (item) {
|
||||
let rest = item.url.length - end.length;
|
||||
let query = item.url.substring(begin.length, rest);
|
||||
if (item.url.substr(rest) == end && query.contains("&"))
|
||||
if (item.url.substr(rest) == end && query.includes("&"))
|
||||
try {
|
||||
item.url = decodeURIComponent(query.replace(/[&#].*/, "").replace(/\+/g, " "));
|
||||
if (!seen.add(item.url))
|
||||
@@ -765,7 +765,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
return;
|
||||
|
||||
let words = ctxt.filter.toLowerCase().split(/\s+/g);
|
||||
ctxt.completions = ctxt.completions.filter(i => words.every(w => i.toLowerCase().contains(w)));
|
||||
ctxt.completions = ctxt.completions.filter(i => words.every(w => i.toLowerCase().includes(w)));
|
||||
|
||||
ctxt.hasItems = ctxt.completions.length;
|
||||
ctxt.incomplete = true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
|
||||
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
|
||||
// Copyright (c) 2008-2014 Kris Maglione <maglione.k at Gmail>
|
||||
// Copyright (c) 2008-2015 Kris Maglione <maglione.k at Gmail>
|
||||
//
|
||||
// This work is licensed for reuse under an MIT license. Details are
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
@@ -106,7 +106,10 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
else {
|
||||
// code which should happen for all (also background) newly loaded tabs goes here:
|
||||
if (doc != config.browser.contentDocument)
|
||||
dactyl.echomsg({ domains: [util.getHost(doc.location)], message: _("buffer.backgroundLoaded", (doc.title || doc.location.href)) }, 3);
|
||||
dactyl.echomsg({
|
||||
domains: [util.getHost(doc.location)],
|
||||
message: _("buffer.backgroundLoaded", (doc.title || doc.location.href))
|
||||
}, 3);
|
||||
|
||||
this._triggerLoadAutocmd("PageLoad", doc);
|
||||
}
|
||||
@@ -161,10 +164,11 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
dactyl.applyTriggerObserver("browser.locationChange", arguments);
|
||||
|
||||
let win = webProgress.DOMWindow;
|
||||
if (win && uri) {
|
||||
if (win && uri && !Cu.isCrossProcessWrapper(win)) {
|
||||
Buffer(win).updateZoom();
|
||||
|
||||
let oldURI = overlay.getData(win.document)["uri"];
|
||||
|
||||
if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex
|
||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||
for (let frame of buffer.allFrames(win))
|
||||
@@ -204,7 +208,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
onProgressChange: function onProgressChange(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {},
|
||||
|
||||
onLocationChange: util.wrapCallback(function onLocationChange(browser) {
|
||||
Buffer(browser.contentWindow).locationChanged();
|
||||
Buffer(null, browser).locationChanged();
|
||||
})
|
||||
}
|
||||
}, {
|
||||
|
||||
@@ -646,6 +646,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
* Initialize the help system.
|
||||
*/
|
||||
initHelp: function initHelp() {
|
||||
util.dumpStack('INIT HELP');
|
||||
if ("noscriptOverlay" in window)
|
||||
window.noscriptOverlay.safeAllow("dactyl:", true, false);
|
||||
|
||||
@@ -852,7 +853,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
click: function onClick(event) {
|
||||
let elem = event.originalTarget;
|
||||
|
||||
if (elem instanceof Ci.nsIDOMElement && services.security.isSystemPrincipal(elem.nodePrincipal)) {
|
||||
if (elem instanceof Ci.nsIDOMElement &&
|
||||
!Cu.isCrossProcessWrapper(elem) &&
|
||||
services.security.isSystemPrincipal(elem.nodePrincipal)) {
|
||||
let command = elem.getAttributeNS(NS, "command");
|
||||
if (command && event.button == 0) {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -784,7 +784,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
context.keys = { text: identity, description: editor.bound.getRegister };
|
||||
|
||||
context.match = function (r) {
|
||||
return !this.filter || this.filter.contains(r);
|
||||
return !this.filter || this.filter.includes(r);
|
||||
};
|
||||
|
||||
context.fork("clipboard", 0, this, ctxt => {
|
||||
|
||||
@@ -621,7 +621,8 @@ var Events = Module("events", {
|
||||
|
||||
let win = (elem.ownerDocument || elem).defaultView || elem;
|
||||
|
||||
if (!(services.focus.getLastFocusMethod(win) & 0x3000)
|
||||
if (!Cu.isCrossProcessWrapper(win) &&
|
||||
!(services.focus.getLastFocusMethod(win) & 0x3000)
|
||||
&& events.isContentNode(elem)
|
||||
&& !buffer.focusAllowed(elem)
|
||||
&& isinstance(elem, [Ci.nsIDOMHTMLInputElement,
|
||||
@@ -808,7 +809,7 @@ var Events = Module("events", {
|
||||
// Prevents certain sites from transferring focus to an input box
|
||||
// before we get a chance to process our key bindings on the
|
||||
// "keypress" event.
|
||||
if (!pass)
|
||||
if (!pass && Cu.getClassName(event, true) !== "Proxy")
|
||||
event.stopPropagation();
|
||||
},
|
||||
keydown: function onKeyDown(event) {
|
||||
|
||||
@@ -155,6 +155,9 @@ var Modes = Module("modes", {
|
||||
dactyl.focusContent(true);
|
||||
if (prev.main == modes.NORMAL) {
|
||||
dactyl.focusContent(true);
|
||||
|
||||
let { win } = buffer;
|
||||
if (!Cu.isCrossProcessWrapper(win) && win instanceof Ci.nsIDOMWindow)
|
||||
for (let frame of buffer.allFrames()) {
|
||||
// clear any selection made
|
||||
let selection = frame.getSelection();
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
let securityState = new WeakMap();
|
||||
|
||||
var StatusLine = Module("statusline", {
|
||||
init: function init() {
|
||||
this._statusLine = document.getElementById("status-bar");
|
||||
@@ -121,7 +123,7 @@ var StatusLine = Module("statusline", {
|
||||
});
|
||||
|
||||
try {
|
||||
this.security = content.document.dactylSecurity || "insecure";
|
||||
this.security = securityState.get(content) || "insecure";
|
||||
}
|
||||
catch (e) {}
|
||||
},
|
||||
@@ -179,7 +181,7 @@ var StatusLine = Module("statusline", {
|
||||
this.security = "insecure";
|
||||
|
||||
if (webProgress && webProgress.DOMWindow)
|
||||
webProgress.DOMWindow.document.dactylSecurity = this.security;
|
||||
securityState.set(webProgress.DOMWindow, this.security);
|
||||
},
|
||||
"browser.stateChange": function onStateChange(webProgress, request, flags, status) {
|
||||
const L = Ci.nsIWebProgressListener;
|
||||
@@ -261,12 +263,13 @@ var StatusLine = Module("statusline", {
|
||||
if (isinstance(uri, Ci.nsIURI)) {
|
||||
// when session information is available, add [+] when we can go
|
||||
// backwards, [-] when we can go forwards
|
||||
if (uri.equals(buffer.uri) && window.getWebNavigation) {
|
||||
let sh = window.getWebNavigation().sessionHistory;
|
||||
if (sh && sh.index > 0)
|
||||
if (uri.equals(buffer.uri)) {
|
||||
let { webNav } = buffer;
|
||||
if (webNav.canGoBack)
|
||||
modified += "-";
|
||||
if (sh && sh.index < sh.count - 1)
|
||||
if (webNav.canGoForward)
|
||||
modified += "+";
|
||||
|
||||
if (this.bookmarked)
|
||||
modified += UTF8("❤");
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ var Tabs = Module("tabs", {
|
||||
}
|
||||
},
|
||||
|
||||
_alternates: Class.Memoize(() => [config.tabbrowser.mCurrentTab, null]),
|
||||
_alternates: Class.Memoize(() => [gBrowser.mCurrentTab, null]),
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let tab of this.allTabs) {
|
||||
@@ -118,7 +118,7 @@ var Tabs = Module("tabs", {
|
||||
},
|
||||
|
||||
get allTabs() {
|
||||
return Array.slice(config.tabbrowser.tabContainer.childNodes);
|
||||
return Array.slice(gBrowser.tabs);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ var Tabs = Module("tabs", {
|
||||
*/
|
||||
get browsers() {
|
||||
return function* () {
|
||||
for (let [i, browser] of config.tabbrowser.browsers.entries())
|
||||
for (let [i, browser] of gBrowser.browsers.entries())
|
||||
if (browser !== undefined) // Bug in Google's Page Speed add-on.
|
||||
yield [i, browser];
|
||||
}();
|
||||
@@ -145,7 +145,7 @@ var Tabs = Module("tabs", {
|
||||
/**
|
||||
* @property {number} The number of tabs in the current window.
|
||||
*/
|
||||
get count() { return config.tabbrowser.mTabs.length; },
|
||||
get count() { return gBrowser.mTabs.length; },
|
||||
|
||||
/**
|
||||
* @property {Object} The local options store for the current tab.
|
||||
@@ -153,7 +153,7 @@ var Tabs = Module("tabs", {
|
||||
get options() { return this.localStore.options; },
|
||||
|
||||
get visibleTabs() {
|
||||
return config.tabbrowser.visibleTabs ||
|
||||
return gBrowser.visibleTabs ||
|
||||
this.allTabs.filter(tab => !tab.hidden);
|
||||
},
|
||||
|
||||
@@ -202,11 +202,11 @@ var Tabs = Module("tabs", {
|
||||
* @param {boolean} activate Whether to select the newly cloned tab.
|
||||
*/
|
||||
cloneTab: function cloneTab(tab, activate) {
|
||||
let newTab = config.tabbrowser.addTab("about:blank", { ownerTab: tab });
|
||||
let newTab = gBrowser.addTab("about:blank", { ownerTab: tab });
|
||||
Tabs.copyTab(newTab, tab);
|
||||
|
||||
if (activate)
|
||||
config.tabbrowser.mTabContainer.selectedItem = newTab;
|
||||
gBrowser.mTabContainer.selectedItem = newTab;
|
||||
|
||||
return newTab;
|
||||
},
|
||||
@@ -219,7 +219,7 @@ var Tabs = Module("tabs", {
|
||||
*/
|
||||
detachTab: function detachTab(tab) {
|
||||
if (!tab)
|
||||
tab = config.tabbrowser.mTabContainer.selectedItem;
|
||||
tab = gBrowser.mTabContainer.selectedItem;
|
||||
|
||||
services.windowWatcher
|
||||
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
|
||||
@@ -280,7 +280,7 @@ var Tabs = Module("tabs", {
|
||||
return index;
|
||||
if (index != null)
|
||||
return this[visible ? "visibleTabs" : "allTabs"][index];
|
||||
return config.tabbrowser.mCurrentTab;
|
||||
return gBrowser.mCurrentTab;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -293,7 +293,7 @@ var Tabs = Module("tabs", {
|
||||
*/
|
||||
index: function index(tab, visible) {
|
||||
let tabs = this[visible ? "visibleTabs" : "allTabs"];
|
||||
return tabs.indexOf(tab || config.tabbrowser.mCurrentTab);
|
||||
return tabs.indexOf(tab || gBrowser.mCurrentTab);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -340,7 +340,7 @@ var Tabs = Module("tabs", {
|
||||
* @param {Object} tab The tab to keep.
|
||||
*/
|
||||
keepOnly: function keepOnly(tab) {
|
||||
config.tabbrowser.removeAllTabsBut(tab);
|
||||
gBrowser.removeAllTabsBut(tab);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -416,7 +416,7 @@ var Tabs = Module("tabs", {
|
||||
*/
|
||||
move: function move(tab, spec, wrap) {
|
||||
let index = tabs.indexFromSpec(spec, wrap, -1);
|
||||
config.tabbrowser.moveTabTo(tab, index);
|
||||
gBrowser.moveTabTo(tab, index);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -439,7 +439,7 @@ var Tabs = Module("tabs", {
|
||||
next = index + (focusLeftTab ? 1 : -1);
|
||||
if (next in tabs) {
|
||||
this._alternates[0] = tabs[next];
|
||||
config.tabbrowser.mTabContainer.selectedItem = tabs[next];
|
||||
gBrowser.mTabContainer.selectedItem = tabs[next];
|
||||
}
|
||||
|
||||
if (focusLeftTab)
|
||||
@@ -464,10 +464,10 @@ var Tabs = Module("tabs", {
|
||||
try {
|
||||
if (bypassCache) {
|
||||
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
||||
config.tabbrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
||||
gBrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
||||
}
|
||||
else
|
||||
config.tabbrowser.reloadTab(tab);
|
||||
gBrowser.reloadTab(tab);
|
||||
}
|
||||
catch (e if !(e instanceof Error)) {}
|
||||
},
|
||||
@@ -501,7 +501,7 @@ var Tabs = Module("tabs", {
|
||||
if (index == -1)
|
||||
dactyl.beep();
|
||||
else
|
||||
config.tabbrowser.mTabContainer.selectedIndex = index;
|
||||
gBrowser.mTabContainer.selectedIndex = index;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -606,7 +606,7 @@ var Tabs = Module("tabs", {
|
||||
if (!tabs) {
|
||||
if (this.getTab() == this._alternates[0]
|
||||
|| this.alternate && this.allTabs.indexOf(this._alternates[0]) == -1
|
||||
|| this.alternate && config.tabbrowser._removingTabs && config.tabbrowser._removingTabs.indexOf(this._alternates[0]) >= 0)
|
||||
|| this.alternate && gBrowser._removingTabs && gBrowser._removingTabs.indexOf(this._alternates[0]) >= 0)
|
||||
tabs = [this.getTab(), this.alternate];
|
||||
}
|
||||
this._alternates = tabs || [this.getTab(), this._alternates[0]];
|
||||
@@ -614,7 +614,7 @@ var Tabs = Module("tabs", {
|
||||
}, {
|
||||
copyTab: function (to, from) {
|
||||
if (!from)
|
||||
from = config.tabbrowser.mTabContainer.selectedItem;
|
||||
from = gBrowser.mTabContainer.selectedItem;
|
||||
|
||||
let tabState = services.sessionStore.getTabState(from);
|
||||
services.sessionStore.setTabState(to, tabState);
|
||||
@@ -1146,7 +1146,7 @@ var Tabs = Module("tabs", {
|
||||
};
|
||||
},
|
||||
events: function initEvents() {
|
||||
let tabContainer = config.tabbrowser.mTabContainer;
|
||||
let tabContainer = gBrowser.mTabContainer;
|
||||
function callback() {
|
||||
tabs.timeout(function () { this.updateTabCount(); });
|
||||
}
|
||||
@@ -1268,8 +1268,8 @@ var Tabs = Module("tabs", {
|
||||
else
|
||||
config.tabStrip.collapsed = false;
|
||||
|
||||
if (config.tabbrowser.tabContainer._positionPinnedTabs)
|
||||
config.tabbrowser.tabContainer._positionPinnedTabs();
|
||||
if (gBrowser.tabContainer._positionPinnedTabs)
|
||||
gBrowser.tabContainer._positionPinnedTabs();
|
||||
return value;
|
||||
},
|
||||
values: {
|
||||
|
||||
@@ -275,6 +275,8 @@ literal.locations = literal_.locations;
|
||||
function apply(obj, meth, args) {
|
||||
// The function's own apply method breaks in strange ways
|
||||
// when using CPOWs.
|
||||
if (callable(meth))
|
||||
return Function.apply.call(meth, obj, args);
|
||||
return Function.apply.call(obj[meth], obj, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ lazyRequire("promises", ["CancelablePromise", "Promise", "promises"]);
|
||||
lazyRequire("sanitizer", ["sanitizer"]);
|
||||
lazyRequire("storage", ["File", "storage"]);
|
||||
lazyRequire("template", ["template"]);
|
||||
|
||||
let global = this;
|
||||
/**
|
||||
* A class to manage the primary web content buffer. The name comes
|
||||
* from Vim's term, 'buffer', which signifies instances of open
|
||||
@@ -30,14 +30,17 @@ lazyRequire("template", ["template"]);
|
||||
*/
|
||||
var Buffer = Module("Buffer", {
|
||||
Local: function Local(dactyl, modules, window) {
|
||||
let gBrowser = window.gBrowser;
|
||||
return {
|
||||
get win() { return window.content; }
|
||||
get browser() { return gBrowser.mCurrentBrowser; },
|
||||
};
|
||||
},
|
||||
|
||||
init: function init(win) {
|
||||
init: function init(win, browser) {
|
||||
if (win)
|
||||
this.win = win;
|
||||
if (browser)
|
||||
this.browser = browser;
|
||||
},
|
||||
|
||||
get addPageInfoSection() { return Buffer.bound.addPageInfoSection; },
|
||||
@@ -66,7 +69,9 @@ var Buffer = Module("Buffer", {
|
||||
/**
|
||||
* The load context of the window bound to this buffer.
|
||||
*/
|
||||
get loadContext() { return sanitizer.getContext(this.win); },
|
||||
get loadContext() {
|
||||
return sanitizer.getContext(this.win, this.topWindow);
|
||||
},
|
||||
|
||||
/**
|
||||
* Content preference methods.
|
||||
@@ -243,24 +248,62 @@ var Buffer = Module("Buffer", {
|
||||
},
|
||||
set lastInputField(value) { this.localStore.lastInputField = util.weakReference(value); },
|
||||
|
||||
get win() {
|
||||
if (this.browser)
|
||||
return this.browser.contentWindow;
|
||||
return this._win;
|
||||
},
|
||||
|
||||
set win(value) {
|
||||
this._win = value;
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {nsIURI} The current top-level document.
|
||||
*/
|
||||
get doc() { return this.win.document; },
|
||||
get doc() {
|
||||
if (this.browser)
|
||||
return this.browser.contentDocument;
|
||||
return this.win.document;
|
||||
},
|
||||
|
||||
get docShell() { return util.docShell(this.win); },
|
||||
get docShell() {
|
||||
let docShell;
|
||||
if (this.browser)
|
||||
docShell = this.browser.docShell;
|
||||
|
||||
if (!docShell && this.win && this.win.QueryInterface)
|
||||
docShell = util.docShell(this.win);
|
||||
|
||||
return docShell;
|
||||
},
|
||||
|
||||
get webNav() {
|
||||
if (this.browser)
|
||||
return this.browser.webNavigation;
|
||||
|
||||
return this.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
},
|
||||
|
||||
get modules() { return this.topWindow.dactyl.modules; },
|
||||
set modules(val) {},
|
||||
|
||||
topWindow: Class.Memoize(function () {
|
||||
if (this.browser)
|
||||
return this.browser.ownerDocument.defaultView;
|
||||
|
||||
return util.topWindow(this.win);
|
||||
}),
|
||||
|
||||
/**
|
||||
* @property {nsIURI} The current top-level document's URI.
|
||||
*/
|
||||
get uri() { return util.newURI(this.win.location.href); },
|
||||
get uri() {
|
||||
if (this.browser)
|
||||
return this.browser.currentURI.clone();
|
||||
|
||||
return util.newURI(this.win.location.href);
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {nsIURI} The current top-level document's URI, sans
|
||||
@@ -278,16 +321,20 @@ var Buffer = Module("Buffer", {
|
||||
* fragment identifier.
|
||||
*/
|
||||
get documentURI() {
|
||||
return this.doc.documentURIObject ||
|
||||
util.newURI(this.doc.documentURI);
|
||||
if (this.browser)
|
||||
return this.browser.documentURI.clone();
|
||||
|
||||
return this.uri.cloneIgnoringRef();
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {string} The current top-level document's URL.
|
||||
*/
|
||||
get URL() {
|
||||
return update(new String(this.win.location.href),
|
||||
util.newURI(this.win.location.href));
|
||||
let uri = this.browser ? this.browser.currentURI
|
||||
: util.newURI(this.win.location.href);
|
||||
|
||||
return update(new String(uri.spec), uri);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -296,6 +343,9 @@ var Buffer = Module("Buffer", {
|
||||
get pageHeight() { return this.win.innerHeight; },
|
||||
|
||||
get contentViewer() {
|
||||
if (!this.win || Cu.isCrossProcessWrapper(this.win) || !this.docShell)
|
||||
return null; // e10s
|
||||
|
||||
return this.docShell.contentViewer
|
||||
.QueryInterface(Ci.nsIMarkupDocumentViewer ||
|
||||
Ci.nsIContentViewer);
|
||||
@@ -307,6 +357,9 @@ var Buffer = Module("Buffer", {
|
||||
*/
|
||||
get zoomLevel() {
|
||||
let v = this.contentViewer;
|
||||
if (v == null)
|
||||
return this.ZoomManager.zoom * 100;
|
||||
|
||||
return v[v.textZoom == 1 ? "fullZoom" : "textZoom"] * 100;
|
||||
},
|
||||
set zoomLevel(value) { this.setZoom(value, this.fullZoom); },
|
||||
@@ -323,7 +376,12 @@ var Buffer = Module("Buffer", {
|
||||
/**
|
||||
* @property {string} The current document's title.
|
||||
*/
|
||||
get title() { return this.doc.title; },
|
||||
get title() {
|
||||
if (this.browser)
|
||||
return this.browser.contentTitle;
|
||||
|
||||
return this.doc.title;
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {number} The buffer's horizontal scroll percentile.
|
||||
@@ -370,10 +428,20 @@ var Buffer = Module("Buffer", {
|
||||
* @property {Window} Returns the currently focused frame.
|
||||
*/
|
||||
get focusedFrame() {
|
||||
try {
|
||||
if (Cu.isCrossProcessWrapper(this.win))
|
||||
return this.win;
|
||||
} catch (e) {
|
||||
util.dump("WTF: " + e);
|
||||
util.dump(this.win, this.browser);
|
||||
return this.win;
|
||||
}
|
||||
|
||||
let frame = this.localStore.focusedFrame;
|
||||
return frame && frame.get() || this.win;
|
||||
},
|
||||
set focusedFrame(frame) {
|
||||
if (!Cu.isCrossProcessWrapper(this.win))
|
||||
this.localStore.focusedFrame = util.weakReference(frame);
|
||||
},
|
||||
|
||||
@@ -2652,10 +2720,18 @@ var Buffer = Module("Buffer", {
|
||||
"boolean", false,
|
||||
{
|
||||
setter: function (value) {
|
||||
return buffer.contentViewer.authorStyleDisabled = value;
|
||||
let { contentViewer } = buffer;
|
||||
|
||||
if (contentViewer)
|
||||
return contentViewer.authorStyleDisabled = value;
|
||||
return false;
|
||||
},
|
||||
getter: function () {
|
||||
return buffer.contentViewer.authorStyleDisabled;
|
||||
let { contentViewer } = buffer;
|
||||
|
||||
if (contentViewer)
|
||||
return contentViewer.authorStyleDisabled;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
|
||||
},
|
||||
|
||||
parse: function parse(str) {
|
||||
if ('{['.contains(str[0]))
|
||||
if ('{['.includes(str[0]))
|
||||
return JSON.parse(str);
|
||||
return str;
|
||||
},
|
||||
|
||||
@@ -620,7 +620,7 @@ var CompletionContext = Class("CompletionContext", {
|
||||
var substrings = [text];
|
||||
}
|
||||
else {
|
||||
var compare = function compare(text, s) { return text.contains(s); };
|
||||
var compare = function compare(text, s) { return text.includes(s); };
|
||||
var substrings = [];
|
||||
let start = 0;
|
||||
let idx;
|
||||
@@ -1169,7 +1169,7 @@ var Completion = Module("completion", {
|
||||
if (context.ignoreCase) {
|
||||
compare = util.compareIgnoreCase;
|
||||
contains = function contains_(a, b) {
|
||||
return a && a.toLowerCase().contains(b.toLowerCase());
|
||||
return a && a.toLowerCase().includes(b.toLowerCase());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -409,7 +409,9 @@ var Contexts = Module("contexts", {
|
||||
return frame;
|
||||
},
|
||||
|
||||
groups: Class.Memoize(function () { return this.matchingGroups(); }),
|
||||
groups: Class.Memoize(function () {
|
||||
return this.matchingGroups();
|
||||
}),
|
||||
|
||||
allGroups: Class.Memoize(function () {
|
||||
return Object.create(this.groupsProto, {
|
||||
|
||||
@@ -954,6 +954,11 @@ var DOM = Class("DOM", {
|
||||
try {
|
||||
if (elem instanceof Ci.nsIDOMDocument)
|
||||
elem = elem.defaultView;
|
||||
|
||||
if (Cu.isCrossProcessWrapper(elem)) {
|
||||
elem.focus();
|
||||
}
|
||||
else {
|
||||
if (elem instanceof Ci.nsIDOMElement)
|
||||
services.focus.setFocus(elem, flags);
|
||||
else if (elem instanceof Ci.nsIDOMWindow) {
|
||||
@@ -962,6 +967,7 @@ var DOM = Class("DOM", {
|
||||
services.focus.clearFocus(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
util.dump(elem);
|
||||
util.reportError(e);
|
||||
|
||||
@@ -299,7 +299,7 @@ var DownloadList = Class("DownloadList",
|
||||
addDownload: function addDownload(download) {
|
||||
if (!this.downloads.has(download)) {
|
||||
download = Download(download, this);
|
||||
if (this.filter && !download.displayName.contains(this.filter))
|
||||
if (this.filter && !download.displayName.includes(this.filter))
|
||||
return;
|
||||
|
||||
this.downloads.set(download.download, download);
|
||||
|
||||
@@ -117,7 +117,7 @@ var Help = Module("Help", {
|
||||
| ^ (?P<space> \s*)
|
||||
(?P<char> [-•*+]) \ //
|
||||
(?P<content> .*\n
|
||||
(?: ${"\\2"} // This is incorrectly interpreted as an octal literal otherwise}\ \ .*\n | \s*\n)* )
|
||||
(?: ${"\\2" /* This is incorrectly interpreted as an octal literal otherwise */}\ \ .*\n | \s*\n)* )
|
||||
|
||||
| (?P<par>
|
||||
(?: ^ [^\S\n]*
|
||||
|
||||
@@ -97,9 +97,12 @@ var Modules = function Modules(window) {
|
||||
if (normal)
|
||||
return create(proto);
|
||||
|
||||
let sandbox = Components.utils.Sandbox(window, { sandboxPrototype: proto || modules,
|
||||
let sandbox = Components.utils.Sandbox(Cu.getObjectPrincipal(global),
|
||||
{ sandboxPrototype: proto || modules,
|
||||
sandboxName: name || ("Dactyl Sandbox " + ++_id),
|
||||
wantXrays: true });
|
||||
addonId: config.addon.id,
|
||||
wantXrays: true,
|
||||
metadata: { addonID: config.addon.id } });
|
||||
|
||||
// Hack:
|
||||
// sandbox.Object = jsmodules.Object;
|
||||
|
||||
@@ -425,7 +425,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
||||
delete desc.writable;
|
||||
desc.get = function get() { return value; }
|
||||
desc.set = function set(val) {
|
||||
if (!callable(val) || !Function.prototype.toString(val).contains(sentinel))
|
||||
if (!callable(val) || !Function.prototype.toString(val).includes(sentinel))
|
||||
Class.replaceProperty(this, k, val);
|
||||
else {
|
||||
let package_ = util.newURI(Components.stack.caller.filename).host;
|
||||
|
||||
@@ -411,7 +411,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
function* prefs() {
|
||||
for (let pref of prefArray) {
|
||||
let userValue = services.pref.prefHasUserValue(pref);
|
||||
if (onlyNonDefault && !userValue || !pref.contains(filter))
|
||||
if (onlyNonDefault && !userValue || !pref.includes(filter))
|
||||
continue;
|
||||
|
||||
let value = this.get(pref);
|
||||
|
||||
@@ -329,10 +329,13 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
* @param {Window|Document|Node} thing The thing for which to return
|
||||
* a load context.
|
||||
*/
|
||||
getContext: function getContext(thing) {
|
||||
getContext: function getContext(thing, global = null) {
|
||||
if (!Ci.nsILoadContext)
|
||||
return null;
|
||||
|
||||
if (Cu.isCrossProcessWrapper(thing) && global)
|
||||
thing = global;
|
||||
|
||||
if (thing instanceof Ci.nsIDOMNode && thing.ownerDocument)
|
||||
thing = thing.ownerDocument;
|
||||
if (thing instanceof Ci.nsIDOMDocument)
|
||||
@@ -634,7 +637,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
completion: function initCompletion(dactyl, modules, window) {
|
||||
modules.completion.visibleHosts = function completeHosts(context) {
|
||||
let res = util.visibleHosts(window.content);
|
||||
if (context.filter && !res.some(host => host.contains(context.filter)))
|
||||
if (context.filter && !res.some(host => host.includes(context.filter)))
|
||||
res.push(context.filter);
|
||||
|
||||
context.title = ["Domain"];
|
||||
|
||||
@@ -225,7 +225,7 @@ var Hive = Class("Hive", {
|
||||
name = null;
|
||||
}
|
||||
|
||||
if (filter && filter.contains(","))
|
||||
if (filter && filter.includes(","))
|
||||
return filter.split(",").reduce(
|
||||
(n, f) => n + this.removeSheet(name, f, index), 0);
|
||||
|
||||
|
||||
@@ -562,7 +562,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
rec([]);
|
||||
return res;
|
||||
}
|
||||
catch (e if e.message && e.message.contains("res is undefined")) {
|
||||
catch (e if e.message && e.message.includes("res is undefined")) {
|
||||
// prefs.safeSet() would be reset on :rehash
|
||||
prefs.set("javascript.options.methodjit.chrome", false);
|
||||
util.dactyl.warn(_(UTF8("error.damnYouJägermonkey")));
|
||||
@@ -591,7 +591,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
*/
|
||||
dequote: function dequote(pattern, chars) {
|
||||
return pattern.replace(/\\(.)/,
|
||||
(m0, m1) => chars.contains(m1) ? m1 : m0);
|
||||
(m0, m1) => chars.includes(m1) ? m1 : m0);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1485,6 +1485,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
this.dump(util.stackLines(error.stack).join("\n"));
|
||||
}
|
||||
catch (e) { dump(e + "\n"); }
|
||||
dump("Stack: " + Error().stack + "\n");
|
||||
}
|
||||
|
||||
// ctypes.open("libc.so.6").declare("kill", ctypes.default_abi, ctypes.void_t, ctypes.int, ctypes.int)(
|
||||
@@ -1727,10 +1728,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
* @returns {Window} The top-level parent window.
|
||||
*/
|
||||
topWindow: function topWindow(win) {
|
||||
return win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDocShell);
|
||||
let { rootTreeItem } = docShell;
|
||||
if (rootTreeItem)
|
||||
return rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindow);
|
||||
},
|
||||
|
||||
@@ -1742,9 +1744,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
*/
|
||||
trapErrors: function trapErrors(func, self, ...args) {
|
||||
try {
|
||||
if (!callable(func))
|
||||
func = self[func];
|
||||
return func.apply(self || this, args);
|
||||
return apply(self || this, func, args);
|
||||
}
|
||||
catch (e) {
|
||||
this.reportError(e);
|
||||
|
||||
Reference in New Issue
Block a user