-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgecko.patch
299 lines (284 loc) · 10.8 KB
/
gecko.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# HG changeset patch
# User Henri Sivonen <[email protected]>
# Date 1476099337 -10800
# Mon Oct 10 14:35:37 2016 +0300
# Node ID 20b0566d3ad9e7e3469cfd98e75835b9d3e47095
# Parent 027ab974b5b531d134601b7a006fc0c173fbdfed
Export uconv testing functions and disable various unnecessary things that could interfere.
MozReview-Commit-ID: JjLex95VNEl
diff --git a/intl/uconv/nsUConvModule.cpp b/intl/uconv/nsUConvModule.cpp
--- a/intl/uconv/nsUConvModule.cpp
+++ b/intl/uconv/nsUConvModule.cpp
@@ -1,16 +1,18 @@
/* -*- 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 "nsEncoderDecoderUtils.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeEncoder.h"
+#include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/Unused.h"
#include "nsUConvCID.h"
#include "nsTextToSubURI.h"
#include "nsUTF8ConverterService.h"
#include "nsConverterInputStream.h"
#include "nsConverterOutputStream.h"
#include "nsScriptableUConv.h"
#include "nsIOutputStream.h"
@@ -575,8 +577,73 @@ static const mozilla::Module::ContractID
static const mozilla::Module kUConvModule = {
mozilla::Module::kVersion,
kUConvCIDs,
kUConvContracts,
kUConvCategories
};
NSMODULE_DEFN(nsUConvModule) = &kUConvModule;
+
+EXPORT_XPCOM_API(nsIUnicodeDecoder*)
+NS_CreateUnicodeDecoder(const char* aName, size_t aNameLen)
+{
+ nsDependentCSubstring encoding(aName, aNameLen);
+ nsAutoCString contractId(NS_UNICODEDECODER_CONTRACTID_BASE);
+ contractId.Append(encoding);
+
+ nsCOMPtr<nsIUnicodeDecoder> decoder = do_CreateInstance(contractId.get());
+ MOZ_RELEASE_ASSERT(decoder, "Tried to create decoder for unknown encoding.");
+ return decoder.forget().take();
+}
+
+EXPORT_XPCOM_API(void)
+NS_ReleaseUnicodeDecoder(nsIUnicodeDecoder* aDecoder)
+{
+ NS_RELEASE(aDecoder);
+}
+
+EXPORT_XPCOM_API(void)
+NS_DecodeWithUnicodeDecoder(nsIUnicodeDecoder* aDecoder, const char* aSrc, int32_t aSrcLength,
+ char16_t* aDest, int32_t aDestLength)
+{
+ int32_t oldLen = aSrcLength;
+ MOZ_RELEASE_ASSERT(aDecoder->Convert(aSrc, &aSrcLength, aDest, &aDestLength) == NS_OK);
+ MOZ_RELEASE_ASSERT(aSrcLength == oldLen);
+ aDecoder->Reset();
+}
+
+EXPORT_XPCOM_API(nsIUnicodeEncoder*)
+NS_CreateUnicodeEncoder(const char* aName, size_t aNameLen)
+{
+ nsDependentCSubstring encoding(aName, aNameLen);
+ nsAutoCString contractId(NS_UNICODEENCODER_CONTRACTID_BASE);
+ contractId.Append(encoding);
+
+ nsCOMPtr<nsIUnicodeEncoder> encoder = do_CreateInstance(contractId.get());
+ MOZ_RELEASE_ASSERT(encoder, "Tried to create decoder for unknown encoding.");
+ return encoder.forget().take();
+}
+
+EXPORT_XPCOM_API(void)
+NS_ReleaseUnicodeEncoder(nsIUnicodeEncoder* aEncoder)
+{
+ NS_RELEASE(aEncoder);
+}
+
+EXPORT_XPCOM_API(void)
+NS_EncodeWithUnicodeEncoder(nsIUnicodeEncoder* aEncoder, const char16_t* aSrc, int32_t aSrcLength,
+ char* aDest, int32_t aDestLength)
+{
+ int32_t oldLen = aSrcLength;
+ MOZ_RELEASE_ASSERT(aEncoder->Convert(aSrc, &aSrcLength, aDest, &aDestLength) == NS_OK);
+ MOZ_RELEASE_ASSERT(aSrcLength == oldLen);
+ aEncoder->Reset();
+}
+
+EXPORT_XPCOM_API(int32_t)
+NS_FindEncodingForLabel(const char* aName, size_t aNameLen)
+{
+ nsDependentCSubstring label(aName, aNameLen);
+ nsAutoCString encoding;
+ mozilla::Unused << mozilla::dom::EncodingUtils::FindEncodingForLabel(label, encoding);
+ return encoding.Length();
+}
diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -650,53 +650,53 @@ NS_InitXPCOM2(nsIServiceManager** aResul
nsCycleCollector_startup();
// Register ICU memory functions. This really shouldn't be necessary: the
// JS engine should do this on its own inside JS_Init, and memory-reporting
// code should call a JSAPI function to observe ICU memory usage. But we
// can't define the alloc/free functions in the JS engine, because it can't
// depend on the XPCOM-based memory reporting goop. So for now, we have
// this oddness.
- mozilla::SetICUMemoryFunctions();
+// mozilla::SetICUMemoryFunctions();
// Do the same for libogg.
- ogg_set_mem_functions(OggReporter::CountingMalloc,
- OggReporter::CountingCalloc,
- OggReporter::CountingRealloc,
- OggReporter::CountingFree);
-
-#if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
- // And for VPX.
- vpx_mem_set_functions(VPXReporter::CountingMalloc,
- VPXReporter::CountingCalloc,
- VPXReporter::CountingRealloc,
- VPXReporter::CountingFree,
- memcpy,
- memset,
- memmove);
-#endif
-
-#if EXPOSE_INTL_API && defined(MOZ_ICU_DATA_ARCHIVE)
- nsCOMPtr<nsIFile> greDir;
- nsDirectoryService::gService->Get(NS_GRE_DIR,
- NS_GET_IID(nsIFile),
- getter_AddRefs(greDir));
- MOZ_ASSERT(greDir);
- nsAutoCString nativeGREPath;
- greDir->GetNativePath(nativeGREPath);
- u_setDataDirectory(nativeGREPath.get());
-#endif
-
- // Initialize the JS engine.
- const char* jsInitFailureReason = JS_InitWithFailureDiagnostic();
- if (jsInitFailureReason) {
- NS_RUNTIMEABORT(jsInitFailureReason);
- }
- sInitializedJS = true;
-
+// ogg_set_mem_functions(OggReporter::CountingMalloc,
+// OggReporter::CountingCalloc,
+// OggReporter::CountingRealloc,
+// OggReporter::CountingFree);
+//
+//#if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
+// // And for VPX.
+// vpx_mem_set_functions(VPXReporter::CountingMalloc,
+// VPXReporter::CountingCalloc,
+// VPXReporter::CountingRealloc,
+// VPXReporter::CountingFree,
+// memcpy,
+// memset,
+// memmove);
+//#endif
+//
+//#if EXPOSE_INTL_API && defined(MOZ_ICU_DATA_ARCHIVE)
+// nsCOMPtr<nsIFile> greDir;
+// nsDirectoryService::gService->Get(NS_GRE_DIR,
+// NS_GET_IID(nsIFile),
+// getter_AddRefs(greDir));
+// MOZ_ASSERT(greDir);
+// nsAutoCString nativeGREPath;
+// greDir->GetNativePath(nativeGREPath);
+// u_setDataDirectory(nativeGREPath.get());
+//#endif
+//
+// // Initialize the JS engine.
+// const char* jsInitFailureReason = JS_InitWithFailureDiagnostic();
+// if (jsInitFailureReason) {
+// NS_RUNTIMEABORT(jsInitFailureReason);
+// }
+// sInitializedJS = true;
+//
// Init AbstractThread.
AbstractThread::InitStatics();
rv = nsComponentManagerImpl::gComponentManager->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(nsComponentManagerImpl::gComponentManager);
return rv;
}
@@ -714,18 +714,18 @@ NS_InitXPCOM2(nsIServiceManager** aResul
// to the directory service.
nsDirectoryService::gService->RegisterCategoryProviders();
// Init SharedThreadPool (which needs the service manager).
SharedThreadPool::InitStatics();
// Force layout to spin up so that nsContentUtils is available for cx stack
// munging.
- nsCOMPtr<nsISupports> componentLoader =
- do_GetService("@mozilla.org/moz/jsloader;1");
+// nsCOMPtr<nsISupports> componentLoader =
+// do_GetService("@mozilla.org/moz/jsloader;1");
mozilla::scache::StartupCache::GetSingleton();
mozilla::AvailableMemoryTracker::Activate();
// Notify observers of xpcom autoregistration start
NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_CATEGORY,
nullptr,
NS_XPCOM_STARTUP_OBSERVER_ID);
diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -169,17 +169,17 @@ nsDirectoryService::GetCurrentProcessDir
return NS_OK;
}
}
#if defined(DEBUG)
static bool firstWarning = true;
if ((!moz5 || !*moz5) && firstWarning) {
// Warn that MOZILLA_FIVE_HOME not set, once.
- printf("Warning: MOZILLA_FIVE_HOME not set.\n");
+// printf("Warning: MOZILLA_FIVE_HOME not set.\n");
firstWarning = false;
}
#endif /* DEBUG */
// Fall back to current directory.
if (getcwd(buf, sizeof(buf))) {
localFile->InitWithNativePath(nsDependentCString(buf));
localFile.forget(aFile);
diff --git a/xpcom/string/nsSubstring.cpp b/xpcom/string/nsSubstring.cpp
--- a/xpcom/string/nsSubstring.cpp
+++ b/xpcom/string/nsSubstring.cpp
@@ -65,35 +65,35 @@ public:
{
// this is a hack to suppress duplicate string stats printing
// in seamonkey as a result of the string code being linked
// into seamonkey and libxpcom! :-(
if (!mAllocCount && !mAdoptCount) {
return;
}
- printf("nsStringStats\n");
- printf(" => mAllocCount: % 10d\n", int(mAllocCount));
- printf(" => mReallocCount: % 10d\n", int(mReallocCount));
- printf(" => mFreeCount: % 10d", int(mFreeCount));
- if (mAllocCount > mFreeCount) {
- printf(" -- LEAKED %d !!!\n", mAllocCount - mFreeCount);
- } else {
- printf("\n");
- }
- printf(" => mShareCount: % 10d\n", int(mShareCount));
- printf(" => mAdoptCount: % 10d\n", int(mAdoptCount));
- printf(" => mAdoptFreeCount: % 10d", int(mAdoptFreeCount));
- if (mAdoptCount > mAdoptFreeCount) {
- printf(" -- LEAKED %d !!!\n", mAdoptCount - mAdoptFreeCount);
- } else {
- printf("\n");
- }
- printf(" => Process ID: %" PRIuPTR ", Thread ID: %" PRIuPTR "\n",
- uintptr_t(getpid()), uintptr_t(pthread_self()));
+// printf("nsStringStats\n");
+// printf(" => mAllocCount: % 10d\n", int(mAllocCount));
+// printf(" => mReallocCount: % 10d\n", int(mReallocCount));
+// printf(" => mFreeCount: % 10d", int(mFreeCount));
+// if (mAllocCount > mFreeCount) {
+// printf(" -- LEAKED %d !!!\n", mAllocCount - mFreeCount);
+// } else {
+// printf("\n");
+// }
+// printf(" => mShareCount: % 10d\n", int(mShareCount));
+// printf(" => mAdoptCount: % 10d\n", int(mAdoptCount));
+// printf(" => mAdoptFreeCount: % 10d", int(mAdoptFreeCount));
+// if (mAdoptCount > mAdoptFreeCount) {
+// printf(" -- LEAKED %d !!!\n", mAdoptCount - mAdoptFreeCount);
+// } else {
+// printf("\n");
+// }
+// printf(" => Process ID: %" PRIuPTR ", Thread ID: %" PRIuPTR "\n",
+// uintptr_t(getpid()), uintptr_t(pthread_self()));
}
Atomic<int32_t> mAllocCount;
Atomic<int32_t> mReallocCount;
Atomic<int32_t> mFreeCount;
Atomic<int32_t> mShareCount;
Atomic<int32_t> mAdoptCount;
Atomic<int32_t> mAdoptFreeCount;