summaryrefslogtreecommitdiffstats
path: root/dom/base/Element.h
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 05:33:06 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 05:33:06 -0400
commit17f7e1c8c6fca351174bdbd73981aa8e44d0f9da (patch)
treee8ea42c3121ecd79638172d226a94ad241a21ea9 /dom/base/Element.h
parent940d191ef8b61309f4ea83d0fea77828f361251b (diff)
downloadUXP-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.tar
UXP-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.tar.gz
UXP-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.tar.lz
UXP-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.tar.xz
UXP-17f7e1c8c6fca351174bdbd73981aa8e44d0f9da.zip
Bug 1365092 - Move side effects of SetAttr and ParseAttribute to BeforeSetAttr and AfterSetAttr
* Moves side effects of nsGenericHTMLElement and Element's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of HTMLAnchorElement's SetAttr, UnsetAttr, and ParseAttribute functions to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of HTMLImageElement's SetAttr function to the corresponding BeforeSetAttr and AfterSetAttr functions * Moves side effects of SetAttr, UnsetAttr, and ParseAttribute functions to BeforeSetAttr and AfterSetAttr Tag #1375
Diffstat (limited to 'dom/base/Element.h')
-rw-r--r--dom/base/Element.h66
1 files changed, 60 insertions, 6 deletions
diff --git a/dom/base/Element.h b/dom/base/Element.h
index 6f60c9ad0..df0dbcc45 100644
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -523,6 +523,7 @@ public:
already_AddRefed<mozilla::dom::NodeInfo>
GetExistingAttrNameFromQName(const nsAString& aStr) const;
+ MOZ_ALWAYS_INLINE // Avoid a crashy hook from Avast 10 Beta (Bug 1058131)
nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{
@@ -1378,14 +1379,9 @@ protected:
* will be null.
* @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;
- }
+ bool aNotify);
/**
* Hook that is called by Element::SetAttr to allow subclasses to
@@ -1413,6 +1409,64 @@ protected:
}
/**
+ * This function shall be called just before the id attribute changes. It will
+ * be called after BeforeSetAttr. If the attribute being changed is not the id
+ * attribute, this function does nothing. Otherwise, it will remove the old id
+ * from the document's id cache.
+ *
+ * This must happen after BeforeSetAttr (rather than during) because the
+ * the subclasses' calls to BeforeSetAttr may notify on state changes. If they
+ * incorrectly determine whether the element had an id, the element may not be
+ * restyled properly.
+ *
+ * @param aNamespaceID the namespace of the attr being set
+ * @param aName the localname of the attribute being set
+ * @param aValue the new id value. Will be null if the id is being unset.
+ */
+ void PreIdMaybeChange(int32_t aNamespaceID, nsIAtom* aName,
+ const nsAttrValueOrString* aValue);
+
+ /**
+ * This function shall be called just after the id attribute changes. It will
+ * be called before AfterSetAttr. If the attribute being changed is not the id
+ * attribute, this function does nothing. Otherwise, it will add the new id to
+ * the document's id cache and properly set the ElementHasID flag.
+ *
+ * This must happen before AfterSetAttr (rather than during) because the
+ * the subclasses' calls to AfterSetAttr may notify on state changes. If they
+ * incorrectly determine whether the element now has an id, the element may
+ * not be restyled properly.
+ *
+ * @param aNamespaceID the namespace of the attr being set
+ * @param aName the localname of the attribute being set
+ * @param aValue the new id value. Will be null if the id is being unset.
+ */
+ void PostIdMaybeChange(int32_t aNamespaceID, nsIAtom* aName,
+ const nsAttrValue* aValue);
+
+ /**
+ * Usually, setting an attribute to the value that it already has results in
+ * no action. However, in some cases, setting an attribute to its current
+ * value should have the effect of, for example, forcing a reload of
+ * network data. To address that, this function will be called in this
+ * situation to allow the handling of such a case.
+ *
+ * @param aNamespaceID the namespace of the attr being set
+ * @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.
+ * @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 OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName,
+ const nsAttrValueOrString& aValue,
+ bool aNotify)
+ {
+ return NS_OK;
+ }
+
+ /**
* Hook to allow subclasses to produce a different EventListenerManager if
* needed for attachment of attribute-defined handlers
*/