mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-26 11:15:46 +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,12 +155,15 @@ var Modes = Module("modes", {
|
||||
dactyl.focusContent(true);
|
||||
if (prev.main == modes.NORMAL) {
|
||||
dactyl.focusContent(true);
|
||||
for (let frame of buffer.allFrames()) {
|
||||
// clear any selection made
|
||||
let selection = frame.getSelection();
|
||||
if (selection && !selection.isCollapsed)
|
||||
selection.collapseToStart();
|
||||
}
|
||||
|
||||
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();
|
||||
if (selection && !selection.isCollapsed)
|
||||
selection.collapseToStart();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user