Commit 53352793 authored by Henri Sivonen's avatar Henri Sivonen
Browse files

Bug 1543077 part 4 - Have only one item for Japanese in the Text Encoding menu. r=emk,Gijs

Differential Revision: https://phabricator.services.mozilla.com/D28634

--HG--
extra : moz-landing-system : lando
parent 1447a771
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -6620,6 +6620,9 @@ function handleDroppedLink(event, urlOrLinks, nameOrTriggeringPrincipal, trigger

function BrowserSetForcedCharacterSet(aCharset) {
  if (aCharset) {
    if (aCharset == "Japanese") {
      aCharset = "Shift_JIS";
    }
    gBrowser.selectedBrowser.characterSet = aCharset;
    // Save the forced character-set
    PlacesUIUtils.setCharsetForPage(getWebNavigation().currentURI,
@@ -6634,7 +6637,8 @@ function BrowserCharsetReload() {
}

function UpdateCurrentCharset(target) {
  let selectedCharset = CharsetMenu.foldCharset(gBrowser.selectedBrowser.characterSet);
  let selectedCharset = CharsetMenu.foldCharset(gBrowser.selectedBrowser.characterSet,
                                                gBrowser.selectedBrowser.charsetAutodetected);
  for (let menuItem of target.getElementsByTagName("menuitem")) {
    let isSelected = menuItem.getAttribute("charset") === selectedCharset;
    menuItem.setAttribute("checked", isSelected);
+2 −1
Original line number Diff line number Diff line
@@ -358,7 +358,8 @@ const CustomizableWidgets = [
    },
    updateCurrentCharset(aDocument) {
      let currentCharset = aDocument.defaultView.gBrowser.selectedBrowser.characterSet;
      currentCharset = CharsetMenu.foldCharset(currentCharset);
      let {charsetAutodetected} = aDocument.defaultView.gBrowser.selectedBrowser;
      currentCharset = CharsetMenu.foldCharset(currentCharset, charsetAutodetected);

      let pinnedContainer = aDocument.getElementById("PanelUI-characterEncodingView-pinned");
      let charsetContainer = aDocument.getElementById("PanelUI-characterEncodingView-charsets");
+27 −6
Original line number Diff line number Diff line
@@ -1275,7 +1275,6 @@ nsDocShell::GatherCharsetMenuTelemetry() {
    case kCharsetFromDocTypeDefault:
    case kCharsetFromCache:
    case kCharsetFromParentFrame:
    case kCharsetFromHintPrevDoc:
      // Changing charset on an unlabeled doc.
      if (isFileURL) {
        Telemetry::AccumulateCategorical(
@@ -1891,6 +1890,26 @@ nsDocShell::GetMayEnableCharacterEncodingMenu(
  return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetCharsetAutodetected(bool* aCharsetAutodetected) {
  *aCharsetAutodetected = false;
  if (!mContentViewer) {
    return NS_OK;
  }
  Document* doc = mContentViewer->GetDocument();
  if (!doc) {
    return NS_OK;
  }
  int32_t source = doc->GetDocumentCharacterSetSource();

  if (source == kCharsetFromAutoDetection ||
      source == kCharsetFromUserForcedAutoDetection) {
    *aCharsetAutodetected = true;
  }

  return NS_OK;
}

NS_IMETHODIMP
nsDocShell::GetDocShellEnumerator(int32_t aItemType,
                                  DocShellEnumeratorDirection aDirection,
@@ -8365,11 +8384,11 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {

  const Encoding* forceCharset = nullptr;
  const Encoding* hintCharset = nullptr;
  int32_t hintCharsetSource;
  float textZoom;
  float pageZoom;
  float overrideDPPX;
  bool styleDisabled;
  int32_t hintCharsetSource = kCharsetUninitialized;
  float textZoom = 1.0;
  float pageZoom = 1.0;
  float overrideDPPX = 1.0;
  bool styleDisabled = false;
  // |newMUDV| also serves as a flag to set the data from the above vars
  nsCOMPtr<nsIContentViewer> newCv;

@@ -10181,6 +10200,8 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
    MOZ_ASSERT(NS_SUCCEEDED(rv));
  }

  Unused << rv;  // Keep Coverity happy

  nsCOMPtr<nsIWritablePropertyBag2> props(do_QueryInterface(channel));
  if (props) {
    // save true referrer for those who need it (e.g. xpinstall whitelisting)
+5 −0
Original line number Diff line number Diff line
@@ -878,6 +878,11 @@ interface nsIDocShell : nsIDocShellTreeItem
   */
  [infallible] readonly attribute boolean mayEnableCharacterEncodingMenu;

  /**
   * Indicates that the character encoding was autodetected.
   */
  [infallible] readonly attribute boolean charsetAutodetected;

           attribute  nsIEditor editor;
  readonly attribute  boolean   editable;             /* this docShell is editable */
  readonly attribute  boolean   hasEditingSession;    /* this docShell has an editing session */
+6 −0
Original line number Diff line number Diff line
@@ -93,6 +93,12 @@ interface nsIBrowser : nsISupports
   */
  attribute boolean mayEnableCharacterEncodingMenu;

  /**
   * Whether or not the character encoding was detected by analyzing
   * content (as opposed to reading a protocol label).
   */
  attribute boolean charsetAutodetected;

  /**
   * Called by Gecko to update the browser when its state changes.
   *
Loading