ページのソースをタブで開く機能の実装を開始

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1292 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-22 23:29:07 +00:00
parent 1abfa2032b
commit 1062e53bfc
4 changed files with 152 additions and 4 deletions

View File

@ -1,6 +1,7 @@
content treestyletab jar:chrome/treestyletab.jar!/content/treestyletab/
overlay chrome://browser/content/browser.xul chrome://treestyletab/content/treestyletab.xul
overlay chrome://global/content/viewSource.xul chrome://treestyletab/content/viewSourceOverlay.xul
overlay chrome://multipletab/content/config.xul chrome://treestyletab/content/multipletabConfigOverlay.xul
locale treestyletab en-US jar:chrome/treestyletab.jar!/locale/en-US/treestyletab/

View File

@ -800,6 +800,69 @@ catch(e) {
openUILinkIn(]]></>
)
);
eval('nsContextMenu.prototype.viewPartialSource = '+
nsContextMenu.prototype.viewPartialSource.toSource().replace(
'window.openDialog(',
<><![CDATA[
if (TreeStyleTabService.getPref('extensions.treestyletab.viewSourceInTab')) {
TreeStyleTabService.viewSource.clear();
TreeStyleTabService.viewSource.frame = focusedWindow;
TreeStyleTabService.viewSource.uri = docUrl;
TreeStyleTabService.viewSource.charset = docCharset;
TreeStyleTabService.viewSource.reference = reference;
TreeStyleTabService.viewSource.context = context;
var b = ('SplitBrowser' in window) ? TreeStyleTabService.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(frame.top).browser) : gBrowser ;
b.selectedTab = b.addTab('chrome://global/content/viewPartialSource.xul');
}
else
window.openDialog(]]></>
)
);
eval('nsContextMenu.prototype.viewFrameSource = '+
nsContextMenu.prototype.viewFrameSource.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.viewSource.clear();
TreeStyleTabService.viewSource.frame = this.target.ownerDocument.defaultView;
]]></>
)
);
eval('window.BrowserViewSourceOfDocument = '+
window.BrowserViewSourceOfDocument.toSource().replace(
'ViewSourceOfURL(',
<><![CDATA[
if (!TreeStyleTabService.viewSource.frame) {
TreeStyleTabService.viewSource.clear();
TreeStyleTabService.viewSource.frame = TreeStyleTabService.browser.contentWindow;
}
ViewSourceOfURL(]]></>
)
);
eval('window.ViewSourceOfURL = '+
window.ViewSourceOfURL.toSource().replace(
'gViewSourceUtils.openInExternalEditor(',
<><![CDATA[
TreeStyleTabService.viewSource.clear();
gViewSourceUtils.openInExternalEditor(]]></>
)
);
eval('gViewSourceUtils.openInInternalViewer = '+
gViewSourceUtils.openInInternalViewer.toSource().replace(
/(openDialog\([^\)]+\))/,
<><![CDATA[
if (TreeStyleTabService.getPref('extensions.treestyletab.viewSourceInTab')) {
TreeStyleTabService.readyToOpenChildTab(TreeStyleTabService.viewSource.target);
var b = ('SplitBrowser' in window) ? TreeStyleTabService.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(TreeStyleTabService.viewSource.frame.top).browser) : gBrowser ;
b.selectedTab = b.addTab('chrome://global/content/viewSource.xul');
}
else {
TreeStyleTabService.viewSource.clear();
$1;
}
]]></>
)
);
funcs = 'handleLinkClick __splitbrowser__handleLinkClick __ctxextensions__handleLinkClick'.split(' ');
for (var i in funcs)
@ -839,8 +902,8 @@ catch(e) {
)
);
eval('window.nsBrowserAccess.prototype.openURI = '+
window.nsBrowserAccess.prototype.openURI.toSource().replace(
eval('nsBrowserAccess.prototype.openURI = '+
nsBrowserAccess.prototype.openURI.toSource().replace(
/switch\s*\(aWhere\)/,
<><![CDATA[
if (aOpener &&
@ -1287,7 +1350,7 @@ catch(e) {
sep.setAttribute('hidden', true);
}
},
/* Tab Utilities */
getTabValue : function(aTab, aKey)
@ -1640,7 +1703,7 @@ catch(e) {
},
/* Commands */
initTabbar : function(aTabBrowser, aPosition)
{
if (!aPosition) aPosition = this.getPref('extensions.treestyletab.tabbar.position');
@ -2386,6 +2449,24 @@ catch(e) {
return node.href ? node : null ;
},
/* view source */
viewSource : {
clear : function()
{
this.frame = null;
this.uri = null;
this.charset = null;
this.reference = null;
this.context = null;
},
frame : null,
uri : null,
charset : null,
reference : null,
context : null
},
/* Pref Listener */
domain : 'extensions.treestyletab',

View File

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript"><![CDATA[
function getParentBrowserWindow()
{
if (gParentBrowserWindow === void(0)) {
try {
gParentBrowserWindow = window
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.parent
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.document.defaultView
.wrappedJSObject;
if (gParentBrowserWindow.location.href != 'chrome://browser/content/browser.xul')
gParentBrowserWindow = null;
}
catch(e) {
gParentBrowserWindow = null
}
}
return gParentBrowserWindow;
}
var gParentBrowserWindow;
function getParentBrowserViewSourceInfo()
{
if (!getParentBrowserWindow()) return {};
return getParentBrowserWindow().TreeStyleTabService.viewSource;
}
if ('onLoadViewSource' in window) {
eval('window.onLoadViewSource = '+
window.onLoadViewSource.toSource().replace(
'window.arguments[0]',
'window.arguments.length ? window.arguments[0] : getParentBrowserViewSourceInfo().frame.location.href'
)
);
}
if ('viewSource' in window) {
eval('window.viewSource = '+
window.viewSource.toSource().replace(
'window.arguments.length >= 2',
'window.arguments.length >= 2 || getParentBrowserViewSourceInfo().charset'
).replace(
'window.arguments[1]',
'window.arguments.length >= 2 ? window.arguments[1] : getParentBrowserViewSourceInfo().charset'
)
);
}
if (!window.arguments) window.arguments = [];
]]></script>
</overlay>

View File

@ -11,6 +11,7 @@ pref("extensions.treestyletab.show.openSelectionLinks", true);
pref("extensions.treestyletab.openGroupBookmarkAsTabSubTree", true);
pref("extensions.treestyletab.loadDroppedLinkToNewChildTab", false);
pref("extensions.treestyletab.viewSourceInTab", true);
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true);
pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false);