Reverse the order of the calls to IsEventAttributeName and GetEventNameForAttr, to simplify some code
Categories
(Core :: DOM: Events, task)
Tracking
()
People
(Reporter: mstange, Assigned: mstange)
Details
Attachments
(3 files)
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.
Assignee | ||
Comment 1•9 months ago
|
||
Updated•9 months ago
|
Assignee | ||
Comment 2•9 months ago
|
||
Some event names differ from their corresponding event attribute names.
For example, on SVG elements, "onbegin" is the attribute name for the
event with the name "beginEvent", whose event type atom is nsGkAtoms::onbeginEvent.
In EventNameList.h, in the past we had to duplicate some items because
nsContentUtils::IsEventAttributeName wasn't differentiating between the two
properly.
This patch removes the duplicate items, renames nsContentUtils::IsEventAttributeName
to nsContentUtils::IsValidEventNameForElementType, and makes it so that
nsIContent::IsEventAttributeName (now Element::IsEventAttributeName) does
the appropriate translation.
Depends on D188495
Assignee | ||
Comment 3•9 months ago
|
||
Depends on D188496
Description
•