Bug 733339 - part 1: remove unneeded legacy style sheet switching functions and bind remaining ones to gPageStyleMenu. r=dolske

This commit is contained in:
Dão Gottwald 2012-03-11 05:23:51 +01:00
parent b0ca471a79
commit f721bff622
4 changed files with 18 additions and 19 deletions

View File

@ -291,12 +291,13 @@
</menu> </menu>
<menu id="pageStyleMenu" label="&pageStyleMenu.label;" <menu id="pageStyleMenu" label="&pageStyleMenu.label;"
accesskey="&pageStyleMenu.accesskey;" observes="isImage"> accesskey="&pageStyleMenu.accesskey;" observes="isImage">
<menupopup onpopupshowing="stylesheetFillPopup(this);" <menupopup onpopupshowing="gPageStyleMenu.fillPopup(this);"
oncommand="stylesheetSwitchAll(window.content, event.target.getAttribute('data')); setStyleDisabled(false);"> oncommand="gPageStyleMenu.switchStyleSheet(window.content, event.target.getAttribute('data'));
gPageStyleMenu.setStyleDisabled(false);">
<menuitem id="menu_pageStyleNoStyle" <menuitem id="menu_pageStyleNoStyle"
label="&pageStyleNoStyle.label;" label="&pageStyleNoStyle.label;"
accesskey="&pageStyleNoStyle.accesskey;" accesskey="&pageStyleNoStyle.accesskey;"
oncommand="setStyleDisabled(true); event.stopPropagation();" oncommand="gPageStyleMenu.setStyleDisabled(true); event.stopPropagation();"
type="radio"/> type="radio"/>
<menuitem id="menu_pageStylePersistentOnly" <menuitem id="menu_pageStylePersistentOnly"
label="&pageStylePersistentOnly.label;" label="&pageStylePersistentOnly.label;"

View File

@ -6092,7 +6092,7 @@ var gPageStyleMenu = {
return styleSheetsArray; return styleSheetsArray;
}, },
stylesheetFillPopup: function (menuPopup) { fillPopup: function (menuPopup) {
var noStyle = menuPopup.firstChild; var noStyle = menuPopup.firstChild;
var persistentOnly = noStyle.nextSibling; var persistentOnly = noStyle.nextSibling;
var sep = persistentOnly.nextSibling; var sep = persistentOnly.nextSibling;
@ -6147,12 +6147,12 @@ var gPageStyleMenu = {
return true; return true;
}, },
stylesheetInFrame: function (frame, title) { _stylesheetInFrame: function (frame, title) {
return Array.some(frame.document.styleSheets, return Array.some(frame.document.styleSheets,
function (stylesheet) stylesheet.title == title); function (stylesheet) stylesheet.title == title);
}, },
stylesheetSwitchFrame: function (frame, title) { _stylesheetSwitchFrame: function (frame, title) {
var docStyleSheets = frame.document.styleSheets; var docStyleSheets = frame.document.styleSheets;
for (let i = 0; i < docStyleSheets.length; ++i) { for (let i = 0; i < docStyleSheets.length; ++i) {
@ -6167,12 +6167,12 @@ var gPageStyleMenu = {
} }
}, },
stylesheetSwitchAll: function (frameset, title) { switchStyleSheet: function (frameset, title) {
if (!title || title == "_nostyle" || this.stylesheetInFrame(frameset, title)) if (!title || title == "_nostyle" || this._stylesheetInFrame(frameset, title))
this.stylesheetSwitchFrame(frameset, title); this._stylesheetSwitchFrame(frameset, title);
for (let i = 0; i < frameset.frames.length; i++) for (let i = 0; i < frameset.frames.length; i++)
this.stylesheetSwitchAll(frameset.frames[i], title); this.switchStyleSheet(frameset.frames[i], title);
}, },
setStyleDisabled: function (disabled) { setStyleDisabled: function (disabled) {
@ -6181,12 +6181,10 @@ var gPageStyleMenu = {
}; };
/* Legacy global page-style functions */ /* Legacy global page-style functions */
var getAllStyleSheets = gPageStyleMenu.getAllStyleSheets; var getAllStyleSheets = gPageStyleMenu.getAllStyleSheets.bind(gPageStyleMenu);
var stylesheetFillPopup = gPageStyleMenu.stylesheetFillPopup; var stylesheetFillPopup = gPageStyleMenu.fillPopup.bind(gPageStyleMenu);
var stylesheetInFrame = gPageStyleMenu.stylesheetInFrame; var stylesheetSwitchAll = gPageStyleMenu.switchStyleSheet.bind(gPageStyleMenu);
var stylesheetSwitchFrame = gPageStyleMenu.stylesheetSwitchFrame; var setStyleDisabled = gPageStyleMenu.setStyleDisabled.bind(gPageStyleMenu);
var stylesheetSwitchAll = gPageStyleMenu.stylesheetSwitchAll;
var setStyleDisabled = gPageStyleMenu.setStyleDisabled;
var BrowserOffline = { var BrowserOffline = {

View File

@ -14,7 +14,7 @@ function test() {
function checkPageStyleMenu() { function checkPageStyleMenu() {
var menupopup = document.getElementById("pageStyleMenu") var menupopup = document.getElementById("pageStyleMenu")
.getElementsByTagName("menupopup")[0]; .getElementsByTagName("menupopup")[0];
stylesheetFillPopup(menupopup); gPageStyleMenu.fillPopup(menupopup);
var items = []; var items = [];
var current = menupopup.getElementsByTagName("menuseparator")[0]; var current = menupopup.getElementsByTagName("menuseparator")[0];

View File

@ -50,8 +50,8 @@ function test() {
Array.forEach(tab.linkedBrowser.contentDocument.styleSheets, function(aSS, aIx) { Array.forEach(tab.linkedBrowser.contentDocument.styleSheets, function(aSS, aIx) {
pendingCount++; pendingCount++;
let ssTitle = aSS.title; let ssTitle = aSS.title;
stylesheetSwitchAll(tab.linkedBrowser.contentWindow, ssTitle); gPageStyleMenu.switchStyleSheet(tab.linkedBrowser.contentWindow, ssTitle);
let newTab = gBrowser.duplicateTab(tab); let newTab = gBrowser.duplicateTab(tab);
newTab.linkedBrowser.addEventListener("load", function(aEvent) { newTab.linkedBrowser.addEventListener("load", function(aEvent) {
newTab.linkedBrowser.removeEventListener("load", arguments.callee, true); newTab.linkedBrowser.removeEventListener("load", arguments.callee, true);