mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
parent
6a3c79040e
commit
a47dfd1d82
1 changed files with 32 additions and 38 deletions
|
|
@ -2017,49 +2017,43 @@ function readFromClipboard()
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function BrowserViewSourceOfDocument(aDocument)
|
function BrowserViewSourceOfDocument(aArgsOrDocument)
|
||||||
{
|
{
|
||||||
var pageCookie;
|
let args;
|
||||||
var webNav;
|
|
||||||
|
|
||||||
// Get the document charset
|
if (aArgsOrDocument instanceof Document) {
|
||||||
var docCharset = "charset=" + aDocument.characterSet;
|
let doc = aArgsOrDocument;
|
||||||
|
|
||||||
// Get the nsIWebNavigation associated with the document
|
let requestor = doc.defaultView
|
||||||
try {
|
.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||||
var win;
|
let browser = requestor.getInterface(Ci.nsIWebNavigation)
|
||||||
var ifRequestor;
|
.QueryInterface(Ci.nsIDocShell)
|
||||||
|
.chromeEventHandler;
|
||||||
|
let outerWindowID = requestor.getInterface(Ci.nsIDOMWindowUtils)
|
||||||
|
.outerWindowID;
|
||||||
|
let URL = browser.currentURI.spec;
|
||||||
|
args = { browser, outerWindowID, URL };
|
||||||
|
} else {
|
||||||
|
args = aArgsOrDocument;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the DOMWindow for the requested document. If the DOMWindow
|
let viewInternal = () => {
|
||||||
// cannot be found, then just use the content window...
|
top.gViewSourceUtils.viewSource(args);
|
||||||
//
|
}
|
||||||
// XXX: This is a bit of a hack...
|
|
||||||
win = aDocument.defaultView;
|
// Check if external view source is enabled. If so, try it. If it fails,
|
||||||
if (win == window) {
|
// fallback to internal view source.
|
||||||
win = content;
|
if (Services.prefs.getBoolPref("view_source.editor.external")) {
|
||||||
|
top.gViewSourceUtils
|
||||||
|
.openInExternalEditor(args, null, null, null, result => {
|
||||||
|
if (!result) {
|
||||||
|
viewInternal();
|
||||||
}
|
}
|
||||||
ifRequestor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
});
|
||||||
|
} else {
|
||||||
webNav = ifRequestor.getInterface(nsIWebNavigation);
|
// Display using internal view source
|
||||||
} catch(err) {
|
viewInternal();
|
||||||
// If nsIWebNavigation cannot be found, just get the one for the whole
|
|
||||||
// window...
|
|
||||||
webNav = gBrowser.webNavigation;
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Get the 'PageDescriptor' for the current document. This allows the
|
|
||||||
// view-source to access the cached copy of the content rather than
|
|
||||||
// refetching it from the network...
|
|
||||||
//
|
|
||||||
try{
|
|
||||||
var PageLoader = webNav.QueryInterface(Components.interfaces.nsIWebPageDescriptor);
|
|
||||||
|
|
||||||
pageCookie = PageLoader.currentDescriptor;
|
|
||||||
} catch(err) {
|
|
||||||
// If no page descriptor is available, just use the view-source URL...
|
|
||||||
}
|
|
||||||
|
|
||||||
top.gViewSourceUtils.viewSource(webNav.currentURI.spec, pageCookie, aDocument);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// doc - document to use for source, or null for this window's document
|
// doc - document to use for source, or null for this window's document
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue