зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to mozilla-central r=merge a=merge
This commit is contained in:
Коммит
919dce54f4
|
@ -7,6 +7,7 @@
|
|||
#ifndef MOZILLA_SOURCEBUFFERRESOURCE_H_
|
||||
#define MOZILLA_SOURCEBUFFERRESOURCE_H_
|
||||
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "MediaResource.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "MediaPrefs.h"
|
||||
#include "MediaSourceDemuxer.h"
|
||||
#include "MediaSourceUtils.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "SourceBuffer.h"
|
||||
#include "SourceBufferResource.h"
|
||||
|
|
|
@ -117,13 +117,8 @@ using namespace mozilla;
|
|||
// The old low-level prefs API
|
||||
//===========================================================================
|
||||
|
||||
struct PrefHashEntry;
|
||||
|
||||
typedef nsTArray<nsCString> PrefSaveData;
|
||||
|
||||
static PrefHashEntry*
|
||||
pref_HashTableLookup(const char* aKey);
|
||||
|
||||
// 1 MB should be enough for everyone.
|
||||
static const uint32_t MAX_PREF_LENGTH = 1 * 1024 * 1024;
|
||||
// Actually, 4kb should be enough for everyone.
|
||||
|
@ -165,143 +160,207 @@ PrefTypeToString(PrefType aType)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Keep the type of the preference, as well as the flags guiding its behaviour.
|
||||
class PrefTypeFlags
|
||||
static ArenaAllocator<8192, 1> gPrefNameArena;
|
||||
|
||||
class PrefHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
public:
|
||||
PrefTypeFlags()
|
||||
: mValue(AsInt(PrefType::Invalid))
|
||||
PrefHashEntry(const char* aName, PrefType aType)
|
||||
{
|
||||
mName = ArenaStrdup(aName, gPrefNameArena);
|
||||
SetType(aType);
|
||||
// We don't set the other fields because PLDHashTable always zeroes new
|
||||
// entries.
|
||||
}
|
||||
|
||||
explicit PrefTypeFlags(PrefType aType)
|
||||
: mValue(AsInt(aType))
|
||||
const char* Name() { return mName; }
|
||||
|
||||
// Types.
|
||||
|
||||
PrefType Type() const { return static_cast<PrefType>(mType); }
|
||||
void SetType(PrefType aType) { mType = static_cast<uint32_t>(aType); }
|
||||
|
||||
bool IsType(PrefType aType) const { return Type() == aType; }
|
||||
bool IsTypeString() const { return IsType(PrefType::String); }
|
||||
bool IsTypeInt() const { return IsType(PrefType::Int); }
|
||||
bool IsTypeBool() const { return IsType(PrefType::Bool); }
|
||||
|
||||
// Other properties.
|
||||
|
||||
bool IsSticky() const { return mIsSticky; }
|
||||
void SetIsSticky(bool aValue) { mIsSticky = aValue; }
|
||||
|
||||
bool IsLocked() const { return mIsLocked; }
|
||||
void SetIsLocked(bool aValue) { mIsLocked = aValue; }
|
||||
|
||||
bool HasDefaultValue() const { return mHasDefaultValue; }
|
||||
void SetHasDefaultValue(bool aValue) { mHasDefaultValue = aValue; }
|
||||
|
||||
bool HasUserValue() const { return mHasUserValue; }
|
||||
void SetHasUserValue(bool aValue) { mHasUserValue = aValue; }
|
||||
|
||||
// Other operations.
|
||||
|
||||
static bool MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
|
||||
{
|
||||
auto pref = static_cast<const PrefHashEntry*>(aEntry);
|
||||
auto key = static_cast<const char*>(aKey);
|
||||
|
||||
if (pref->mName == aKey) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pref->mName || !aKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strcmp(pref->mName, key) == 0;
|
||||
}
|
||||
|
||||
PrefTypeFlags& Reset()
|
||||
static void ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
mValue = AsInt(PrefType::Invalid);
|
||||
return *this;
|
||||
}
|
||||
auto pref = static_cast<PrefHashEntry*>(aEntry);
|
||||
|
||||
bool IsTypeValid() const { return !IsPrefType(PrefType::Invalid); }
|
||||
bool IsTypeString() const { return IsPrefType(PrefType::String); }
|
||||
bool IsTypeInt() const { return IsPrefType(PrefType::Int); }
|
||||
bool IsTypeBool() const { return IsPrefType(PrefType::Bool); }
|
||||
bool IsPrefType(PrefType type) const { return GetPrefType() == type; }
|
||||
if (pref->IsTypeString()) {
|
||||
free(const_cast<char*>(pref->mDefaultValue.mStringVal));
|
||||
free(const_cast<char*>(pref->mUserValue.mStringVal));
|
||||
}
|
||||
|
||||
void SetPrefType(PrefType aType)
|
||||
{
|
||||
mValue = mValue - AsInt(GetPrefType()) + AsInt(aType);
|
||||
}
|
||||
|
||||
PrefType GetPrefType() const
|
||||
{
|
||||
return (PrefType)(mValue & (AsInt(PrefType::String) | AsInt(PrefType::Int) |
|
||||
AsInt(PrefType::Bool)));
|
||||
}
|
||||
|
||||
bool HasDefaultValue() const { return mValue & PREF_FLAG_HAS_DEFAULT_VALUE; }
|
||||
|
||||
void SetHasDefaultValue(bool aSetOrUnset)
|
||||
{
|
||||
SetFlag(PREF_FLAG_HAS_DEFAULT_VALUE, aSetOrUnset);
|
||||
}
|
||||
|
||||
bool IsSticky() const { return mValue & PREF_FLAG_STICKY; }
|
||||
|
||||
void SetIsSticky(bool aSetOrUnset)
|
||||
{
|
||||
SetFlag(PREF_FLAG_STICKY, aSetOrUnset);
|
||||
}
|
||||
|
||||
bool IsLocked() const { return mValue & PREF_FLAG_LOCKED; }
|
||||
|
||||
void SetLocked(bool aSetOrUnset) { SetFlag(PREF_FLAG_LOCKED, aSetOrUnset); }
|
||||
|
||||
bool HasUserValue() const { return mValue & PREF_FLAG_HAS_USER_VALUE; }
|
||||
|
||||
void SetHasUserValue(bool aSetOrUnset)
|
||||
{
|
||||
SetFlag(PREF_FLAG_HAS_USER_VALUE, aSetOrUnset);
|
||||
// Don't need to free this because it's allocated in memory owned by
|
||||
// gPrefNameArena.
|
||||
pref->mName = nullptr;
|
||||
memset(aEntry, 0, aTable->EntrySize());
|
||||
}
|
||||
|
||||
private:
|
||||
static uint16_t AsInt(PrefType aType) { return (uint16_t)aType; }
|
||||
|
||||
void SetFlag(uint16_t aFlag, bool aSetOrUnset)
|
||||
static void AssignPrefValueToDomPrefValue(PrefType aType,
|
||||
PrefValue* aValue,
|
||||
dom::PrefValue* aDomValue)
|
||||
{
|
||||
mValue = aSetOrUnset ? mValue | aFlag : mValue & ~aFlag;
|
||||
switch (aType) {
|
||||
case PrefType::String:
|
||||
*aDomValue = nsDependentCString(aValue->mStringVal);
|
||||
return;
|
||||
|
||||
case PrefType::Int:
|
||||
*aDomValue = aValue->mIntVal;
|
||||
return;
|
||||
|
||||
case PrefType::Bool:
|
||||
*aDomValue = !!aValue->mBoolVal;
|
||||
return;
|
||||
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
|
||||
// We pack both the value of type (PrefType) and flags into the same int. The
|
||||
// flag enum starts at 4 so that the PrefType can occupy the bottom two bits.
|
||||
enum
|
||||
public:
|
||||
void ToSetting(dom::PrefSetting* aSetting)
|
||||
{
|
||||
PREF_FLAG_LOCKED = 4,
|
||||
PREF_FLAG_HAS_USER_VALUE = 8,
|
||||
PREF_FLAG_HAS_DEFAULT_VALUE = 16,
|
||||
PREF_FLAG_STICKY = 32,
|
||||
};
|
||||
uint16_t mValue;
|
||||
};
|
||||
aSetting->name() = mName;
|
||||
|
||||
struct PrefHashEntry : PLDHashEntryHdr
|
||||
{
|
||||
PrefTypeFlags mPrefFlags; // this field first to minimize 64-bit struct size
|
||||
const char* mKey;
|
||||
PrefValue mDefaultValue;
|
||||
PrefValue mUserValue;
|
||||
if (HasDefaultValue()) {
|
||||
aSetting->defaultValue() = dom::PrefValue();
|
||||
AssignPrefValueToDomPrefValue(
|
||||
Type(), &mDefaultValue, &aSetting->defaultValue().get_PrefValue());
|
||||
} else {
|
||||
aSetting->defaultValue() = null_t();
|
||||
}
|
||||
|
||||
if (HasUserValue()) {
|
||||
aSetting->userValue() = dom::PrefValue();
|
||||
AssignPrefValueToDomPrefValue(
|
||||
Type(), &mUserValue, &aSetting->userValue().get_PrefValue());
|
||||
} else {
|
||||
aSetting->userValue() = null_t();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSetting->defaultValue().type() ==
|
||||
dom::MaybePrefValue::Tnull_t ||
|
||||
aSetting->userValue().type() == dom::MaybePrefValue::Tnull_t ||
|
||||
(aSetting->defaultValue().get_PrefValue().type() ==
|
||||
aSetting->userValue().get_PrefValue().type()));
|
||||
}
|
||||
|
||||
bool HasAdvisablySizedValues()
|
||||
{
|
||||
if (!IsTypeString()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* stringVal;
|
||||
if (HasDefaultValue()) {
|
||||
stringVal = mDefaultValue.mStringVal;
|
||||
if (strlen(stringVal) > MAX_ADVISABLE_PREF_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasUserValue()) {
|
||||
stringVal = mUserValue.mStringVal;
|
||||
if (strlen(stringVal) > MAX_ADVISABLE_PREF_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Overwrite the type and value of an existing preference. Caller must ensure
|
||||
// that they are not changing the type of a preference that has a default
|
||||
// value.
|
||||
void ReplaceValue(PrefValueKind aKind, PrefType aNewType, PrefValue aNewValue)
|
||||
{
|
||||
PrefValue* value =
|
||||
aKind == PrefValueKind::Default ? &mDefaultValue : &mUserValue;
|
||||
|
||||
if (Type() == PrefType::String) {
|
||||
free(const_cast<char*>(value->mStringVal));
|
||||
}
|
||||
|
||||
SetType(aNewType);
|
||||
|
||||
if (aNewType == PrefType::String) {
|
||||
MOZ_ASSERT(aNewValue.mStringVal);
|
||||
value->mStringVal = moz_xstrdup(aNewValue.mStringVal);
|
||||
} else {
|
||||
*value = aNewValue;
|
||||
}
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
// Note: mKey is allocated in gPrefNameArena, measured elsewhere.
|
||||
// Note: mName is allocated in gPrefNameArena, measured elsewhere.
|
||||
size_t n = 0;
|
||||
if (mPrefFlags.IsTypeString()) {
|
||||
if (mPrefFlags.HasDefaultValue()) {
|
||||
if (IsTypeString()) {
|
||||
if (HasDefaultValue()) {
|
||||
n += aMallocSizeOf(mDefaultValue.mStringVal);
|
||||
}
|
||||
if (mPrefFlags.HasUserValue()) {
|
||||
if (HasUserValue()) {
|
||||
n += aMallocSizeOf(mUserValue.mStringVal);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
private:
|
||||
// These fields go first to minimize this struct's size on 64-bit. (Because
|
||||
// this a subclass of PLDHashEntryHdr, there's a preceding 32-bit mKeyHash
|
||||
// field.)
|
||||
uint32_t mType : 2;
|
||||
uint32_t mIsSticky : 1;
|
||||
uint32_t mIsLocked : 1;
|
||||
uint32_t mHasUserValue : 1;
|
||||
uint32_t mHasDefaultValue : 1;
|
||||
|
||||
const char* mName;
|
||||
|
||||
public:
|
||||
PrefValue mDefaultValue;
|
||||
PrefValue mUserValue;
|
||||
};
|
||||
|
||||
static void
|
||||
ClearPrefEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
auto pref = static_cast<PrefHashEntry*>(aEntry);
|
||||
if (pref->mPrefFlags.IsTypeString()) {
|
||||
free(const_cast<char*>(pref->mDefaultValue.mStringVal));
|
||||
free(const_cast<char*>(pref->mUserValue.mStringVal));
|
||||
}
|
||||
|
||||
// Don't need to free this because it's allocated in memory owned by
|
||||
// gPrefNameArena.
|
||||
pref->mKey = nullptr;
|
||||
memset(aEntry, 0, aTable->EntrySize());
|
||||
}
|
||||
|
||||
static bool
|
||||
MatchPrefEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
|
||||
{
|
||||
auto pref = static_cast<const PrefHashEntry*>(aEntry);
|
||||
|
||||
if (pref->mKey == aKey) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pref->mKey || !aKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto otherKey = static_cast<const char*>(aKey);
|
||||
return (strcmp(pref->mKey, otherKey) == 0);
|
||||
}
|
||||
|
||||
struct CallbackNode
|
||||
{
|
||||
const char* mDomain;
|
||||
|
@ -317,8 +376,6 @@ struct CallbackNode
|
|||
|
||||
static PLDHashTable* gHashTable;
|
||||
|
||||
static ArenaAllocator<8192, 1> gPrefNameArena;
|
||||
|
||||
// The callback list contains all the priority callbacks followed by the
|
||||
// non-priority callbacks. gLastPriorityNode records where the first part ends.
|
||||
static CallbackNode* gFirstCallback = nullptr;
|
||||
|
@ -332,14 +389,17 @@ static bool gShouldCleanupDeadNodes = false;
|
|||
|
||||
static PLDHashTableOps pref_HashTableOps = {
|
||||
PLDHashTable::HashStringKey,
|
||||
MatchPrefEntry,
|
||||
PrefHashEntry::MatchEntry,
|
||||
PLDHashTable::MoveEntryStub,
|
||||
ClearPrefEntry,
|
||||
PrefHashEntry::ClearEntry,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
static PrefHashEntry*
|
||||
pref_HashTableLookup(const char* aPrefName);
|
||||
|
||||
static bool
|
||||
pref_ValueChanged(PrefValue aOldValue, PrefValue aNewValue, PrefType aType);
|
||||
|
||||
|
@ -353,12 +413,6 @@ enum
|
|||
kPrefSticky = 4,
|
||||
};
|
||||
|
||||
static nsresult
|
||||
pref_SetPref(const char* aKey,
|
||||
PrefValue aValue,
|
||||
PrefType aType,
|
||||
uint32_t aFlags);
|
||||
|
||||
#define PREF_HASHTABLE_INITIAL_LENGTH 1024
|
||||
|
||||
// Assign to aResult a quoted, escaped copy of aOriginal.
|
||||
|
@ -423,12 +477,10 @@ pref_savePrefs()
|
|||
// where we're getting our pref from
|
||||
PrefValue* sourceValue;
|
||||
|
||||
if (pref->mPrefFlags.HasUserValue() &&
|
||||
(pref_ValueChanged(pref->mDefaultValue,
|
||||
pref->mUserValue,
|
||||
pref->mPrefFlags.GetPrefType()) ||
|
||||
!pref->mPrefFlags.HasDefaultValue() ||
|
||||
pref->mPrefFlags.IsSticky())) {
|
||||
if (pref->HasUserValue() &&
|
||||
(pref_ValueChanged(
|
||||
pref->mDefaultValue, pref->mUserValue, pref->Type()) ||
|
||||
!pref->HasDefaultValue() || pref->IsSticky())) {
|
||||
sourceValue = &pref->mUserValue;
|
||||
} else {
|
||||
// do not save default prefs that haven't changed
|
||||
|
@ -436,16 +488,16 @@ pref_savePrefs()
|
|||
}
|
||||
|
||||
nsAutoCString prefName;
|
||||
StrEscape(pref->mKey, prefName);
|
||||
StrEscape(pref->Name(), prefName);
|
||||
|
||||
nsAutoCString prefValue;
|
||||
if (pref->mPrefFlags.IsTypeString()) {
|
||||
if (pref->IsTypeString()) {
|
||||
StrEscape(sourceValue->mStringVal, prefValue);
|
||||
|
||||
} else if (pref->mPrefFlags.IsTypeInt()) {
|
||||
} else if (pref->IsTypeInt()) {
|
||||
prefValue.AppendInt(sourceValue->mIntVal);
|
||||
|
||||
} else if (pref->mPrefFlags.IsTypeBool()) {
|
||||
} else if (pref->IsTypeBool()) {
|
||||
prefValue = sourceValue->mBoolVal ? "true" : "false";
|
||||
}
|
||||
|
||||
|
@ -456,86 +508,6 @@ pref_savePrefs()
|
|||
return savedPrefs;
|
||||
}
|
||||
|
||||
static bool
|
||||
pref_EntryHasAdvisablySizedValues(PrefHashEntry* aPref)
|
||||
{
|
||||
if (aPref->mPrefFlags.GetPrefType() != PrefType::String) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* stringVal;
|
||||
if (aPref->mPrefFlags.HasDefaultValue()) {
|
||||
stringVal = aPref->mDefaultValue.mStringVal;
|
||||
if (strlen(stringVal) > MAX_ADVISABLE_PREF_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (aPref->mPrefFlags.HasUserValue()) {
|
||||
stringVal = aPref->mUserValue.mStringVal;
|
||||
if (strlen(stringVal) > MAX_ADVISABLE_PREF_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
GetPrefValueFromEntry(PrefHashEntry* aPref,
|
||||
dom::PrefSetting* aSetting,
|
||||
PrefValueKind aKind)
|
||||
{
|
||||
PrefValue* value;
|
||||
dom::PrefValue* settingValue;
|
||||
if (aKind == PrefValueKind::User) {
|
||||
value = &aPref->mUserValue;
|
||||
aSetting->userValue() = dom::PrefValue();
|
||||
settingValue = &aSetting->userValue().get_PrefValue();
|
||||
} else {
|
||||
value = &aPref->mDefaultValue;
|
||||
aSetting->defaultValue() = dom::PrefValue();
|
||||
settingValue = &aSetting->defaultValue().get_PrefValue();
|
||||
}
|
||||
|
||||
switch (aPref->mPrefFlags.GetPrefType()) {
|
||||
case PrefType::String:
|
||||
*settingValue = nsDependentCString(value->mStringVal);
|
||||
return;
|
||||
case PrefType::Int:
|
||||
*settingValue = value->mIntVal;
|
||||
return;
|
||||
case PrefType::Bool:
|
||||
*settingValue = !!value->mBoolVal;
|
||||
return;
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pref_GetPrefFromEntry(PrefHashEntry* aPref, dom::PrefSetting* aSetting)
|
||||
{
|
||||
aSetting->name() = aPref->mKey;
|
||||
|
||||
if (aPref->mPrefFlags.HasDefaultValue()) {
|
||||
GetPrefValueFromEntry(aPref, aSetting, PrefValueKind::Default);
|
||||
} else {
|
||||
aSetting->defaultValue() = null_t();
|
||||
}
|
||||
|
||||
if (aPref->mPrefFlags.HasUserValue()) {
|
||||
GetPrefValueFromEntry(aPref, aSetting, PrefValueKind::User);
|
||||
} else {
|
||||
aSetting->userValue() = null_t();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aSetting->defaultValue().type() == dom::MaybePrefValue::Tnull_t ||
|
||||
aSetting->userValue().type() == dom::MaybePrefValue::Tnull_t ||
|
||||
(aSetting->defaultValue().get_PrefValue().type() ==
|
||||
aSetting->userValue().get_PrefValue().type()));
|
||||
}
|
||||
|
||||
static bool
|
||||
PREF_HasUserPref(const char* aPrefName)
|
||||
{
|
||||
|
@ -544,7 +516,7 @@ PREF_HasUserPref(const char* aPrefName)
|
|||
}
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
return pref && pref->mPrefFlags.HasUserValue();
|
||||
return pref && pref->HasUserValue();
|
||||
}
|
||||
|
||||
// Clears the given pref (reverts it to its default value).
|
||||
|
@ -556,10 +528,10 @@ PREF_ClearUserPref(const char* aPrefName)
|
|||
}
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (pref && pref->mPrefFlags.HasUserValue()) {
|
||||
pref->mPrefFlags.SetHasUserValue(false);
|
||||
if (pref && pref->HasUserValue()) {
|
||||
pref->SetHasUserValue(false);
|
||||
|
||||
if (!pref->mPrefFlags.HasDefaultValue()) {
|
||||
if (!pref->HasDefaultValue()) {
|
||||
gHashTable->RemoveEntry(pref);
|
||||
}
|
||||
|
||||
|
@ -583,13 +555,13 @@ PREF_ClearAllUserPrefs()
|
|||
for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto pref = static_cast<PrefHashEntry*>(iter.Get());
|
||||
|
||||
if (pref->mPrefFlags.HasUserValue()) {
|
||||
if (!prefNames.append(pref->mKey)) {
|
||||
if (pref->HasUserValue()) {
|
||||
if (!prefNames.append(pref->Name())) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
pref->mPrefFlags.SetHasUserValue(false);
|
||||
if (!pref->mPrefFlags.HasDefaultValue()) {
|
||||
pref->SetHasUserValue(false);
|
||||
if (!pref->HasDefaultValue()) {
|
||||
iter.Remove();
|
||||
}
|
||||
}
|
||||
|
@ -606,26 +578,26 @@ PREF_ClearAllUserPrefs()
|
|||
// Function that sets whether or not the preference is locked and therefore
|
||||
// cannot be changed.
|
||||
static nsresult
|
||||
PREF_LockPref(const char* aKey, bool aLockIt)
|
||||
PREF_LockPref(const char* aPrefName, bool aLockIt)
|
||||
{
|
||||
if (!gHashTable) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aKey);
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (!pref) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (aLockIt) {
|
||||
if (!pref->mPrefFlags.IsLocked()) {
|
||||
pref->mPrefFlags.SetLocked(true);
|
||||
if (!pref->IsLocked()) {
|
||||
pref->SetIsLocked(true);
|
||||
gIsAnyPrefLocked = true;
|
||||
pref_DoCallback(aKey);
|
||||
pref_DoCallback(aPrefName);
|
||||
}
|
||||
} else if (pref->mPrefFlags.IsLocked()) {
|
||||
pref->mPrefFlags.SetLocked(false);
|
||||
pref_DoCallback(aKey);
|
||||
} else if (pref->IsLocked()) {
|
||||
pref->SetIsLocked(false);
|
||||
pref_DoCallback(aPrefName);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -663,49 +635,32 @@ pref_ValueChanged(PrefValue aOldValue, PrefValue aNewValue, PrefType aType)
|
|||
return changed;
|
||||
}
|
||||
|
||||
// Overwrite the type and value of an existing preference. Caller must ensure
|
||||
// that they are not changing the type of a preference that has a default
|
||||
// value.
|
||||
static void
|
||||
pref_SetValue(PrefValue* aExistingValue,
|
||||
PrefType aExistingType,
|
||||
PrefValue aNewValue,
|
||||
PrefType aNewType)
|
||||
{
|
||||
if (aExistingType == PrefType::String) {
|
||||
free(const_cast<char*>(aExistingValue->mStringVal));
|
||||
}
|
||||
|
||||
if (aNewType == PrefType::String) {
|
||||
MOZ_ASSERT(aNewValue.mStringVal);
|
||||
aExistingValue->mStringVal =
|
||||
aNewValue.mStringVal ? moz_xstrdup(aNewValue.mStringVal) : nullptr;
|
||||
} else {
|
||||
*aExistingValue = aNewValue;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static pref_initPhase gPhase = START;
|
||||
|
||||
struct StringComparator
|
||||
{
|
||||
const char* mKey;
|
||||
explicit StringComparator(const char* aKey)
|
||||
: mKey(aKey)
|
||||
const char* mPrefName;
|
||||
|
||||
explicit StringComparator(const char* aPrefName)
|
||||
: mPrefName(aPrefName)
|
||||
{
|
||||
}
|
||||
int operator()(const char* aString) const { return strcmp(mKey, aString); }
|
||||
|
||||
int operator()(const char* aPrefName) const
|
||||
{
|
||||
return strcmp(mPrefName, aPrefName);
|
||||
}
|
||||
};
|
||||
|
||||
static bool
|
||||
InInitArray(const char* aKey)
|
||||
InInitArray(const char* aPrefName)
|
||||
{
|
||||
size_t prefsLen;
|
||||
size_t found;
|
||||
const char** list = mozilla::dom::ContentPrefs::GetContentPrefs(&prefsLen);
|
||||
return BinarySearchIf(list, 0, prefsLen, StringComparator(aKey), &found);
|
||||
return BinarySearchIf(list, 0, prefsLen, StringComparator(aPrefName), &found);
|
||||
}
|
||||
|
||||
static bool gInstallingCallback = false;
|
||||
|
@ -752,7 +707,7 @@ pref_HashTableLookup(const char* aKey)
|
|||
}
|
||||
|
||||
static nsresult
|
||||
pref_SetPref(const char* aKey,
|
||||
pref_SetPref(const char* aPrefName,
|
||||
PrefValue aValue,
|
||||
PrefType aType,
|
||||
uint32_t aFlags)
|
||||
|
@ -763,27 +718,22 @@ pref_SetPref(const char* aKey,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(aKey, fallible));
|
||||
auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(aPrefName, fallible));
|
||||
if (!pref) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// New entry, need to initialize.
|
||||
if (!pref->mKey) {
|
||||
// Initialize the pref entry.
|
||||
pref->mPrefFlags.Reset().SetPrefType(aType);
|
||||
pref->mKey = ArenaStrdup(aKey, gPrefNameArena);
|
||||
memset(&pref->mDefaultValue, 0, sizeof(pref->mDefaultValue));
|
||||
memset(&pref->mUserValue, 0, sizeof(pref->mUserValue));
|
||||
if (!pref->Name()) {
|
||||
// New (zeroed) entry. Initialize it.
|
||||
new (pref) PrefHashEntry(aPrefName, aType);
|
||||
|
||||
} else if (pref->mPrefFlags.HasDefaultValue() &&
|
||||
!pref->mPrefFlags.IsPrefType(aType)) {
|
||||
} else if (pref->HasDefaultValue() && !pref->IsType(aType)) {
|
||||
NS_WARNING(
|
||||
nsPrintfCString(
|
||||
"Ignoring attempt to overwrite value of default pref %s (type %s) with "
|
||||
"the wrong type (%s)!",
|
||||
aKey,
|
||||
PrefTypeToString(pref->mPrefFlags.GetPrefType()),
|
||||
aPrefName,
|
||||
PrefTypeToString(pref->Type()),
|
||||
PrefTypeToString(aType))
|
||||
.get());
|
||||
|
||||
|
@ -792,18 +742,16 @@ pref_SetPref(const char* aKey,
|
|||
|
||||
bool valueChanged = false;
|
||||
if (aFlags & kPrefSetDefault) {
|
||||
if (!pref->mPrefFlags.IsLocked()) {
|
||||
if (!pref->IsLocked()) {
|
||||
// ?? change of semantics?
|
||||
if (pref_ValueChanged(pref->mDefaultValue, aValue, aType) ||
|
||||
!pref->mPrefFlags.HasDefaultValue()) {
|
||||
pref_SetValue(
|
||||
&pref->mDefaultValue, pref->mPrefFlags.GetPrefType(), aValue, aType);
|
||||
pref->mPrefFlags.SetPrefType(aType);
|
||||
pref->mPrefFlags.SetHasDefaultValue(true);
|
||||
!pref->HasDefaultValue()) {
|
||||
pref->ReplaceValue(PrefValueKind::Default, aType, aValue);
|
||||
pref->SetHasDefaultValue(true);
|
||||
if (aFlags & kPrefSticky) {
|
||||
pref->mPrefFlags.SetIsSticky(true);
|
||||
pref->SetIsSticky(true);
|
||||
}
|
||||
if (!pref->mPrefFlags.HasUserValue()) {
|
||||
if (!pref->HasUserValue()) {
|
||||
valueChanged = true;
|
||||
}
|
||||
}
|
||||
|
@ -814,26 +762,22 @@ pref_SetPref(const char* aKey,
|
|||
// If new value is same as the default value and it's not a "sticky" pref,
|
||||
// then un-set the user value. Otherwise, set the user value only if it has
|
||||
// changed.
|
||||
if ((pref->mPrefFlags.HasDefaultValue()) &&
|
||||
!(pref->mPrefFlags.IsSticky()) &&
|
||||
if (pref->HasDefaultValue() && !pref->IsSticky() &&
|
||||
!pref_ValueChanged(pref->mDefaultValue, aValue, aType) &&
|
||||
!(aFlags & kPrefForceSet)) {
|
||||
if (pref->mPrefFlags.HasUserValue()) {
|
||||
if (pref->HasUserValue()) {
|
||||
// XXX should we free a user-set string value if there is one?
|
||||
pref->mPrefFlags.SetHasUserValue(false);
|
||||
if (!pref->mPrefFlags.IsLocked()) {
|
||||
pref->SetHasUserValue(false);
|
||||
if (!pref->IsLocked()) {
|
||||
Preferences::HandleDirty();
|
||||
valueChanged = true;
|
||||
}
|
||||
}
|
||||
} else if (!pref->mPrefFlags.HasUserValue() ||
|
||||
!pref->mPrefFlags.IsPrefType(aType) ||
|
||||
} else if (!pref->HasUserValue() || !pref->IsType(aType) ||
|
||||
pref_ValueChanged(pref->mUserValue, aValue, aType)) {
|
||||
pref_SetValue(
|
||||
&pref->mUserValue, pref->mPrefFlags.GetPrefType(), aValue, aType);
|
||||
pref->mPrefFlags.SetPrefType(aType);
|
||||
pref->mPrefFlags.SetHasUserValue(true);
|
||||
if (!pref->mPrefFlags.IsLocked()) {
|
||||
pref->ReplaceValue(PrefValueKind::User, aType, aValue);
|
||||
pref->SetHasUserValue(true);
|
||||
if (!pref->IsLocked()) {
|
||||
Preferences::HandleDirty();
|
||||
valueChanged = true;
|
||||
}
|
||||
|
@ -841,7 +785,7 @@ pref_SetPref(const char* aKey,
|
|||
}
|
||||
|
||||
if (valueChanged) {
|
||||
return pref_DoCallback(aKey);
|
||||
return pref_DoCallback(aPrefName);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -855,7 +799,7 @@ PREF_PrefIsLocked(const char* aPrefName)
|
|||
bool result = false;
|
||||
if (gIsAnyPrefLocked && gHashTable) {
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (pref && pref->mPrefFlags.IsLocked()) {
|
||||
if (pref && pref->IsLocked()) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
@ -2012,7 +1956,7 @@ nsPrefBranch::GetPrefType(const char* aPrefName, int32_t* aRetVal)
|
|||
if (gHashTable) {
|
||||
PrefHashEntry* pref = pref_HashTableLookup(prefName.get());
|
||||
if (pref) {
|
||||
type = pref->mPrefFlags.GetPrefType();
|
||||
type = pref->Type();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2578,11 +2522,11 @@ nsPrefBranch::DeleteBranch(const char* aStartingAt)
|
|||
auto pref = static_cast<PrefHashEntry*>(iter.Get());
|
||||
|
||||
// The first disjunct matches branches: e.g. a branch name "foo.bar."
|
||||
// matches an mKey "foo.bar.baz" (but it won't match "foo.barrel.baz").
|
||||
// matches a name "foo.bar.baz" (but it won't match "foo.barrel.baz").
|
||||
// The second disjunct matches leaf nodes: e.g. a branch name "foo.bar."
|
||||
// matches an mKey "foo.bar" (by ignoring the trailing '.').
|
||||
nsDependentCString key(pref->mKey);
|
||||
if (StringBeginsWith(key, branchName) || key.Equals(branchNameNoDot)) {
|
||||
// matches a name "foo.bar" (by ignoring the trailing '.').
|
||||
nsDependentCString name(pref->Name());
|
||||
if (StringBeginsWith(name, branchName) || name.Equals(branchNameNoDot)) {
|
||||
iter.Remove();
|
||||
}
|
||||
}
|
||||
|
@ -2615,8 +2559,8 @@ nsPrefBranch::GetChildList(const char* aStartingAt,
|
|||
size_t parentLen = parent.Length();
|
||||
for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto pref = static_cast<PrefHashEntry*>(iter.Get());
|
||||
if (strncmp(pref->mKey, parent.get(), parentLen) == 0) {
|
||||
prefArray.AppendElement(pref->mKey);
|
||||
if (strncmp(pref->Name(), parent.get(), parentLen) == 0) {
|
||||
prefArray.AppendElement(pref->Name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3827,12 +3771,8 @@ void
|
|||
Preferences::GetPreference(PrefSetting* aSetting)
|
||||
{
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aSetting->name().get());
|
||||
if (!pref) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pref_EntryHasAdvisablySizedValues(pref)) {
|
||||
pref_GetPrefFromEntry(pref, aSetting);
|
||||
if (pref && pref->HasAdvisablySizedValues()) {
|
||||
pref->ToSetting(aSetting);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3843,12 +3783,10 @@ Preferences::GetPreferences(InfallibleTArray<PrefSetting>* aSettings)
|
|||
for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
|
||||
auto pref = static_cast<PrefHashEntry*>(iter.Get());
|
||||
|
||||
if (!pref_EntryHasAdvisablySizedValues(pref)) {
|
||||
continue;
|
||||
if (pref->HasAdvisablySizedValues()) {
|
||||
dom::PrefSetting* setting = aSettings->AppendElement();
|
||||
pref->ToSetting(setting);
|
||||
}
|
||||
|
||||
dom::PrefSetting* setting = aSettings->AppendElement();
|
||||
pref_GetPrefFromEntry(pref, setting);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4504,15 +4442,15 @@ Preferences::GetBool(const char* aPrefName, bool* aResult, PrefValueKind aKind)
|
|||
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (!pref || !pref->mPrefFlags.IsTypeBool()) {
|
||||
if (!pref || !pref->IsTypeBool()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (aKind == PrefValueKind::Default || pref->mPrefFlags.IsLocked() ||
|
||||
!pref->mPrefFlags.HasUserValue()) {
|
||||
if (aKind == PrefValueKind::Default || pref->IsLocked() ||
|
||||
!pref->HasUserValue()) {
|
||||
|
||||
// Do we have a default?
|
||||
if (!pref->mPrefFlags.HasDefaultValue()) {
|
||||
if (!pref->HasDefaultValue()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
*aResult = pref->mDefaultValue.mBoolVal;
|
||||
|
@ -4532,15 +4470,15 @@ Preferences::GetInt(const char* aPrefName,
|
|||
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (!pref || !pref->mPrefFlags.IsTypeInt()) {
|
||||
if (!pref || !pref->IsTypeInt()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (aKind == PrefValueKind::Default || pref->mPrefFlags.IsLocked() ||
|
||||
!pref->mPrefFlags.HasUserValue()) {
|
||||
if (aKind == PrefValueKind::Default || pref->IsLocked() ||
|
||||
!pref->HasUserValue()) {
|
||||
|
||||
// Do we have a default?
|
||||
if (!pref->mPrefFlags.HasDefaultValue()) {
|
||||
if (!pref->HasDefaultValue()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
*aResult = pref->mDefaultValue.mIntVal;
|
||||
|
@ -4576,16 +4514,16 @@ Preferences::GetCString(const char* aPrefName,
|
|||
aResult.SetIsVoid(true);
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(aPrefName);
|
||||
if (!pref || !pref->mPrefFlags.IsTypeString()) {
|
||||
if (!pref || !pref->IsTypeString()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
const char* stringVal = nullptr;
|
||||
if (aKind == PrefValueKind::Default || pref->mPrefFlags.IsLocked() ||
|
||||
!pref->mPrefFlags.HasUserValue()) {
|
||||
if (aKind == PrefValueKind::Default || pref->IsLocked() ||
|
||||
!pref->HasUserValue()) {
|
||||
|
||||
// Do we have a default?
|
||||
if (!pref->mPrefFlags.HasDefaultValue()) {
|
||||
if (!pref->HasDefaultValue()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
stringVal = pref->mDefaultValue.mStringVal;
|
||||
|
|
|
@ -12,7 +12,6 @@ BROWSER_CHROME_MANIFESTS += ['tests/mochitest/browser.ini']
|
|||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIExpatSink.idl',
|
||||
'nsIExtendedExpatSink.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'htmlparser'
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "nsParserCIID.h"
|
||||
#include "CParserContext.h"
|
||||
#include "nsIExpatSink.h"
|
||||
#include "nsIExtendedExpatSink.h"
|
||||
#include "nsIContentSink.h"
|
||||
#include "nsParserMsgUtils.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -183,60 +182,6 @@ Driver_HandleExternalEntityRef(void *aExternalEntityRefHandler,
|
|||
aPublicId);
|
||||
}
|
||||
|
||||
static void
|
||||
Driver_HandleStartNamespaceDecl(void *aUserData,
|
||||
const XML_Char *aPrefix,
|
||||
const XML_Char *aUri)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "expat driver should exist");
|
||||
if (aUserData) {
|
||||
static_cast<nsExpatDriver*>(aUserData)->
|
||||
HandleStartNamespaceDecl(aPrefix, aUri);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Driver_HandleEndNamespaceDecl(void *aUserData,
|
||||
const XML_Char *aPrefix)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "expat driver should exist");
|
||||
if (aUserData) {
|
||||
static_cast<nsExpatDriver*>(aUserData)->
|
||||
HandleEndNamespaceDecl(aPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Driver_HandleNotationDecl(void *aUserData,
|
||||
const XML_Char *aNotationName,
|
||||
const XML_Char *aBase,
|
||||
const XML_Char *aSysid,
|
||||
const XML_Char *aPubid)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "expat driver should exist");
|
||||
if (aUserData) {
|
||||
static_cast<nsExpatDriver*>(aUserData)->
|
||||
HandleNotationDecl(aNotationName, aBase, aSysid, aPubid);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Driver_HandleUnparsedEntityDecl(void *aUserData,
|
||||
const XML_Char *aEntityName,
|
||||
const XML_Char *aBase,
|
||||
const XML_Char *aSysid,
|
||||
const XML_Char *aPubid,
|
||||
const XML_Char *aNotationName)
|
||||
{
|
||||
NS_ASSERTION(aUserData, "expat driver should exist");
|
||||
if (aUserData) {
|
||||
static_cast<nsExpatDriver*>(aUserData)->
|
||||
HandleUnparsedEntityDecl(aEntityName, aBase, aSysid, aPubid,
|
||||
aNotationName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************** END CALL BACKS ********************************/
|
||||
|
||||
/***************************** CATALOG UTILS *********************************/
|
||||
|
@ -334,7 +279,7 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsExpatDriver)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsExpatDriver)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(nsExpatDriver, mSink, mExtendedSink)
|
||||
NS_IMPL_CYCLE_COLLECTION(nsExpatDriver, mSink)
|
||||
|
||||
nsExpatDriver::nsExpatDriver()
|
||||
: mExpatParser(nullptr),
|
||||
|
@ -533,58 +478,6 @@ nsExpatDriver::HandleEndCdataSection()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExpatDriver::HandleStartNamespaceDecl(const char16_t* aPrefix,
|
||||
const char16_t* aUri)
|
||||
{
|
||||
if (mExtendedSink) {
|
||||
nsresult rv = mExtendedSink->HandleStartNamespaceDecl(aPrefix, aUri);
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExpatDriver::HandleEndNamespaceDecl(const char16_t* aPrefix)
|
||||
{
|
||||
if (mExtendedSink && mInternalState != NS_ERROR_HTMLPARSER_STOPPARSING) {
|
||||
nsresult rv = mExtendedSink->HandleEndNamespaceDecl(aPrefix);
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExpatDriver::HandleNotationDecl(const char16_t* aNotationName,
|
||||
const char16_t* aBase,
|
||||
const char16_t* aSysid,
|
||||
const char16_t* aPubid)
|
||||
{
|
||||
if (mExtendedSink) {
|
||||
nsresult rv = mExtendedSink->HandleNotationDecl(aNotationName, aSysid,
|
||||
aPubid);
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExpatDriver::HandleUnparsedEntityDecl(const char16_t* aEntityName,
|
||||
const char16_t* aBase,
|
||||
const char16_t* aSysid,
|
||||
const char16_t* aPubid,
|
||||
const char16_t* aNotationName)
|
||||
{
|
||||
if (mExtendedSink) {
|
||||
nsresult rv = mExtendedSink->HandleUnparsedEntityDecl(aEntityName,
|
||||
aSysid,
|
||||
aPubid,
|
||||
aNotationName);
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExpatDriver::HandleStartDoctypeDecl(const char16_t* aDoctypeName,
|
||||
const char16_t* aSysid,
|
||||
|
@ -595,11 +488,6 @@ nsExpatDriver::HandleStartDoctypeDecl(const char16_t* aDoctypeName,
|
|||
mSystemID = aSysid;
|
||||
mPublicID = aPubid;
|
||||
|
||||
if (mExtendedSink) {
|
||||
nsresult rv = mExtendedSink->HandleStartDTD(aDoctypeName, aSysid, aPubid);
|
||||
MaybeStopParser(rv);
|
||||
}
|
||||
|
||||
if (aHasInternalSubset) {
|
||||
// Consuming a huge internal subset translates to numerous
|
||||
// allocations. In an effort to avoid too many allocations
|
||||
|
@ -1274,19 +1162,6 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
|
|||
XML_SetDoctypeDeclHandler(mExpatParser, Driver_HandleStartDoctypeDecl,
|
||||
Driver_HandleEndDoctypeDecl);
|
||||
|
||||
// If the sink is an nsIExtendedExpatSink,
|
||||
// register some addtional handlers.
|
||||
mExtendedSink = do_QueryInterface(mSink);
|
||||
if (mExtendedSink) {
|
||||
XML_SetNamespaceDeclHandler(mExpatParser,
|
||||
Driver_HandleStartNamespaceDecl,
|
||||
Driver_HandleEndNamespaceDecl);
|
||||
XML_SetUnparsedEntityDeclHandler(mExpatParser,
|
||||
Driver_HandleUnparsedEntityDecl);
|
||||
XML_SetNotationDeclHandler(mExpatParser,
|
||||
Driver_HandleNotationDecl);
|
||||
}
|
||||
|
||||
// Set up the user data.
|
||||
XML_SetUserData(mExpatParser, this);
|
||||
|
||||
|
@ -1304,7 +1179,6 @@ nsExpatDriver::DidBuildModel(nsresult anErrorCode)
|
|||
{
|
||||
mOriginalSink = nullptr;
|
||||
mSink = nullptr;
|
||||
mExtendedSink = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
class nsIExpatSink;
|
||||
class nsIExtendedExpatSink;
|
||||
struct nsCatalogData;
|
||||
|
||||
class nsExpatDriver : public nsIDTD,
|
||||
|
@ -54,18 +53,6 @@ public:
|
|||
const char16_t* aPubid,
|
||||
bool aHasInternalSubset);
|
||||
nsresult HandleEndDoctypeDecl();
|
||||
nsresult HandleStartNamespaceDecl(const char16_t* aPrefix,
|
||||
const char16_t* aUri);
|
||||
nsresult HandleEndNamespaceDecl(const char16_t* aPrefix);
|
||||
nsresult HandleNotationDecl(const char16_t* aNotationName,
|
||||
const char16_t* aBase,
|
||||
const char16_t* aSysid,
|
||||
const char16_t* aPubid);
|
||||
nsresult HandleUnparsedEntityDecl(const char16_t* aEntityName,
|
||||
const char16_t* aBase,
|
||||
const char16_t* aSysid,
|
||||
const char16_t* aPubid,
|
||||
const char16_t* aNotationName);
|
||||
|
||||
private:
|
||||
// Load up an external stream to get external entity information
|
||||
|
@ -130,7 +117,6 @@ private:
|
|||
// only to avoid QI-ing back to nsIContentSink*.
|
||||
nsCOMPtr<nsIContentSink> mOriginalSink;
|
||||
nsCOMPtr<nsIExpatSink> mSink;
|
||||
nsCOMPtr<nsIExtendedExpatSink> mExtendedSink;
|
||||
|
||||
const nsCatalogData* mCatalogData; // weak
|
||||
nsString mURISpec;
|
||||
|
|
|
@ -1,72 +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 "nsIExpatSink.idl"
|
||||
|
||||
/**
|
||||
* This interface provides notification of syntax-level events.
|
||||
*/
|
||||
[scriptable, uuid(5e3e4f0c-7b77-47ca-a7c5-a3d87f2a9c82)]
|
||||
interface nsIExtendedExpatSink : nsIExpatSink
|
||||
{
|
||||
/**
|
||||
* Called at the beginning of the DTD, before any entity or notation
|
||||
* events.
|
||||
* @param aDoctypeName The document type name.
|
||||
* @param aSysid The declared system identifier for the external DTD subset,
|
||||
* or null if none was declared.
|
||||
* @param aPubid The declared public identifier for the external DTD subset,
|
||||
* or null if none was declared.
|
||||
*/
|
||||
void handleStartDTD(in wstring aDoctypeName,
|
||||
in wstring aSysid,
|
||||
in wstring aPubid);
|
||||
|
||||
/**
|
||||
* Called when a prefix mapping starts to be in-scope, before any
|
||||
* startElement events.
|
||||
* @param aPrefix The Namespace prefix being declared. An empty string
|
||||
* is used for the default element namespace, which has
|
||||
* no prefix.
|
||||
* @param aUri The Namespace URI the prefix is mapped to.
|
||||
*/
|
||||
void handleStartNamespaceDecl(in wstring aPrefix,
|
||||
in wstring aUri);
|
||||
|
||||
/**
|
||||
* Called when a prefix mapping is no longer in-scope, after any
|
||||
* endElement events.
|
||||
* @param aPrefix The prefix that was being mapped. This is the empty string
|
||||
* when a default mapping scope ends.
|
||||
*/
|
||||
void handleEndNamespaceDecl(in wstring aPrefix);
|
||||
|
||||
/**
|
||||
* This is called for a declaration of notation. The base argument is
|
||||
* whatever was set by XML_SetBase. aNotationName will never be
|
||||
* null. The other arguments can be.
|
||||
* @param aNotationName The notation name.
|
||||
* @param aSysId The notation's system identifier, or null if none was given.
|
||||
* @param aPubId The notation's pubilc identifier, or null if none was given.
|
||||
*/
|
||||
void handleNotationDecl(in wstring aNotationName,
|
||||
in wstring aSysid,
|
||||
in wstring aPubid);
|
||||
|
||||
/**
|
||||
* This is called for a declaration of an unparsed (NDATA) entity.
|
||||
* aName, aSysid and aNotationName arguments will never be
|
||||
* null. The other arguments may be.
|
||||
* @param aName The unparsed entity's name.
|
||||
* @param aSysId The notation's system identifier.
|
||||
* @param aPubId The notation's pubilc identifier, or null if none was given.
|
||||
* @param aNotationName The name of the associated notation.
|
||||
*/
|
||||
void handleUnparsedEntityDecl(in wstring aName,
|
||||
in wstring aSysid,
|
||||
in wstring aPubid,
|
||||
in wstring aNotationName);
|
||||
|
||||
};
|
Загрузка…
Ссылка в новой задаче