Bug 1488659 - Part 1: Remove the XPCOM registrations for character detector classes; r=hsivonen

Differential Revision: https://phabricator.services.mozilla.com/D5392
This commit is contained in:
Ehsan Akhgari 2018-09-09 20:27:17 -04:00
Родитель 713ce33a4a
Коммит 15fb2860c4
11 изменённых файлов: 18 добавлений и 136 удалений

Просмотреть файл

@ -6,7 +6,6 @@
UNIFIED_SOURCES += [
'nsUdetXPCOMWrapper.cpp',
'nsUniversalCharDetModule.cpp',
]
FINAL_LIBRARY = 'xul'

Просмотреть файл

@ -10,8 +10,8 @@
#include "nsIStringCharsetDetector.h"
#include "nsICharsetDetectionObserver.h"
#include "nsCOMPtr.h"
#include "nsIFactory.h"
#include "nsUniversalDetector.h"
// {12BB8F1B-2389-11d3-B3BF-00805F8A6670}
#define NS_JA_PSMDETECTOR_CID \

Просмотреть файл

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "mozilla/ModuleUtils.h"
#include "nsCOMPtr.h"
#include "nspr.h"
#include "nsString.h"
#include "nsUniversalCharDetDll.h"
#include "nsISupports.h"
#include "nsICategoryManager.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsICharsetDetector.h"
#include "nsIStringCharsetDetector.h"
#include "nsUniversalDetector.h"
#include "nsUdetXPCOMWrapper.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAPSMDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJAStringPSMDetector)
NS_DEFINE_NAMED_CID(NS_JA_PSMDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_JA_STRING_PSMDETECTOR_CID);
static const mozilla::Module::CIDEntry kChardetCIDs[] = {
{ &kNS_JA_PSMDETECTOR_CID, false, nullptr, nsJAPSMDetectorConstructor },
{ &kNS_JA_STRING_PSMDETECTOR_CID, false, nullptr, nsJAStringPSMDetectorConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kChardetContracts[] = {
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", &kNS_JA_PSMDETECTOR_CID },
{ NS_STRCDETECTOR_CONTRACTID_BASE "ja_parallel_state_machine", &kNS_JA_STRING_PSMDETECTOR_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kChardetCategories[] = {
{ NS_CHARSET_DETECTOR_CATEGORY, "ja_parallel_state_machine", NS_CHARSET_DETECTOR_CONTRACTID_BASE "ja_parallel_state_machine" },
{ nullptr }
};
static const mozilla::Module kChardetModule = {
mozilla::Module::kVersion,
kChardetCIDs,
kChardetContracts,
kChardetCategories
};
NSMODULE_DEFN(nsUniversalCharDetModule) = &kChardetModule;

Просмотреть файл

@ -12,7 +12,6 @@ EXPORTS += [
]
UNIFIED_SOURCES += [
'nsChardetModule.cpp',
'nsCyrillicDetector.cpp',
]

Просмотреть файл

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
/*
* Header file to be included by module -
* warning: defines a whole bunch of static functions
*/
#ifndef nsCharDetConstructors_h__
#define nsCharDetConstructors_h__
// chardet
#include "nsISupports.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionObserver.h"
#include "nsIStringCharsetDetector.h"
#include "nsCyrillicDetector.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUProbDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKProbDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUStringProbDetector)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKStringProbDetector)
#endif

Просмотреть файл

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "mozilla/ModuleUtils.h"
#include "nsCharDetConstructors.h"
NS_DEFINE_NAMED_CID(NS_RU_PROBDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_UK_PROBDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_RU_STRING_PROBDETECTOR_CID);
NS_DEFINE_NAMED_CID(NS_UK_STRING_PROBDETECTOR_CID);
static const mozilla::Module::CIDEntry kChardetCIDs[] = {
{ &kNS_RU_PROBDETECTOR_CID, false, nullptr, nsRUProbDetectorConstructor },
{ &kNS_UK_PROBDETECTOR_CID, false, nullptr, nsUKProbDetectorConstructor },
{ &kNS_RU_STRING_PROBDETECTOR_CID, false, nullptr, nsRUStringProbDetectorConstructor },
{ &kNS_UK_STRING_PROBDETECTOR_CID, false, nullptr, nsUKStringProbDetectorConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kChardetContracts[] = {
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_PROBDETECTOR_CID },
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob", &kNS_UK_PROBDETECTOR_CID },
{ NS_STRCDETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_STRING_PROBDETECTOR_CID },
{ NS_STRCDETECTOR_CONTRACTID_BASE "ukprob", &kNS_UK_STRING_PROBDETECTOR_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kChardetCategories[] = {
{ NS_CHARSET_DETECTOR_CATEGORY, "off", "off" },
{ NS_CHARSET_DETECTOR_CATEGORY, "ruprob", NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob" },
{ NS_CHARSET_DETECTOR_CATEGORY, "ukprob", NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob" },
{ nullptr }
};
static const mozilla::Module kChardetModule = {
mozilla::Module::kVersion,
kChardetCIDs,
kChardetContracts,
kChardetCategories
};
NSMODULE_DEFN(nsChardetModule) = &kChardetModule;

Просмотреть файл

@ -6,6 +6,7 @@
#define nsCyrillicDetector_h__
#include "nsCyrillicClass.h"
#include "nsIStringCharsetDetector.h"

Просмотреть файл

@ -14,9 +14,6 @@ class nsICharsetDetectionObserver;
#define NS_ICHARSETDETECTOR_IID \
{ 0x12bb8f14, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
#define NS_CHARSET_DETECTOR_CONTRACTID_BASE "@mozilla.org/intl/charsetdetect;1?type="
#define NS_CHARSET_DETECTOR_CATEGORY "charset-detectors"
class nsICharsetDetector : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICHARSETDETECTOR_IID)

Просмотреть файл

@ -12,9 +12,6 @@
#define NS_ISTRINGCHARSETDETECTOR_IID \
{ 0x12bb8f15, 0x2389, 0x11d3, { 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
#define NS_STRCDETECTOR_CONTRACTID_BASE "@mozilla.org/intl/stringcharsetdetect;1?type="
/*
This interface is similar to nsICharsetDetector
The difference is it is for line base detection instead of block based

Просмотреть файл

@ -96,6 +96,9 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/dom/base',
'/extensions/universalchardet/src/base',
'/extensions/universalchardet/src/xpcom',
'/intl/chardet',
]
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/Encoding.h"
#include "nsContentUtils.h"
#include "nsCyrillicDetector.h"
#include "nsHtml5Tokenizer.h"
#include "nsIHttpChannel.h"
#include "nsHtml5Parser.h"
@ -31,6 +32,7 @@
#include "nsIThreadRetargetableRequest.h"
#include "nsPrintfCString.h"
#include "nsNetUtil.h"
#include "nsUdetXPCOMWrapper.h"
#include "nsXULAppAPI.h"
#include "mozilla/SchedulerGroup.h"
#include "nsJSEnvironment.h"
@ -203,10 +205,17 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
nsAutoCString detectorName;
Preferences::GetLocalizedCString("intl.charset.detector", detectorName);
if (!detectorName.IsEmpty()) {
nsAutoCString detectorContractID;
detectorContractID.AssignLiteral(NS_CHARSET_DETECTOR_CONTRACTID_BASE);
detectorContractID += detectorName;
if ((mChardet = do_CreateInstance(detectorContractID.get()))) {
// We recognize one of the three magic strings for the following languages.
if (detectorName.EqualsLiteral("ruprob")) {
mChardet = new nsRUProbDetector();
} else if (detectorName.EqualsLiteral("ukprob")) {
mChardet = new nsUKProbDetector();
} else if (detectorName.EqualsLiteral("ja_parallel_state_machine")) {
mChardet = new nsJAPSMDetector();
} else {
mChardet = nullptr;
}
if (mChardet) {
(void)mChardet->Init(this);
mFeedChardet = true;
}