mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:37:11 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- test part of Bug 789788 - Revise the don't-use-document-fonts option (1b6a0e6ed)
- Bug 1172782 - Change how nsTHashtable::Clear() works. r=froydnj. (c8c2adc51)
- Bug 1180072 - Remove PL_DHashTableEnumerate(). r=froydnj. (b5448efda)
- Bug 1180122 - Make Chaos Mode affect PLDHashTable's iterators. r=froydnj. (11fd0e222)
- Bug 1182516 - Add Chaos Mode environment variable MOZ_CHAOSMODE. r=roc (d636f6c90)
- Bug 1182516 - Fix mid-air conflict with 3fd2ab6cb762 on a CLOSED TREE. r=bustage (8dec46b7a)
- Bug 1184280 - Remove warning about mDisabledJSAndPlugins being false. r=ehsan (c23e96fc1)
- Bug 1181411 - Test some expected aborts in PLDHashTable. r=glandium. (682788df7)
- Bug 1185399 (part 1) - Remove macros from pldhash.h. r=froydnj. (15001ff2a)
- Bug 1185399 (part 2) - Remove macros from pldhash.cpp. r=froydnj. (afeddcc90)
- Bug 1187197 (part 1) - Move comments from PL_DHashTable* functions to the equivalent methods. r=froydnj. (78921590e)
- Bug 1187197 (part 2) - Put function return types on their own line. r=froydnj. (9aae02f83)
- Bug 1187197 (part 3) - Convert pldhash.{cpp,h} to C++ style comments. r=froydnj. (57afe7e1f)
- Bug 1202526 (part 1) - Add PLDHashTable::RemoveEntry(). r=froydnj. (1b5453695)
- Bug 1202526 (part 2) - Avoid PL_DHashTableRawRemove() in nsLoadGroup. r=mcmanus. (1ad20b17f)
- Bug 1202526 (part 3) - Avoid PL_DHashTableRawRemove() in nsDocument. r=bz. (cdde6eff0)
- Bug 1202526 (part 4) - Avoid PL_DHashTableRawRemove() in nsPropertyTable. r=bz. (ed437f4d6)
- Bug 1202526 (part 5) - Use PLDHashTable::RemoveEntry() in nsSecureBrowserUIImpl. r=dkeeler. (ac1d44066)
- Bug 1202526 (part 6) - Use PLDHashTable::RemoveEntry() in XULDocument. r=bz. (2639a053e)
- Bug 1202526 (part 7) - Use PLDHashTable::RemoveEntry() in prefs code. r=bz. (2eb3b1097)
- Bug 1202526 (part 8) - Use PLDHashTable::RemoveEntry() in the cycle collector. r=mccr8. (ec77d7635)
- Bug 1130096 - Convert embedding/components/commandhandler/ to Gecko style. r=mccr8 (a5aecf9de)
- Bug 1184842. Remove layout.frames.force_resizability pref. r=mats (9226b0caf)
- Bug 1184842. Remove frameset mVisibilityOverride since it's always false now. r=mats (1b439feb8)
- Bug 1184842. Change nsAttrAndChildArray::SetAndTakeAttr to nsAttrAndChildArray::SetAndSwapAttr. r=peterv (1442f0eae)
- Bug 1184842. Make SetAttrAndNotify use the real old value instead of aOldValue when possible. r=bz (bc45970f5)
- Bug 1184842. Add aOldValue parameter to nsNodeUtils::AttributeChanged. r=peterv (31bf8c08e)
- Bug 1184842. Pass aOldValue to all mutation observers. r=peterv (e69daf7f7)
- Bug 1184842. Allow BeforeSetAttr to preparse aValue. r=peterv (9c51655de)
- follow up fix to Bug 1184842. Allow BeforeSetAttr to preparse aValue (fb997a066)
- Bug 1149042 - Call AttributeWillChange before a style="" attribute gets created when touching element.style. r=smaug (41f2ea361)
- Bug 1184842. Pass preparsed attribute values to nsNodeUtils::AttributeWillChange. r=peterv (646622252)
- Bug 1013743, MutationObserver should observe only the subtree it is attached to, r=wchen (ad606eb15)
- Bug 1184842. Add aNewValue to nsIMutationObserver::AttributeWillChange. r=peterv (796042972)
- Bug 1184842. Preparse class attribute values in Element::BeforeSetAttr. r=peterv (e18989b2b)
- Bug 1154149 - Remove nsPresContext arguments from a bunch of nsStyleSBug 1154149 - Remove nsPresContext arguments from a bunch of nsStyleS (b7797ef66)
- Bug 1184842. Route aOldValue/aNewValue to AttributeData. r=heycam (14489941b)
- Bug 1184842. Restyling should consider only the classes that have changed. r=heycam (5a5e670dc)
- Bug 1121760 (part 1) - Remove PL_DHashTableSearch(). r=poiru. (d92813655)
This commit is contained in:
@@ -693,7 +693,8 @@ void
|
||||
DocAccessible::AttributeWillChange(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute, int32_t aModType)
|
||||
nsIAtom* aAttribute, int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
Accessible* accessible = GetAccessible(aElement);
|
||||
if (!accessible) {
|
||||
@@ -734,7 +735,8 @@ void
|
||||
DocAccessible::AttributeChanged(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
NS_ASSERTION(!IsDefunct(),
|
||||
"Attribute changed called on defunct document accessible!");
|
||||
|
||||
@@ -325,7 +325,8 @@ nsSHEntryShared::AttributeWillChange(nsIDocument* aDocument,
|
||||
dom::Element* aContent,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -334,7 +335,8 @@ nsSHEntryShared::AttributeChanged(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
RemoveFromBFCacheAsync();
|
||||
}
|
||||
|
||||
+56
-17
@@ -2274,9 +2274,11 @@ Element::SetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
|
||||
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &value, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAttrValue* preparsedAttrValue = value.GetStoredAttrValue();
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType,
|
||||
preparsedAttrValue);
|
||||
}
|
||||
|
||||
// Hold a script blocker while calling ParseAttribute since that can call
|
||||
@@ -2284,6 +2286,11 @@ Element::SetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
nsAttrValue attrValue;
|
||||
if (preparsedAttrValue) {
|
||||
attrValue.SwapValueWith(*preparsedAttrValue);
|
||||
}
|
||||
// Even the value was pre-parsed in BeforeSetAttr, we still need to call
|
||||
// ParseAttribute because it can have side effects.
|
||||
if (!ParseAttribute(aNamespaceID, aName, aValue, attrValue)) {
|
||||
attrValue.SetTo(aValue);
|
||||
}
|
||||
@@ -2323,7 +2330,8 @@ Element::SetParsedAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
|
||||
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType,
|
||||
&aParsedValue);
|
||||
}
|
||||
|
||||
return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue,
|
||||
@@ -2350,10 +2358,10 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
nsMutationGuard::DidMutate();
|
||||
|
||||
// Copy aParsedValue for later use since it will be lost when we call
|
||||
// SetAndTakeMappedAttr below
|
||||
nsAttrValue aValueForAfterSetAttr;
|
||||
// SetAndSwapMappedAttr below
|
||||
nsAttrValue valueForAfterSetAttr;
|
||||
if (aCallAfterSetAttr) {
|
||||
aValueForAfterSetAttr.SetTo(aParsedValue);
|
||||
valueForAfterSetAttr.SetTo(aParsedValue);
|
||||
}
|
||||
|
||||
bool hadValidDir = false;
|
||||
@@ -2369,7 +2377,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
// stuff to Element?
|
||||
if (!IsAttributeMapped(aName) ||
|
||||
!SetMappedAttribute(document, aName, aParsedValue, &rv)) {
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(aName, aParsedValue);
|
||||
rv = mAttrsAndChildren.SetAndSwapAttr(aName, aParsedValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -2378,8 +2386,13 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
aNamespaceID,
|
||||
nsIDOMNode::ATTRIBUTE_NODE);
|
||||
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(ni, aParsedValue);
|
||||
rv = mAttrsAndChildren.SetAndSwapAttr(ni, aParsedValue);
|
||||
}
|
||||
|
||||
// If the old value owns its own data, we know it is OK to keep using it.
|
||||
const nsAttrValue* oldValue =
|
||||
aParsedValue.StoresOwnData() ? &aParsedValue : &aOldValue;
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
|
||||
@@ -2393,8 +2406,8 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
|
||||
nsIDocument* ownerDoc = OwnerDoc();
|
||||
if (ownerDoc && GetCustomElementData()) {
|
||||
nsCOMPtr<nsIAtom> oldValueAtom = aOldValue.GetAsAtom();
|
||||
nsCOMPtr<nsIAtom> newValueAtom = aValueForAfterSetAttr.GetAsAtom();
|
||||
nsCOMPtr<nsIAtom> oldValueAtom = oldValue->GetAsAtom();
|
||||
nsCOMPtr<nsIAtom> newValueAtom = valueForAfterSetAttr.GetAsAtom();
|
||||
LifecycleCallbackArgs args = {
|
||||
nsDependentAtomString(aName),
|
||||
aModType == nsIDOMMutationEvent::ADDITION ?
|
||||
@@ -2406,17 +2419,21 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
}
|
||||
|
||||
if (aCallAfterSetAttr) {
|
||||
rv = AfterSetAttr(aNamespaceID, aName, &aValueForAfterSetAttr, aNotify);
|
||||
rv = AfterSetAttr(aNamespaceID, aName, &valueForAfterSetAttr, aNotify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::dir) {
|
||||
OnSetDirAttr(this, &aValueForAfterSetAttr,
|
||||
OnSetDirAttr(this, &valueForAfterSetAttr,
|
||||
hadValidDir, hadDirAuto, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType);
|
||||
// Don't pass aOldValue to AttributeChanged since it may not be reliable.
|
||||
// Callers only compute aOldValue under certain conditions which may not
|
||||
// be triggered by all nsIMutationObservers.
|
||||
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType,
|
||||
oldValue == &aParsedValue ? &aParsedValue : nullptr);
|
||||
}
|
||||
|
||||
if (aFireMutation) {
|
||||
@@ -2434,8 +2451,8 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
if (!newValue.IsEmpty()) {
|
||||
mutation.mNewAttrValue = do_GetAtom(newValue);
|
||||
}
|
||||
if (!aOldValue.IsEmptyString()) {
|
||||
mutation.mPrevAttrValue = aOldValue.GetAsAtom();
|
||||
if (!oldValue->IsEmptyString()) {
|
||||
mutation.mPrevAttrValue = oldValue->GetAsAtom();
|
||||
}
|
||||
mutation.mAttrChange = aModType;
|
||||
|
||||
@@ -2446,6 +2463,25 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
Element::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
nsAttrValueOrString* aValue, bool aNotify)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aName == nsGkAtoms::_class) {
|
||||
// aValue->GetAttrValue will only be non-null here when this is called
|
||||
// via Element::SetParsedAttr. This shouldn't happen for "class", but
|
||||
// this will handle it.
|
||||
if (aValue && !aValue->GetAttrValue()) {
|
||||
nsAttrValue attr;
|
||||
attr.ParseAtomArray(aValue->String());
|
||||
aValue->TakeParsedValue(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Element::ParseAttribute(int32_t aNamespaceID,
|
||||
nsIAtom* aAttribute,
|
||||
@@ -2455,7 +2491,7 @@ Element::ParseAttribute(int32_t aNamespaceID,
|
||||
if (aNamespaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::_class) {
|
||||
SetFlags(NODE_MAY_HAVE_CLASS);
|
||||
aResult.ParseAtomArray(aValue);
|
||||
// Result should have been preparsed above.
|
||||
return true;
|
||||
}
|
||||
if (aAttribute == nsGkAtoms::id) {
|
||||
@@ -2562,7 +2598,8 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
|
||||
if (aNotify) {
|
||||
nsNodeUtils::AttributeWillChange(this, aNameSpaceID, aName,
|
||||
nsIDOMMutationEvent::REMOVAL);
|
||||
nsIDOMMutationEvent::REMOVAL,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
bool hasMutationListeners = aNotify &&
|
||||
@@ -2628,8 +2665,10 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
}
|
||||
|
||||
if (aNotify) {
|
||||
// We can always pass oldValue here since there is no new value which could
|
||||
// have corrupted it.
|
||||
nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName,
|
||||
nsIDOMMutationEvent::REMOVAL);
|
||||
nsIDOMMutationEvent::REMOVAL, &oldValue);
|
||||
}
|
||||
|
||||
rv = AfterSetAttr(aNameSpaceID, aName, nullptr, aNotify);
|
||||
|
||||
+16
-10
@@ -486,6 +486,8 @@ public:
|
||||
|
||||
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
|
||||
const nsAString& aValue, bool aNotify) override;
|
||||
// aParsedValue receives the old value of the attribute. That's useful if
|
||||
// either the input or output value of aParsedValue is StoresOwnData.
|
||||
nsresult SetParsedAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
|
||||
nsAttrValue& aParsedValue, bool aNotify);
|
||||
// GetAttr is not inlined on purpose, to keep down codesize from all
|
||||
@@ -1128,10 +1130,15 @@ protected:
|
||||
* @param aNamespaceID namespace of attribute
|
||||
* @param aAttribute local-name of attribute
|
||||
* @param aPrefix aPrefix of attribute
|
||||
* @param aOldValue previous value of attribute. Only needed if
|
||||
* aFireMutation is true or if the element is a
|
||||
* custom element (in web components).
|
||||
* @param aParsedValue parsed new value of attribute
|
||||
* @param aOldValue The old value of the attribute to use as a fallback
|
||||
* in the cases where the actual old value (i.e.
|
||||
* its current value) is !StoresOwnData() --- in which
|
||||
* case the current value is probably already useless.
|
||||
* If the current value is StoresOwnData() (or absent),
|
||||
* aOldValue will not be used.
|
||||
* @param aParsedValue parsed new value of attribute. Replaced by the
|
||||
* old value of the attribute. This old value is only
|
||||
* useful if either it or the new value is StoresOwnData.
|
||||
* @param aModType nsIDOMMutationEvent::MODIFICATION or ADDITION. Only
|
||||
* needed if aFireMutation or aNotify is true.
|
||||
* @param aFireMutation should mutation-events be fired?
|
||||
@@ -1204,17 +1211,16 @@ protected:
|
||||
* @param aName the localname of the attribute being set
|
||||
* @param aValue the value it's being set to represented as either a string or
|
||||
* a parsed nsAttrValue. Alternatively, if the attr is being removed it
|
||||
* will be null.
|
||||
* will be null. BeforeSetAttr is allowed to modify aValue by parsing
|
||||
* the string to an nsAttrValue (to avoid having to reparse it in
|
||||
* ParseAttribute).
|
||||
* @param aNotify Whether we plan to notify document observers.
|
||||
*/
|
||||
// Note that this is inlined so that when subclasses call it it gets
|
||||
// inlined. Those calls don't go through a vtable.
|
||||
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify);
|
||||
|
||||
/**
|
||||
* Hook that is called by Element::SetAttr to allow subclasses to
|
||||
|
||||
@@ -613,7 +613,8 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (!IsPooledNode(aElement, aElement->GetParent(), mPoolHost)) {
|
||||
return;
|
||||
|
||||
@@ -390,14 +390,12 @@ nsAttrAndChildArray::AttrAt(uint32_t aPos) const
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAndTakeAttr(nsIAtom* aLocalName, nsAttrValue& aValue)
|
||||
nsAttrAndChildArray::SetAndSwapAttr(nsIAtom* aLocalName, nsAttrValue& aValue)
|
||||
{
|
||||
uint32_t i, slotCount = AttrSlotCount();
|
||||
for (i = 0; i < slotCount && AttrSlotIsTaken(i); ++i) {
|
||||
if (ATTRS(mImpl)[i].mName.Equals(aLocalName)) {
|
||||
ATTRS(mImpl)[i].mValue.Reset();
|
||||
ATTRS(mImpl)[i].mValue.SwapValueWith(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
@@ -417,12 +415,12 @@ nsAttrAndChildArray::SetAndTakeAttr(nsIAtom* aLocalName, nsAttrValue& aValue)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAttrAndChildArray::SetAndTakeAttr(mozilla::dom::NodeInfo* aName, nsAttrValue& aValue)
|
||||
nsAttrAndChildArray::SetAndSwapAttr(mozilla::dom::NodeInfo* aName, nsAttrValue& aValue)
|
||||
{
|
||||
int32_t namespaceID = aName->NamespaceID();
|
||||
nsIAtom* localName = aName->NameAtom();
|
||||
if (namespaceID == kNameSpaceID_None) {
|
||||
return SetAndTakeAttr(localName, aValue);
|
||||
return SetAndSwapAttr(localName, aValue);
|
||||
}
|
||||
|
||||
uint32_t i, slotCount = AttrSlotCount();
|
||||
|
||||
@@ -88,8 +88,9 @@ public:
|
||||
const nsAttrValue* GetAttr(const nsAString& aName,
|
||||
nsCaseTreatment aCaseSensitive) const;
|
||||
const nsAttrValue* AttrAt(uint32_t aPos) const;
|
||||
nsresult SetAndTakeAttr(nsIAtom* aLocalName, nsAttrValue& aValue);
|
||||
nsresult SetAndTakeAttr(mozilla::dom::NodeInfo* aName, nsAttrValue& aValue);
|
||||
// SetAndSwapAttr swaps the current attribute value with aValue.
|
||||
nsresult SetAndSwapAttr(nsIAtom* aLocalName, nsAttrValue& aValue);
|
||||
nsresult SetAndSwapAttr(mozilla::dom::NodeInfo* aName, nsAttrValue& aValue);
|
||||
|
||||
// Remove the attr at position aPos. The value of the attr is placed in
|
||||
// aValue; any value that was already in aValue is destroyed.
|
||||
|
||||
@@ -127,6 +127,12 @@ public:
|
||||
static void Shutdown();
|
||||
|
||||
ValueType Type() const;
|
||||
// Returns true when this value is self-contained and does not depend on
|
||||
// the state of its associated element.
|
||||
// Returns false when this value depends on the state of its associated
|
||||
// element and may be invalid if that state has been changed by changes to
|
||||
// that element state outside of attribute setting.
|
||||
inline bool StoresOwnData() const;
|
||||
|
||||
void Reset();
|
||||
|
||||
|
||||
@@ -191,6 +191,16 @@ nsAttrValue::IsSVGType(ValueType aType) const
|
||||
return aType >= eSVGTypesBegin && aType <= eSVGTypesEnd;
|
||||
}
|
||||
|
||||
inline bool
|
||||
nsAttrValue::StoresOwnData() const
|
||||
{
|
||||
if (BaseType() != eOtherBase) {
|
||||
return true;
|
||||
}
|
||||
ValueType t = Type();
|
||||
return t != eCSSStyleRule && !IsSVGType(t);
|
||||
}
|
||||
|
||||
inline void
|
||||
nsAttrValue::SetPtrValueAndType(void* aValue, ValueBaseType aType)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,21 @@ public:
|
||||
, mCheapString(nullptr)
|
||||
{ }
|
||||
|
||||
void TakeParsedValue(nsAttrValue& aValue)
|
||||
{
|
||||
mStoredAttrValue.SwapValueWith(aValue);
|
||||
mAttrValue = &mStoredAttrValue;
|
||||
mStringPtr = nullptr;
|
||||
}
|
||||
/**
|
||||
* If TakeParsedValue has been called, returns the value that it set.
|
||||
*/
|
||||
nsAttrValue* GetStoredAttrValue()
|
||||
{
|
||||
return mAttrValue == &mStoredAttrValue ? &mStoredAttrValue : nullptr;
|
||||
}
|
||||
const nsAttrValue* GetAttrValue() { return mAttrValue; }
|
||||
|
||||
/**
|
||||
* Returns a reference to the string value of the contents of this object.
|
||||
*
|
||||
@@ -74,6 +89,7 @@ protected:
|
||||
const nsAttrValue* mAttrValue;
|
||||
mutable const nsAString* mStringPtr;
|
||||
mutable nsCheapString mCheapString;
|
||||
nsAttrValue mStoredAttrValue;
|
||||
};
|
||||
|
||||
#endif // nsAttrValueOrString_h___
|
||||
|
||||
@@ -671,7 +671,8 @@ nsContentList::Item(uint32_t aIndex)
|
||||
void
|
||||
nsContentList::AttributeChanged(nsIDocument *aDocument, Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
NS_PRECONDITION(aElement, "Must have a content node to work with");
|
||||
|
||||
|
||||
@@ -4037,9 +4037,8 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode,
|
||||
return;
|
||||
}
|
||||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
auto entry = static_cast<EventListenerManagerMapEntry*>
|
||||
(sEventListenerManagersHash->Search(aNode));
|
||||
if (entry) {
|
||||
CycleCollectionNoteChild(cb, entry->mListenerManager.get(),
|
||||
"[via hash] mListenerManager");
|
||||
@@ -4087,9 +4086,8 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
auto entry = static_cast<EventListenerManagerMapEntry*>
|
||||
(sEventListenerManagersHash->Search(aNode));
|
||||
if (entry) {
|
||||
return entry->mListenerManager;
|
||||
}
|
||||
@@ -4102,9 +4100,8 @@ void
|
||||
nsContentUtils::RemoveListenerManager(nsINode *aNode)
|
||||
{
|
||||
if (sEventListenerManagersHash) {
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
auto entry = static_cast<EventListenerManagerMapEntry*>
|
||||
(sEventListenerManagersHash->Search(aNode));
|
||||
if (entry) {
|
||||
nsRefPtr<EventListenerManager> listenerManager;
|
||||
listenerManager.swap(entry->mListenerManager);
|
||||
|
||||
@@ -64,6 +64,13 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMMutationRecord,
|
||||
|
||||
// Observer
|
||||
|
||||
bool
|
||||
nsMutationReceiverBase::IsObservable(nsIContent* aContent)
|
||||
{
|
||||
return !aContent->ChromeOnlyAccess() &&
|
||||
(Observer()->IsChrome() || !aContent->IsInAnonymousSubtree());
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMutationReceiver)
|
||||
NS_IMPL_RELEASE(nsMutationReceiver)
|
||||
|
||||
@@ -108,11 +115,11 @@ nsMutationReceiver::AttributeWillChange(nsIDocument* aDocument,
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
if (nsAutoMutationBatch::IsBatching() ||
|
||||
!ObservesAttr(aElement, aNameSpaceID, aAttribute) ||
|
||||
aElement->ChromeOnlyAccess()) {
|
||||
!ObservesAttr(RegisterTarget(), aElement, aNameSpaceID, aAttribute)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,14 +154,16 @@ nsMutationReceiver::CharacterDataWillChange(nsIDocument *aDocument,
|
||||
CharacterDataChangeInfo* aInfo)
|
||||
{
|
||||
if (nsAutoMutationBatch::IsBatching() ||
|
||||
!CharacterData() || !(Subtree() || aContent == Target()) ||
|
||||
aContent->ChromeOnlyAccess()) {
|
||||
!CharacterData() ||
|
||||
(!Subtree() && aContent != Target()) ||
|
||||
(Subtree() && RegisterTarget()->SubtreeRoot() != aContent->SubtreeRoot()) ||
|
||||
!IsObservable(aContent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nsDOMMutationRecord* m =
|
||||
Observer()->CurrentRecord(nsGkAtoms::characterData);
|
||||
|
||||
|
||||
NS_ASSERTION(!m->mTarget || m->mTarget == aContent,
|
||||
"Wrong target!");
|
||||
|
||||
@@ -173,8 +182,11 @@ nsMutationReceiver::ContentAppended(nsIDocument* aDocument,
|
||||
int32_t aNewIndexInContainer)
|
||||
{
|
||||
nsINode* parent = NODE_FROM(aContainer, aDocument);
|
||||
bool wantsChildList = ChildList() && (Subtree() || parent == Target());
|
||||
if (!wantsChildList || aFirstNewContent->ChromeOnlyAccess()) {
|
||||
bool wantsChildList =
|
||||
ChildList() &&
|
||||
((Subtree() && RegisterTarget()->SubtreeRoot() == parent->SubtreeRoot()) ||
|
||||
parent == Target());
|
||||
if (!wantsChildList || !IsObservable(aFirstNewContent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,8 +223,11 @@ nsMutationReceiver::ContentInserted(nsIDocument* aDocument,
|
||||
int32_t aIndexInContainer)
|
||||
{
|
||||
nsINode* parent = NODE_FROM(aContainer, aDocument);
|
||||
bool wantsChildList = ChildList() && (Subtree() || parent == Target());
|
||||
if (!wantsChildList || aChild->ChromeOnlyAccess()) {
|
||||
bool wantsChildList =
|
||||
ChildList() &&
|
||||
((Subtree() && RegisterTarget()->SubtreeRoot() == parent->SubtreeRoot()) ||
|
||||
parent == Target());
|
||||
if (!wantsChildList || !IsObservable(aChild)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,11 +258,14 @@ nsMutationReceiver::ContentRemoved(nsIDocument* aDocument,
|
||||
int32_t aIndexInContainer,
|
||||
nsIContent* aPreviousSibling)
|
||||
{
|
||||
if (aChild->ChromeOnlyAccess()) {
|
||||
if (!IsObservable(aChild)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsINode* parent = NODE_FROM(aContainer, aDocument);
|
||||
if (Subtree() && parent->SubtreeRoot() != RegisterTarget()->SubtreeRoot()) {
|
||||
return;
|
||||
}
|
||||
if (nsAutoMutationBatch::IsBatching()) {
|
||||
if (nsAutoMutationBatch::IsRemovalDone()) {
|
||||
// This can happen for example if HTML parser parses to
|
||||
@@ -265,7 +283,7 @@ nsMutationReceiver::ContentRemoved(nsIDocument* aDocument,
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Subtree()) {
|
||||
// Try to avoid creating transient observer if the node
|
||||
@@ -719,8 +737,9 @@ nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal,
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(window->IsInnerWindow());
|
||||
bool isChrome = nsContentUtils::IsChromeDoc(window->GetExtantDoc());
|
||||
nsRefPtr<nsDOMMutationObserver> observer =
|
||||
new nsDOMMutationObserver(window.forget(), aCb);
|
||||
new nsDOMMutationObserver(window.forget(), aCb, isChrome);
|
||||
return observer.forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -248,14 +248,20 @@ protected:
|
||||
mRegisterTarget->OwnerDoc()->SetMayHaveDOMMutationObservers();
|
||||
}
|
||||
|
||||
bool ObservesAttr(mozilla::dom::Element* aElement,
|
||||
bool IsObservable(nsIContent* aContent);
|
||||
|
||||
bool ObservesAttr(nsINode* aRegisterTarget,
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttr)
|
||||
{
|
||||
if (mParent) {
|
||||
return mParent->ObservesAttr(aElement, aNameSpaceID, aAttr);
|
||||
return mParent->ObservesAttr(aRegisterTarget, aElement, aNameSpaceID, aAttr);
|
||||
}
|
||||
if (!Attributes() || (!Subtree() && aElement != Target())) {
|
||||
if (!Attributes() ||
|
||||
(!Subtree() && aElement != Target()) ||
|
||||
(Subtree() && aRegisterTarget->SubtreeRoot() != aElement->SubtreeRoot()) ||
|
||||
!IsObservable(aElement)) {
|
||||
return false;
|
||||
}
|
||||
if (AllAttributes()) {
|
||||
@@ -368,7 +374,7 @@ public:
|
||||
{
|
||||
// We can reuse AttributeWillChange implementation.
|
||||
AttributeWillChange(aDocument, aElement, aNameSpaceID, aAttribute,
|
||||
nsIDOMMutationEvent::MODIFICATION);
|
||||
nsIDOMMutationEvent::MODIFICATION, nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -447,9 +453,10 @@ class nsDOMMutationObserver final : public nsISupports,
|
||||
{
|
||||
public:
|
||||
nsDOMMutationObserver(already_AddRefed<nsPIDOMWindow>&& aOwner,
|
||||
mozilla::dom::MutationCallback& aCb)
|
||||
mozilla::dom::MutationCallback& aCb,
|
||||
bool aChrome)
|
||||
: mOwner(aOwner), mLastPendingMutation(nullptr), mPendingMutationCount(0),
|
||||
mCallback(&aCb), mWaitingForRun(false), mId(++sCount)
|
||||
mCallback(&aCb), mWaitingForRun(false), mIsChrome(aChrome), mId(++sCount)
|
||||
{
|
||||
}
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
@@ -471,6 +478,11 @@ public:
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
bool IsChrome()
|
||||
{
|
||||
return mIsChrome;
|
||||
}
|
||||
|
||||
void Observe(nsINode& aTarget,
|
||||
const mozilla::dom::MutationObserverInit& aOptions,
|
||||
mozilla::ErrorResult& aRv);
|
||||
@@ -572,6 +584,7 @@ protected:
|
||||
nsRefPtr<mozilla::dom::MutationCallback> mCallback;
|
||||
|
||||
bool mWaitingForRun;
|
||||
bool mIsChrome;
|
||||
|
||||
uint64_t mId;
|
||||
|
||||
|
||||
+3
-10
@@ -3989,13 +3989,7 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
||||
// aSubDoc is nullptr, remove the mapping
|
||||
|
||||
if (mSubDocuments) {
|
||||
SubDocMapEntry *entry =
|
||||
static_cast<SubDocMapEntry*>
|
||||
(PL_DHashTableSearch(mSubDocuments, aElement));
|
||||
|
||||
if (entry) {
|
||||
PL_DHashTableRawRemove(mSubDocuments, entry);
|
||||
}
|
||||
PL_DHashTableRemove(mSubDocuments, aElement);
|
||||
}
|
||||
} else {
|
||||
if (!mSubDocuments) {
|
||||
@@ -4041,9 +4035,8 @@ nsIDocument*
|
||||
nsDocument::GetSubDocumentFor(nsIContent *aContent) const
|
||||
{
|
||||
if (mSubDocuments && aContent->IsElement()) {
|
||||
SubDocMapEntry *entry =
|
||||
static_cast<SubDocMapEntry*>
|
||||
(PL_DHashTableSearch(mSubDocuments, aContent->AsElement()));
|
||||
auto entry = static_cast<SubDocMapEntry*>
|
||||
(mSubDocuments->Search(aContent->AsElement()));
|
||||
|
||||
if (entry) {
|
||||
return entry->mSubDocument;
|
||||
|
||||
@@ -2607,7 +2607,8 @@ nsFrameLoader::AttributeChanged(nsIDocument* aDocument,
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
MOZ_ASSERT(mObservingOwnerContent);
|
||||
// TODO: Implement ContentShellAdded for remote browsers (bug 658304)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsAttrValue;
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
@@ -21,8 +22,8 @@ class Element;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IMUTATION_OBSERVER_IID \
|
||||
{ 0x16fe5e3e, 0xeadc, 0x4312, \
|
||||
{ 0x9d, 0x44, 0xb6, 0xbe, 0xdd, 0x6b, 0x54, 0x74 } }
|
||||
{ 0xdd74f0cc, 0x2849, 0x4d05, \
|
||||
{ 0x9c, 0xe3, 0xb0, 0x95, 0x3e, 0xc2, 0xfd, 0x44 } }
|
||||
|
||||
/**
|
||||
* Information details about a characterdata change. Basically, we
|
||||
@@ -157,6 +158,8 @@ public:
|
||||
* @param aModType Whether or not the attribute will be added, changed, or
|
||||
* removed. The constants are defined in
|
||||
* nsIDOMMutationEvent.h.
|
||||
* @param aNewValue The new value, IF it has been preparsed by
|
||||
* BeforeSetAttr, otherwise null.
|
||||
*
|
||||
* @note Callers of this method might not hold a strong reference to the
|
||||
* observer. The observer is responsible for making sure it stays
|
||||
@@ -168,7 +171,8 @@ public:
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType) = 0;
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue) = 0;
|
||||
|
||||
/**
|
||||
* Notification that an attribute of an element has changed.
|
||||
@@ -180,6 +184,8 @@ public:
|
||||
* @param aModType Whether or not the attribute was added, changed, or
|
||||
* removed. The constants are defined in
|
||||
* nsIDOMMutationEvent.h.
|
||||
* @param aOldValue The old value, if either the old value or the new
|
||||
* value are StoresOwnData() (or absent); null otherwise.
|
||||
*
|
||||
* @note Callers of this method might not hold a strong reference to the
|
||||
* observer. The observer is responsible for making sure it stays
|
||||
@@ -191,7 +197,8 @@ public:
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType) = 0;
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue) = 0;
|
||||
|
||||
/**
|
||||
* Notification that an attribute of an element has been
|
||||
@@ -336,14 +343,16 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutationObserver, NS_IMUTATION_OBSERVER_IID)
|
||||
mozilla::dom::Element* aElement, \
|
||||
int32_t aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
int32_t aModType) override;
|
||||
int32_t aModType, \
|
||||
const nsAttrValue* aNewValue) override;
|
||||
|
||||
#define NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED \
|
||||
virtual void AttributeChanged(nsIDocument* aDocument, \
|
||||
mozilla::dom::Element* aElement, \
|
||||
int32_t aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
int32_t aModType) override;
|
||||
int32_t aModType, \
|
||||
const nsAttrValue* aOldValue) override;
|
||||
|
||||
#define NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED \
|
||||
virtual void ContentAppended(nsIDocument* aDocument, \
|
||||
@@ -405,7 +414,8 @@ _class::AttributeWillChange(nsIDocument* aDocument, \
|
||||
mozilla::dom::Element* aElement, \
|
||||
int32_t aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
int32_t aModType) \
|
||||
int32_t aModType, \
|
||||
const nsAttrValue* aNewValue) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
@@ -413,7 +423,8 @@ _class::AttributeChanged(nsIDocument* aDocument, \
|
||||
mozilla::dom::Element* aElement, \
|
||||
int32_t aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
int32_t aModType) \
|
||||
int32_t aModType, \
|
||||
const nsAttrValue* aOldValue) \
|
||||
{ \
|
||||
} \
|
||||
void \
|
||||
|
||||
@@ -123,24 +123,26 @@ void
|
||||
nsNodeUtils::AttributeWillChange(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
nsIDocument* doc = aElement->OwnerDoc();
|
||||
IMPL_MUTATION_NOTIFICATION(AttributeWillChange, aElement,
|
||||
(doc, aElement, aNameSpaceID, aAttribute,
|
||||
aModType));
|
||||
aModType, aNewValue));
|
||||
}
|
||||
|
||||
void
|
||||
nsNodeUtils::AttributeChanged(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
nsIDocument* doc = aElement->OwnerDoc();
|
||||
IMPL_MUTATION_NOTIFICATION(AttributeChanged, aElement,
|
||||
(doc, aElement, aNameSpaceID, aAttribute,
|
||||
aModType));
|
||||
aModType, aOldValue));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -48,12 +48,15 @@ public:
|
||||
* @param aNameSpaceID Namespace of changing attribute
|
||||
* @param aAttribute Local-name of changing attribute
|
||||
* @param aModType Type of change (add/change/removal)
|
||||
* @param aNewValue The parsed new value, but only if BeforeSetAttr
|
||||
* preparsed it!!!
|
||||
* @see nsIMutationObserver::AttributeWillChange
|
||||
*/
|
||||
static void AttributeWillChange(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType);
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue);
|
||||
|
||||
/**
|
||||
* Send AttributeChanged notifications to nsIMutationObservers.
|
||||
@@ -61,12 +64,16 @@ public:
|
||||
* @param aNameSpaceID Namespace of changed attribute
|
||||
* @param aAttribute Local-name of changed attribute
|
||||
* @param aModType Type of change (add/change/removal)
|
||||
* @param aOldValue If the old value was StoresOwnData() (or absent),
|
||||
* that value, otherwise null
|
||||
* @see nsIMutationObserver::AttributeChanged
|
||||
*/
|
||||
static void AttributeChanged(mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType);
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue);
|
||||
|
||||
/**
|
||||
* Send AttributeSetToCurrentValue notifications to nsIMutationObservers.
|
||||
* @param aElement Element whose data changed
|
||||
|
||||
@@ -93,9 +93,8 @@ nsPropertyTable::TransferOrDeleteAllPropertiesFor(nsPropertyOwner aObject,
|
||||
nsresult rv = NS_OK;
|
||||
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
|
||||
if (prop->mTransfer) {
|
||||
PropertyListMapEntry *entry =
|
||||
static_cast<PropertyListMapEntry*>
|
||||
(PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
|
||||
auto entry = static_cast<PropertyListMapEntry*>
|
||||
(prop->mObjectValueMap.Search(aObject));
|
||||
if (entry) {
|
||||
rv = aOtherTable->SetProperty(aObject, prop->mName,
|
||||
entry->value, prop->mDtorFunc,
|
||||
@@ -107,7 +106,7 @@ nsPropertyTable::TransferOrDeleteAllPropertiesFor(nsPropertyOwner aObject,
|
||||
break;
|
||||
}
|
||||
|
||||
PL_DHashTableRawRemove(&prop->mObjectValueMap, entry);
|
||||
prop->mObjectValueMap.RemoveEntry(entry);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -124,8 +123,8 @@ nsPropertyTable::Enumerate(nsPropertyOwner aObject,
|
||||
{
|
||||
PropertyList* prop;
|
||||
for (prop = mPropertyList; prop; prop = prop->mNext) {
|
||||
PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
|
||||
(PL_DHashTableSearch(&prop->mObjectValueMap, aObject));
|
||||
auto entry = static_cast<PropertyListMapEntry*>
|
||||
(prop->mObjectValueMap.Search(aObject));
|
||||
if (entry) {
|
||||
aCallback(const_cast<void*>(aObject.get()), prop->mName, entry->value,
|
||||
aData);
|
||||
@@ -157,14 +156,13 @@ nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
|
||||
|
||||
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
|
||||
if (propertyList) {
|
||||
PropertyListMapEntry *entry =
|
||||
static_cast<PropertyListMapEntry*>
|
||||
(PL_DHashTableSearch(&propertyList->mObjectValueMap, aObject));
|
||||
auto entry = static_cast<PropertyListMapEntry*>
|
||||
(propertyList->mObjectValueMap.Search(aObject));
|
||||
if (entry) {
|
||||
propValue = entry->value;
|
||||
if (aRemove) {
|
||||
// don't call propertyList->mDtorFunc. That's the caller's job now.
|
||||
PL_DHashTableRawRemove(&propertyList->mObjectValueMap, entry);
|
||||
propertyList->mObjectValueMap.RemoveEntry(entry);
|
||||
}
|
||||
rv = NS_OK;
|
||||
}
|
||||
@@ -294,14 +292,13 @@ nsPropertyTable::PropertyList::Destroy()
|
||||
bool
|
||||
nsPropertyTable::PropertyList::DeletePropertyFor(nsPropertyOwner aObject)
|
||||
{
|
||||
PropertyListMapEntry *entry =
|
||||
static_cast<PropertyListMapEntry*>
|
||||
(PL_DHashTableSearch(&mObjectValueMap, aObject));
|
||||
auto entry =
|
||||
static_cast<PropertyListMapEntry*>(mObjectValueMap.Search(aObject));
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
void* value = entry->value;
|
||||
PL_DHashTableRawRemove(&mObjectValueMap, entry);
|
||||
mObjectValueMap.RemoveEntry(entry);
|
||||
|
||||
if (mDtorFunc)
|
||||
mDtorFunc(const_cast<void*>(aObject.get()), mName, value, mDtorData);
|
||||
|
||||
@@ -83,7 +83,8 @@ nsScriptElement::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
MaybeProcessScript();
|
||||
}
|
||||
|
||||
@@ -159,10 +159,8 @@ nsScriptNameSpaceManager::GetConstructorProto(const nsGlobalNameStruct* aStruct)
|
||||
NS_ASSERTION(aStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias,
|
||||
"This function only works on constructor aliases!");
|
||||
if (!aStruct->mAlias->mProto) {
|
||||
GlobalNameMapEntry *proto =
|
||||
static_cast<GlobalNameMapEntry *>
|
||||
(PL_DHashTableSearch(&mGlobalNames,
|
||||
&aStruct->mAlias->mProtoName));
|
||||
auto proto = static_cast<GlobalNameMapEntry*>
|
||||
(mGlobalNames.Search(&aStruct->mAlias->mProtoName));
|
||||
if (proto) {
|
||||
aStruct->mAlias->mProto = &proto->mGlobalName;
|
||||
}
|
||||
@@ -344,9 +342,7 @@ nsGlobalNameStruct*
|
||||
nsScriptNameSpaceManager::LookupNameInternal(const nsAString& aName,
|
||||
const char16_t **aClassName)
|
||||
{
|
||||
GlobalNameMapEntry *entry =
|
||||
static_cast<GlobalNameMapEntry *>
|
||||
(PL_DHashTableSearch(&mGlobalNames, &aName));
|
||||
auto entry = static_cast<GlobalNameMapEntry*>(mGlobalNames.Search(&aName));
|
||||
|
||||
if (entry) {
|
||||
if (aClassName) {
|
||||
@@ -364,9 +360,7 @@ nsScriptNameSpaceManager::LookupNameInternal(const nsAString& aName,
|
||||
const nsGlobalNameStruct*
|
||||
nsScriptNameSpaceManager::LookupNavigatorName(const nsAString& aName)
|
||||
{
|
||||
GlobalNameMapEntry *entry =
|
||||
static_cast<GlobalNameMapEntry *>
|
||||
(PL_DHashTableSearch(&mNavigatorNames, &aName));
|
||||
auto entry = static_cast<GlobalNameMapEntry*>(mNavigatorNames.Search(&aName));
|
||||
|
||||
return entry ? &entry->mGlobalName : nullptr;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ nsStyledElementNotElementCSSInlineStyle::ReparseStyleAttribute(bool aForceInData
|
||||
ParseStyleAttribute(stringValue, attrValue, aForceInDataDoc);
|
||||
// Don't bother going through SetInlineStyleRule, we don't want to fire off
|
||||
// mutation events or document notifications anyway
|
||||
nsresult rv = mAttrsAndChildren.SetAndTakeAttr(nsGkAtoms::style, attrValue);
|
||||
nsresult rv = mAttrsAndChildren.SetAndSwapAttr(nsGkAtoms::style, attrValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,8 @@ nsAttributeTextNode::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName &&
|
||||
aElement == mGrandparent) {
|
||||
|
||||
@@ -20,6 +20,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=641821
|
||||
|
||||
/** Test for Bug 641821 **/
|
||||
|
||||
SimpleTest.requestFlakyTimeout("requestFlakyTimeout is silly. (But make sure marquee has time to initialize itself.)");
|
||||
|
||||
var div = document.createElement("div");
|
||||
|
||||
var M;
|
||||
@@ -580,7 +582,7 @@ function testExpandos() {
|
||||
var m2 = new M(function(records, observer) {
|
||||
is(observer.expandoProperty, true);
|
||||
observer.disconnect();
|
||||
then();
|
||||
then(testOutsideShadowDOM);
|
||||
});
|
||||
m2.expandoProperty = true;
|
||||
m2.observe(div, { attributes: true });
|
||||
@@ -596,6 +598,159 @@ function testExpandos() {
|
||||
div.setAttribute("foo", "bar2");
|
||||
}
|
||||
|
||||
function testOutsideShadowDOM() {
|
||||
var m = new M(function(records, observer) {
|
||||
is(records.length, 1);
|
||||
is(records[0].type, "attributes", "Should have got attributes");
|
||||
observer.disconnect();
|
||||
then(testInsideShadowDOM);
|
||||
});
|
||||
m.observe(div, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true
|
||||
})
|
||||
var sr = div.createShadowRoot();
|
||||
sr.innerHTML = "<div" + ">text</" + "div>";
|
||||
sr.firstChild.setAttribute("foo", "bar");
|
||||
sr.firstChild.firstChild.data = "text2";
|
||||
sr.firstChild.appendChild(document.createElement("div"));
|
||||
div.setAttribute("foo", "bar");
|
||||
}
|
||||
|
||||
function testInsideShadowDOM() {
|
||||
var m = new M(function(records, observer) {
|
||||
is(records.length, 4);
|
||||
is(records[0].type, "childList");
|
||||
is(records[1].type, "attributes");
|
||||
is(records[2].type, "characterData");
|
||||
is(records[3].type, "childList");
|
||||
observer.disconnect();
|
||||
then(testMarquee);
|
||||
});
|
||||
var sr = div.createShadowRoot();
|
||||
m.observe(sr, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
sr.innerHTML = "<div" + ">text</" + "div>";
|
||||
sr.firstChild.setAttribute("foo", "bar");
|
||||
sr.firstChild.firstChild.data = "text2";
|
||||
sr.firstChild.appendChild(document.createElement("div"));
|
||||
div.setAttribute("foo", "bar2");
|
||||
|
||||
}
|
||||
|
||||
function testMarquee() {
|
||||
var m = new M(function(records, observer) {
|
||||
is(records.length, 1);
|
||||
is(records[0].type, "attributes");
|
||||
is(records[0].attributeName, "ok");
|
||||
is(records[0].oldValue, null);
|
||||
observer.disconnect();
|
||||
then(testStyleCreate);
|
||||
});
|
||||
var marquee = document.createElement("marquee");
|
||||
m.observe(marquee, {
|
||||
attributes: true,
|
||||
attributeOldValue: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true
|
||||
});
|
||||
document.body.appendChild(marquee);
|
||||
setTimeout(function() {marquee.setAttribute("ok", "ok")}, 500);
|
||||
}
|
||||
|
||||
function testStyleCreate() {
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 1, "number of records");
|
||||
is(records[0].type, "attributes", "record.type");
|
||||
is(records[0].attributeName, "style", "record.attributeName");
|
||||
is(records[0].oldValue, null, "record.oldValue");
|
||||
isnot(div.getAttribute("style"), null, "style attribute after creation");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
div.removeAttribute("style");
|
||||
then(testStyleModify);
|
||||
});
|
||||
m.observe(div, { attributes: true, attributeOldValue: true });
|
||||
is(div.getAttribute("style"), null, "style attribute before creation");
|
||||
div.style.color = "blue";
|
||||
}
|
||||
|
||||
function testStyleModify() {
|
||||
div.style.color = "yellow";
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 1, "number of records");
|
||||
is(records[0].type, "attributes", "record.type");
|
||||
is(records[0].attributeName, "style", "record.attributeName");
|
||||
isnot(div.getAttribute("style"), null, "style attribute after modification");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
div.removeAttribute("style");
|
||||
then(testStyleRead);
|
||||
});
|
||||
m.observe(div, { attributes: true });
|
||||
isnot(div.getAttribute("style"), null, "style attribute before modification");
|
||||
div.style.color = "blue";
|
||||
}
|
||||
|
||||
function testStyleRead() {
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 1, "number of records");
|
||||
is(records[0].type, "attributes", "record.type");
|
||||
is(records[0].attributeName, "data-test", "record.attributeName");
|
||||
is(div.getAttribute("style"), null, "style attribute after read");
|
||||
observer.disconnect();
|
||||
div.removeAttribute("data-test");
|
||||
m = null;
|
||||
then(testStyleRemoveProperty);
|
||||
});
|
||||
m.observe(div, { attributes: true });
|
||||
is(div.getAttribute("style"), null, "style attribute before read");
|
||||
var value = div.style.color; // shouldn't generate any mutation records
|
||||
div.setAttribute("data-test", "a");
|
||||
}
|
||||
|
||||
function testStyleRemoveProperty() {
|
||||
div.style.color = "blue";
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 1, "number of records");
|
||||
is(records[0].type, "attributes", "record.type");
|
||||
is(records[0].attributeName, "style", "record.attributeName");
|
||||
isnot(div.getAttribute("style"), null, "style attribute after successful removeProperty");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
div.removeAttribute("style");
|
||||
then(testStyleRemoveProperty2);
|
||||
});
|
||||
m.observe(div, { attributes: true });
|
||||
isnot(div.getAttribute("style"), null, "style attribute before successful removeProperty");
|
||||
div.style.removeProperty("color");
|
||||
}
|
||||
|
||||
function testStyleRemoveProperty2() {
|
||||
m = new M(function(records, observer) {
|
||||
is(records.length, 1, "number of records");
|
||||
is(records[0].type, "attributes", "record.type");
|
||||
is(records[0].attributeName, "data-test", "record.attributeName");
|
||||
is(div.getAttribute("style"), null, "style attribute after unsuccessful removeProperty");
|
||||
observer.disconnect();
|
||||
m = null;
|
||||
div.removeAttribute("data-test");
|
||||
then();
|
||||
});
|
||||
m.observe(div, { attributes: true });
|
||||
is(div.getAttribute("style"), null, "style attribute before unsuccessful removeProperty");
|
||||
div.style.removeProperty("color"); // shouldn't generate any mutation records
|
||||
div.setAttribute("data-test", "a");
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
|
||||
@@ -744,7 +744,8 @@ IMEContentObserver::AttributeWillChange(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
nsIContent *content = GetContentBR(aElement);
|
||||
mPreAttrChangeLength = content ?
|
||||
@@ -756,7 +757,8 @@ IMEContentObserver::AttributeChanged(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
mEndOfAddedTextCache.Clear();
|
||||
mStartOfRemovingTextRangeCache.Clear();
|
||||
|
||||
@@ -491,7 +491,7 @@ HTMLButtonElement::DoneCreatingElement()
|
||||
|
||||
nsresult
|
||||
HTMLButtonElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNotify && aName == nsGkAtoms::disabled &&
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
* Called when an attribute is about to be changed
|
||||
*/
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
/**
|
||||
* Called when an attribute has just been changed
|
||||
|
||||
@@ -50,7 +50,7 @@ HTMLDetailsElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
|
||||
nsresult
|
||||
HTMLDetailsElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::open) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
int32_t aModType) const override;
|
||||
|
||||
nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
|
||||
// WebIDL methods.
|
||||
|
||||
@@ -371,7 +371,7 @@ HTMLImageElement::GetAttributeMappingFunction() const
|
||||
|
||||
nsresult
|
||||
HTMLImageElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ protected:
|
||||
void UpdateFormOwner();
|
||||
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
|
||||
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
|
||||
@@ -1331,7 +1331,7 @@ HTMLInputElement::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) co
|
||||
|
||||
nsresult
|
||||
HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
|
||||
@@ -865,7 +865,7 @@ protected:
|
||||
* Called when an attribute is about to be changed
|
||||
*/
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
/**
|
||||
* Called when an attribute has just been changed
|
||||
|
||||
@@ -215,7 +215,7 @@ HTMLOptionElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
||||
|
||||
nsresult
|
||||
HTMLOptionElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
nsresult rv = nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName,
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
int32_t aModType) const override;
|
||||
|
||||
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue, bool aNotify) override;
|
||||
|
||||
@@ -159,7 +159,8 @@ HTMLPropertiesCollection::NamedItem(const nsAString& aName)
|
||||
void
|
||||
HTMLPropertiesCollection::AttributeChanged(nsIDocument *aDocument, Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
mIsDirty = true;
|
||||
}
|
||||
@@ -438,7 +439,8 @@ PropertyNodeList::GetValues(JSContext* aCx, nsTArray<JS::Value >& aResult,
|
||||
void
|
||||
PropertyNodeList::AttributeChanged(nsIDocument* aDocument, Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
mIsDirty = true;
|
||||
}
|
||||
|
||||
@@ -1328,7 +1328,7 @@ HTMLSelectElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
|
||||
nsresult
|
||||
HTMLSelectElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNotify && aName == nsGkAtoms::disabled &&
|
||||
|
||||
@@ -372,7 +372,7 @@ public:
|
||||
bool aCompileEventHandlers) override;
|
||||
virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue, bool aNotify) override;
|
||||
|
||||
@@ -956,7 +956,7 @@ HTMLTableElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
|
||||
nsresult
|
||||
HTMLTableElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) {
|
||||
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
* Called when an attribute is about to be changed
|
||||
*/
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
/**
|
||||
* Called when an attribute has just been changed
|
||||
|
||||
@@ -1209,7 +1209,7 @@ HTMLTextAreaElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
|
||||
nsresult
|
||||
HTMLTextAreaElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNotify && aName == nsGkAtoms::disabled &&
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
* Called when an attribute is about to be changed
|
||||
*/
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
|
||||
// nsIMutationObserver
|
||||
|
||||
@@ -649,7 +649,8 @@ UndoMutationObserver::AttributeWillChange(nsIDocument* aDocument,
|
||||
mozilla::dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
if (!IsManagerForMutation(aElement)) {
|
||||
return;
|
||||
|
||||
@@ -259,7 +259,8 @@ bool nsDOMStringMap::AttrToDataProp(const nsAString& aAttr,
|
||||
void
|
||||
nsDOMStringMap::AttributeChanged(nsIDocument *aDocument, Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if ((aModType == nsIDOMMutationEvent::ADDITION ||
|
||||
aModType == nsIDOMMutationEvent::REMOVAL) &&
|
||||
|
||||
@@ -2097,7 +2097,7 @@ nsGenericHTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLFormElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
|
||||
@@ -1372,7 +1372,7 @@ protected:
|
||||
virtual ~nsGenericHTMLFormElement();
|
||||
|
||||
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
|
||||
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
|
||||
@@ -1783,11 +1783,11 @@ NPObjWrapper_ObjectMoved(JSObject* obj, const JSObject* old)
|
||||
return;
|
||||
}
|
||||
|
||||
// Calling PL_DHashTableSearch() will not result in GC.
|
||||
// Calling PLDHashTable::Search() will not result in GC.
|
||||
JS::AutoSuppressGCAnalysis nogc;
|
||||
|
||||
NPObjWrapperHashEntry* entry = static_cast<NPObjWrapperHashEntry*>
|
||||
(PL_DHashTableSearch(sNPObjWrappers, npobj));
|
||||
auto entry =
|
||||
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Search(npobj));
|
||||
MOZ_ASSERT(entry && entry->mJSObj);
|
||||
MOZ_ASSERT(entry->mJSObj == old);
|
||||
entry->mJSObj = obj;
|
||||
@@ -1839,8 +1839,8 @@ nsNPObjWrapper::OnDestroy(NPObject* npobj)
|
||||
return;
|
||||
}
|
||||
|
||||
NPObjWrapperHashEntry* entry = static_cast<NPObjWrapperHashEntry*>
|
||||
(PL_DHashTableSearch(sNPObjWrappers, npobj));
|
||||
auto entry =
|
||||
static_cast<NPObjWrapperHashEntry*>(sNPObjWrappers->Search(npobj));
|
||||
|
||||
if (entry && entry->mJSObj) {
|
||||
// Found a live NPObject wrapper, null out its JSObjects' private
|
||||
@@ -1923,7 +1923,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext* cx, NPObject* npobj)
|
||||
// Reload entry if the JS_NewObject call caused a GC and reallocated
|
||||
// the table (see bug 445229). This is guaranteed to succeed.
|
||||
|
||||
NS_ASSERTION(PL_DHashTableSearch(sNPObjWrappers, npobj),
|
||||
NS_ASSERTION(sNPObjWrappers->Search(npobj),
|
||||
"Hashtable didn't find what we just added?");
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,8 @@ SVGMPathElement::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (aNameSpaceID == kNameSpaceID_None) {
|
||||
if (aAttribute == nsGkAtoms::d) {
|
||||
|
||||
@@ -156,7 +156,8 @@ SVGUseElement::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (nsContentUtils::IsInSameAnonymousTree(this, aElement)) {
|
||||
TriggerReclone();
|
||||
|
||||
@@ -273,7 +273,7 @@ nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
ParseStyleAttribute(stringValue, attrValue, true);
|
||||
// Don't bother going through SetInlineStyleRule, we don't want to fire off
|
||||
// mutation events or document notifications anyway
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(nsGkAtoms::style, attrValue);
|
||||
rv = mAttrsAndChildren.SetAndSwapAttr(nsGkAtoms::style, attrValue);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@@ -1439,7 +1439,8 @@ nsSVGElement::WillChangeValue(nsIAtom* aName)
|
||||
uint8_t modType = attrValue
|
||||
? static_cast<uint8_t>(nsIDOMMutationEvent::MODIFICATION)
|
||||
: static_cast<uint8_t>(nsIDOMMutationEvent::ADDITION);
|
||||
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, aName, modType);
|
||||
nsNodeUtils::AttributeWillChange(this, kNameSpaceID_None, aName, modType,
|
||||
nullptr);
|
||||
|
||||
return emptyOrOldAttrValue;
|
||||
}
|
||||
@@ -1454,6 +1455,8 @@ nsSVGElement::WillChangeValue(nsIAtom* aName)
|
||||
* b) WillChangeXXX will ensure the object represents a serialized version of
|
||||
* the old attribute value so that the value doesn't change when the
|
||||
* underlying SVG type is updated.
|
||||
*
|
||||
* aNewValue is replaced with the old value.
|
||||
*/
|
||||
void
|
||||
nsSVGElement::DidChangeValue(nsIAtom* aName,
|
||||
@@ -1489,7 +1492,7 @@ nsSVGElement::MaybeSerializeAttrBeforeRemoval(nsIAtom* aName, bool aNotify)
|
||||
nsAutoString serializedValue;
|
||||
attrValue->ToString(serializedValue);
|
||||
nsAttrValue oldAttrValue(serializedValue);
|
||||
mAttrsAndChildren.SetAndTakeAttr(aName, oldAttrValue);
|
||||
mAttrsAndChildren.SetAndSwapAttr(aName, oldAttrValue);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
||||
@@ -331,8 +331,11 @@ protected:
|
||||
// BeforeSetAttr since it would involve allocating extra SVG value types.
|
||||
// See the comment in nsSVGElement::WillChangeValue.
|
||||
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
bool aNotify) override final { return NS_OK; }
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override final
|
||||
{
|
||||
return nsSVGElementBase::BeforeSetAttr(aNamespaceID, aName, aValue, aNotify);
|
||||
}
|
||||
#endif // DEBUG
|
||||
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue, bool aNotify) override;
|
||||
@@ -347,6 +350,8 @@ protected:
|
||||
mozilla::css::StyleRule* GetAnimatedContentStyleRule();
|
||||
|
||||
nsAttrValue WillChangeValue(nsIAtom* aName);
|
||||
// aNewValue is set to the old value. This value may be invalid if
|
||||
// !StoresOwnData.
|
||||
void DidChangeValue(nsIAtom* aName, const nsAttrValue& aEmptyOrOldValue,
|
||||
nsAttrValue& aNewValue);
|
||||
void MaybeSerializeAttrBeforeRemoval(nsIAtom* aName, bool aNotify);
|
||||
|
||||
@@ -218,7 +218,8 @@ nsXMLPrettyPrinter::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
MaybeUnhook(aElement);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ XPathResult::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
Invalidate(aElement);
|
||||
}
|
||||
|
||||
@@ -1245,7 +1245,8 @@ txMozillaXSLTProcessor::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
mStylesheet = nullptr;
|
||||
}
|
||||
|
||||
+13
-16
@@ -768,10 +768,8 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
mBroadcasterMap = new PLDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
}
|
||||
|
||||
BroadcasterMapEntry* entry =
|
||||
static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
|
||||
|
||||
auto entry = static_cast<BroadcasterMapEntry*>
|
||||
(mBroadcasterMap->Search(&aBroadcaster));
|
||||
if (!entry) {
|
||||
entry = static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible));
|
||||
@@ -829,10 +827,8 @@ XULDocument::RemoveBroadcastListenerFor(Element& aBroadcaster,
|
||||
if (! mBroadcasterMap)
|
||||
return;
|
||||
|
||||
BroadcasterMapEntry* entry =
|
||||
static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
|
||||
|
||||
auto entry = static_cast<BroadcasterMapEntry*>
|
||||
(mBroadcasterMap->Search(&aBroadcaster));
|
||||
if (entry) {
|
||||
nsCOMPtr<nsIAtom> attr = do_GetAtom(aAttr);
|
||||
for (size_t i = entry->mListeners.Length() - 1; i != (size_t)-1; --i) {
|
||||
@@ -844,7 +840,7 @@ XULDocument::RemoveBroadcastListenerFor(Element& aBroadcaster,
|
||||
delete bl;
|
||||
|
||||
if (entry->mListeners.IsEmpty())
|
||||
PL_DHashTableRemove(mBroadcasterMap, &aBroadcaster);
|
||||
mBroadcasterMap->RemoveEntry(entry);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -914,7 +910,8 @@ XULDocument::ExecuteOnBroadcastHandlerFor(Element* aBroadcaster,
|
||||
void
|
||||
XULDocument::AttributeWillChange(nsIDocument* aDocument,
|
||||
Element* aElement, int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute, int32_t aModType)
|
||||
nsIAtom* aAttribute, int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
MOZ_ASSERT(aElement, "Null content!");
|
||||
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
|
||||
@@ -931,7 +928,8 @@ XULDocument::AttributeWillChange(nsIDocument* aDocument,
|
||||
void
|
||||
XULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement, int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute, int32_t aModType)
|
||||
nsIAtom* aAttribute, int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
NS_ASSERTION(aDocument == this, "unexpected doc");
|
||||
|
||||
@@ -949,9 +947,8 @@ XULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
// Synchronize broadcast listeners
|
||||
if (mBroadcasterMap &&
|
||||
CanBroadcast(aNameSpaceID, aAttribute)) {
|
||||
BroadcasterMapEntry* entry =
|
||||
static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableSearch(mBroadcasterMap, aElement));
|
||||
auto entry = static_cast<BroadcasterMapEntry*>
|
||||
(mBroadcasterMap->Search(aElement));
|
||||
|
||||
if (entry) {
|
||||
// We've got listeners: push the value.
|
||||
@@ -4127,8 +4124,8 @@ XULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
|
||||
if (!aNode->IsElement())
|
||||
return rv;
|
||||
|
||||
BroadcasterMapEntry* entry = static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableSearch(mBroadcasterMap, aNode->AsElement()));
|
||||
auto entry = static_cast<BroadcasterMapEntry*>
|
||||
(mBroadcasterMap->Search(aNode->AsElement()));
|
||||
if (!entry)
|
||||
return rv;
|
||||
|
||||
|
||||
@@ -403,10 +403,10 @@ nsXULElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
|
||||
}
|
||||
|
||||
if (originalName->IsAtom()) {
|
||||
rv = element->mAttrsAndChildren.SetAndTakeAttr(originalName->Atom(),
|
||||
rv = element->mAttrsAndChildren.SetAndSwapAttr(originalName->Atom(),
|
||||
attrValue);
|
||||
} else {
|
||||
rv = element->mAttrsAndChildren.SetAndTakeAttr(originalName->NodeInfo(),
|
||||
rv = element->mAttrsAndChildren.SetAndSwapAttr(originalName->NodeInfo(),
|
||||
attrValue);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -1045,7 +1045,7 @@ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
|
||||
|
||||
nsresult
|
||||
nsXULElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue, bool aNotify)
|
||||
nsAttrValueOrString* aValue, bool aNotify)
|
||||
{
|
||||
if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::accesskey &&
|
||||
IsInDoc()) {
|
||||
@@ -1891,10 +1891,10 @@ nsXULElement::MakeHeavyweight(nsXULPrototypeElement* aPrototype)
|
||||
|
||||
// XXX we might wanna have a SetAndTakeAttr that takes an nsAttrName
|
||||
if (protoattr->mName.IsAtom()) {
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(protoattr->mName.Atom(), attrValue);
|
||||
rv = mAttrsAndChildren.SetAndSwapAttr(protoattr->mName.Atom(), attrValue);
|
||||
}
|
||||
else {
|
||||
rv = mAttrsAndChildren.SetAndTakeAttr(protoattr->mName.NodeInfo(),
|
||||
rv = mAttrsAndChildren.SetAndSwapAttr(protoattr->mName.NodeInfo(),
|
||||
attrValue);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@@ -657,7 +657,7 @@ protected:
|
||||
nsresult MakeHeavyweight(nsXULPrototypeElement* aPrototype);
|
||||
|
||||
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override;
|
||||
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
const nsAttrValue* aValue, bool aNotify) override;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
}
|
||||
|
||||
bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) {
|
||||
PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mMap, aElement);
|
||||
PLDHashEntryHdr* hdr = mMap.Search(aElement);
|
||||
if (!hdr)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ public:
|
||||
|
||||
void
|
||||
Put(nsIContent* aContent, nsIContent* aTemplate) {
|
||||
NS_ASSERTION(!PL_DHashTableSearch(&mTable, aContent),
|
||||
"aContent already in map");
|
||||
NS_ASSERTION(!mTable.Search(aContent), "aContent already in map");
|
||||
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(&mTable, aContent, fallible));
|
||||
@@ -51,9 +50,7 @@ public:
|
||||
|
||||
void
|
||||
GetTemplateFor(nsIContent* aContent, nsIContent** aResult) {
|
||||
Entry* entry =
|
||||
static_cast<Entry*>(PL_DHashTableSearch(&mTable, aContent));
|
||||
|
||||
auto entry = static_cast<Entry*>(mTable.Search(aContent));
|
||||
if (entry)
|
||||
NS_IF_ADDREF(*aResult = entry->mTemplate);
|
||||
else
|
||||
|
||||
@@ -1510,7 +1510,8 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
|
||||
|
||||
@@ -1536,7 +1537,7 @@ nsXULContentBuilder::AttributeChanged(nsIDocument* aDocument,
|
||||
|
||||
// Pass along to the generic template builder.
|
||||
nsXULTemplateBuilder::AttributeChanged(aDocument, aElement, aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
aAttribute, aModType, aOldValue);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1093,7 +1093,8 @@ nsXULTemplateBuilder::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (aElement == mRoot && aNameSpaceID == kNameSpaceID_None) {
|
||||
// Check for a change to the 'ref' attribute on an atom, in which
|
||||
|
||||
@@ -208,7 +208,9 @@ nsEditingSession::DisableJSAndPlugins(nsIDOMWindow *aWindow)
|
||||
NS_IMETHODIMP
|
||||
nsEditingSession::RestoreJSAndPlugins(nsIDOMWindow *aWindow)
|
||||
{
|
||||
NS_ENSURE_TRUE(mDisabledJSAndPlugins, NS_OK);
|
||||
if (!mDisabledJSAndPlugins) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mDisabledJSAndPlugins = false;
|
||||
|
||||
|
||||
@@ -31,20 +31,22 @@ nsBaseCommandController::~nsBaseCommandController()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::Init(nsIControllerCommandTable *aCommandTable)
|
||||
nsBaseCommandController::Init(nsIControllerCommandTable* aCommandTable)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (aCommandTable)
|
||||
mCommandTable = aCommandTable; // owning addref
|
||||
else
|
||||
mCommandTable = do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||
|
||||
if (aCommandTable) {
|
||||
mCommandTable = aCommandTable;
|
||||
} else {
|
||||
mCommandTable =
|
||||
do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::SetCommandContext(nsISupports *aCommandContext)
|
||||
nsBaseCommandController::SetCommandContext(nsISupports* aCommandContext)
|
||||
{
|
||||
mCommandContextWeakPtr = nullptr;
|
||||
mCommandContextRawPtr = nullptr;
|
||||
@@ -55,8 +57,7 @@ nsBaseCommandController::SetCommandContext(nsISupports *aCommandContext)
|
||||
nsresult rv =
|
||||
weak->GetWeakReference(getter_AddRefs(mCommandContextWeakPtr));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mCommandContextRawPtr = aCommandContext;
|
||||
}
|
||||
}
|
||||
@@ -65,32 +66,30 @@ nsBaseCommandController::SetCommandContext(nsISupports *aCommandContext)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::GetInterface(const nsIID & aIID, void * *result)
|
||||
nsBaseCommandController::GetInterface(const nsIID& aIID, void** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (NS_SUCCEEDED(QueryInterface(aIID, result)))
|
||||
if (NS_SUCCEEDED(QueryInterface(aIID, aResult))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable)))
|
||||
{
|
||||
if (mCommandTable)
|
||||
return mCommandTable->QueryInterface(aIID, result);
|
||||
if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable))) {
|
||||
if (mCommandTable) {
|
||||
return mCommandTable->QueryInterface(aIID, aResult);
|
||||
}
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* =======================================================================
|
||||
* nsIController
|
||||
* ======================================================================= */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::IsCommandEnabled(const char *aCommand,
|
||||
bool *aResult)
|
||||
nsBaseCommandController::IsCommandEnabled(const char* aCommand, bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
@@ -106,7 +105,7 @@ nsBaseCommandController::IsCommandEnabled(const char *aCommand,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::SupportsCommand(const char *aCommand, bool *aResult)
|
||||
nsBaseCommandController::SupportsCommand(const char* aCommand, bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
@@ -122,7 +121,7 @@ nsBaseCommandController::SupportsCommand(const char *aCommand, bool *aResult)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::DoCommand(const char *aCommand)
|
||||
nsBaseCommandController::DoCommand(const char* aCommand)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_STATE(mCommandTable);
|
||||
@@ -137,8 +136,8 @@ nsBaseCommandController::DoCommand(const char *aCommand)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::DoCommandWithParams(const char *aCommand,
|
||||
nsICommandParams *aParams)
|
||||
nsBaseCommandController::DoCommandWithParams(const char* aCommand,
|
||||
nsICommandParams* aParams)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_STATE(mCommandTable);
|
||||
@@ -153,8 +152,8 @@ nsBaseCommandController::DoCommandWithParams(const char *aCommand,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::GetCommandStateWithParams(const char *aCommand,
|
||||
nsICommandParams *aParams)
|
||||
nsBaseCommandController::GetCommandStateWithParams(const char* aCommand,
|
||||
nsICommandParams* aParams)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_STATE(mCommandTable);
|
||||
@@ -169,14 +168,15 @@ nsBaseCommandController::GetCommandStateWithParams(const char *aCommand,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::OnEvent(const char * aEventName)
|
||||
nsBaseCommandController::OnEvent(const char* aEventName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEventName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::GetSupportedCommands(uint32_t* aCount, char*** aCommands)
|
||||
nsBaseCommandController::GetSupportedCommands(uint32_t* aCount,
|
||||
char*** aCommands)
|
||||
{
|
||||
NS_ENSURE_STATE(mCommandTable);
|
||||
return mCommandTable->GetSupportedCommands(aCount, aCommands);
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
#define nsBaseCommandController_h__
|
||||
|
||||
#define NS_BASECOMMANDCONTROLLER_CID \
|
||||
{ 0xbf88b48c, 0xfd8e, 0x40b4, { 0xba, 0x36, 0xc7, 0xc3, 0xad, 0x6d, 0x8a, 0xc9 } }
|
||||
{ 0xbf88b48c, 0xfd8e, 0x40b4, { 0xba, 0x36, 0xc7, 0xc3, 0xad, 0x6d, 0x8a, 0xc9 } }
|
||||
#define NS_BASECOMMANDCONTROLLER_CONTRACTID \
|
||||
"@mozilla.org/embedcomp/base-command-controller;1"
|
||||
|
||||
"@mozilla.org/embedcomp/base-command-controller;1"
|
||||
|
||||
#include "nsIController.h"
|
||||
#include "nsIControllerContext.h"
|
||||
@@ -18,43 +17,32 @@
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
|
||||
// The base editor controller is used for both text widgets,
|
||||
// and all other text and html editing
|
||||
class nsBaseCommandController : public nsIController,
|
||||
public nsIControllerContext,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsICommandController
|
||||
// The base editor controller is used for both text widgets, and all other text
|
||||
// and html editing
|
||||
class nsBaseCommandController
|
||||
: public nsIController
|
||||
, public nsIControllerContext
|
||||
, public nsIInterfaceRequestor
|
||||
, public nsICommandController
|
||||
{
|
||||
public:
|
||||
|
||||
nsBaseCommandController();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIController
|
||||
NS_DECL_NSICONTROLLER
|
||||
|
||||
// nsICommandController
|
||||
NS_DECL_NSICOMMANDCONTROLLER
|
||||
|
||||
//nsIControllerContext
|
||||
NS_DECL_NSICONTROLLERCONTEXT
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
protected:
|
||||
virtual ~nsBaseCommandController();
|
||||
|
||||
private:
|
||||
nsWeakPtr mCommandContextWeakPtr;
|
||||
nsISupports* mCommandContextRawPtr;
|
||||
|
||||
nsWeakPtr mCommandContextWeakPtr;
|
||||
nsISupports* mCommandContextRawPtr;
|
||||
|
||||
// Our reference to the command manager
|
||||
nsCOMPtr<nsIControllerCommandTable> mCommandTable;
|
||||
// Our reference to the command manager
|
||||
nsCOMPtr<nsIControllerCommandTable> mCommandTable;
|
||||
};
|
||||
|
||||
#endif /* nsBaseCommandController_h_ */
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
#include "nsIControllerCommand.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
|
||||
class nsGroupsEnumerator : public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
explicit nsGroupsEnumerator(nsControllerCommandGroup::GroupsHashtable &inHashTable);
|
||||
explicit nsGroupsEnumerator(
|
||||
nsControllerCommandGroup::GroupsHashtable& aInHashTable);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
@@ -26,84 +26,90 @@ public:
|
||||
protected:
|
||||
virtual ~nsGroupsEnumerator();
|
||||
|
||||
static PLDHashOperator HashEnum(const nsACString &aKey, nsTArray<nsCString> *aData, void *aClosure);
|
||||
static PLDHashOperator HashEnum(const nsACString& aKey,
|
||||
nsTArray<nsCString>* aData, void* aClosure);
|
||||
nsresult Initialize();
|
||||
|
||||
protected:
|
||||
|
||||
nsControllerCommandGroup::GroupsHashtable &mHashTable;
|
||||
nsControllerCommandGroup::GroupsHashtable& mHashTable;
|
||||
int32_t mIndex;
|
||||
char **mGroupNames; // array of pointers to char16_t* in the hash table
|
||||
char** mGroupNames; // array of pointers to char16_t* in the hash table
|
||||
bool mInitted;
|
||||
|
||||
};
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS(nsGroupsEnumerator, nsISimpleEnumerator)
|
||||
|
||||
nsGroupsEnumerator::nsGroupsEnumerator(nsControllerCommandGroup::GroupsHashtable &inHashTable)
|
||||
: mHashTable(inHashTable)
|
||||
, mIndex(-1)
|
||||
, mGroupNames(nullptr)
|
||||
, mInitted(false)
|
||||
nsGroupsEnumerator::nsGroupsEnumerator(
|
||||
nsControllerCommandGroup::GroupsHashtable& aInHashTable)
|
||||
: mHashTable(aInHashTable)
|
||||
, mIndex(-1)
|
||||
, mGroupNames(nullptr)
|
||||
, mInitted(false)
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsGroupsEnumerator::~nsGroupsEnumerator()
|
||||
{
|
||||
delete [] mGroupNames; // ok on null pointer
|
||||
delete[] mGroupNames;
|
||||
}
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
NS_IMETHODIMP
|
||||
nsGroupsEnumerator::HasMoreElements(bool *_retval)
|
||||
nsGroupsEnumerator::HasMoreElements(bool* aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mInitted) {
|
||||
rv = Initialize();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
*_retval = (mIndex < static_cast<int32_t>(mHashTable.Count()) - 1);
|
||||
|
||||
*aResult = (mIndex < static_cast<int32_t>(mHashTable.Count()) - 1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISupports getNext (); */
|
||||
NS_IMETHODIMP
|
||||
nsGroupsEnumerator::GetNext(nsISupports **_retval)
|
||||
nsGroupsEnumerator::GetNext(nsISupports** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mInitted) {
|
||||
rv = Initialize();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
mIndex ++;
|
||||
if (mIndex >= static_cast<int32_t>(mHashTable.Count()))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
char *thisGroupName = mGroupNames[mIndex];
|
||||
|
||||
nsCOMPtr<nsISupportsCString> supportsString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mIndex++;
|
||||
if (mIndex >= static_cast<int32_t>(mHashTable.Count())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
char* thisGroupName = mGroupNames[mIndex];
|
||||
|
||||
nsCOMPtr<nsISupportsCString> supportsString =
|
||||
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
supportsString->SetData(nsDependentCString(thisGroupName));
|
||||
return CallQueryInterface(supportsString, _retval);
|
||||
return CallQueryInterface(supportsString, aResult);
|
||||
}
|
||||
|
||||
/* static */
|
||||
/* return false to stop */
|
||||
PLDHashOperator
|
||||
nsGroupsEnumerator::HashEnum(const nsACString &aKey, nsTArray<nsCString> *aData, void *aClosure)
|
||||
nsGroupsEnumerator::HashEnum(const nsACString& aKey, nsTArray<nsCString>* aData,
|
||||
void* aClosure)
|
||||
{
|
||||
nsGroupsEnumerator *groupsEnum = static_cast<nsGroupsEnumerator*>(aClosure);
|
||||
nsGroupsEnumerator* groupsEnum = static_cast<nsGroupsEnumerator*>(aClosure);
|
||||
groupsEnum->mGroupNames[groupsEnum->mIndex] = (char*)aKey.Data();
|
||||
groupsEnum->mIndex++;
|
||||
return PL_DHASH_NEXT;
|
||||
@@ -112,12 +118,16 @@ nsGroupsEnumerator::HashEnum(const nsACString &aKey, nsTArray<nsCString> *aData,
|
||||
nsresult
|
||||
nsGroupsEnumerator::Initialize()
|
||||
{
|
||||
if (mInitted) return NS_OK;
|
||||
|
||||
if (mInitted) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mGroupNames = new char*[mHashTable.Count()];
|
||||
if (!mGroupNames) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mIndex = 0;
|
||||
if (!mGroupNames) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mIndex = 0;
|
||||
mHashTable.EnumerateRead(HashEnum, this);
|
||||
|
||||
mIndex = -1;
|
||||
@@ -125,14 +135,10 @@ nsGroupsEnumerator::Initialize()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
class nsNamedGroupEnumerator : public nsISimpleEnumerator
|
||||
{
|
||||
public:
|
||||
explicit nsNamedGroupEnumerator(nsTArray<nsCString> *inArray);
|
||||
explicit nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
@@ -140,13 +146,13 @@ public:
|
||||
protected:
|
||||
virtual ~nsNamedGroupEnumerator();
|
||||
|
||||
nsTArray<nsCString> *mGroupArray;
|
||||
nsTArray<nsCString>* mGroupArray;
|
||||
int32_t mIndex;
|
||||
};
|
||||
|
||||
nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<nsCString> *inArray)
|
||||
: mGroupArray(inArray)
|
||||
, mIndex(-1)
|
||||
nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray)
|
||||
: mGroupArray(aInArray)
|
||||
, mIndex(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -156,46 +162,43 @@ nsNamedGroupEnumerator::~nsNamedGroupEnumerator()
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsNamedGroupEnumerator, nsISimpleEnumerator)
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
NS_IMETHODIMP
|
||||
nsNamedGroupEnumerator::HasMoreElements(bool *_retval)
|
||||
nsNamedGroupEnumerator::HasMoreElements(bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
int32_t arrayLen = mGroupArray ? mGroupArray->Length() : 0;
|
||||
*_retval = (mIndex < arrayLen - 1);
|
||||
*aResult = (mIndex < arrayLen - 1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISupports getNext (); */
|
||||
NS_IMETHODIMP
|
||||
nsNamedGroupEnumerator::GetNext(nsISupports **_retval)
|
||||
nsNamedGroupEnumerator::GetNext(nsISupports** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (!mGroupArray)
|
||||
if (!mGroupArray) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mIndex++;
|
||||
if (mIndex >= int32_t(mGroupArray->Length()))
|
||||
if (mIndex >= int32_t(mGroupArray->Length())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
const nsCString& thisGroupName = mGroupArray->ElementAt(mIndex);
|
||||
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISupportsCString> supportsString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsISupportsCString> supportsString =
|
||||
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
supportsString->SetData(thisGroupName);
|
||||
return CallQueryInterface(supportsString, _retval);
|
||||
return CallQueryInterface(supportsString, aResult);
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS(nsControllerCommandGroup, nsIControllerCommandGroup)
|
||||
|
||||
nsControllerCommandGroup::nsControllerCommandGroup()
|
||||
@@ -213,25 +216,20 @@ nsControllerCommandGroup::ClearGroupsHash()
|
||||
mGroupsHash.Clear();
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
/* void addCommandToGroup (in DOMString aCommand, in DOMString aGroup); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandGroup::AddCommandToGroup(const char *aCommand, const char *aGroup)
|
||||
nsControllerCommandGroup::AddCommandToGroup(const char* aCommand,
|
||||
const char* aGroup)
|
||||
{
|
||||
nsDependentCString groupKey(aGroup);
|
||||
nsTArray<nsCString> *commandList;
|
||||
if ((commandList = mGroupsHash.Get(groupKey)) == nullptr)
|
||||
{
|
||||
nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
|
||||
if (!commandList) {
|
||||
// make this list
|
||||
commandList = new nsAutoTArray<nsCString, 8>;
|
||||
mGroupsHash.Put(groupKey, commandList);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsCString *appended =
|
||||
nsCString* appended =
|
||||
#endif
|
||||
commandList->AppendElement(aCommand);
|
||||
NS_ASSERTION(appended, "Append failed");
|
||||
@@ -239,20 +237,20 @@ nsControllerCommandGroup::AddCommandToGroup(const char *aCommand, const char *aG
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void removeCommandFromGroup (in DOMString aCommand, in DOMString aGroup); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandGroup::RemoveCommandFromGroup(const char *aCommand, const char *aGroup)
|
||||
nsControllerCommandGroup::RemoveCommandFromGroup(const char* aCommand,
|
||||
const char* aGroup)
|
||||
{
|
||||
nsDependentCString groupKey(aGroup);
|
||||
nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey);
|
||||
if (!commandList) return NS_OK; // no group
|
||||
nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
|
||||
if (!commandList) {
|
||||
return NS_OK; // no group
|
||||
}
|
||||
|
||||
uint32_t numEntries = commandList->Length();
|
||||
for (uint32_t i = 0; i < numEntries; i++)
|
||||
{
|
||||
for (uint32_t i = 0; i < numEntries; i++) {
|
||||
nsCString commandString = commandList->ElementAt(i);
|
||||
if (nsDependentCString(aCommand) != commandString)
|
||||
{
|
||||
if (nsDependentCString(aCommand) != commandString) {
|
||||
commandList->RemoveElementAt(i);
|
||||
break;
|
||||
}
|
||||
@@ -260,53 +258,49 @@ nsControllerCommandGroup::RemoveCommandFromGroup(const char *aCommand, const cha
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isCommandInGroup (in DOMString aCommand, in DOMString aGroup); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandGroup::IsCommandInGroup(const char *aCommand, const char *aGroup, bool *_retval)
|
||||
nsControllerCommandGroup::IsCommandInGroup(const char* aCommand,
|
||||
const char* aGroup, bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = false;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = false;
|
||||
|
||||
nsDependentCString groupKey(aGroup);
|
||||
nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey);
|
||||
if (!commandList) return NS_OK; // no group
|
||||
|
||||
nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey);
|
||||
if (!commandList) {
|
||||
return NS_OK; // no group
|
||||
}
|
||||
|
||||
uint32_t numEntries = commandList->Length();
|
||||
for (uint32_t i = 0; i < numEntries; i++)
|
||||
{
|
||||
for (uint32_t i = 0; i < numEntries; i++) {
|
||||
nsCString commandString = commandList->ElementAt(i);
|
||||
if (nsDependentCString(aCommand) != commandString)
|
||||
{
|
||||
*_retval = true;
|
||||
if (nsDependentCString(aCommand) != commandString) {
|
||||
*aResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator getGroupsEnumerator (); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator **_retval)
|
||||
nsControllerCommandGroup::GetGroupsEnumerator(nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsRefPtr<nsGroupsEnumerator> groupsEnum = new nsGroupsEnumerator(mGroupsHash);
|
||||
|
||||
groupsEnum.forget(_retval);
|
||||
groupsEnum.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator getEnumeratorForGroup (in DOMString aGroup); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandGroup::GetEnumeratorForGroup(const char *aGroup, nsISimpleEnumerator **_retval)
|
||||
nsControllerCommandGroup::GetEnumeratorForGroup(const char* aGroup,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsDependentCString groupKey(aGroup);
|
||||
nsTArray<nsCString> *commandList = mGroupsHash.Get(groupKey); // may be null
|
||||
nsTArray<nsCString>* commandList = mGroupsHash.Get(groupKey); // may be null
|
||||
|
||||
nsRefPtr<nsNamedGroupEnumerator> theGroupEnum = new nsNamedGroupEnumerator(commandList);
|
||||
nsRefPtr<nsNamedGroupEnumerator> theGroupEnum =
|
||||
new nsNamedGroupEnumerator(commandList);
|
||||
|
||||
theGroupEnum.forget(_retval);
|
||||
theGroupEnum.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
// {ecd55a01-2780-11d5-a73c-ca641a6813bc}
|
||||
#define NS_CONTROLLER_COMMAND_GROUP_CID \
|
||||
{ 0xecd55a01, 0x2780, 0x11d5, { 0xa7, 0x3c, 0xca, 0x64, 0x1a, 0x68, 0x13, 0xbc } }
|
||||
{ 0xecd55a01, 0x2780, 0x11d5, { 0xa7, 0x3c, 0xca, 0x64, 0x1a, 0x68, 0x13, 0xbc } }
|
||||
|
||||
#define NS_CONTROLLER_COMMAND_GROUP_CONTRACTID \
|
||||
"@mozilla.org/embedcomp/controller-command-group;1"
|
||||
"@mozilla.org/embedcomp/controller-command-group;1"
|
||||
|
||||
class nsControllerCommandGroup : public nsIControllerCommandGroup
|
||||
{
|
||||
@@ -26,7 +26,8 @@ public:
|
||||
NS_DECL_NSICONTROLLERCOMMANDGROUP
|
||||
|
||||
public:
|
||||
typedef nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>> GroupsHashtable;
|
||||
typedef nsClassHashtable<nsCStringHashKey, nsTArray<nsCString>>
|
||||
GroupsHashtable;
|
||||
|
||||
protected:
|
||||
virtual ~nsControllerCommandGroup();
|
||||
@@ -34,8 +35,9 @@ protected:
|
||||
void ClearGroupsHash();
|
||||
|
||||
protected:
|
||||
GroupsHashtable mGroupsHash; // hash keyed on command group.
|
||||
// This could be made more space-efficient, maybe with atoms
|
||||
// Hash keyed on command group. This could be made more space-efficient,
|
||||
// maybe with atoms.
|
||||
GroupsHashtable mGroupsHash;
|
||||
};
|
||||
|
||||
#endif // nsCommandGroup_h__
|
||||
|
||||
@@ -24,25 +24,21 @@
|
||||
|
||||
#include "nsCommandManager.h"
|
||||
|
||||
|
||||
nsCommandManager::nsCommandManager()
|
||||
: mWindow(nullptr)
|
||||
: mWindow(nullptr)
|
||||
{
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
nsCommandManager::~nsCommandManager()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseCommandObservers(const char* aKey,
|
||||
nsCommandManager::ObserverList* aObservers,
|
||||
void* aClosure)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
nsCycleCollectionTraversalCallback* cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(aClosure);
|
||||
|
||||
int32_t i, numItems = aObservers->Length();
|
||||
@@ -66,40 +62,32 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsCommandManager)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsCommandManager)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCommandManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICommandManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPICommandUpdater)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICommandManager)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPICommandUpdater)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandManager)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
/* void init (in nsIDOMWindow aWindow); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::Init(nsIDOMWindow *aWindow)
|
||||
nsCommandManager::Init(nsIDOMWindow* aWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWindow);
|
||||
|
||||
|
||||
NS_ASSERTION(aWindow, "Need non-null window here");
|
||||
mWindow = aWindow; // weak ptr
|
||||
mWindow = aWindow; // weak ptr
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void commandStatusChanged (in DOMString aCommandName, in long aChangeFlags); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::CommandStatusChanged(const char * aCommandName)
|
||||
nsCommandManager::CommandStatusChanged(const char* aCommandName)
|
||||
{
|
||||
ObserverList* commandObservers;
|
||||
mObserversTable.Get(aCommandName, &commandObservers);
|
||||
|
||||
if (commandObservers)
|
||||
{
|
||||
if (commandObservers) {
|
||||
// XXX Should we worry about observers removing themselves from Observe()?
|
||||
int32_t i, numItems = commandObservers->Length();
|
||||
for (i = 0; i < numItems; ++i)
|
||||
{
|
||||
for (i = 0; i < numItems; ++i) {
|
||||
nsCOMPtr<nsIObserver> observer = commandObservers->ElementAt(i);
|
||||
// should we get the command state to pass here? This might be expensive.
|
||||
observer->Observe(NS_ISUPPORTS_CAST(nsICommandManager*, this),
|
||||
@@ -115,9 +103,9 @@ nsCommandManager::CommandStatusChanged(const char * aCommandName)
|
||||
#pragma mark -
|
||||
#endif
|
||||
|
||||
/* void addCommandObserver (in nsIObserver aCommandObserver, in wstring aCommandToObserve); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::AddCommandObserver(nsIObserver *aCommandObserver, const char *aCommandToObserve)
|
||||
nsCommandManager::AddCommandObserver(nsIObserver* aCommandObserver,
|
||||
const char* aCommandToObserve)
|
||||
{
|
||||
NS_ENSURE_ARG(aCommandObserver);
|
||||
|
||||
@@ -125,148 +113,153 @@ nsCommandManager::AddCommandObserver(nsIObserver *aCommandObserver, const char *
|
||||
|
||||
// for each command in the table, we make a list of observers for that command
|
||||
ObserverList* commandObservers;
|
||||
if (!mObserversTable.Get(aCommandToObserve, &commandObservers))
|
||||
{
|
||||
if (!mObserversTable.Get(aCommandToObserve, &commandObservers)) {
|
||||
commandObservers = new ObserverList;
|
||||
mObserversTable.Put(aCommandToObserve, commandObservers);
|
||||
}
|
||||
|
||||
// need to check that this command observer hasn't already been registered
|
||||
int32_t existingIndex = commandObservers->IndexOf(aCommandObserver);
|
||||
if (existingIndex == -1)
|
||||
if (existingIndex == -1) {
|
||||
commandObservers->AppendElement(aCommandObserver);
|
||||
else
|
||||
} else {
|
||||
NS_WARNING("Registering command observer twice on the same command");
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void removeCommandObserver (in nsIObserver aCommandObserver, in wstring aCommandObserved); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::RemoveCommandObserver(nsIObserver *aCommandObserver, const char *aCommandObserved)
|
||||
nsCommandManager::RemoveCommandObserver(nsIObserver* aCommandObserver,
|
||||
const char* aCommandObserved)
|
||||
{
|
||||
NS_ENSURE_ARG(aCommandObserver);
|
||||
|
||||
// XXX todo: handle special cases of aCommandToObserve being null, or empty
|
||||
|
||||
ObserverList* commandObservers;
|
||||
if (!mObserversTable.Get(aCommandObserved, &commandObservers))
|
||||
if (!mObserversTable.Get(aCommandObserved, &commandObservers)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
commandObservers->RemoveElement(aCommandObserver);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isCommandSupported(in string aCommandName,
|
||||
in nsIDOMWindow aTargetWindow); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::IsCommandSupported(const char *aCommandName,
|
||||
nsIDOMWindow *aTargetWindow,
|
||||
bool *outCommandSupported)
|
||||
nsCommandManager::IsCommandSupported(const char* aCommandName,
|
||||
nsIDOMWindow* aTargetWindow,
|
||||
bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outCommandSupported);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsCOMPtr<nsIController> controller;
|
||||
GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller));
|
||||
*outCommandSupported = (controller.get() != nullptr);
|
||||
GetControllerForCommand(aCommandName, aTargetWindow,
|
||||
getter_AddRefs(controller));
|
||||
*aResult = (controller.get() != nullptr);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isCommandEnabled(in string aCommandName,
|
||||
in nsIDOMWindow aTargetWindow); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::IsCommandEnabled(const char *aCommandName,
|
||||
nsIDOMWindow *aTargetWindow,
|
||||
bool *outCommandEnabled)
|
||||
nsCommandManager::IsCommandEnabled(const char* aCommandName,
|
||||
nsIDOMWindow* aTargetWindow,
|
||||
bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outCommandEnabled);
|
||||
|
||||
bool commandEnabled = false;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
bool commandEnabled = false;
|
||||
|
||||
nsCOMPtr<nsIController> controller;
|
||||
GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller));
|
||||
if (controller)
|
||||
{
|
||||
GetControllerForCommand(aCommandName, aTargetWindow,
|
||||
getter_AddRefs(controller));
|
||||
if (controller) {
|
||||
controller->IsCommandEnabled(aCommandName, &commandEnabled);
|
||||
}
|
||||
*outCommandEnabled = commandEnabled;
|
||||
*aResult = commandEnabled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getCommandState (in DOMString aCommandName,
|
||||
in nsIDOMWindow aTargetWindow,
|
||||
inout nsICommandParams aCommandParams); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::GetCommandState(const char *aCommandName,
|
||||
nsIDOMWindow *aTargetWindow,
|
||||
nsICommandParams *aCommandParams)
|
||||
nsCommandManager::GetCommandState(const char* aCommandName,
|
||||
nsIDOMWindow* aTargetWindow,
|
||||
nsICommandParams* aCommandParams)
|
||||
{
|
||||
nsCOMPtr<nsIController> controller;
|
||||
nsAutoString tValue;
|
||||
nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller));
|
||||
if (!controller)
|
||||
nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow,
|
||||
getter_AddRefs(controller));
|
||||
if (!controller) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICommandController> commandController = do_QueryInterface(controller);
|
||||
if (commandController)
|
||||
rv = commandController->GetCommandStateWithParams(aCommandName, aCommandParams);
|
||||
else
|
||||
nsCOMPtr<nsICommandController> commandController =
|
||||
do_QueryInterface(controller);
|
||||
if (commandController) {
|
||||
rv = commandController->GetCommandStateWithParams(aCommandName,
|
||||
aCommandParams);
|
||||
} else {
|
||||
rv = NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void doCommand(in string aCommandName,
|
||||
in nsICommandParams aCommandParams,
|
||||
in nsIDOMWindow aTargetWindow); */
|
||||
NS_IMETHODIMP
|
||||
nsCommandManager::DoCommand(const char *aCommandName,
|
||||
nsICommandParams *aCommandParams,
|
||||
nsIDOMWindow *aTargetWindow)
|
||||
nsCommandManager::DoCommand(const char* aCommandName,
|
||||
nsICommandParams* aCommandParams,
|
||||
nsIDOMWindow* aTargetWindow)
|
||||
{
|
||||
nsCOMPtr<nsIController> controller;
|
||||
nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow, getter_AddRefs(controller));
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv = GetControllerForCommand(aCommandName, aTargetWindow,
|
||||
getter_AddRefs(controller));
|
||||
if (!controller) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICommandController> commandController = do_QueryInterface(controller);
|
||||
if (commandController && aCommandParams)
|
||||
nsCOMPtr<nsICommandController> commandController =
|
||||
do_QueryInterface(controller);
|
||||
if (commandController && aCommandParams) {
|
||||
rv = commandController->DoCommandWithParams(aCommandName, aCommandParams);
|
||||
else
|
||||
} else {
|
||||
rv = controller->DoCommand(aCommandName);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCommandManager::GetControllerForCommand(const char *aCommand,
|
||||
nsIDOMWindow *aTargetWindow,
|
||||
nsIController** outController)
|
||||
nsCommandManager::GetControllerForCommand(const char* aCommand,
|
||||
nsIDOMWindow* aTargetWindow,
|
||||
nsIController** aResult)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
*outController = nullptr;
|
||||
*aResult = nullptr;
|
||||
|
||||
// check if we're in content or chrome
|
||||
// if we're not chrome we must have a target window or we bail
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
if (!aTargetWindow)
|
||||
if (!aTargetWindow) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// if a target window is specified, it must be the window we expect
|
||||
if (aTargetWindow != mWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (aTargetWindow != mWindow) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (aTargetWindow) {
|
||||
// get the controller for this particular window
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
rv = aTargetWindow->GetControllers(getter_AddRefs(controllers));
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
if (!controllers)
|
||||
}
|
||||
if (!controllers) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// dispatch the command
|
||||
return controllers->GetControllerForCommand(aCommand, outController);
|
||||
return controllers->GetControllerForCommand(aCommand, aResult);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mWindow));
|
||||
@@ -275,6 +268,5 @@ nsCommandManager::GetControllerForCommand(const char *aCommand,
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
|
||||
|
||||
// no target window; send command to focus controller
|
||||
return root->GetControllerForCommand(aCommand, outController);
|
||||
return root->GetControllerForCommand(aCommand, aResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef nsCommandManager_h__
|
||||
#define nsCommandManager_h__
|
||||
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsWeakReference.h"
|
||||
@@ -18,41 +17,33 @@
|
||||
class nsIController;
|
||||
template<class E> class nsCOMArray;
|
||||
|
||||
|
||||
class nsCommandManager : public nsICommandManager,
|
||||
public nsPICommandUpdater,
|
||||
public nsSupportsWeakReference
|
||||
|
||||
class nsCommandManager
|
||||
: public nsICommandManager
|
||||
, public nsPICommandUpdater
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
typedef nsTArray<nsCOMPtr<nsIObserver> > ObserverList;
|
||||
|
||||
nsCommandManager();
|
||||
nsCommandManager();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsCommandManager, nsICommandManager)
|
||||
|
||||
// nsICommandManager
|
||||
|
||||
NS_DECL_NSICOMMANDMANAGER
|
||||
|
||||
// nsPICommandUpdater
|
||||
NS_DECL_NSPICOMMANDUPDATER
|
||||
|
||||
|
||||
protected:
|
||||
virtual ~nsCommandManager();
|
||||
|
||||
nsresult GetControllerForCommand(const char * aCommand,
|
||||
nsIDOMWindow *aDirectedToThisWindow,
|
||||
nsIController** outController);
|
||||
virtual ~nsCommandManager();
|
||||
|
||||
nsresult GetControllerForCommand(const char* aCommand,
|
||||
nsIDOMWindow* aDirectedToThisWindow,
|
||||
nsIController** aResult);
|
||||
|
||||
protected:
|
||||
nsClassHashtable<nsCharPtrHashKey, ObserverList> mObserversTable;
|
||||
|
||||
nsIDOMWindow* mWindow; // weak ptr. The window should always outlive us
|
||||
nsIDOMWindow* mWindow; // weak ptr. The window should always outlive us
|
||||
};
|
||||
|
||||
|
||||
#endif // nsCommandManager_h__
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "xpcom-config.h"
|
||||
#include <new> // for placement new
|
||||
#include <new>
|
||||
#include "nscore.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
@@ -132,116 +132,113 @@ nsCommandParams::GetISupportsValue(const char* aName, nsISupports** aRetVal)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetBooleanValue(const char* aName, bool value)
|
||||
nsCommandParams::SetBooleanValue(const char* aName, bool aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eBooleanType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mData.mBoolean = value;
|
||||
foundEntry->mData.mBoolean = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetLongValue(const char* aName, int32_t value)
|
||||
nsCommandParams::SetLongValue(const char* aName, int32_t aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eLongType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mData.mLong = value;
|
||||
foundEntry->mData.mLong = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetDoubleValue(const char* aName, double value)
|
||||
nsCommandParams::SetDoubleValue(const char* aName, double aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eDoubleType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mData.mDouble = value;
|
||||
foundEntry->mData.mDouble = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetStringValue(const char* aName, const nsAString& value)
|
||||
nsCommandParams::SetStringValue(const char* aName, const nsAString& aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eWStringType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mData.mString = new nsString(value);
|
||||
foundEntry->mData.mString = new nsString(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetCStringValue(const char* aName, const char* value)
|
||||
nsCommandParams::SetCStringValue(const char* aName, const char* aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eStringType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mData.mCString = new nsCString(value);
|
||||
foundEntry->mData.mCString = new nsCString(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::SetISupportsValue(const char* aName, nsISupports* value)
|
||||
nsCommandParams::SetISupportsValue(const char* aName, nsISupports* aValue)
|
||||
{
|
||||
HashEntry* foundEntry = GetOrMakeEntry(aName, eISupportsType);
|
||||
if (!foundEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
foundEntry->mISupports = value; // addrefs
|
||||
foundEntry->mISupports = aValue; // addrefs
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandParams::RemoveValue(const char* aName)
|
||||
{
|
||||
// PL_DHashTableRemove doesn't tell us if the entry was really removed, so we
|
||||
// return NS_OK unconditionally.
|
||||
(void)PL_DHashTableRemove(&mValuesHash, (void *)aName);
|
||||
PL_DHashTableRemove(&mValuesHash, (void*)aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCommandParams::HashEntry*
|
||||
nsCommandParams::GetNamedEntry(const char* aName)
|
||||
{
|
||||
return (HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
|
||||
return static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
|
||||
}
|
||||
|
||||
nsCommandParams::HashEntry*
|
||||
nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t entryType)
|
||||
nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType)
|
||||
{
|
||||
HashEntry *foundEntry =
|
||||
(HashEntry *)PL_DHashTableSearch(&mValuesHash, (void *)aName);
|
||||
auto foundEntry = static_cast<HashEntry*>(mValuesHash.Search((void*)aName));
|
||||
if (foundEntry) { // reuse existing entry
|
||||
foundEntry->Reset(entryType);
|
||||
foundEntry->Reset(aEntryType);
|
||||
return foundEntry;
|
||||
}
|
||||
|
||||
foundEntry = static_cast<HashEntry*>
|
||||
(PL_DHashTableAdd(&mValuesHash, (void *)aName, fallible));
|
||||
foundEntry = static_cast<HashEntry*>(
|
||||
PL_DHashTableAdd(&mValuesHash, (void*)aName, fallible));
|
||||
if (!foundEntry) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Use placement new. Our ctor does not clobber keyHash, which is important.
|
||||
new (foundEntry) HashEntry(entryType, aName);
|
||||
new (foundEntry) HashEntry(aEntryType, aName);
|
||||
return foundEntry;
|
||||
}
|
||||
|
||||
PLDHashNumber
|
||||
nsCommandParams::HashKey(PLDHashTable *aTable, const void *aKey)
|
||||
nsCommandParams::HashKey(PLDHashTable* aTable, const void* aKey)
|
||||
{
|
||||
return HashString((const char *)aKey);
|
||||
return HashString((const char*)aKey);
|
||||
}
|
||||
|
||||
bool
|
||||
nsCommandParams::HashMatchEntry(PLDHashTable *aTable,
|
||||
const PLDHashEntryHdr *aEntry, const void *aKey)
|
||||
nsCommandParams::HashMatchEntry(PLDHashTable* aTable,
|
||||
const PLDHashEntryHdr* aEntry, const void* aKey)
|
||||
{
|
||||
const char* keyString = (const char*)aKey;
|
||||
const HashEntry* thisEntry = static_cast<const HashEntry*>(aEntry);
|
||||
@@ -249,22 +246,21 @@ nsCommandParams::HashMatchEntry(PLDHashTable *aTable,
|
||||
}
|
||||
|
||||
void
|
||||
nsCommandParams::HashMoveEntry(PLDHashTable *aTable,
|
||||
const PLDHashEntryHdr *aFrom,
|
||||
PLDHashEntryHdr *aTo)
|
||||
nsCommandParams::HashMoveEntry(PLDHashTable* aTable,
|
||||
const PLDHashEntryHdr* aFrom,
|
||||
PLDHashEntryHdr* aTo)
|
||||
{
|
||||
const HashEntry* fromEntry = static_cast<const HashEntry*>(aFrom);
|
||||
HashEntry* toEntry = static_cast<HashEntry*>(aTo);
|
||||
|
||||
new (toEntry) HashEntry(*fromEntry);
|
||||
|
||||
fromEntry->~HashEntry(); // call dtor explicitly
|
||||
fromEntry->~HashEntry();
|
||||
}
|
||||
|
||||
void
|
||||
nsCommandParams::HashClearEntry(PLDHashTable *aTable, PLDHashEntryHdr *aEntry)
|
||||
nsCommandParams::HashClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
HashEntry* thisEntry = static_cast<HashEntry*>(aEntry);
|
||||
thisEntry->~HashEntry(); // call dtor explicitly
|
||||
thisEntry->~HashEntry();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ protected:
|
||||
uint8_t mEntryType;
|
||||
union
|
||||
{
|
||||
bool mBoolean;
|
||||
int32_t mLong;
|
||||
double mDouble;
|
||||
nsString* mString;
|
||||
nsCString* mCString;
|
||||
bool mBoolean;
|
||||
int32_t mLong;
|
||||
double mDouble;
|
||||
nsString* mString;
|
||||
nsCString* mCString;
|
||||
} mData;
|
||||
|
||||
nsCOMPtr<nsISupports> mISupports;
|
||||
@@ -69,17 +69,14 @@ protected:
|
||||
mData.mCString = new nsCString(*aRHS.mData.mCString);
|
||||
break;
|
||||
case eISupportsType:
|
||||
mISupports = aRHS.mISupports.get(); // additional addref
|
||||
mISupports = aRHS.mISupports.get();
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown type");
|
||||
}
|
||||
}
|
||||
|
||||
~HashEntry()
|
||||
{
|
||||
Reset(eNoType);
|
||||
}
|
||||
~HashEntry() { Reset(eNoType); }
|
||||
|
||||
void Reset(uint8_t aNewType)
|
||||
{
|
||||
@@ -100,7 +97,7 @@ protected:
|
||||
mData.mString = nullptr;
|
||||
break;
|
||||
case eISupportsType:
|
||||
mISupports = nullptr; // clear the nsCOMPtr
|
||||
mISupports = nullptr;
|
||||
break;
|
||||
case eStringType:
|
||||
delete mData.mCString;
|
||||
@@ -120,7 +117,7 @@ protected:
|
||||
static PLDHashNumber HashKey(PLDHashTable* aTable, const void* aKey);
|
||||
|
||||
static bool HashMatchEntry(PLDHashTable* aTable,
|
||||
const PLDHashEntryHdr *aEntry, const void* aKey);
|
||||
const PLDHashEntryHdr* aEntry, const void* aKey);
|
||||
|
||||
static void HashMoveEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom,
|
||||
PLDHashEntryHdr* aTo);
|
||||
|
||||
@@ -7,27 +7,23 @@
|
||||
#include "nsIControllerCommand.h"
|
||||
#include "nsControllerCommandTable.h"
|
||||
|
||||
// prototype;
|
||||
nsresult
|
||||
NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
|
||||
|
||||
nsresult NS_NewControllerCommandTable(nsIControllerCommandTable** aResult);
|
||||
|
||||
// this value is used to size the hash table. Just a sensible upper bound
|
||||
#define NUM_COMMANDS_LENGTH 32
|
||||
|
||||
#define NUM_COMMANDS_LENGTH 32
|
||||
|
||||
nsControllerCommandTable::nsControllerCommandTable()
|
||||
: mCommandsTable(NUM_COMMANDS_LENGTH)
|
||||
, mMutable(true)
|
||||
: mCommandsTable(NUM_COMMANDS_LENGTH)
|
||||
, mMutable(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
nsControllerCommandTable::~nsControllerCommandTable()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsControllerCommandTable, nsIControllerCommandTable, nsISupportsWeakReference)
|
||||
NS_IMPL_ISUPPORTS(nsControllerCommandTable, nsIControllerCommandTable,
|
||||
nsISupportsWeakReference)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::MakeImmutable(void)
|
||||
@@ -37,7 +33,8 @@ nsControllerCommandTable::MakeImmutable(void)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::RegisterCommand(const char * aCommandName, nsIControllerCommand *aCommand)
|
||||
nsControllerCommandTable::RegisterCommand(const char* aCommandName,
|
||||
nsIControllerCommand* aCommand)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMutable, NS_ERROR_FAILURE);
|
||||
|
||||
@@ -46,14 +43,13 @@ nsControllerCommandTable::RegisterCommand(const char * aCommandName, nsIControll
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::UnregisterCommand(const char * aCommandName, nsIControllerCommand *aCommand)
|
||||
nsControllerCommandTable::UnregisterCommand(const char* aCommandName,
|
||||
nsIControllerCommand* aCommand)
|
||||
{
|
||||
NS_ENSURE_TRUE(mMutable, NS_ERROR_FAILURE);
|
||||
|
||||
nsDependentCString commandKey(aCommandName);
|
||||
|
||||
if (!mCommandsTable.Get(commandKey, nullptr)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -62,66 +58,65 @@ nsControllerCommandTable::UnregisterCommand(const char * aCommandName, nsIContro
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::FindCommandHandler(const char * aCommandName, nsIControllerCommand **outCommand)
|
||||
nsControllerCommandTable::FindCommandHandler(const char* aCommandName,
|
||||
nsIControllerCommand** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*outCommand = nullptr;
|
||||
*aResult = nullptr;
|
||||
|
||||
nsCOMPtr<nsIControllerCommand> foundCommand;
|
||||
mCommandsTable.Get(nsDependentCString(aCommandName), getter_AddRefs(foundCommand));
|
||||
if (!foundCommand) return NS_ERROR_FAILURE;
|
||||
mCommandsTable.Get(nsDependentCString(aCommandName),
|
||||
getter_AddRefs(foundCommand));
|
||||
if (!foundCommand) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
foundCommand.forget(outCommand);
|
||||
foundCommand.forget(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* boolean isCommandEnabled (in wstring command); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, bool *aResult)
|
||||
nsControllerCommandTable::IsCommandEnabled(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon,
|
||||
bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = false;
|
||||
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
NS_WARNING("Controller command table asked about a command that it does not handle -- ");
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
if (!commandHandler) {
|
||||
NS_WARNING("Controller command table asked about a command that it does "
|
||||
"not handle");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon, aResult);
|
||||
return commandHandler->IsCommandEnabled(aCommandName, aCommandRefCon,
|
||||
aResult);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::UpdateCommandState(const char * aCommandName, nsISupports *aCommandRefCon)
|
||||
nsControllerCommandTable::UpdateCommandState(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon)
|
||||
{
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
NS_WARNING("Controller command table asked to update the state of a command that it does not handle -- ");
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
if (!commandHandler) {
|
||||
NS_WARNING("Controller command table asked to update the state of a "
|
||||
"command that it does not handle");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::SupportsCommand(const char * aCommandName, nsISupports *aCommandRefCon, bool *aResult)
|
||||
nsControllerCommandTable::SupportsCommand(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon,
|
||||
bool* aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
@@ -129,7 +124,6 @@ nsControllerCommandTable::SupportsCommand(const char * aCommandName, nsISupports
|
||||
|
||||
*aResult = false;
|
||||
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
|
||||
@@ -137,55 +131,50 @@ nsControllerCommandTable::SupportsCommand(const char * aCommandName, nsISupports
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doCommand (in wstring command); */
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::DoCommand(const char * aCommandName, nsISupports *aCommandRefCon)
|
||||
nsControllerCommandTable::DoCommand(const char* aCommandName,
|
||||
nsISupports* aCommandRefCon)
|
||||
{
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
if (!commandHandler) {
|
||||
NS_WARNING("Controller command table asked to do a command that it does "
|
||||
"not handle");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return commandHandler->DoCommand(aCommandName, aCommandRefCon);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon)
|
||||
nsControllerCommandTable::DoCommandParams(const char* aCommandName,
|
||||
nsICommandParams* aParams,
|
||||
nsISupports* aCommandRefCon)
|
||||
{
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
if (!commandHandler) {
|
||||
NS_WARNING("Controller command table asked to do a command that it does "
|
||||
"not handle");
|
||||
return NS_OK;
|
||||
}
|
||||
return commandHandler->DoCommandParams(aCommandName, aParams, aCommandRefCon);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::GetCommandState(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon)
|
||||
nsControllerCommandTable::GetCommandState(const char* aCommandName,
|
||||
nsICommandParams* aParams,
|
||||
nsISupports* aCommandRefCon)
|
||||
{
|
||||
// find the command
|
||||
nsCOMPtr<nsIControllerCommand> commandHandler;
|
||||
FindCommandHandler(aCommandName, getter_AddRefs(commandHandler));
|
||||
if (!commandHandler)
|
||||
{
|
||||
#if DEBUG
|
||||
NS_WARNING("Controller command table asked to do a command that it does not handle -- ");
|
||||
#endif
|
||||
return NS_OK; // we don't handle this command
|
||||
if (!commandHandler) {
|
||||
NS_WARNING("Controller command table asked to do a command that it does "
|
||||
"not handle");
|
||||
return NS_OK;
|
||||
}
|
||||
return commandHandler->GetCommandStateParams(aCommandName, aParams, aCommandRefCon);
|
||||
return commandHandler->GetCommandStateParams(aCommandName, aParams,
|
||||
aCommandRefCon);
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
@@ -205,7 +194,7 @@ nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
|
||||
char*** aCommands)
|
||||
{
|
||||
char** commands =
|
||||
static_cast<char **>(NS_Alloc(sizeof(char *) * mCommandsTable.Count()));
|
||||
static_cast<char**>(NS_Alloc(sizeof(char*) * mCommandsTable.Count()));
|
||||
*aCount = mCommandsTable.Count();
|
||||
*aCommands = commands;
|
||||
|
||||
@@ -217,13 +206,11 @@ nsresult
|
||||
NS_NewControllerCommandTable(nsIControllerCommandTable** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nullptr, "null ptr");
|
||||
if (! aResult)
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsControllerCommandTable* newCommandTable = new nsControllerCommandTable();
|
||||
if (! newCommandTable)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(newCommandTable);
|
||||
*aResult = newCommandTable;
|
||||
return NS_OK;
|
||||
|
||||
@@ -6,27 +6,24 @@
|
||||
#ifndef nsControllerCommandTable_h_
|
||||
#define nsControllerCommandTable_h_
|
||||
|
||||
|
||||
#include "nsIControllerCommandTable.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
class nsIControllerCommand;
|
||||
|
||||
class nsControllerCommandTable final : public nsIControllerCommandTable,
|
||||
public nsSupportsWeakReference
|
||||
class nsControllerCommandTable final
|
||||
: public nsIControllerCommandTable
|
||||
, public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
|
||||
nsControllerCommandTable();
|
||||
nsControllerCommandTable();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSICONTROLLERCOMMANDTABLE
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~nsControllerCommandTable();
|
||||
virtual ~nsControllerCommandTable();
|
||||
|
||||
// Hash table of nsIControllerCommands, keyed by command name.
|
||||
nsInterfaceHashtable<nsCStringHashKey, nsIControllerCommand> mCommandsTable;
|
||||
@@ -35,5 +32,4 @@ protected:
|
||||
bool mMutable;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsControllerCommandTable_h_
|
||||
|
||||
@@ -157,7 +157,7 @@ ElementHasActiveStyle(dom::Element* aElement)
|
||||
}
|
||||
nsStyleSet* styleSet = pc->StyleSet();
|
||||
for (dom::Element* e = aElement; e; e = e->GetParentElement()) {
|
||||
if (styleSet->HasStateDependentStyle(pc, e, NS_EVENT_STATE_ACTIVE)) {
|
||||
if (styleSet->HasStateDependentStyle(e, NS_EVENT_STATE_ACTIVE)) {
|
||||
AEM_LOG("Element %p's style is dependent on the active state\n", e);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -711,9 +711,7 @@ public:
|
||||
GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList,
|
||||
uint32_t *aTimestamp, uint32_t *aFilesize)
|
||||
{
|
||||
FNCMapEntry *entry =
|
||||
static_cast<FNCMapEntry*>(PL_DHashTableSearch(&mMap,
|
||||
aFileName.get()));
|
||||
auto entry = static_cast<FNCMapEntry*>(mMap.Search(aFileName.get()));
|
||||
if (entry) {
|
||||
*aTimestamp = entry->mTimestamp;
|
||||
*aFilesize = entry->mFilesize;
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
inline XPCWrappedNative* Find(nsISupports* Obj)
|
||||
{
|
||||
NS_PRECONDITION(Obj,"bad param");
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, Obj);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(Obj));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
|
||||
inline nsXPCWrappedJSClass* Find(REFNSIID iid)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(&iid));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public:
|
||||
|
||||
inline XPCNativeInterface* Find(REFNSIID iid)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(&iid));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
|
||||
inline XPCNativeSet* Find(nsIClassInfo* info)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(info));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public:
|
||||
|
||||
inline XPCWrappedNativeProto* Find(nsIClassInfo* info)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, info);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(info));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
|
||||
inline XPCNativeSet* Find(XPCNativeSetKey* key)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, key);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(key));
|
||||
return entry ? entry->key_value : nullptr;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public:
|
||||
|
||||
inline nsIXPCFunctionThisTranslator* Find(REFNSIID iid)
|
||||
{
|
||||
Entry* entry = (Entry*) PL_DHashTableSearch(mTable, &iid);
|
||||
auto entry = static_cast<Entry*>(mTable->Search(&iid));
|
||||
return entry ? entry->value : nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1095,16 +1095,14 @@ RestyleManager::ContentStateChanged(nsIContent* aContent,
|
||||
nsRestyleHint rshint;
|
||||
|
||||
if (pseudoType >= nsCSSPseudoElements::ePseudo_PseudoElementCount) {
|
||||
rshint = styleSet->HasStateDependentStyle(mPresContext, aElement,
|
||||
aStateMask);
|
||||
rshint = styleSet->HasStateDependentStyle(aElement, aStateMask);
|
||||
} else if (nsCSSPseudoElements::PseudoElementSupportsUserActionState(
|
||||
pseudoType)) {
|
||||
// If aElement is a pseudo-element, we want to check to see whether there
|
||||
// are any state-dependent rules applying to that pseudo.
|
||||
Element* ancestor = ElementForStyleContext(nullptr, primaryFrame,
|
||||
pseudoType);
|
||||
rshint = styleSet->HasStateDependentStyle(mPresContext, ancestor,
|
||||
pseudoType, aElement,
|
||||
rshint = styleSet->HasStateDependentStyle(ancestor, pseudoType, aElement,
|
||||
aStateMask);
|
||||
} else {
|
||||
rshint = nsRestyleHint(0);
|
||||
@@ -1130,14 +1128,15 @@ void
|
||||
RestyleManager::AttributeWillChange(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
nsRestyleHint rshint =
|
||||
mPresContext->StyleSet()->HasAttributeDependentStyle(mPresContext,
|
||||
aElement,
|
||||
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
|
||||
aAttribute,
|
||||
aModType,
|
||||
false);
|
||||
false,
|
||||
aNewValue);
|
||||
PostRestyleEvent(aElement, rshint, NS_STYLE_HINT_NONE);
|
||||
}
|
||||
|
||||
@@ -1147,7 +1146,8 @@ void
|
||||
RestyleManager::AttributeChanged(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
// Hold onto the PresShell to prevent ourselves from being destroyed.
|
||||
// XXXbz how, exactly, would this attribute change cause us to be
|
||||
@@ -1221,11 +1221,11 @@ RestyleManager::AttributeChanged(Element* aElement,
|
||||
// See if we can optimize away the style re-resolution -- must be called after
|
||||
// the frame's AttributeChanged() in case it does something that affects the style
|
||||
nsRestyleHint rshint =
|
||||
mPresContext->StyleSet()->HasAttributeDependentStyle(mPresContext,
|
||||
aElement,
|
||||
mPresContext->StyleSet()->HasAttributeDependentStyle(aElement,
|
||||
aAttribute,
|
||||
aModType,
|
||||
true);
|
||||
true,
|
||||
aOldValue);
|
||||
|
||||
PostRestyleEvent(aElement, rshint, hint);
|
||||
}
|
||||
|
||||
@@ -79,13 +79,15 @@ public:
|
||||
void AttributeWillChange(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType);
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue);
|
||||
// Forwarded nsIMutationObserver method, to handle restyling (and
|
||||
// passing the notification to the frame).
|
||||
void AttributeChanged(Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType);
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue);
|
||||
|
||||
// Get an integer that increments every time there is a style change
|
||||
// as a result of a change to the :hover content state.
|
||||
|
||||
@@ -164,9 +164,8 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
|
||||
{
|
||||
NS_PRECONDITION(aFrame, "null param unexpected");
|
||||
|
||||
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
||||
(PL_DHashTableSearch(const_cast<PLDHashTable*>(&mPlaceholderMap),
|
||||
aFrame));
|
||||
auto entry = static_cast<PlaceholderMapEntry*>
|
||||
(const_cast<PLDHashTable*>(&mPlaceholderMap)->Search(aFrame));
|
||||
if (entry) {
|
||||
return entry->placeholderFrame;
|
||||
}
|
||||
|
||||
@@ -1917,7 +1917,7 @@ nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
|
||||
mPendingMediaFeatureValuesChanged = false;
|
||||
|
||||
// MediumFeaturesChanged updates the applied rules, so it always gets called.
|
||||
if (mShell && mShell->StyleSet()->MediumFeaturesChanged(this)) {
|
||||
if (mShell && mShell->StyleSet()->MediumFeaturesChanged()) {
|
||||
aRestyleHint |= eRestyle_Subtree;
|
||||
}
|
||||
|
||||
@@ -2133,7 +2133,7 @@ nsPresContext::FlushUserFontSet()
|
||||
if (mFontFaceSetDirty) {
|
||||
if (gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) {
|
||||
nsTArray<nsFontFaceRuleContainer> rules;
|
||||
if (!mShell->StyleSet()->AppendFontFaceRules(this, rules)) {
|
||||
if (!mShell->StyleSet()->AppendFontFaceRules(rules)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1225,7 +1225,7 @@ PresShell::Destroy()
|
||||
mViewManager = nullptr;
|
||||
}
|
||||
|
||||
mStyleSet->BeginShutdown(mPresContext);
|
||||
mStyleSet->BeginShutdown();
|
||||
nsRefreshDriver* rd = GetPresContext()->RefreshDriver();
|
||||
|
||||
// This shell must be removed from the document before the frame
|
||||
@@ -1283,7 +1283,7 @@ PresShell::Destroy()
|
||||
}
|
||||
|
||||
// Let the style set do its cleanup.
|
||||
mStyleSet->Shutdown(mPresContext);
|
||||
mStyleSet->Shutdown();
|
||||
|
||||
if (mPresContext) {
|
||||
// We hold a reference to the pres context, and it holds a weak link back
|
||||
@@ -4151,8 +4151,7 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument,
|
||||
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
|
||||
|
||||
if (mDidInitialize &&
|
||||
mStyleSet->HasDocumentStateDependentStyle(mPresContext,
|
||||
mDocument->GetRootElement(),
|
||||
mStyleSet->HasDocumentStateDependentStyle(mDocument->GetRootElement(),
|
||||
aStateMask)) {
|
||||
mPresContext->RestyleManager()->PostRestyleEvent(mDocument->GetRootElement(),
|
||||
eRestyle_Subtree,
|
||||
@@ -4173,7 +4172,8 @@ PresShell::AttributeWillChange(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aNewValue)
|
||||
{
|
||||
NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeWillChange");
|
||||
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
|
||||
@@ -4184,7 +4184,8 @@ PresShell::AttributeWillChange(nsIDocument* aDocument,
|
||||
if (mDidInitialize) {
|
||||
nsAutoCauseReflowNotifier crNotifier(this);
|
||||
mPresContext->RestyleManager()->AttributeWillChange(aElement, aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
aAttribute, aModType,
|
||||
aNewValue);
|
||||
VERIFY_STYLE_TREE;
|
||||
}
|
||||
}
|
||||
@@ -4194,7 +4195,8 @@ PresShell::AttributeChanged(nsIDocument* aDocument,
|
||||
Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
NS_PRECONDITION(!mIsDocumentGone, "Unexpected AttributeChanged");
|
||||
NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
|
||||
@@ -4205,7 +4207,8 @@ PresShell::AttributeChanged(nsIDocument* aDocument,
|
||||
if (mDidInitialize) {
|
||||
nsAutoCauseReflowNotifier crNotifier(this);
|
||||
mPresContext->RestyleManager()->AttributeChanged(aElement, aNameSpaceID,
|
||||
aAttribute, aModType);
|
||||
aAttribute, aModType,
|
||||
aOldValue);
|
||||
VERIFY_STYLE_TREE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus) override;
|
||||
|
||||
bool GetVisibility() { return mVisibility || mVisibilityOverride; }
|
||||
bool GetVisibility() { return mVisibility; }
|
||||
void SetVisibility(bool aVisibility);
|
||||
void SetColor(nscolor aColor);
|
||||
|
||||
@@ -129,7 +129,6 @@ protected:
|
||||
int32_t mWidth;
|
||||
bool mVertical;
|
||||
bool mVisibility;
|
||||
bool mVisibilityOverride;
|
||||
bool mCanResize;
|
||||
friend class nsHTMLFramesetFrame;
|
||||
};
|
||||
@@ -173,7 +172,6 @@ protected:
|
||||
* nsHTMLFramesetFrame
|
||||
******************************************************************************/
|
||||
bool nsHTMLFramesetFrame::gDragInProgress = false;
|
||||
#define kFrameResizePref "layout.frames.force_resizability"
|
||||
#define DEFAULT_BORDER_WIDTH_PX 6
|
||||
|
||||
nsHTMLFramesetFrame::nsHTMLFramesetFrame(nsStyleContext* aContext)
|
||||
@@ -199,7 +197,6 @@ nsHTMLFramesetFrame::nsHTMLFramesetFrame(nsStyleContext* aContext)
|
||||
mHorBorders = nullptr;
|
||||
mChildFrameborder = nullptr;
|
||||
mChildBorderColors = nullptr;
|
||||
mForceFrameResizability = false;
|
||||
}
|
||||
|
||||
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
||||
@@ -210,43 +207,12 @@ nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
||||
delete[] mHorBorders;
|
||||
delete[] mChildFrameborder;
|
||||
delete[] mChildBorderColors;
|
||||
|
||||
Preferences::UnregisterCallback(FrameResizePrefCallback,
|
||||
kFrameResizePref, this);
|
||||
}
|
||||
|
||||
NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsHTMLFramesetFrame)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
||||
|
||||
// static
|
||||
void
|
||||
nsHTMLFramesetFrame::FrameResizePrefCallback(const char* aPref, void* aClosure)
|
||||
{
|
||||
nsHTMLFramesetFrame *frame =
|
||||
reinterpret_cast<nsHTMLFramesetFrame *>(aClosure);
|
||||
|
||||
nsIDocument* doc = frame->mContent->GetComposedDoc();
|
||||
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
|
||||
if (doc) {
|
||||
nsNodeUtils::AttributeWillChange(frame->GetContent()->AsElement(),
|
||||
kNameSpaceID_None,
|
||||
nsGkAtoms::frameborder,
|
||||
nsIDOMMutationEvent::MODIFICATION);
|
||||
}
|
||||
|
||||
frame->mForceFrameResizability =
|
||||
Preferences::GetBool(kFrameResizePref, frame->mForceFrameResizability);
|
||||
|
||||
frame->RecalculateBorderResize();
|
||||
if (doc) {
|
||||
nsNodeUtils::AttributeChanged(frame->GetContent()->AsElement(),
|
||||
kNameSpaceID_None,
|
||||
nsGkAtoms::frameborder,
|
||||
nsIDOMMutationEvent::MODIFICATION);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLFramesetFrame::Init(nsIContent* aContent,
|
||||
nsContainerFrame* aParent,
|
||||
@@ -584,13 +550,9 @@ void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
|
||||
int32_t nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
|
||||
bool aTakeForcingIntoAccount)
|
||||
{
|
||||
bool forcing = mForceFrameResizability && aTakeForcingIntoAccount;
|
||||
|
||||
if (!forcing) {
|
||||
nsFrameborder frameborder = GetFrameBorder();
|
||||
if (frameborder == eFrameborder_No) {
|
||||
return 0;
|
||||
}
|
||||
nsFrameborder frameborder = GetFrameBorder();
|
||||
if (frameborder == eFrameborder_No) {
|
||||
return 0;
|
||||
}
|
||||
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
||||
|
||||
@@ -605,15 +567,11 @@ int32_t nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
|
||||
}
|
||||
}
|
||||
|
||||
if (forcing && intVal == 0) {
|
||||
intVal = DEFAULT_BORDER_WIDTH_PX;
|
||||
}
|
||||
return nsPresContext::CSSPixelsToAppUnits(intVal);
|
||||
}
|
||||
}
|
||||
|
||||
if (mParentBorderWidth > 0 ||
|
||||
(mParentBorderWidth == 0 && !forcing)) {
|
||||
if (mParentBorderWidth >= 0) {
|
||||
return mParentBorderWidth;
|
||||
}
|
||||
|
||||
@@ -880,12 +838,6 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
||||
MOZ_ASSERT(!mChildFrameborder == !mChildBorderColors);
|
||||
bool firstTime = !!mChildFrameborder;
|
||||
|
||||
if (firstTime) {
|
||||
Preferences::RegisterCallback(FrameResizePrefCallback,
|
||||
kFrameResizePref, this);
|
||||
mForceFrameResizability = Preferences::GetBool(kFrameResizePref);
|
||||
}
|
||||
|
||||
// subtract out the width of all of the potential borders. There are
|
||||
// only borders between <frame>s. There are none on the edges (e.g the
|
||||
// leftmost <frame> has no left border).
|
||||
@@ -1121,11 +1073,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
||||
for (int verX = 0; verX < mNumCols-1; verX++) {
|
||||
if (mVerBorders[verX]) {
|
||||
mVerBorders[verX]->SetVisibility(verBordersVis[verX]);
|
||||
if (mForceFrameResizability) {
|
||||
mVerBorders[verX]->mVisibilityOverride = true;
|
||||
} else {
|
||||
SetBorderResize(mVerBorders[verX]);
|
||||
}
|
||||
SetBorderResize(mVerBorders[verX]);
|
||||
childColor = (NO_COLOR == verBorderColors[verX]) ? borderColor : verBorderColors[verX];
|
||||
mVerBorders[verX]->SetColor(childColor);
|
||||
}
|
||||
@@ -1133,11 +1081,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
||||
for (int horX = 0; horX < mNumRows-1; horX++) {
|
||||
if (mHorBorders[horX]) {
|
||||
mHorBorders[horX]->SetVisibility(horBordersVis[horX]);
|
||||
if (mForceFrameResizability) {
|
||||
mHorBorders[horX]->mVisibilityOverride = true;
|
||||
} else {
|
||||
SetBorderResize(mHorBorders[horX]);
|
||||
}
|
||||
SetBorderResize(mHorBorders[horX]);
|
||||
childColor = (NO_COLOR == horBorderColors[horX]) ? borderColor : horBorderColors[horX];
|
||||
mHorBorders[horX]->SetColor(childColor);
|
||||
}
|
||||
@@ -1238,24 +1182,14 @@ nsHTMLFramesetFrame::RecalculateBorderResize()
|
||||
for (verX = 0; verX < mNumCols-1; verX++) {
|
||||
if (mVerBorders[verX]) {
|
||||
mVerBorders[verX]->mCanResize = true;
|
||||
if (mForceFrameResizability) {
|
||||
mVerBorders[verX]->mVisibilityOverride = true;
|
||||
} else {
|
||||
mVerBorders[verX]->mVisibilityOverride = false;
|
||||
SetBorderResize(mVerBorders[verX]);
|
||||
}
|
||||
SetBorderResize(mVerBorders[verX]);
|
||||
}
|
||||
}
|
||||
int32_t horX;
|
||||
for (horX = 0; horX < mNumRows-1; horX++) {
|
||||
if (mHorBorders[horX]) {
|
||||
mHorBorders[horX]->mCanResize = true;
|
||||
if (mForceFrameResizability) {
|
||||
mHorBorders[horX]->mVisibilityOverride = true;
|
||||
} else {
|
||||
mHorBorders[horX]->mVisibilityOverride = false;
|
||||
SetBorderResize(mHorBorders[horX]);
|
||||
}
|
||||
SetBorderResize(mHorBorders[horX]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1416,7 +1350,6 @@ nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(nsStyleContext* aContext,
|
||||
bool aVisibility)
|
||||
: nsLeafFrame(aContext), mWidth(aWidth), mVertical(aVertical), mVisibility(aVisibility)
|
||||
{
|
||||
mVisibilityOverride = false;
|
||||
mCanResize = true;
|
||||
mColor = NO_COLOR;
|
||||
mPrevNeighbor = 0;
|
||||
@@ -1537,7 +1470,7 @@ void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
|
||||
NS_RGB(128, 128, 128))));
|
||||
|
||||
ColorPattern color(ToDeviceColor(NS_RGB(255, 255, 255))); // default to white
|
||||
if (mVisibility || mVisibilityOverride) {
|
||||
if (mVisibility) {
|
||||
color = (NO_COLOR == mColor) ? bgColor :
|
||||
ColorPattern(ToDeviceColor(mColor));
|
||||
}
|
||||
@@ -1566,7 +1499,7 @@ void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
|
||||
}
|
||||
}
|
||||
|
||||
if (!mVisibility && !mVisibilityOverride)
|
||||
if (!mVisibility)
|
||||
return;
|
||||
|
||||
if (widthInPixels >= 5) {
|
||||
|
||||
@@ -187,8 +187,6 @@ protected:
|
||||
|
||||
void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame);
|
||||
|
||||
static void FrameResizePrefCallback(const char* aPref, void* aClosure);
|
||||
|
||||
nsFramesetDrag mDrag;
|
||||
nsBorderColor mEdgeColors;
|
||||
nsHTMLFramesetBorderFrame* mDragger;
|
||||
@@ -212,7 +210,6 @@ protected:
|
||||
int32_t mNextNeighborOrigSize;
|
||||
int32_t mMinDrag;
|
||||
int32_t mChildCount;
|
||||
bool mForceFrameResizability;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -918,7 +918,8 @@ nsImageMap::AttributeChanged(nsIDocument* aDocument,
|
||||
dom::Element* aElement,
|
||||
int32_t aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
// If the parent of the changing content node is our map then update
|
||||
// the map. But only do this if the node is an HTML <area> or <a>
|
||||
|
||||
@@ -343,7 +343,7 @@ private:
|
||||
uint32_t count = GetChildCount();
|
||||
mFlags.mHasHashedFrames = 1;
|
||||
uint32_t minLength = std::max(kMinChildCountForHashtable,
|
||||
uint32_t(PL_DHASH_DEFAULT_INITIAL_LENGTH));
|
||||
uint32_t(PLDHashTable::kDefaultInitialLength));
|
||||
mFrames = new nsTHashtable< nsPtrHashKey<nsIFrame> >(std::max(count, minLength));
|
||||
for (nsIFrame* f = mFirstChild; count-- > 0; f = f->GetNextSibling()) {
|
||||
mFrames->PutEntry(f);
|
||||
|
||||
@@ -632,7 +632,8 @@ inDOMView::NodeWillBeDestroyed(const nsINode* aNode)
|
||||
void
|
||||
inDOMView::AttributeChanged(nsIDocument* aDocument, dom::Element* aElement,
|
||||
int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
int32_t aModType)
|
||||
int32_t aModType,
|
||||
const nsAttrValue* aOldValue)
|
||||
{
|
||||
if (!mTree) {
|
||||
return;
|
||||
|
||||
@@ -20,16 +20,16 @@ p {
|
||||
</head>
|
||||
<body>
|
||||
<p>default font</p>
|
||||
<p>serif</p>
|
||||
<p>sans-serif</p>
|
||||
<p style="font-family: serif">serif</p>
|
||||
<p style="font-family: sans-serif">sans-serif</p>
|
||||
<p style="font-family: monospace">monospace</p>
|
||||
<p style="font-family: monospace">-moz-fixed</p>
|
||||
<p>unknown, serif</p>
|
||||
<p>unknown, sans-serif</p>
|
||||
<p style="font-family: serif">unknown, serif</p>
|
||||
<p style="font-family: sans-serif">unknown, sans-serif</p>
|
||||
<p style="font-family: monospace">unknown, monospace</p>
|
||||
<p style="font-family: monospace">unknown, -moz-fixed</p>
|
||||
<p>unknown, serif, monospace</p>
|
||||
<p>unknown, sans-serif, -moz-fixed</p>
|
||||
<p style="font-family: serif">unknown, serif, monospace</p>
|
||||
<p style="font-family: sans-serif">unknown, sans-serif, -moz-fixed</p>
|
||||
<p style="font-family: monospace">unknown, monospace, serif</p>
|
||||
<p style="font-family: monospace">unknown, -moz-fixed, sans-serif</p>
|
||||
</body>
|
||||
|
||||
@@ -2021,7 +2021,7 @@ CounterStyleManager::BuildCounterStyle(const nsSubstring& aName)
|
||||
// It is intentional that the predefined names are case-insensitive
|
||||
// but the user-defined names case-sensitive.
|
||||
nsCSSCounterStyleRule* rule =
|
||||
mPresContext->StyleSet()->CounterStyleRuleForName(mPresContext, aName);
|
||||
mPresContext->StyleSet()->CounterStyleRuleForName(aName);
|
||||
if (rule) {
|
||||
data = new (mPresContext) CustomCounterStyle(this, rule);
|
||||
} else {
|
||||
@@ -2074,7 +2074,7 @@ InvalidateOldStyle(const nsSubstring& aKey,
|
||||
bool toBeUpdated = false;
|
||||
bool toBeRemoved = false;
|
||||
nsCSSCounterStyleRule* newRule = data->mPresContext->
|
||||
StyleSet()->CounterStyleRuleForName(data->mPresContext, aKey);
|
||||
StyleSet()->CounterStyleRuleForName(aKey);
|
||||
if (!newRule) {
|
||||
if (aStyle->IsCustomStyle()) {
|
||||
toBeRemoved = true;
|
||||
|
||||
@@ -1009,7 +1009,7 @@ public:
|
||||
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
void DropReference(void);
|
||||
virtual css::Declaration* GetCSSDeclaration(bool aAllocate) override;
|
||||
virtual css::Declaration* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(css::Declaration* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
@@ -1114,7 +1114,7 @@ DOMCSSDeclarationImpl::DropReference(void)
|
||||
}
|
||||
|
||||
css::Declaration*
|
||||
DOMCSSDeclarationImpl::GetCSSDeclaration(bool aAllocate)
|
||||
DOMCSSDeclarationImpl::GetCSSDeclaration(Operation aOperation)
|
||||
{
|
||||
if (mRule) {
|
||||
return mRule->GetDeclaration();
|
||||
|
||||
@@ -510,8 +510,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
nsCSSKeyframesRule* rule =
|
||||
src.GetName().IsEmpty()
|
||||
? nullptr
|
||||
: mPresContext->StyleSet()->KeyframesRuleForName(mPresContext,
|
||||
src.GetName());
|
||||
: mPresContext->StyleSet()->KeyframesRuleForName(src.GetName());
|
||||
if (!rule) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "RuleProcessorCache.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@@ -671,24 +672,22 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
}
|
||||
// universal rules within the namespace
|
||||
if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace)));
|
||||
auto entry = static_cast<RuleHashTableEntry*>
|
||||
(mNameSpaceTable.Search(NS_INT32_TO_PTR(nameSpace)));
|
||||
if (entry) {
|
||||
mEnumList[valueCount++] = ToEnumData(entry->mRules);
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls);
|
||||
}
|
||||
}
|
||||
if (mTagTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mTagTable, tag));
|
||||
auto entry = static_cast<RuleHashTableEntry*>(mTagTable.Search(tag));
|
||||
if (entry) {
|
||||
mEnumList[valueCount++] = ToEnumData(entry->mRules);
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls);
|
||||
}
|
||||
}
|
||||
if (id && mIdTable.EntryCount() > 0) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mIdTable, id));
|
||||
auto entry = static_cast<RuleHashTableEntry*>(mIdTable.Search(id));
|
||||
if (entry) {
|
||||
mEnumList[valueCount++] = ToEnumData(entry->mRules);
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls);
|
||||
@@ -696,8 +695,8 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso
|
||||
}
|
||||
if (mClassTable.EntryCount() > 0) {
|
||||
for (int32_t index = 0; index < classCount; ++index) {
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableSearch(&mClassTable, classList->AtomAt(index)));
|
||||
auto entry = static_cast<RuleHashTableEntry*>
|
||||
(mClassTable.Search(classList->AtomAt(index)));
|
||||
if (entry) {
|
||||
mEnumList[valueCount++] = ToEnumData(entry->mRules);
|
||||
RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementClassCalls);
|
||||
@@ -2539,8 +2538,8 @@ nsCSSRuleProcessor::RulesMatching(AnonBoxRuleProcessorData* aData)
|
||||
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
|
||||
|
||||
if (cascade && cascade->mAnonBoxRules.EntryCount()) {
|
||||
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
|
||||
(PL_DHashTableSearch(&cascade->mAnonBoxRules, aData->mPseudoTag));
|
||||
auto entry = static_cast<RuleHashTagTableEntry*>
|
||||
(cascade->mAnonBoxRules.Search(aData->mPseudoTag));
|
||||
if (entry) {
|
||||
nsTArray<RuleValue>& rules = entry->mRules;
|
||||
for (RuleValue *value = rules.Elements(), *end = value + rules.Length();
|
||||
@@ -2559,8 +2558,8 @@ nsCSSRuleProcessor::RulesMatching(XULTreeRuleProcessorData* aData)
|
||||
RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
|
||||
|
||||
if (cascade && cascade->mXULTreeRules.EntryCount()) {
|
||||
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>
|
||||
(PL_DHashTableSearch(&cascade->mXULTreeRules, aData->mPseudoTag));
|
||||
auto entry = static_cast<RuleHashTagTableEntry*>
|
||||
(cascade->mXULTreeRules.Search(aData->mPseudoTag));
|
||||
if (entry) {
|
||||
NodeMatchContext nodeContext(EventStates(),
|
||||
nsCSSRuleProcessor::IsLink(aData->mElement));
|
||||
@@ -2793,9 +2792,8 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
|
||||
if (aData->mAttribute == nsGkAtoms::id) {
|
||||
nsIAtom* id = aData->mElement->GetID();
|
||||
if (id) {
|
||||
AtomSelectorEntry *entry =
|
||||
static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableSearch(&cascade->mIdSelectors, id));
|
||||
auto entry =
|
||||
static_cast<AtomSelectorEntry*>(cascade->mIdSelectors.Search(id));
|
||||
if (entry) {
|
||||
EnumerateSelectors(entry->mSelectors, &data);
|
||||
}
|
||||
@@ -2805,17 +2803,38 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
|
||||
}
|
||||
|
||||
if (aData->mAttribute == nsGkAtoms::_class) {
|
||||
const nsAttrValue* otherClasses = aData->mOtherValue;
|
||||
NS_ASSERTION(otherClasses ||
|
||||
aData->mModType == nsIDOMMutationEvent::REMOVAL,
|
||||
"All class values should be StoresOwnData and parsed"
|
||||
"via Element::BeforeSetAttr, so available here");
|
||||
// For WillChange, enumerate classes that will be removed to see which
|
||||
// rules apply before the change.
|
||||
// For Changed, enumerate classes that have been added to see which rules
|
||||
// apply after the change.
|
||||
// In both cases we're interested in the classes that are currently on
|
||||
// the element but not in mOtherValue.
|
||||
const nsAttrValue* elementClasses = aData->mElement->GetClasses();
|
||||
if (elementClasses) {
|
||||
int32_t atomCount = elementClasses->GetAtomCount();
|
||||
for (int32_t i = 0; i < atomCount; ++i) {
|
||||
nsIAtom* curClass = elementClasses->AtomAt(i);
|
||||
AtomSelectorEntry *entry =
|
||||
static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableSearch(&cascade->mClassSelectors,
|
||||
curClass));
|
||||
if (entry) {
|
||||
EnumerateSelectors(entry->mSelectors, &data);
|
||||
if (atomCount > 0) {
|
||||
nsTHashtable<nsPtrHashKey<nsIAtom>> otherClassesTable;
|
||||
if (otherClasses) {
|
||||
int32_t otherClassesCount = otherClasses->GetAtomCount();
|
||||
for (int32_t i = 0; i < otherClassesCount; ++i) {
|
||||
otherClassesTable.PutEntry(otherClasses->AtomAt(i));
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < atomCount; ++i) {
|
||||
nsIAtom* curClass = elementClasses->AtomAt(i);
|
||||
if (!otherClassesTable.Contains(curClass)) {
|
||||
auto entry =
|
||||
static_cast<AtomSelectorEntry*>
|
||||
(cascade->mClassSelectors.Search(curClass));
|
||||
if (entry) {
|
||||
EnumerateSelectors(entry->mSelectors, &data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2823,10 +2842,9 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
|
||||
EnumerateSelectors(cascade->mPossiblyNegatedClassSelectors, &data);
|
||||
}
|
||||
|
||||
AtomSelectorEntry *entry =
|
||||
auto entry =
|
||||
static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableSearch(&cascade->mAttributeSelectors,
|
||||
aData->mAttribute));
|
||||
(cascade->mAttributeSelectors.Search(aData->mAttribute));
|
||||
if (entry) {
|
||||
EnumerateSelectors(entry->mSelectors, &data);
|
||||
}
|
||||
|
||||
@@ -2109,7 +2109,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSKeyframeStyleDeclaration)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
|
||||
|
||||
css::Declaration*
|
||||
nsCSSKeyframeStyleDeclaration::GetCSSDeclaration(bool aAllocate)
|
||||
nsCSSKeyframeStyleDeclaration::GetCSSDeclaration(Operation aOperation)
|
||||
{
|
||||
if (mRule) {
|
||||
return mRule->Declaration();
|
||||
@@ -2670,7 +2670,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsCSSPageStyleDeclaration)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMCSSDeclaration)
|
||||
|
||||
css::Declaration*
|
||||
nsCSSPageStyleDeclaration::GetCSSDeclaration(bool aAllocate)
|
||||
nsCSSPageStyleDeclaration::GetCSSDeclaration(Operation aOperation)
|
||||
{
|
||||
if (mRule) {
|
||||
return mRule->Declaration();
|
||||
|
||||
@@ -410,7 +410,7 @@ public:
|
||||
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
void DropReference() { mRule = nullptr; }
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) override;
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
@@ -543,7 +543,7 @@ public:
|
||||
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
void DropReference() { mRule = nullptr; }
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) override;
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
|
||||
@@ -544,7 +544,7 @@ nsComputedDOMStyle::GetPresShellForContent(nsIContent* aContent)
|
||||
// on a nsComputedDOMStyle object, but must be defined to avoid
|
||||
// compile errors.
|
||||
css::Declaration*
|
||||
nsComputedDOMStyle::GetCSSDeclaration(bool)
|
||||
nsComputedDOMStyle::GetCSSDeclaration(Operation)
|
||||
{
|
||||
NS_RUNTIMEABORT("called nsComputedDOMStyle::GetCSSDeclaration");
|
||||
return nullptr;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
// nsDOMCSSDeclaration abstract methods which should never be called
|
||||
// on a nsComputedDOMStyle object, but must be defined to avoid
|
||||
// compile errors.
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(bool) override;
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(Operation) override;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration*) override;
|
||||
virtual nsIDocument* DocToUpdate() override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
|
||||
@@ -91,23 +91,13 @@ nsDOMCSSAttributeDeclaration::SetCSSDeclaration(css::Declaration* aDecl)
|
||||
nsIDocument*
|
||||
nsDOMCSSAttributeDeclaration::DocToUpdate()
|
||||
{
|
||||
// XXXbz this is a bit of a hack, especially doing it before the
|
||||
// BeginUpdate(), but this is a good chokepoint where we know we
|
||||
// plan to modify the CSSDeclaration, so need to notify
|
||||
// AttributeWillChange if this is inline style.
|
||||
if (!mIsSMILOverride) {
|
||||
nsNodeUtils::AttributeWillChange(mElement, kNameSpaceID_None,
|
||||
nsGkAtoms::style,
|
||||
nsIDOMMutationEvent::MODIFICATION);
|
||||
}
|
||||
|
||||
// We need OwnerDoc() rather than GetCurrentDoc() because it might
|
||||
// be the BeginUpdate call that inserts mElement into the document.
|
||||
return mElement->OwnerDoc();
|
||||
}
|
||||
|
||||
css::Declaration*
|
||||
nsDOMCSSAttributeDeclaration::GetCSSDeclaration(bool aAllocate)
|
||||
nsDOMCSSAttributeDeclaration::GetCSSDeclaration(Operation aOperation)
|
||||
{
|
||||
if (!mElement)
|
||||
return nullptr;
|
||||
@@ -118,10 +108,32 @@ nsDOMCSSAttributeDeclaration::GetCSSDeclaration(bool aAllocate)
|
||||
else
|
||||
cssRule = mElement->GetInlineStyleRule();
|
||||
|
||||
// Notify observers that our style="" attribute is going to change
|
||||
// unless:
|
||||
// * this is a declaration that holds SMIL animation values (which
|
||||
// aren't reflected in the DOM style="" attribute), or
|
||||
// * we're getting the declaration for reading, or
|
||||
// * we're getting it for property removal but we don't currently have
|
||||
// a declaration.
|
||||
|
||||
// XXXbz this is a bit of a hack, especially doing it before the
|
||||
// BeginUpdate(), but this is a good chokepoint where we know we
|
||||
// plan to modify the CSSDeclaration, so need to notify
|
||||
// AttributeWillChange if this is inline style.
|
||||
if (!mIsSMILOverride &&
|
||||
((aOperation == eOperation_Modify) ||
|
||||
(aOperation == eOperation_RemoveProperty && cssRule))) {
|
||||
nsNodeUtils::AttributeWillChange(mElement, kNameSpaceID_None,
|
||||
nsGkAtoms::style,
|
||||
nsIDOMMutationEvent::MODIFICATION,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
if (cssRule) {
|
||||
return cssRule->GetDeclaration();
|
||||
}
|
||||
if (!aAllocate) {
|
||||
|
||||
if (aOperation != eOperation_Modify) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
// If GetCSSDeclaration returns non-null, then the decl it returns
|
||||
// is owned by our current style rule.
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) override;
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) override;
|
||||
virtual void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) override;
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ nsDOMCSSDeclaration::GetPropertyValue(const nsCSSProperty aPropID,
|
||||
NS_PRECONDITION(aPropID != eCSSProperty_UNKNOWN,
|
||||
"Should never pass eCSSProperty_UNKNOWN around");
|
||||
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
|
||||
aValue.Truncate();
|
||||
if (decl) {
|
||||
@@ -62,7 +62,7 @@ nsDOMCSSDeclaration::GetCustomPropertyValue(const nsAString& aPropertyName,
|
||||
MOZ_ASSERT(Substring(aPropertyName, 0,
|
||||
CSS_CUSTOM_NAME_PREFIX_LENGTH).EqualsLiteral("--"));
|
||||
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
if (!decl) {
|
||||
aValue.Truncate();
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ nsDOMCSSDeclaration::SetPropertyValue(const nsCSSProperty aPropID,
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetCssText(nsAString& aCssText)
|
||||
{
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
aCssText.Truncate();
|
||||
|
||||
if (decl) {
|
||||
@@ -105,7 +105,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
||||
{
|
||||
// We don't need to *do* anything with the old declaration, but we need
|
||||
// to ensure that it exists, or else SetCSSDeclaration may crash.
|
||||
css::Declaration* olddecl = GetCSSDeclaration(true);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ nsDOMCSSDeclaration::SetCssText(const nsAString& aCssText)
|
||||
NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetLength(uint32_t* aLength)
|
||||
{
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
|
||||
if (decl) {
|
||||
*aLength = decl->Count();
|
||||
@@ -162,7 +162,7 @@ nsDOMCSSDeclaration::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorRe
|
||||
void
|
||||
nsDOMCSSDeclaration::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName)
|
||||
{
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
aFound = decl && decl->GetNthProperty(aIndex, aPropName);
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ nsDOMCSSDeclaration::GetAuthoredPropertyValue(const nsAString& aPropertyName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
if (!decl) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ NS_IMETHODIMP
|
||||
nsDOMCSSDeclaration::GetPropertyPriority(const nsAString& aPropertyName,
|
||||
nsAString& aReturn)
|
||||
{
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_Read);
|
||||
|
||||
aReturn.Truncate();
|
||||
if (decl && decl->GetValueIsImportant(aPropertyName)) {
|
||||
@@ -311,7 +311,7 @@ nsDOMCSSDeclaration::ParsePropertyValue(const nsCSSProperty aPropID,
|
||||
const nsAString& aPropValue,
|
||||
bool aIsImportant)
|
||||
{
|
||||
css::Declaration* olddecl = GetCSSDeclaration(true);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
|
||||
{
|
||||
MOZ_ASSERT(nsCSSProps::IsCustomPropertyName(aPropertyName));
|
||||
|
||||
css::Declaration* olddecl = GetCSSDeclaration(true);
|
||||
css::Declaration* olddecl = GetCSSDeclaration(eOperation_Modify);
|
||||
if (!olddecl) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -392,7 +392,7 @@ nsDOMCSSDeclaration::ParseCustomPropertyValue(const nsAString& aPropertyName,
|
||||
nsresult
|
||||
nsDOMCSSDeclaration::RemoveProperty(const nsCSSProperty aPropID)
|
||||
{
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
if (!decl) {
|
||||
return NS_OK; // no decl, so nothing to remove
|
||||
}
|
||||
@@ -415,7 +415,7 @@ nsDOMCSSDeclaration::RemoveCustomProperty(const nsAString& aPropertyName)
|
||||
MOZ_ASSERT(Substring(aPropertyName, 0,
|
||||
CSS_CUSTOM_NAME_PREFIX_LENGTH).EqualsLiteral("--"));
|
||||
|
||||
css::Declaration* decl = GetCSSDeclaration(false);
|
||||
css::Declaration* decl = GetCSSDeclaration(eOperation_RemoveProperty);
|
||||
if (!decl) {
|
||||
return NS_OK; // no decl, so nothing to remove
|
||||
}
|
||||
|
||||
@@ -100,10 +100,26 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
protected:
|
||||
// This method can return null regardless of the value of aAllocate;
|
||||
// however, a null return should only be considered a failure
|
||||
// if aAllocate is true.
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(bool aAllocate) = 0;
|
||||
// The reason for calling GetCSSDeclaration.
|
||||
enum Operation {
|
||||
// We are calling GetCSSDeclaration so that we can read from it. Does not
|
||||
// allocate a new declaration if we don't have one yet; returns nullptr in
|
||||
// this case.
|
||||
eOperation_Read,
|
||||
|
||||
// We are calling GetCSSDeclaration so that we can set a property on it
|
||||
// or re-parse the whole declaration. Allocates a new declaration if we
|
||||
// don't have one yet and calls AttributeWillChange. A nullptr return value
|
||||
// indicates an error allocating the declaration.
|
||||
eOperation_Modify,
|
||||
|
||||
// We are calling GetCSSDeclaration so that we can remove a property from
|
||||
// it. Does not allocates a new declaration if we don't have one yet;
|
||||
// returns nullptr in this case. If we do have a declaration, calls
|
||||
// AttributeWillChange.
|
||||
eOperation_RemoveProperty
|
||||
};
|
||||
virtual mozilla::css::Declaration* GetCSSDeclaration(Operation aOperation) = 0;
|
||||
virtual nsresult SetCSSDeclaration(mozilla::css::Declaration* aDecl) = 0;
|
||||
// Document that we must call BeginUpdate/EndUpdate on around the
|
||||
// calls to SetCSSDeclaration and the style rule mutation that leads
|
||||
|
||||
@@ -574,16 +574,20 @@ struct MOZ_STACK_CLASS AttributeRuleProcessorData :
|
||||
nsIAtom* aAttribute,
|
||||
int32_t aModType,
|
||||
bool aAttrHasChanged,
|
||||
const nsAttrValue* aOtherValue,
|
||||
TreeMatchContext& aTreeMatchContext)
|
||||
: ElementDependentRuleProcessorData(aPresContext, aElement, nullptr,
|
||||
aTreeMatchContext),
|
||||
mAttribute(aAttribute),
|
||||
mOtherValue(aOtherValue),
|
||||
mModType(aModType),
|
||||
mAttrHasChanged(aAttrHasChanged)
|
||||
{
|
||||
NS_PRECONDITION(!aTreeMatchContext.mForStyling, "Not styling here!");
|
||||
}
|
||||
nsIAtom* mAttribute; // |HasAttributeDependentStyle| for which attribute?
|
||||
// non-null if we have the value.
|
||||
const nsAttrValue* mOtherValue;
|
||||
int32_t mModType; // The type of modification (see nsIDOMMutationEvent).
|
||||
bool mAttrHasChanged; // Whether the attribute has already changed.
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user