Commit 49662ba6 authored by Masatoshi Kimura's avatar Masatoshi Kimura
Browse files

Bug 1202362 - Remove nsISaveAsCharset & nsSaveAsCharset. r=hsivonen

MozReview-Commit-ID: KbepWLdKQ5E

--HG--
extra : rebase_source : 56d97edbaf933dc981c21ca09a49661fa3a347ef
parent c8614154
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#include "nsError.h"
#include "nsGenericHTMLElement.h"
#include "nsAttrValueInlines.h"
#include "nsISaveAsCharset.h"
#include "nsIFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsStringStream.h"
+0 −5
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@

// unicharutil
#include "nsEntityConverter.h"
#include "nsSaveAsCharset.h"
#include "nsUnicodeNormalizer.h"

// string bundles (intl)
@@ -31,7 +30,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStringBundleService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStringBundleTextOverride, Init)

NS_GENERIC_FACTORY_CONSTRUCTOR(nsEntityConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSaveAsCharset)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeNormalizer)

NS_DEFINE_NAMED_CID(MOZ_LOCALESERVICE_CID);
@@ -39,7 +37,6 @@ NS_DEFINE_NAMED_CID(MOZ_OSPREFERENCES_CID);
NS_DEFINE_NAMED_CID(NS_LBRK_CID);
NS_DEFINE_NAMED_CID(NS_WBRK_CID);
NS_DEFINE_NAMED_CID(NS_ENTITYCONVERTER_CID);
NS_DEFINE_NAMED_CID(NS_SAVEASCHARSET_CID);
NS_DEFINE_NAMED_CID(NS_UNICODE_NORMALIZER_CID);
NS_DEFINE_NAMED_CID(NS_STRINGBUNDLESERVICE_CID);
NS_DEFINE_NAMED_CID(NS_STRINGBUNDLETEXTOVERRIDE_CID);
@@ -54,7 +51,6 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
    { &kNS_LBRK_CID, false, nullptr, nsJISx4051LineBreakerConstructor },
    { &kNS_WBRK_CID, false, nullptr, nsSampleWordBreakerConstructor },
    { &kNS_ENTITYCONVERTER_CID, false, nullptr, nsEntityConverterConstructor },
    { &kNS_SAVEASCHARSET_CID, false, nullptr, nsSaveAsCharsetConstructor },
    { &kNS_UNICODE_NORMALIZER_CID, false, nullptr, nsUnicodeNormalizerConstructor },
    { &kNS_STRINGBUNDLESERVICE_CID, false, nullptr, nsStringBundleServiceConstructor },
    { &kNS_STRINGBUNDLETEXTOVERRIDE_CID, false, nullptr, nsStringBundleTextOverrideConstructor },
@@ -71,7 +67,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
    { NS_LBRK_CONTRACTID, &kNS_LBRK_CID },
    { NS_WBRK_CONTRACTID, &kNS_WBRK_CID },
    { NS_ENTITYCONVERTER_CONTRACTID, &kNS_ENTITYCONVERTER_CID },
    { NS_SAVEASCHARSET_CONTRACTID, &kNS_SAVEASCHARSET_CID },
    { NS_UNICODE_NORMALIZER_CONTRACTID, &kNS_UNICODE_NORMALIZER_CID },
    { NS_STRINGBUNDLE_CONTRACTID, &kNS_STRINGBUNDLESERVICE_CID },
    { NS_STRINGBUNDLETEXTOVERRIDE_CONTRACTID, &kNS_STRINGBUNDLETEXTOVERRIDE_CID },
+0 −2
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ TEST_DIRS += ['tests']

XPIDL_SOURCES += [
    'nsIEntityConverter.idl',
    'nsISaveAsCharset.idl',
    'nsIUnicodeNormalizer.idl',
]

@@ -22,7 +21,6 @@ EXPORTS += [

UNIFIED_SOURCES += [
    'nsEntityConverter.cpp',
    'nsSaveAsCharset.cpp',
]

if CONFIG['ENABLE_INTL_API']:
+0 −50
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsIEntityConverter.idl"

%{C++
#define NS_SAVEASCHARSET_CID { 0xcd233e0, 0x7a86, 0x11d3, { 0x91, 0x5c, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
#define NS_SAVEASCHARSET_CONTRACTID "@mozilla.org/intl/saveascharset;1"
%}

/**
 * DO NOT USE! For compat with legacy extension code only.
 */
[scriptable, uuid(b3b8124f-0abb-460e-88ac-3cf1a0134b2d)]
interface nsISaveAsCharset : nsISupports
{
  // attributes
  const unsigned long mask_Fallback                = 0x000000FF; // mask for fallback (8bits)
  const unsigned long mask_Entity                  = 0x00000300; // mask for entity (2bits)
  const unsigned long mask_CharsetFallback         = 0x00000400; // mask for charset fallback (1bit)

  const unsigned long attr_FallbackNone = 0;                   // IGNORED
  const unsigned long attr_FallbackQuestionMark = 1;           // IGNORED
  const unsigned long attr_FallbackEscapeU = 2;                // IGNORED
  const unsigned long attr_FallbackDecimalNCR = 3;             // IGNORED
  const unsigned long attr_FallbackHexNCR = 4;                 // IGNORED

  const unsigned long attr_EntityNone = 0;                       // IGNORED
  const unsigned long attr_EntityBeforeCharsetConv = 0x00000100; // IGNORED
  const unsigned long attr_EntityAfterCharsetConv =  0x00000200; // IGNORED

  const unsigned long attr_CharsetFallback        =  0x00000400; // IGNORED


                                                               // default attribute for plain text
  const unsigned long attr_plainTextDefault = attr_FallbackNone + attr_EntityNone;               
  
                                                               // default attribute for html text
                                                               // generate entity before charset conversion, use decimal NCR
  const unsigned long attr_htmlTextDefault = attr_FallbackDecimalNCR + attr_EntityBeforeCharsetConv;

  readonly attribute AUTF8String charset;                      // charset used for the conversion

  void Init(in AUTF8String charset, in unsigned long ignored, in unsigned long alsoIgnored);

  ACString Convert(in AString inString);
};
+0 −61
Original line number Diff line number Diff line
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsSaveAsCharset.h"

using namespace mozilla;

//
// nsISupports methods
//
NS_IMPL_ISUPPORTS(nsSaveAsCharset, nsISaveAsCharset)

//
// nsSaveAsCharset
//
nsSaveAsCharset::nsSaveAsCharset()
{
}

nsSaveAsCharset::~nsSaveAsCharset()
{
}

NS_IMETHODIMP
nsSaveAsCharset::Init(const nsACString& aCharset, uint32_t aIgnored, uint32_t aAlsoIgnored)
{
  mEncoding = Encoding::ForLabelNoReplacement(aCharset);
  if (!mEncoding) {
    return NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR;
  }
  return NS_OK;
}

NS_IMETHODIMP
nsSaveAsCharset::Convert(const nsAString& aIn, nsACString& aOut)
{
  if (!mEncoding) {
    return NS_ERROR_DOM_ENCODING_NOT_SUPPORTED_ERR;
  }
  nsresult rv;
  const Encoding* ignored;
  Tie(rv, ignored) = mEncoding->Encode(aIn, aOut);
  if (NS_FAILED(rv)) {
    return rv;
  }
  return NS_OK;
}

NS_IMETHODIMP
nsSaveAsCharset::GetCharset(nsACString& aCharset)
{
  if (!mEncoding) {
    aCharset.Truncate();
  } else {
    mEncoding->Name(aCharset);
  }
  return NS_OK;
}
Loading