mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:27:59 +01:00
Fix cross-compartment instanceof issues.
--HG-- extra : rebase_source : 9145412ce33e18bae5d889454fd1ff98c4067d09
This commit is contained in:
@@ -118,7 +118,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
* @param {Element} elem A form element for which to add a keyword.
|
* @param {Element} elem A form element for which to add a keyword.
|
||||||
*/
|
*/
|
||||||
addSearchKeyword: function addSearchKeyword(elem) {
|
addSearchKeyword: function addSearchKeyword(elem) {
|
||||||
if (elem instanceof HTMLFormElement || elem.form)
|
if (elem instanceof Ci.nsIDOMHTMLFormElement || elem.form)
|
||||||
var { url, postData, charset } = DOM(elem).formData;
|
var { url, postData, charset } = DOM(elem).formData;
|
||||||
else
|
else
|
||||||
var [url, postData, charset] = [elem.href || elem.src, null, elem.ownerDocument.characterSet];
|
var [url, postData, charset] = [elem.href || elem.src, null, elem.ownerDocument.characterSet];
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
events: {
|
events: {
|
||||||
DOMContentLoaded: function onDOMContentLoaded(event) {
|
DOMContentLoaded: function onDOMContentLoaded(event) {
|
||||||
let doc = event.originalTarget;
|
let doc = event.originalTarget;
|
||||||
if (doc instanceof HTMLDocument)
|
if (doc instanceof Ci.nsIDOMHTMLDocument)
|
||||||
this._triggerLoadAutocmd("DOMLoad", doc);
|
this._triggerLoadAutocmd("DOMLoad", doc);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
if (doc instanceof Document)
|
if (doc instanceof Document)
|
||||||
dactyl.initDocument(doc);
|
dactyl.initDocument(doc);
|
||||||
|
|
||||||
if (doc instanceof HTMLDocument) {
|
if (doc instanceof Ci.nsIDOMHTMLDocument) {
|
||||||
if (doc.defaultView.frameElement) {
|
if (doc.defaultView.frameElement) {
|
||||||
// document is part of a frameset
|
// document is part of a frameset
|
||||||
|
|
||||||
|
|||||||
@@ -600,7 +600,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
if (win.frameElement)
|
if (win.frameElement)
|
||||||
win.frameElement.blur();
|
win.frameElement.blur();
|
||||||
// Grr.
|
// Grr.
|
||||||
if (content.document.activeElement instanceof HTMLIFrameElement)
|
if (content.document.activeElement instanceof Ci.nsIDOMHTMLIFrameElement)
|
||||||
content.document.activeElement.blur();
|
content.document.activeElement.blur();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -611,7 +611,10 @@ var Events = Module("events", {
|
|||||||
if (!(services.focus.getLastFocusMethod(win) & 0x3000)
|
if (!(services.focus.getLastFocusMethod(win) & 0x3000)
|
||||||
&& events.isContentNode(elem)
|
&& events.isContentNode(elem)
|
||||||
&& !buffer.focusAllowed(elem)
|
&& !buffer.focusAllowed(elem)
|
||||||
&& isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement, Window])) {
|
&& isinstance(elem, [Ci.nsIDOMHTMLInputElement,
|
||||||
|
Ci.nsIDOMHTMLSelectElement,
|
||||||
|
Ci.nsIDOMHTMLTextAreaElement,
|
||||||
|
Ci.nsIDOMWindow])) {
|
||||||
|
|
||||||
if (elem.frameElement)
|
if (elem.frameElement)
|
||||||
dactyl.focusContent(true);
|
dactyl.focusContent(true);
|
||||||
@@ -673,7 +676,7 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
// Hack to deal with <BS> and so forth not dispatching input
|
// Hack to deal with <BS> and so forth not dispatching input
|
||||||
// events
|
// events
|
||||||
if (key && event.originalTarget instanceof HTMLInputElement && !modes.main.passthrough) {
|
if (key && event.originalTarget instanceof Ci.nsIDOMHTMLInputElement && !modes.main.passthrough) {
|
||||||
let elem = event.originalTarget;
|
let elem = event.originalTarget;
|
||||||
elem.dactylKeyPress = elem.value;
|
elem.dactylKeyPress = elem.value;
|
||||||
util.timeout(function () {
|
util.timeout(function () {
|
||||||
@@ -844,7 +847,7 @@ var Events = Module("events", {
|
|||||||
// access to the real focus target
|
// access to the real focus target
|
||||||
// Huh? --djk
|
// Huh? --djk
|
||||||
onFocusChange: util.wrapCallback(function onFocusChange(event) {
|
onFocusChange: util.wrapCallback(function onFocusChange(event) {
|
||||||
function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument
|
function hasHTMLDocument(win) win && win.document && win.document instanceof Ci.nsIDOMHTMLDocument
|
||||||
if (dactyl.ignoreFocus)
|
if (dactyl.ignoreFocus)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -861,7 +864,7 @@ var Events = Module("events", {
|
|||||||
if (elem && elem.readOnly)
|
if (elem && elem.readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isinstance(elem, [HTMLEmbedElement, HTMLEmbedElement])) {
|
if (isinstance(elem, [Ci.nsIDOMHTMLEmbedElement, Ci.nsIDOMHTMLEmbedElement])) {
|
||||||
if (!modes.main.passthrough && modes.main != modes.EMBED)
|
if (!modes.main.passthrough && modes.main != modes.EMBED)
|
||||||
modes.push(modes.EMBED);
|
modes.push(modes.EMBED);
|
||||||
return;
|
return;
|
||||||
@@ -965,8 +968,9 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
isInputElement: function isInputElement(elem) {
|
isInputElement: function isInputElement(elem) {
|
||||||
return DOM(elem).isEditable ||
|
return DOM(elem).isEditable ||
|
||||||
isinstance(elem, [HTMLEmbedElement, HTMLObjectElement,
|
isinstance(elem, [Ci.nsIDOMHTMLEmbedElement,
|
||||||
HTMLSelectElement])
|
Ci.nsIDOMHTMLObjectElement,
|
||||||
|
Ci.nsIDOMHTMLSelectElement])
|
||||||
},
|
},
|
||||||
|
|
||||||
kill: function kill(event) {
|
kill: function kill(event) {
|
||||||
|
|||||||
@@ -337,9 +337,11 @@ var HintSession = Class("HintSession", CommandMode, {
|
|||||||
|
|
||||||
if (elem.hasAttributeNS(NS, "hint"))
|
if (elem.hasAttributeNS(NS, "hint"))
|
||||||
[hint.text, hint.showText] = [elem.getAttributeNS(NS, "hint"), true];
|
[hint.text, hint.showText] = [elem.getAttributeNS(NS, "hint"), true];
|
||||||
else if (isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
|
else if (isinstance(elem, [Ci.nsIDOMHTMLInputElement,
|
||||||
|
Ci.nsIDOMHTMLSelectElement,
|
||||||
|
Ci.nsIDOMHTMLTextAreaElement]))
|
||||||
[hint.text, hint.showText] = hints.getInputHint(elem, doc);
|
[hint.text, hint.showText] = hints.getInputHint(elem, doc);
|
||||||
else if (elem.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(elem.textContent))
|
else if (elem.firstElementChild instanceof Ci.nsIDOMHTMLImageElement && /^\s*$/.test(elem.textContent))
|
||||||
[hint.text, hint.showText] = [elem.firstElementChild.alt || elem.firstElementChild.title, true];
|
[hint.text, hint.showText] = [elem.firstElementChild.alt || elem.firstElementChild.title, true];
|
||||||
else
|
else
|
||||||
hint.text = elem.textContent.toLowerCase();
|
hint.text = elem.textContent.toLowerCase();
|
||||||
@@ -349,7 +351,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
|||||||
let leftPos = Math.max((rect.left + offsetX), offsetX);
|
let leftPos = Math.max((rect.left + offsetX), offsetX);
|
||||||
let topPos = Math.max((rect.top + offsetY), offsetY);
|
let topPos = Math.max((rect.top + offsetY), offsetY);
|
||||||
|
|
||||||
if (elem instanceof HTMLAreaElement)
|
if (elem instanceof Ci.nsIDOMHTMLAreaElement)
|
||||||
[leftPos, topPos] = this.getAreaOffset(elem, leftPos, topPos);
|
[leftPos, topPos] = this.getAreaOffset(elem, leftPos, topPos);
|
||||||
|
|
||||||
hint.span.setAttribute("style", ["display: none; left:", leftPos, "px; top:", topPos, "px"].join(""));
|
hint.span.setAttribute("style", ["display: none; left:", leftPos, "px; top:", topPos, "px"].join(""));
|
||||||
@@ -596,7 +598,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
|||||||
if (!hint.valid)
|
if (!hint.valid)
|
||||||
continue inner;
|
continue inner;
|
||||||
|
|
||||||
if (hint.text == "" && hint.elem.firstChild && hint.elem.firstChild instanceof HTMLImageElement) {
|
if (hint.text == "" && hint.elem.firstChild && hint.elem.firstChild instanceof Ci.nsIDOMHTMLImageElement) {
|
||||||
if (!hint.imgSpan) {
|
if (!hint.imgSpan) {
|
||||||
let rect = hint.elem.firstChild.getBoundingClientRect();
|
let rect = hint.elem.firstChild.getBoundingClientRect();
|
||||||
if (!rect)
|
if (!rect)
|
||||||
@@ -614,7 +616,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
|||||||
|
|
||||||
let str = this.getHintString(hintnum);
|
let str = this.getHintString(hintnum);
|
||||||
let text = [];
|
let text = [];
|
||||||
if (hint.elem instanceof HTMLInputElement)
|
if (hint.elem instanceof Ci.nsIDOMHTMLInputElement)
|
||||||
if (hint.elem.type === "radio")
|
if (hint.elem.type === "radio")
|
||||||
text.push(UTF8(hint.elem.checked ? "⊙" : "○"));
|
text.push(UTF8(hint.elem.checked ? "⊙" : "○"));
|
||||||
else if (hint.elem.type === "checkbox")
|
else if (hint.elem.type === "checkbox")
|
||||||
@@ -781,7 +783,8 @@ var Hints = Module("hints", {
|
|||||||
this.addMode("i", "Show image", function (elem) dactyl.open(elem.src));
|
this.addMode("i", "Show image", function (elem) dactyl.open(elem.src));
|
||||||
this.addMode("I", "Show image in a new tab", function (elem) dactyl.open(elem.src, dactyl.NEW_TAB));
|
this.addMode("I", "Show image in a new tab", function (elem) dactyl.open(elem.src, dactyl.NEW_TAB));
|
||||||
|
|
||||||
function isScrollable(elem) isinstance(elem, [HTMLFrameElement, HTMLIFrameElement]) ||
|
function isScrollable(elem) isinstance(elem, [Ci.nsIDOMHTMLFrameElement,
|
||||||
|
Ci.nsIDOMHTMLIFrameElement]) ||
|
||||||
Buffer.isScrollable(elem, 0, true) || Buffer.isScrollable(elem, 0, false);
|
Buffer.isScrollable(elem, 0, true) || Buffer.isScrollable(elem, 0, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -850,7 +853,7 @@ var Hints = Module("hints", {
|
|||||||
else {
|
else {
|
||||||
for (let [, option] in Iterator(options["hintinputs"])) {
|
for (let [, option] in Iterator(options["hintinputs"])) {
|
||||||
if (option == "value") {
|
if (option == "value") {
|
||||||
if (elem instanceof HTMLSelectElement) {
|
if (elem instanceof Ci.nsIDOMHTMLSelectElement) {
|
||||||
if (elem.selectedIndex >= 0)
|
if (elem.selectedIndex >= 0)
|
||||||
return [elem.item(elem.selectedIndex).text.toLowerCase(), false];
|
return [elem.item(elem.selectedIndex).text.toLowerCase(), false];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ var MOW = Module("mow", {
|
|||||||
dactyl.open(event.target.href, where);
|
dactyl.open(event.target.href, where);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (event.target instanceof HTMLAnchorElement)
|
if (event.target instanceof Ci.nsIDOMHTMLAnchorElement)
|
||||||
switch (DOM.Event.stringify(event)) {
|
switch (DOM.Event.stringify(event)) {
|
||||||
case "<LeftMouse>":
|
case "<LeftMouse>":
|
||||||
openLink(dactyl.CURRENT_TAB);
|
openLink(dactyl.CURRENT_TAB);
|
||||||
@@ -192,7 +192,7 @@ var MOW = Module("mow", {
|
|||||||
popupshowing: function onPopupShowing(event) {
|
popupshowing: function onPopupShowing(event) {
|
||||||
let menu = commandline.widgets.contextMenu;
|
let menu = commandline.widgets.contextMenu;
|
||||||
let enabled = {
|
let enabled = {
|
||||||
link: window.document.popupNode instanceof HTMLAnchorElement,
|
link: window.document.popupNode instanceof Ci.nsIDOMHTMLAnchorElement,
|
||||||
path: window.document.popupNode.hasAttribute("path"),
|
path: window.document.popupNode.hasAttribute("path"),
|
||||||
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user