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

View File

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

View File

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

View File

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