Open
Bug 1845422
Opened 1 year ago
Updated 1 year ago
Reverse the order of the calls to IsEventAttributeName and GetEventNameForAttr, to simplify some code
Categories
(Core :: DOM: Events, task)
Core
DOM: Events
Tracking
()
NEW
People
(Reporter: mstange, Unassigned)
Details
In EventNameList.h, we list some events solely so that <div onblah="...">
passes the "attribute is event handler" check:
#ifndef MESSAGE_TO_EVENT
// These are only here so that IsEventAttributeName() will return the right
// thing for these events. We could probably remove them if we used
// Element::GetEventNameForAttr on the input to IsEventAttributeName before
// looking it up in the hashtable...
EVENT(webkitanimationend, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationiteration, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationstart, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkittransitionend, eUnidentifiedEvent, EventNameType_All,
eTransitionEventClass)
#endif
void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aMaybeScriptedPrincipal,
bool aNotify) {
if (aNamespaceID == kNameSpaceID_None) {
if (IsEventAttributeName(aName) && aValue) {
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
"Expected string value for script body");
SetEventHandler(GetEventNameForAttr(aName), aValue->GetStringValue());
} else if (aNotify && aName == nsGkAtoms::spellcheck) {
This bug is for making the change suggested in the comment: First, check if the attribute name starts with "on". If it does, call GetEventNameForAttr
to map it to an event name. Then, call IsEventAttributeName
, which at that point it should be renamed to IsEventTypeAtom
.
This pattern is used in a bunch of different places.
You need to log in
before you can comment on or make changes to this bug.
Description
•