Bug 733339 - part 3: make the content window passed to gPageStyleMenu.switchStyleSheet optional. r=dolske
authorDão Gottwald <dao@mozilla.com>
Sun, 11 Mar 2012 05:25:02 +0100
changeset 88744 cb70875d31bc62f7cf645ae7758d9f12aaeb8e73
parent 88743 f397bf34d922b90ef8fc5b670cba3ada438ad141
child 88745 5f8a4ddce90061fd2524435b40f0980009b5c336
push id22220
push userdholbert@mozilla.com
push dateMon, 12 Mar 2012 02:41:18 +0000
treeherdermozilla-central@5ec9524de1af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs733339
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 733339 - part 3: make the content window passed to gPageStyleMenu.switchStyleSheet optional. r=dolske
browser/base/content/browser-menubar.inc
browser/base/content/browser.js
browser/components/sessionstore/test/browser_408470.js
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -287,17 +287,17 @@
                               type="checkbox"
                               command="cmd_fullZoomToggle"
                               checked="false"/>
                   </menupopup>
                 </menu>
                 <menu id="pageStyleMenu" label="&pageStyleMenu.label;"
                       accesskey="&pageStyleMenu.accesskey;" observes="isImage">
                   <menupopup onpopupshowing="gPageStyleMenu.fillPopup(this);"
-                             oncommand="gPageStyleMenu.switchStyleSheet(window.content, event.target.getAttribute('data'));">
+                             oncommand="gPageStyleMenu.switchStyleSheet(event.target.getAttribute('data'));">
                     <menuitem id="menu_pageStyleNoStyle"
                               label="&pageStyleNoStyle.label;"
                               accesskey="&pageStyleNoStyle.accesskey;"
                               oncommand="gPageStyleMenu.disableStyle(); event.stopPropagation();"
                               type="radio"/>
                     <menuitem id="menu_pageStylePersistentOnly"
                               label="&pageStylePersistentOnly.label;"
                               accesskey="&pageStylePersistentOnly.accesskey;"
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6170,30 +6170,32 @@ var gPageStyleMenu = {
   _stylesheetSwitchAll: 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);
   },
 
-  switchStyleSheet: function (contentWindow, title) {
+  switchStyleSheet: function (title, contentWindow) {
     getMarkupDocumentViewer().authorStyleDisabled = false;
-    this._stylesheetSwitchAll(contentWindow, title);
+    this._stylesheetSwitchAll(contentWindow || content, title);
   },
 
   disableStyle: function () {
     getMarkupDocumentViewer().authorStyleDisabled = true;
   },
 };
 
 /* Legacy global page-style functions */
 var getAllStyleSheets   = gPageStyleMenu.getAllStyleSheets.bind(gPageStyleMenu);
 var stylesheetFillPopup = gPageStyleMenu.fillPopup.bind(gPageStyleMenu);
-var stylesheetSwitchAll = gPageStyleMenu.switchStyleSheet.bind(gPageStyleMenu);
+function stylesheetSwitchAll(contentWindow, title) {
+  gPageStyleMenu.switchStyleSheet(title, contentWindow);
+}
 function setStyleDisabled(disabled) {
   if (disabled)
     gPageStyleMenu.disableStyle();
 }
 
 
 var BrowserOffline = {
   _inited: false,
--- a/browser/components/sessionstore/test/browser_408470.js
+++ b/browser/components/sessionstore/test/browser_408470.js
@@ -45,17 +45,17 @@ function test() {
   let tab = gBrowser.addTab(testUrl);
   
   tab.linkedBrowser.addEventListener("load", function(aEvent) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
     // enable all stylesheets and verify that they're correctly persisted
     Array.forEach(tab.linkedBrowser.contentDocument.styleSheets, function(aSS, aIx) {
       pendingCount++;
       let ssTitle = aSS.title;
-      gPageStyleMenu.switchStyleSheet(tab.linkedBrowser.contentWindow, ssTitle);
+      gPageStyleMenu.switchStyleSheet(ssTitle, tab.linkedBrowser.contentWindow);
 
       let newTab = gBrowser.duplicateTab(tab);
       newTab.linkedBrowser.addEventListener("load", function(aEvent) {
         newTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
         let states = Array.map(newTab.linkedBrowser.contentDocument.styleSheets,
                                function(aSS) !aSS.disabled);
         let correct = states.indexOf(true) == aIx && states.indexOf(true, aIx + 1) == -1;