зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1184842. Allow BeforeSetAttr to preparse aValue. r=peterv
We will pass the preparsed value into AttributeWillChange. --HG-- extra : commitid : HCiY4DRKWkC extra : rebase_source : aa17a819a20578322380d388299279e4e41a690b
This commit is contained in:
Родитель
1e49288224
Коммит
d5d49432af
|
@ -2191,6 +2191,12 @@ Element::SetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
|||
nsAutoScriptBlocker scriptBlocker;
|
||||
|
||||
nsAttrValue attrValue;
|
||||
nsAttrValue* preparsedAttrValue = value.GetStoredAttrValue();
|
||||
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);
|
||||
}
|
||||
|
@ -3505,4 +3511,4 @@ Element::GetReferrerPolicy()
|
|||
}
|
||||
}
|
||||
return net::RP_Unset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1170,13 +1170,15 @@ 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,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
return NS_OK;
|
||||
|
|
|
@ -49,6 +49,20 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to the string value of the contents of this object.
|
||||
*
|
||||
|
@ -74,6 +88,7 @@ protected:
|
|||
const nsAttrValue* mAttrValue;
|
||||
mutable const nsAString* mStringPtr;
|
||||
mutable nsCheapString mCheapString;
|
||||
nsAttrValue mStoredAttrValue;
|
||||
};
|
||||
|
||||
#endif // nsAttrValueOrString_h___
|
||||
|
|
|
@ -493,7 +493,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
|
||||
|
|
|
@ -375,7 +375,7 @@ HTMLImageElement::GetAttributeMappingFunction() const
|
|||
|
||||
nsresult
|
||||
HTMLImageElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
const nsAttrValueOrString* aValue,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify)
|
||||
{
|
||||
|
||||
|
|
|
@ -334,7 +334,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,
|
||||
|
|
|
@ -1020,7 +1020,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
|
||||
|
|
|
@ -182,7 +182,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;
|
||||
|
|
|
@ -1325,7 +1325,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;
|
||||
|
|
|
@ -954,7 +954,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) {
|
||||
|
|
|
@ -190,7 +190,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
|
||||
|
|
|
@ -1212,7 +1212,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
|
||||
|
|
|
@ -2119,7 +2119,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) {
|
||||
|
|
|
@ -1355,7 +1355,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,
|
||||
|
|
|
@ -331,7 +331,7 @@ 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,
|
||||
nsAttrValueOrString* aValue,
|
||||
bool aNotify) override final { return NS_OK; }
|
||||
#endif // DEBUG
|
||||
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
|
|
|
@ -1046,7 +1046,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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// When processing the next thread event, the appshell may process native
|
||||
// events (if not in performance mode), which can result in suppressing the
|
||||
// next thread event for at most this many ticks:
|
||||
#define THREAD_EVENT_STARVATION_LIMIT PR_MillisecondsToInterval(20)
|
||||
#define THREAD_EVENT_STARVATION_LIMIT PR_MillisecondsToInterval(10)
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsBaseAppShell, nsIAppShell, nsIThreadObserver, nsIObserver)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче