Rename BrowserSetForcedDetector and remove unnecessary parameter. Bug 720310, r=gavin
authorSimon Montagu <smontagu@smontagu.org>
Tue, 24 Jan 2012 11:52:05 +0200
changeset 86415 f173a9a1e0560a1c61e69702e4c7558be8dd47df
parent 86414 9aab7ae07561a3004625ca7c80d98f06c6daf9af
child 86416 ab64f34dd8ea8bfc606abec136c266148cc46531
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs720310
milestone12.0a1
Rename BrowserSetForcedDetector and remove unnecessary parameter. Bug 720310, r=gavin
browser/base/content/browser.js
toolkit/components/viewsource/content/viewSource.js
toolkit/content/charsetOverlay.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5968,22 +5968,22 @@ function handleDroppedLink(event, url, n
 };
 
 function MultiplexHandler(event)
 { try {
     var node = event.target;
     var name = node.getAttribute('name');
 
     if (name == 'detectorGroup') {
-        SetForcedDetector(true);
+        BrowserCharsetReload();
         SelectDetector(event, false);
     } else if (name == 'charsetGroup') {
         var charset = node.getAttribute('id');
         charset = charset.substring('charset.'.length, charset.length)
-        SetForcedCharset(charset);
+        BrowserSetForcedCharacterSet(charset);
     } else if (name == 'charsetCustomize') {
         //do nothing - please remove this else statement, once the charset prefs moves to the pref window
     } else {
         SetForcedCharset(node.getAttribute('id'));
     }
     } catch(ex) { alert(ex); }
 }
 
@@ -6004,40 +6004,29 @@ function SelectDetector(event, doReload)
         if (doReload)
           window.content.location.reload();
     }
     catch (ex) {
         dump("Failed to set the intl.charset.detector preference.\n");
     }
 }
 
-function SetForcedDetector(doReload)
-{
-    BrowserSetForcedDetector(doReload);
-}
-
-function SetForcedCharset(charset)
-{
-    BrowserSetForcedCharacterSet(charset);
-}
-
 function BrowserSetForcedCharacterSet(aCharset)
 {
   gBrowser.docShell.charset = aCharset;
   // Save the forced character-set
   PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, aCharset);
+  BrowserCharsetReload();
+}
+
+function BrowserCharsetReload()
+{
   BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
 }
 
-function BrowserSetForcedDetector(doReload)
-{
-  if (doReload)
-    BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
-}
-
 function charsetMenuGetElement(parent, id) {
   return parent.getElementsByAttribute("id", id)[0];
 }
 
 function UpdateCurrentCharset(target) {
     // extract the charset from DOM
     var wnd = document.commandDispatcher.focusedWindow;
     if ((window == wnd) || (wnd == null)) wnd = window.content;
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -706,45 +706,34 @@ function highlightSyntax()
 {
   var highlightSyntaxMenu = document.getElementById("menu_highlightSyntax");
   var highlightSyntax = (highlightSyntaxMenu.getAttribute("checked") == "true");
   gPrefs.setBoolPref("view_source.syntax_highlight", highlightSyntax);
 
   gPageLoader.loadPage(gPageLoader.currentDescriptor, gPageLoader.DISPLAY_NORMAL);
 }
 
+// Reload after change to character encoding or autodetection
+//
 // Fix for bug 136322: this function overrides the function in
 // browser.js to call PageLoader.loadPage() instead of BrowserReloadWithFlags()
-function BrowserSetForcedCharacterSet(aCharset)
+function BrowserCharsetReload()
 {
-  gBrowser.docShell.charset = aCharset;
   if (isHistoryEnabled()) {
     gPageLoader.loadPage(gPageLoader.currentDescriptor,
                          gPageLoader.DISPLAY_NORMAL);
   } else {
     gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
   }
 }
 
-// fix for bug #229503
-// we need to define BrowserSetForcedDetector() so that we can
-// change auto-detect options in the "View | Character Encoding" menu.
-// As with BrowserSetForcedCharacterSet(), call PageLoader.loadPage() 
-// instead of BrowserReloadWithFlags()
-function BrowserSetForcedDetector(doReload)
+function BrowserSetForcedCharacterSet(aCharset)
 {
-  if (doReload)
-  {
-    if (isHistoryEnabled()) {
-      gPageLoader.loadPage(gPageLoader.currentDescriptor,
-                           gPageLoader.DISPLAY_NORMAL);
-    } else {
-      gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
-    }
-  }
+  gBrowser.docShell.charset = aCharset;
+  BrowserCharsetReload();
 }
 
 function BrowserForward(aEvent) {
   try {
     gBrowser.goForward();
   }
   catch(ex) {
   }
--- a/toolkit/content/charsetOverlay.js
+++ b/toolkit/content/charsetOverlay.js
@@ -1,14 +1,14 @@
 function MultiplexHandler(aEvent)
 {
     MultiplexHandlerEx(
         aEvent,
         function Browser_SelectDetector(event) {
-            BrowserSetForcedDetector(true/*Reload from history*/);
+            BrowserCharsetReload();
             /* window.content.location.reload() will re-download everything */
             SelectDetector(event, null);
         },
         function Browser_SetForcedCharset(charset, isPredefined) {
             BrowserSetForcedCharacterSet(charset);
         }
     );
 }