mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
35448d94ad
- Bug 1225821 - Add type write barrier to SetPropertyIC dense element stub. r=bhackett (09c2b77da6) - Bug 1222917 - Fix register allocation in GenerateCallSetter. r=bhackett (a6e0ecd82c) - Bug 1219883 - Fix Ion typed array stub to handle constant string index. r=efaust (b568a7729c) - Bug 1215688 - Remove unused path in Ion's BindNameIC. r=jandem (b63444a595) - Bug 1224883: Only lazy linking from jit code expects to have valid jit code afterwards, r=jandem (327a96a3ef) - Bug 1108290 - remove machine-specific definitions of sub32. r=nbp (07b788b0c9) - Bug 1226277 - fix MSVC warning with a cast. r=bbouvier (23e7499d43) - Bug 1224710 - Fix OOM handling bugs revealed by new testcase r=bbouvier (8e3912dcfd) - Bug 1210554 - Add testAssemblerBuffer to jsapi-tests. r=sstangl (6aa5a5e95c) - Bug 1210554 - Implement BranchDeadlineSet. r=nbp (510ca413ca) - Bug 1210554 - Implement constant pool test. r=nbp (e67a359337) - Bug 1210554 - Add PatchShortRangeBranchToVeneer(). r=nbp (2611009dd2) - Bug 1210554 - Fix unified build breakage. r=sfink (b418fe43e5) - Bug 1210554 - Wire up branchDeadlines_ partially. No Asm callbacks yet. r=nbp (cb613e7b58) - Bug 1210554 - Handle toggled calls in CodeFromJump(). r=sstangl (d55a5e89ef) - Bug 1210554 - Add enum ImmBranchRangeType. r=sstangl (bcadf88269) - Bug 1210554 - Dynamically track short-range branches. r=sstangl (c8cca36e65) - Bug 1225859 - IonMonkey: MIPS64: Fix branchTestBoolean(Address) missing. r=jandem (5498faee06) - Bug 1222640 - Fix truncated Simulator return values. r=jandem (97721fa467) - Bug 1090957 - IonMonkey: MIPS32: Implement atomics in MacroAssembler. r=lth (150529e06b) - Bug 1090957 - IonMonkey: MIPS: Implement atomics in Lowering. r=lth (22ae53fd14) - Bug 1090957 - IonMonkey: MIPS: Implement atomics in CodeGenerator. r=lth (8083eccc07) - Bug 1213743 - IonMonkey: MIPS: Import MIPS64 support into CodeGenerator-mips-shared. r=arai (548fe7f3ee) - Bug 1209553 - IonMonkey: MIPS: Add suffix 'f' for constant float32. r=arai (9902d4652a) - Bug 1209962 - IonMonkey: MIPS: Memory barrier optimization. r=lth (96c39a94e9) - Bug 1215999 - ARM64: Remove unnecessary float registers definitions. r=jolesen (199a27685c) - Bug 1207827 - Remove ARM64 temporary offset buffers. r=nbp (66d20a6c55) - Bug 1217606 - Handle OOM in Assembler::emitExtendedJumpTable(). r=sstangl (7e67cbd4f2) - Bug 1207827 - Fix ARM64 OOM bugs in Assembler::bind(). r=nbp (b3aa93f7db) - Bug 1155473 - Make arm-sim-osx SpiderMonkey shell build work on automation. r=sfink (85421372e7) - Bug 1225605: Make the dependency between SimdTypeDescr::Type and the SimdTypes/SimdLanes arrays clearer; r=jolesen (9d96ba8b8e) - Bug 1225605: Simplify SimdTypeDescr::size()/alignment() and remove a macro; r=jolesen (bea72c1836) - Bug 1224974 - fix GTK shaped window drawing. r=bas (8fd0aa180d) - Bug 1226152 - IonMonkey: MIPS64: Make sure the frame pushed are set correctly for ion vmcalls. r=h4writer (9ff4f3fcbb) - Bug 1148235. Cleanup the state that we maintain in SimplifyOutwardByArea. r=ehsan (fc2472f0fa) - Bug 1185840 - Make nsRegion::ToString() print string literal. r=roc (f82daa9b6e) - Bug 1136557 - pt 1 - Ignore bogus ascent/descent values in 'vhea' table. r=smontagu (e0f17faff8) - Bug 1136557 - pt 2 - Round maxDescent similarly to maxAscent in nsFontMetrics. r=smontagu (b1effc999b) - Bug 1196355: WriteAppNote should use function parameter. r=benwa (0ce7d33286) - Bug 1195152. Pass correct YUV type when converting shared YUV image to RGB. r=nical (133dc40c35) - Bug 852814 - Move the last remaining EXTRA_DSO_LDOPTS to moz.build. r=gps (5ca3d2b687) - Bug 319030: remove fossil support for RACE encoding and multilingual test bed from IDN code, r=jfkthame (3d76161522) - Bug 321491: Refactor error handling in nsIDNService, r=mcmanus (32aae2327f) - Bug 479520: Implement IDNA2008 standard for International Domain Names, patch 1: build system changes, r=ted; code changes, r=jfkthame (0a41d31c03) - Bug 479520: Implement IDNA2008 standard for International Domain Names, patch 2: changes to existing tests, r=jfkthame. (4697b86b73) - Bug 1221453 - Use AbsolutePaths with LOCAL_INCLUDES instead of manual -I in CXXFLAGS. r=gps (e714580566) - Bug 1201468: Map UErrorCode to nsresult, r=jfkthame (9d6cf0fe20) - Bug 479520: Implement IDNA2008 standard for International Domain Names, patch 3: test for transitional processing and CONTEXTJ, r=jfkthame. (179ba01cbc) - Bug 1218179: move from transitional to non-transitional IDNA2008 processing, r=jfkthame (d76a053f00) - Bug 1197923 - Use channel->Open2() in intl/strres/nsStringBundle.cpp (r=sicking) (bc34312da8) - Bug 1205153 - Use channel->Open2() in intl/strres/nsStringBundleTextOverride.cpp (r=sicking) (2ac5e3b920)
287 lines
7.9 KiB
C++
287 lines
7.9 KiB
C++
/* -*- 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 "nsStringBundleTextOverride.h"
|
|
#include "nsString.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
#include "nsContentUtils.h"
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
// first we need a simple class which wraps a nsIPropertyElement and
|
|
// cuts out the leading URL from the key
|
|
class URLPropertyElement : public nsIPropertyElement
|
|
{
|
|
public:
|
|
URLPropertyElement(nsIPropertyElement *aRealElement, uint32_t aURLLength) :
|
|
mRealElement(aRealElement),
|
|
mURLLength(aURLLength)
|
|
{ }
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIPROPERTYELEMENT
|
|
|
|
private:
|
|
nsCOMPtr<nsIPropertyElement> mRealElement;
|
|
uint32_t mURLLength;
|
|
|
|
virtual ~URLPropertyElement() {}
|
|
};
|
|
|
|
NS_IMPL_ISUPPORTS(URLPropertyElement, nsIPropertyElement)
|
|
|
|
// we'll tweak the key on the way through, and remove the url prefix
|
|
NS_IMETHODIMP
|
|
URLPropertyElement::GetKey(nsACString& aKey)
|
|
{
|
|
nsresult rv = mRealElement->GetKey(aKey);
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
// chop off the url
|
|
aKey.Cut(0, mURLLength);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
// values are unaffected
|
|
NS_IMETHODIMP
|
|
URLPropertyElement::GetValue(nsAString& aValue)
|
|
{
|
|
return mRealElement->GetValue(aValue);
|
|
}
|
|
|
|
// setters are kind of strange, hopefully we'll never be called
|
|
NS_IMETHODIMP
|
|
URLPropertyElement::SetKey(const nsACString& aKey)
|
|
{
|
|
// this is just wrong - ideally you'd take the key, append it to
|
|
// the url, and set that as the key. However, that would require
|
|
// us to hold onto a copy of the string, and that's a waste,
|
|
// considering nobody should ever be calling this.
|
|
NS_ERROR("This makes no sense!");
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
URLPropertyElement::SetValue(const nsAString& aValue)
|
|
{
|
|
return mRealElement->SetValue(aValue);
|
|
}
|
|
|
|
|
|
// this is a special enumerator which returns only the elements which
|
|
// are prefixed with a particular url
|
|
class nsPropertyEnumeratorByURL : public nsISimpleEnumerator
|
|
{
|
|
public:
|
|
nsPropertyEnumeratorByURL(const nsACString& aURL,
|
|
nsISimpleEnumerator* aOuter) :
|
|
mOuter(aOuter),
|
|
mURL(aURL)
|
|
{
|
|
// prepare the url once so we can use its value later
|
|
// persistent properties uses ":" as a delimiter, so escape
|
|
// that character
|
|
mURL.ReplaceSubstring(":", "%3A");
|
|
// there is always a # between the url and the real key
|
|
mURL.Append('#');
|
|
}
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSISIMPLEENUMERATOR
|
|
|
|
private:
|
|
|
|
// actual enumerator of all strings from nsIProperties
|
|
nsCOMPtr<nsISimpleEnumerator> mOuter;
|
|
|
|
// the current element that is valid for this url
|
|
nsCOMPtr<nsIPropertyElement> mCurrent;
|
|
|
|
// the url in question, pre-escaped and with the # already in it
|
|
nsCString mURL;
|
|
|
|
virtual ~nsPropertyEnumeratorByURL() {}
|
|
};
|
|
|
|
//
|
|
// nsStringBundleTextOverride implementation
|
|
//
|
|
NS_IMPL_ISUPPORTS(nsStringBundleTextOverride,
|
|
nsIStringBundleOverride)
|
|
|
|
nsresult
|
|
nsStringBundleTextOverride::Init()
|
|
{
|
|
nsresult rv;
|
|
|
|
// check for existence of custom-strings.txt
|
|
|
|
nsCOMPtr<nsIFile> customStringsFile;
|
|
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR,
|
|
getter_AddRefs(customStringsFile));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
// bail if not found - this will cause the service creation to
|
|
// bail as well, and cause this object to go away
|
|
|
|
customStringsFile->AppendNative(NS_LITERAL_CSTRING("custom-strings.txt"));
|
|
|
|
bool exists;
|
|
rv = customStringsFile->Exists(&exists);
|
|
if (NS_FAILED(rv) || !exists)
|
|
return NS_ERROR_FAILURE;
|
|
|
|
NS_WARNING("Using custom-strings.txt to override string bundles.");
|
|
// read in the custom bundle. Keys are in the form
|
|
// chrome://package/locale/foo.properties:keyname
|
|
|
|
nsAutoCString customStringsURLSpec;
|
|
rv = NS_GetURLSpecFromFile(customStringsFile, customStringsURLSpec);
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
rv = NS_NewURI(getter_AddRefs(uri), customStringsURLSpec);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsCOMPtr<nsIChannel> channel;
|
|
rv = NS_NewChannel(getter_AddRefs(channel),
|
|
uri,
|
|
nsContentUtils::GetSystemPrincipal(),
|
|
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
|
|
nsIContentPolicy::TYPE_OTHER);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
nsCOMPtr<nsIInputStream> in;
|
|
rv = channel->Open2(getter_AddRefs(in));
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID);
|
|
mValues = do_CreateInstance(kPersistentPropertiesCID, &rv);
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
rv = mValues->Load(in);
|
|
|
|
// turn this on to see the contents of custom-strings.txt
|
|
#ifdef DEBUG_alecf
|
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
|
mValues->Enumerate(getter_AddRefs(enumerator));
|
|
NS_ASSERTION(enumerator, "no enumerator!\n");
|
|
|
|
printf("custom-strings.txt contains:\n");
|
|
printf("----------------------------\n");
|
|
|
|
bool hasMore;
|
|
enumerator->HasMoreElements(&hasMore);
|
|
do {
|
|
nsCOMPtr<nsISupports> sup;
|
|
enumerator->GetNext(getter_AddRefs(sup));
|
|
|
|
nsCOMPtr<nsIPropertyElement> prop = do_QueryInterface(sup);
|
|
|
|
nsAutoCString key;
|
|
nsAutoString value;
|
|
prop->GetKey(key);
|
|
prop->GetValue(value);
|
|
|
|
printf("%s = '%s'\n", key.get(), NS_ConvertUTF16toUTF8(value).get());
|
|
|
|
enumerator->HasMoreElements(&hasMore);
|
|
} while (hasMore);
|
|
#endif
|
|
|
|
return rv;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsStringBundleTextOverride::GetStringFromName(const nsACString& aURL,
|
|
const nsACString& key,
|
|
nsAString& aResult)
|
|
{
|
|
// concatenate url#key to get the key to read
|
|
nsAutoCString combinedURL(aURL + NS_LITERAL_CSTRING("#") + key);
|
|
|
|
// persistent properties uses ":" as a delimiter, so escape that character
|
|
combinedURL.ReplaceSubstring(":", "%3A");
|
|
|
|
return mValues->GetStringProperty(combinedURL, aResult);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsStringBundleTextOverride::EnumerateKeysInBundle(const nsACString& aURL,
|
|
nsISimpleEnumerator** aResult)
|
|
{
|
|
// enumerate all strings, and let the enumerator know
|
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
|
mValues->Enumerate(getter_AddRefs(enumerator));
|
|
|
|
// make the enumerator wrapper and pass it off
|
|
nsPropertyEnumeratorByURL* propEnum =
|
|
new nsPropertyEnumeratorByURL(aURL, enumerator);
|
|
|
|
if (!propEnum) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(*aResult = propEnum);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
//
|
|
// nsPropertyEnumeratorByURL implementation
|
|
//
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(nsPropertyEnumeratorByURL, nsISimpleEnumerator)
|
|
|
|
NS_IMETHODIMP
|
|
nsPropertyEnumeratorByURL::GetNext(nsISupports **aResult)
|
|
{
|
|
if (!mCurrent) return NS_ERROR_UNEXPECTED;
|
|
|
|
// wrap mCurrent instead of returning it
|
|
*aResult = new URLPropertyElement(mCurrent, mURL.Length());
|
|
NS_ADDREF(*aResult);
|
|
|
|
// release it so we don't return it twice
|
|
mCurrent = nullptr;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsPropertyEnumeratorByURL::HasMoreElements(bool * aResult)
|
|
{
|
|
bool hasMore;
|
|
mOuter->HasMoreElements(&hasMore);
|
|
while (hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
mOuter->GetNext(getter_AddRefs(supports));
|
|
|
|
mCurrent = do_QueryInterface(supports);
|
|
|
|
if (mCurrent) {
|
|
nsAutoCString curKey;
|
|
mCurrent->GetKey(curKey);
|
|
|
|
if (StringBeginsWith(curKey, mURL))
|
|
break;
|
|
}
|
|
|
|
mOuter->HasMoreElements(&hasMore);
|
|
}
|
|
|
|
if (!hasMore)
|
|
mCurrent = nullptr;
|
|
|
|
*aResult = mCurrent ? true : false;
|
|
|
|
return NS_OK;
|
|
}
|