Reduce use of <![CDATA[ ... ]]> for Firefox 17 and later

This commit is contained in:
YUKI Hiroshi 2012-10-12 11:34:13 +09:00
parent 3042dec27e
commit 8affaa2939

View File

@ -52,12 +52,10 @@ var TreeStyleTabWindowHelper = {
eval('window.undoCloseTab = '+ eval('window.undoCloseTab = '+
window.undoCloseTab.toSource().replace( window.undoCloseTab.toSource().replace(
/(\btab\s*=\s*[^\.]+\.undoCloseTab\([^;]+\);)/, /(\btab\s*=\s*[^\.]+\.undoCloseTab\([^;]+\);)/,
<![CDATA[ 'gBrowser.__treestyletab__readyToUndoCloseTab = true;' +
gBrowser.__treestyletab__readyToUndoCloseTab = true; '$1' +
$1 'tab.__treestyletab__restoredByUndoCloseTab = true;' +
tab.__treestyletab__restoredByUndoCloseTab = true; 'delete gBrowser.__treestyletab__readyToUndoCloseTab;'
delete gBrowser.__treestyletab__readyToUndoCloseTab;
]]>
) )
); );
} }
@ -98,12 +96,10 @@ var TreeStyleTabWindowHelper = {
/\.width/g, '[TST.sizeProp]' /\.width/g, '[TST.sizeProp]'
).replace( ).replace(
/(return (?:true|dt.effectAllowed = "copyMove");)/, /(return (?:true|dt.effectAllowed = "copyMove");)/,
<![CDATA[ 'if (!TST.tabbarDNDObserver.canDropTab(arguments[0])) {' +
if (!TST.tabbarDNDObserver.canDropTab(arguments[0])) { ' return dt.effectAllowed = "none";' +
return dt.effectAllowed = "none"; '}' +
} '$1'
$1
]]>
).replace( ).replace(
'sourceNode.parentNode == this &&', 'sourceNode.parentNode == this &&',
'$& TST.getTabFromEvent(event) == sourceNode &&' '$& TST.getTabFromEvent(event) == sourceNode &&'
@ -144,17 +140,15 @@ var TreeStyleTabWindowHelper = {
eval('nsContextMenu.prototype.openLinkInTab = '+ eval('nsContextMenu.prototype.openLinkInTab = '+
nsContextMenu.prototype.openLinkInTab.toSource().replace( nsContextMenu.prototype.openLinkInTab.toSource().replace(
'{', '{',
<![CDATA[$& '{' +
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView); ' TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);'
]]>
) )
); );
eval('nsContextMenu.prototype.openFrameInTab = '+ eval('nsContextMenu.prototype.openFrameInTab = '+
nsContextMenu.prototype.openFrameInTab.toSource().replace( nsContextMenu.prototype.openFrameInTab.toSource().replace(
'{', '{',
<![CDATA[$& '{' +
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView); ' TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);'
]]>
) )
); );
var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ; var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ;
@ -187,14 +181,14 @@ var TreeStyleTabWindowHelper = {
); );
} }
let (functions = this._splitFunctionNames(<![CDATA[ let (functions = [
window.duplicateTab.handleLinkClick 'window.duplicateTab.handleLinkClick',
window.duplicatethistab.handleLinkClick 'window.duplicatethistab.handleLinkClick',
window.__treestyletab__highlander__origHandleLinkClick 'window.__treestyletab__highlander__origHandleLinkClick',
window.__splitbrowser__handleLinkClick 'window.__splitbrowser__handleLinkClick',
window.__ctxextensions__handleLinkClick 'window.__ctxextensions__handleLinkClick',
window.handleLinkClick 'window.handleLinkClick'
]]>)) { ]) {
for (let i = 0, maxi = functions.length; i < maxi; i++) for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i]; let func = functions[i];
@ -218,12 +212,12 @@ var TreeStyleTabWindowHelper = {
); );
} }
let (functions = this._splitFunctionNames(<![CDATA[ let (functions = [
window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"] 'window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"]',
window.__contentAreaClick 'window.__contentAreaClick',
window.__ctxextensions__contentAreaClick 'window.__ctxextensions__contentAreaClick',
window.contentAreaClick 'window.contentAreaClick'
]]>)) { ]) {
for (let i = 0, maxi = functions.length; i < maxi; i++) for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i]; let func = functions[i];
@ -248,11 +242,11 @@ var TreeStyleTabWindowHelper = {
); );
} }
let (functions = this._splitFunctionNames(<![CDATA[ let (functions = [
permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"] 'permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]',
window.BrowserHomeClick 'window.BrowserHomeClick',
window.BrowserGoHome 'window.BrowserGoHome'
]]>)) { ]) {
for (let i = 0, maxi = functions.length; i < maxi; i++) for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i]; let func = functions[i];
@ -350,11 +344,9 @@ var TreeStyleTabWindowHelper = {
searchbar.doSearch.toSource().toSource().indexOf('TreeStyleTabService') < 0) { searchbar.doSearch.toSource().toSource().indexOf('TreeStyleTabService') < 0) {
eval('searchbar.doSearch = '+searchbar.doSearch.toSource().replace( eval('searchbar.doSearch = '+searchbar.doSearch.toSource().replace(
/(openUILinkIn\(.+?\);)/, /(openUILinkIn\(.+?\);)/,
<![CDATA[ 'TreeStyleTabService.onBeforeBrowserSearch(arguments[0]);' +
TreeStyleTabService.onBeforeBrowserSearch(arguments[0]); '$1' +
$1 'TreeStyleTabService.stopToOpenChildTab();'
TreeStyleTabService.stopToOpenChildTab();
]]>.toString()
)); ));
} }
@ -416,26 +408,23 @@ var TreeStyleTabWindowHelper = {
'tabPos + 1', 'nextTab._tPos' 'tabPos + 1', 'nextTab._tPos'
).replace( ).replace(
'this.moveTabTo(', 'this.moveTabTo(',
<![CDATA[ 'var descendant = this.treeStyleTab.getDescendantTabs(nextTab);' +
var descendant = this.treeStyleTab.getDescendantTabs(nextTab); 'if (descendant.length) {' +
if (descendant.length) { ' nextTab = descendant[descendant.length-1];' +
nextTab = descendant[descendant.length-1]; '}' +
} '$&'
$&]]>
).replace( ).replace(
'this.moveTabToStart();', 'this.moveTabToStart();',
<![CDATA[ 'this.treeStyleTab.internallyTabMovingCount++;' +
this.treeStyleTab.internallyTabMovingCount++; 'var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab);' +
var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab); 'if (parentTab) {' +
if (parentTab) { ' this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getFirstChildTab(parentTab)._tPos);' +
this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getFirstChildTab(parentTab)._tPos); ' this.mCurrentTab.focus();' +
this.mCurrentTab.focus(); '}' +
} 'else {' +
else { ' $&' +
$& '}' +
} 'this.treeStyleTab.internallyTabMovingCount--;'
this.treeStyleTab.internallyTabMovingCount--;
]]>
) )
); );
@ -449,41 +438,35 @@ var TreeStyleTabWindowHelper = {
'tabPos - 1', 'prevTab._tPos' 'tabPos - 1', 'prevTab._tPos'
).replace( ).replace(
'this.moveTabToEnd();', 'this.moveTabToEnd();',
<![CDATA[ 'this.treeStyleTab.internallyTabMovingCount++;' +
this.treeStyleTab.internallyTabMovingCount++; 'var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab);' +
var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab); 'if (parentTab) {' +
if (parentTab) { ' this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getLastChildTab(parentTab)._tPos);' +
this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getLastChildTab(parentTab)._tPos); ' this.mCurrentTab.focus();' +
this.mCurrentTab.focus(); '}' +
} 'else {' +
else { ' $&' +
$& '}' +
} 'this.treeStyleTab.internallyTabMovingCount--;'
this.treeStyleTab.internallyTabMovingCount--;
]]>
) )
); );
eval('b.loadTabs = '+ eval('b.loadTabs = '+
b.loadTabs.toSource().replace( b.loadTabs.toSource().replace(
'var tabNum = ', 'var tabNum = ',
<![CDATA[ 'if (this.treeStyleTab.readiedToAttachNewTabGroup)' +
if (this.treeStyleTab.readiedToAttachNewTabGroup) ' TreeStyleTabService.readyToOpenChildTab(firstTabAdded || this.selectedTab, true);' +
TreeStyleTabService.readyToOpenChildTab(firstTabAdded || this.selectedTab, true); '$&'
$&]]>
).replace( ).replace(
'if (!aLoadInBackground)', 'if (!aLoadInBackground)',
<![CDATA[ 'if (TreeStyleTabService.checkToOpenChildTab(this))' +
if (TreeStyleTabService.checkToOpenChildTab(this)) ' TreeStyleTabService.stopToOpenChildTab(this);' +
TreeStyleTabService.stopToOpenChildTab(this); '$&'
$&]]>
).replace( ).replace(
'this.selectedTab = firstTabAdded;', 'this.selectedTab = firstTabAdded;',
<![CDATA[ 'this.selectedTab = aURIs[0].indexOf("about:treestyletab-group") < 0 ? ' +
this.selectedTab = aURIs[0].indexOf('about:treestyletab-group') < 0 ? ' firstTabAdded :' +
firstTabAdded : ' TreeStyleTabService.getNextTab(firstTabAdded) ;'
TreeStyleTabService.getNextTab(firstTabAdded) ;
]]>
) )
); );
@ -514,11 +497,10 @@ var TreeStyleTabWindowHelper = {
eval('b.mTabContainer.advanceSelectedTab = '+ eval('b.mTabContainer.advanceSelectedTab = '+
source.replace( source.replace(
'{', '{',
<![CDATA[$& '{' +
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab; ' var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;' +
if (treeStyleTab.handleAdvanceSelectedTab(arguments[0], arguments[1])) ' if (treeStyleTab.handleAdvanceSelectedTab(arguments[0], arguments[1]))' +
return; ' return;'
]]>
) )
); );
} }
@ -528,12 +510,11 @@ var TreeStyleTabWindowHelper = {
eval('b.mTabContainer._notifyBackgroundTab = '+ eval('b.mTabContainer._notifyBackgroundTab = '+
source.replace( source.replace(
'{', '{',
<![CDATA[{ '{' +
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab; ' var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;' +
if (treeStyleTab.scrollToNewTabMode == 0 || ' if (treeStyleTab.scrollToNewTabMode == 0 ||' +
treeStyleTab.shouldCancelEnsureElementIsVisible()) ' treeStyleTab.shouldCancelEnsureElementIsVisible())' +
return; ' return;'
]]>.toString()
).replace( ).replace(
/\.screenX/g, '[treeStyleTab.screenPositionProp]' /\.screenX/g, '[treeStyleTab.screenPositionProp]'
).replace( ).replace(
@ -575,16 +556,15 @@ var TreeStyleTabWindowHelper = {
eval('scrollbox.ensureElementIsVisible = '+ eval('scrollbox.ensureElementIsVisible = '+
source.replace( source.replace(
'{', '{',
<![CDATA[{ '{' +
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab; ' var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;' +
if (treeStyleTab && treeStyleTab.shouldCancelEnsureElementIsVisible()) ' if (treeStyleTab && treeStyleTab.shouldCancelEnsureElementIsVisible())' +
return; ' return;' +
if ( ' if (' +
treeStyleTab && ' treeStyleTab &&' +
(arguments.length == 1 || arguments[1]) ' (arguments.length == 1 || arguments[1])' +
) ' )' +
return treeStyleTab.scrollToTab(arguments[0]); ' return treeStyleTab.scrollToTab(arguments[0]);'
]]>.toString()
) )
); );
} }