1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:07:59 +01:00

Fix :runtime completion.

This commit is contained in:
Kris Maglione
2010-12-17 20:01:59 -05:00
parent 754d490a56
commit 8f4d26f9ac
11 changed files with 39 additions and 38 deletions

View File

@@ -368,9 +368,9 @@ const Buffer = Module("buffer", {
* tab.
*/
get localStore() {
if (!window.content.dactylStore)
window.content.dactylStore = {};
return window.content.dactylStore;
if (!content.dactylStore)
content.dactylStore = {};
return content.dactylStore;
},
/**
@@ -383,18 +383,18 @@ const Buffer = Module("buffer", {
/**
* @property {string} The current top-level document's URL.
*/
get URL() window.content.location.href,
get URL() content.location.href,
/**
* @property {string} The current top-level document's URL, sans any
* fragment identifier.
*/
get URI() window.content.document.documentURI,
get URI() content.document.documentURI,
/**
* @property {number} The buffer's height in pixels.
*/
get pageHeight() window.content.innerHeight,
get pageHeight() content.innerHeight,
/**
* @property {number} The current browser's zoom level, as a
@@ -413,7 +413,7 @@ const Buffer = Module("buffer", {
/**
* @property {string} The current document's title.
*/
get title() window.content.document.title,
get title() content.document.title,
/**
* @property {number} The buffer's horizontal scroll percentile.
@@ -457,7 +457,7 @@ const Buffer = Module("buffer", {
if (frame.document.body instanceof HTMLBodyElement)
frames.push(frame);
Array.forEach(frame.frames, rec);
})(win || window.content);
})(win || content);
if (focusedFirst)
return frames.filter(function (f) f === buffer.focusedFrame).concat(
frames.filter(function (f) f !== buffer.focusedFrame));
@@ -469,7 +469,7 @@ const Buffer = Module("buffer", {
*/
get focusedFrame() {
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
return frame && frame.get() || window.content;
return frame && frame.get() || content;
},
set focusedFrame(frame) {
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
@@ -485,7 +485,7 @@ const Buffer = Module("buffer", {
* @returns {string}
*/
getCurrentWord: function () {
let win = buffer.focusedFrame || window.content;
let win = buffer.focusedFrame || content;
let selection = win.getSelection();
if (selection.rangeCount == 0)
return "";
@@ -821,7 +821,7 @@ const Buffer = Module("buffer", {
*/
scrollTo: function (x, y) {
marks.add("'", true);
window.content.scrollTo(x, y);
content.scrollTo(x, y);
},
/**
@@ -847,7 +847,7 @@ const Buffer = Module("buffer", {
* count skips backwards.
*/
shiftFrameFocus: function (count) {
if (!(window.content.document instanceof HTMLDocument))
if (!(content.document instanceof HTMLDocument))
return;
let frames = buffer.allFrames();
@@ -872,7 +872,7 @@ const Buffer = Module("buffer", {
// focus next frame and scroll into view
frames[next].focus();
if (frames[next] != window.content)
if (frames[next] != content)
frames[next].frameElement.scrollIntoView(false);
// add the frame indicator
@@ -908,8 +908,8 @@ const Buffer = Module("buffer", {
showPageInfo: function (verbose, sections) {
// Ctrl-g single line output
if (!verbose) {
let file = window.content.document.location.pathname.split("/").pop() || "[No Name]";
let title = window.content.document.title || "[No Title]";
let file = content.document.location.pathname.split("/").pop() || "[No Name]";
let title = content.document.title || "[No Title]";
let info = template.map("gf",
function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "),
@@ -1106,7 +1106,7 @@ const Buffer = Module("buffer", {
if (win && (win.scrollMaxX > 0 || win.scrollMaxY > 0))
return win;
win = window.content;
win = content;
if (win.scrollMaxX > 0 || win.scrollMaxY > 0)
return win;
@@ -1307,7 +1307,7 @@ const Buffer = Module("buffer", {
commands.add(["sav[eas]", "w[rite]"],
"Save current document to disk",
function (args) {
let doc = window.content.document;
let doc = content.document;
let chosenData = null;
let filename = args[0];
@@ -1351,9 +1351,9 @@ const Buffer = Module("buffer", {
prefs.set("browser.download.lastDir", io.cwd);
try {
var contentDisposition = window.content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.getDocumentMetadata("content-disposition");
var contentDisposition = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.getDocumentMetadata("content-disposition");
}
catch (e) {}

View File

@@ -664,7 +664,7 @@ const Commands = Module("commands", {
*/
hasDomain: function (command, host) {
try {
for (let [cmd, args] in this._subCommands(command))
for (let [cmd, args] in this.subCommands(command))
if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host)))
return true;
}
@@ -682,7 +682,7 @@ const Commands = Module("commands", {
* @returns {boolean}
*/
hasPrivateData: function (command) {
for (let [cmd, args] in this._subCommands(command))
for (let [cmd, args] in this.subCommands(command))
if (cmd.privateData)
return !callable(cmd.privateData) || cmd.privateData(args);
return false;
@@ -1059,7 +1059,7 @@ const Commands = Module("commands", {
while (str);
},
_subCommands: function (command) {
subCommands: function (command) {
let commands = [command];
while (command = commands.shift())
try {

View File

@@ -16,7 +16,7 @@
const jsmodules = {};
const modules = {
__proto__: jsmodules,
get content() window.content,
get content() this.config.browser.contentWindow || window.content,
jsmodules: jsmodules,
newContext: newContext,
window: window

View File

@@ -363,7 +363,7 @@ const Dactyl = Module("dactyl", {
return;
let win = document.commandDispatcher.focusedWindow;
let elem = config.mainWidget || window.content;
let elem = config.mainWidget || content;
// TODO: make more generic
try {
if (this.has("mail") && !config.isComposeWindow) {
@@ -374,7 +374,7 @@ const Dactyl = Module("dactyl", {
}
else {
let frame = buffer.focusedFrame;
if (frame && frame.top == window.content && !Editor.getEditor(frame))
if (frame && frame.top == content && !Editor.getEditor(frame))
elem = frame;
}
}
@@ -624,7 +624,7 @@ const Dactyl = Module("dactyl", {
data.push(<>{node.textContent}</>.toXMLString());
}
}
fix(window.content.document.documentElement);
fix(content.document.documentElement);
addDataEntry(file + ".xhtml", data.join(""));
}

View File

@@ -713,7 +713,7 @@ const Events = Module("events", {
if (elem == null && Editor.getEditor(win))
elem = win;
if (win && win.top == window.content && dactyl.has("tabs"))
if (win && win.top == content && dactyl.has("tabs"))
buffer.focusedFrame = win;
try {
@@ -1064,7 +1064,7 @@ const Events = Module("events", {
isContentNode: function isContentNode(node) {
let win = (node.ownerDocument || node).defaultView || node;
for (; win; win = win.parent != win && win.parent)
if (win == window.content)
if (win == content)
return true;
return false;
},

View File

@@ -268,7 +268,7 @@ const RangeFind = Class("RangeFind", {
this.matchCase = Boolean(matchCase);
this.regexp = Boolean(regexp);
this.ranges = this.makeFrameList(window.content);
this.ranges = this.makeFrameList(content);
this.reset();
@@ -295,7 +295,7 @@ const RangeFind = Class("RangeFind", {
get searchString() this.lastString,
get selectedRange() {
let selection = (buffer.focusedFrame || window.content).getSelection();
let selection = (buffer.focusedFrame || content).getSelection();
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
},
set selectedRange(range) {

View File

@@ -9,7 +9,7 @@ function checkFragment() {
var frag = document.location.hash.substr(1);
var elem = document.getElementById(frag);
function action() {
window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
content.scrollTo(0, content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
}
if (elem) {
action();

View File

@@ -260,7 +260,7 @@ const Hints = Module("hints", {
* Pushes the hints into the pageHints object, but does not display them.
*
* @param {Window} win The window for which to generate hints.
* @default window.content
* @default content
*/
_generate: function _generate(win, offsets) {
if (!win)
@@ -845,7 +845,7 @@ const Hints = Module("hints", {
this._canUpdate = false;
this._continue = Boolean(opts.continue);
this._top = opts.window || window.content;
this._top = opts.window || content;
this._top.addEventListener("resize", this._resizeTimer.closure.tell, true);
this._generate();

View File

@@ -677,7 +677,8 @@ lookup:
context.title = [full ? "Path" : "Filename", "Type"];
context.keys = {
text: !full ? "leafName" : function (f) dir + f.leafName,
text: !full ? "leafName" : function (f) this.path,
path: function (f) dir + f.leafName,
description: function (f) this.isdir ? "Directory" : "File",
isdir: function (f) f.isDirectory(),
icon: function (f) this.isdir ? "resource://gre/res/html/folder.png"
@@ -731,7 +732,7 @@ lookup:
dir = dir.replace("/+$", "") + "/";
completion.file(context, true, dir + context.filter);
context.title[0] = dir;
context.keys.text = function (f) f.path.substr(dir.length);
context.keys.text = function (f) this.path.substr(dir.length);
});
};

View File

@@ -443,7 +443,7 @@ const JavaScript = Module("javascript", {
// Find any complete statements that we can eval before we eval our object.
// This allows for things like:
// let doc = window.content.document; let elem = doc.createEle<Tab> ...
// let doc = content.document; let elem = doc.createEle<Tab> ...
let prev = 0;
for (let [, v] in Iterator(this._get(0).fullStatements)) {
let key = this._str.substring(prev, v + 1);

View File

@@ -41,7 +41,7 @@ const Modes = Module("modes", {
this.addMode("VISUAL", { char: "v", ownsFocus: true, display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : "") }, {
leave: function (stack, newMode) {
if (newMode.main == modes.CARET) {
let selection = window.content.getSelection();
let selection = content.getSelection();
if (selection && !selection.isCollapsed)
selection.collapseToStart();
}