find selection in the current tab recursively

This commit is contained in:
SHIMODA Hiroshi 2010-12-09 15:18:37 +09:00
parent 58278779bb
commit 3cdf604b3c

View File

@ -143,14 +143,20 @@ var TreeStyleTabService = {
return Math.max(0, Math.min(aHeight, max * this.MAX_TABBAR_SIZE_RATIO)); return Math.max(0, Math.min(aHeight, max * this.MAX_TABBAR_SIZE_RATIO));
}, },
isSelectedInCurrentTab : function TSTService_isSelectedInCurrentTab(aTerm) shouldOpenSearchResultAsChild : function TSTService_shouldOpenSearchResultAsChild(aTerm)
{ {
if (!aTerm)
return false;
var w = document.commandDispatcher.focusedWindow; var w = document.commandDispatcher.focusedWindow;
return ( if (!w || w.top != this.browser.contentWindow)
w && w = this.browser.contentWindow;
w.top == this.browser.contentWindow &&
w.getSelection().toString() == aTerm return (function(aWindow) {
); if (aWindow.getSelection().toString() == aTerm)
return true;
return Array.slice(aWindow.frames).some(arguments.callee);
})(w);
}, },
/* Initializing */ /* Initializing */
@ -699,7 +705,7 @@ var TreeStyleTabService = {
eval('searchbar.doSearch = '+searchbar.doSearch.toSource().replace( eval('searchbar.doSearch = '+searchbar.doSearch.toSource().replace(
/(openUILinkIn\(.+?\);)/, /(openUILinkIn\(.+?\);)/,
<![CDATA[ <![CDATA[
if (TreeStyleTabService.isSelectedInCurrentTab(arguments[0])) if (TreeStyleTabService.shouldOpenSearchResultAsChild(arguments[0]))
TreeStyleTabService.readyToOpenChildTab(); TreeStyleTabService.readyToOpenChildTab();
$1 $1
TreeStyleTabService.stopToOpenChildTab(); TreeStyleTabService.stopToOpenChildTab();