<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[287019] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/287019">287019</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2021-12-14 02:29:29 -0800 (Tue, 14 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Automatically generate event handler content attribute maps so they are easier to maintain
https://bugs.webkit.org/show_bug.cgi?id=234254

Reviewed by Alexey Shvayka.

Source/WebCore:

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader): Declare forEachEventHandlerContentAttribute
and forEachWindowEventHandlerContentAttribute as needed.
(GenerateImplementation): Call GenerateForEachEventHandlerContentAttribute
as needed.
(GenerateForEachEventHandlerContentAttribute): Define
forEachEventHandlerContentAttribute or forEachWindowEventHandlerContentAttribute.

* bindings/scripts/IDLAttributes.json: Added
GenerateForEachEventHandlerContentAttribute and
GenerateForEachWindowEventHandlerContentAttribute. Even though each
is used in only one class, it's still better to not hard-code the class names.

* html/HTMLAttributeNames.in: Added oncuechange, onrejectionhandled, and
onunhandledrejection even though we are not yet implementing any of them in
this behavior-preserving patch. They need to be present so the automatically
generated code compiles. But added explicit exceptions as mentioned below to
make sure no changes are implemented in this patch, and will take those exceptions
out later in a patch intended to produce a progression, likely with new test cases.
Re-sorted alphabetically, rather an arbitrary semi-sorted order.

* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::createWindowEventHandlerNameMap): Deleted.
(WebCore::HTMLBodyElement::eventNameForWindowEventHandlerAttribute): Use
JSHTMLBodyElement::forEachWindowEventHandlerContentAttribute to create the map.
Use a lambda instead of a separate function and take advantage of the
deduction guide for NeverDestroyed. Added exceptions for onrejectionhandled
and onunhandledrejection, which are both in the IDL file but were not handled
here, along with a FIXME suggesting we remove the exceptions.
* html/HTMLElement.h: Removed createWindowEventHandlerNameMap.
* html/HTMLBodyElement.idl: Added GenerateForEachWindowEventHandlerContentAttribute.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::createEventHandlerNameMap): Deleted.
(WebCore::HTMLElement::populateEventHandlerNameMap): Deleted.
(WebCore::HTMLElement::eventNameForEventHandlerAttribute): Use
JSHTMLElement::forEachEventHandlerContentAttribute to create the map.
Use a lambda instead of a separate function and take advantage of the
deduction guide for NeverDestroyed. Added exception for oncuechange,
which is in the IDL file but was not handled here, and for 19 other attributes,
which are not in the IDL file but were handled here, along with two FIXMEs
suggesting we remove the exceptions.
* html/HTMLElement.h: Removed populateEventHandlerNameMap and
createEventHandlerNameMap.
* html/HTMLElement.idl: Added GenerateForEachEventHandlerContentAttribute.

Source/WTF:

* wtf/NeverDestroyed.h: Add a deduction guide for NeverDestroyed.
In the future we can use this instead of makeNeverDestroyed or writing
out the entire template class type including template arguments.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfNeverDestroyedh">trunk/Source/WTF/wtf/NeverDestroyed.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsIDLAttributesjson">trunk/Source/WebCore/bindings/scripts/IDLAttributes.json</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAttributeNamesin">trunk/Source/WebCore/html/HTMLAttributeNames.in</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementcpp">trunk/Source/WebCore/html/HTMLBodyElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementh">trunk/Source/WebCore/html/HTMLBodyElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLBodyElementidl">trunk/Source/WebCore/html/HTMLBodyElement.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementcpp">trunk/Source/WebCore/html/HTMLElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementh">trunk/Source/WebCore/html/HTMLElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLElementidl">trunk/Source/WebCore/html/HTMLElement.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog       2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WTF/ChangeLog  2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-12-14  Darin Adler  <darin@apple.com>
+
+        Automatically generate event handler content attribute maps so they are easier to maintain
+        https://bugs.webkit.org/show_bug.cgi?id=234254
+
+        Reviewed by Alexey Shvayka.
+
+        * wtf/NeverDestroyed.h: Add a deduction guide for NeverDestroyed.
+        In the future we can use this instead of makeNeverDestroyed or writing
+        out the entire template class type including template arguments.
+
</ins><span class="cx"> 2021-12-13  Saam Barati  <sbarati@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Roll back r286345, r286387, r286471, r286667, r286849
</span></span></pre></div>
<a id="trunkSourceWTFwtfNeverDestroyedh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/NeverDestroyed.h (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/NeverDestroyed.h    2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WTF/wtf/NeverDestroyed.h       2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -179,6 +179,9 @@
</span><span class="cx">     typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type m_storage;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template<typename T> NeverDestroyed(T) -> NeverDestroyed<T>;
+
+// FIXME: Remove this function, relying instead on the deduction guide for NeverDestroyed above.
</ins><span class="cx"> template<typename T, typename AccessTraits> inline NeverDestroyed<T, AccessTraits> makeNeverDestroyed(T&& argument)
</span><span class="cx"> {
</span><span class="cx">     return std::forward<T>(argument);
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/ChangeLog      2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2021-12-14  Darin Adler  <darin@apple.com>
+
+        Automatically generate event handler content attribute maps so they are easier to maintain
+        https://bugs.webkit.org/show_bug.cgi?id=234254
+
+        Reviewed by Alexey Shvayka.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader): Declare forEachEventHandlerContentAttribute
+        and forEachWindowEventHandlerContentAttribute as needed.
+        (GenerateImplementation): Call GenerateForEachEventHandlerContentAttribute
+        as needed.
+        (GenerateForEachEventHandlerContentAttribute): Define
+        forEachEventHandlerContentAttribute or forEachWindowEventHandlerContentAttribute.
+
+        * bindings/scripts/IDLAttributes.json: Added
+        GenerateForEachEventHandlerContentAttribute and
+        GenerateForEachWindowEventHandlerContentAttribute. Even though each
+        is used in only one class, it's still better to not hard-code the class names.
+
+        * html/HTMLAttributeNames.in: Added oncuechange, onrejectionhandled, and
+        onunhandledrejection even though we are not yet implementing any of them in
+        this behavior-preserving patch. They need to be present so the automatically
+        generated code compiles. But added explicit exceptions as mentioned below to
+        make sure no changes are implemented in this patch, and will take those exceptions
+        out later in a patch intended to produce a progression, likely with new test cases.
+        Re-sorted alphabetically, rather an arbitrary semi-sorted order.
+
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::createWindowEventHandlerNameMap): Deleted.
+        (WebCore::HTMLBodyElement::eventNameForWindowEventHandlerAttribute): Use
+        JSHTMLBodyElement::forEachWindowEventHandlerContentAttribute to create the map.
+        Use a lambda instead of a separate function and take advantage of the
+        deduction guide for NeverDestroyed. Added exceptions for onrejectionhandled
+        and onunhandledrejection, which are both in the IDL file but were not handled
+        here, along with a FIXME suggesting we remove the exceptions.
+        * html/HTMLElement.h: Removed createWindowEventHandlerNameMap.
+        * html/HTMLBodyElement.idl: Added GenerateForEachWindowEventHandlerContentAttribute.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::createEventHandlerNameMap): Deleted.
+        (WebCore::HTMLElement::populateEventHandlerNameMap): Deleted.
+        (WebCore::HTMLElement::eventNameForEventHandlerAttribute): Use
+        JSHTMLElement::forEachEventHandlerContentAttribute to create the map.
+        Use a lambda instead of a separate function and take advantage of the
+        deduction guide for NeverDestroyed. Added exception for oncuechange,
+        which is in the IDL file but was not handled here, and for 19 other attributes,
+        which are not in the IDL file but were handled here, along with two FIXMEs
+        suggesting we remove the exceptions.
+        * html/HTMLElement.h: Removed populateEventHandlerNameMap and
+        createEventHandlerNameMap.
+        * html/HTMLElement.idl: Added GenerateForEachEventHandlerContentAttribute.
+
</ins><span class="cx"> 2021-12-14  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [CSS Cascade Layers] revert-layer should revert style attribute to regular author style
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm    2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -487,7 +487,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-sub EventHandlerAttributeEventName
</del><ins>+sub EventHandlerAttributeShortEventName
</ins><span class="cx"> {
</span><span class="cx">     my $attribute = shift;
</span><span class="cx">     my $eventType = $attribute->extendedAttributes->{ImplementedAs} || $attribute->name;
</span><span class="lines">@@ -495,9 +495,15 @@
</span><span class="cx">     # Remove the "on" prefix.
</span><span class="cx">     $eventType = substr($eventType, 2);
</span><span class="cx"> 
</span><del>-    return "eventNames().${eventType}Event";
</del><ins>+    return "${eventType}Event";
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub EventHandlerAttributeEventName
+{
+    my $attribute = shift;
+    return "eventNames()." . EventHandlerAttributeShortEventName($attribute);
+}
+
</ins><span class="cx"> sub GetParentClassName
</span><span class="cx"> {
</span><span class="cx">     my $interface = shift;
</span><span class="lines">@@ -3027,7 +3033,7 @@
</span><span class="cx">     if ($interface->extendedAttributes->{CustomPushEventHandlerScope}) {
</span><span class="cx">         push(@headerContent, "    JSC::JSScope* pushEventHandlerScope(JSC::JSGlobalObject*, JSC::JSScope*) const;\n\n");
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     # Constructor object getter
</span><span class="cx">     unless ($interface->extendedAttributes->{LegacyNoInterfaceObject}) {
</span><span class="cx">         push(@headerContent, "    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);\n");
</span><span class="lines">@@ -3034,6 +3040,13 @@
</span><span class="cx">         push(@headerContent, "    static JSC::JSValue getLegacyFactoryFunction(JSC::VM&, JSC::JSGlobalObject*);\n") if $interface->extendedAttributes->{LegacyFactoryFunction};
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if ($interface->extendedAttributes->{GenerateForEachEventHandlerContentAttribute}) {
+        push(@headerContent, "    static void forEachEventHandlerContentAttribute(const Function<void(const AtomString& attributeName, const AtomString& eventName)>&);\n\n");
+    }
+    if ($interface->extendedAttributes->{GenerateForEachWindowEventHandlerContentAttribute}) {
+        push(@headerContent, "    static void forEachWindowEventHandlerContentAttribute(const Function<void(const AtomString& attributeName, const AtomString& eventName)>&);\n\n");
+    }
+
</ins><span class="cx">     my $numCustomOperations = 0;
</span><span class="cx">     my $numCustomAttributes = 0;
</span><span class="cx"> 
</span><span class="lines">@@ -4944,6 +4957,13 @@
</span><span class="cx">         push(@implContent, "}\n\n");
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    if ($interface->extendedAttributes->{GenerateForEachEventHandlerContentAttribute}) {
+        GenerateForEachEventHandlerContentAttribute(\@implContent, $interface, $className, "forEachEventHandlerContentAttribute");
+    }
+    if ($interface->extendedAttributes->{GenerateForEachWindowEventHandlerContentAttribute}) {
+        GenerateForEachEventHandlerContentAttribute(\@implContent, $interface, $className, "forEachWindowEventHandlerContentAttribute", "WindowEventHandler");
+    }
+
</ins><span class="cx">     if ($indexedGetterOperation) {
</span><span class="cx">         $implIncludes{"<wtf/URL.h>"} = 1 if $indexedGetterOperation->type->name eq "DOMString";
</span><span class="cx">         if ($interfaceName =~ /^HTML\w*Collection$/ or $interfaceName eq "RadioNodeList") {
</span><span class="lines">@@ -5184,6 +5204,27 @@
</span><span class="cx">     push(@$outputArray, "#endif\n") if $conditionalString;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub GenerateForEachEventHandlerContentAttribute
+{
+    my ($outputArray, $interface, $className, $functionName, $eventHandlerExtendedAttributeName) = @_;
+    AddToImplIncludes("HTMLNames.h");
+    push(@$outputArray, "void ${className}::${functionName}(const Function<void(const AtomString& attributeName, const AtomString& eventName)>& function)\n");
+    push(@$outputArray, "{\n");
+    push(@$outputArray, "    static constexpr std::pair<LazyNeverDestroyed<const QualifiedName>*, const AtomString EventNames::*> table[] = {\n");
+    foreach my $attribute (@{$interface->attributes}) {
+        if ($attribute->type->name eq "EventHandler" && (!defined $eventHandlerExtendedAttributeName || $attribute->extendedAttributes->{$eventHandlerExtendedAttributeName})) {
+            my $attributeName = $attribute->name;
+            my $eventName = EventHandlerAttributeShortEventName($attribute);
+            push(@$outputArray, "        { &HTMLNames::${attributeName}Attr, &EventNames::${eventName} },\n");
+        }
+    }
+    push(@$outputArray, "    };\n");
+    push(@$outputArray, "    auto& eventNames = WebCore::eventNames();\n");
+    push(@$outputArray, "    for (auto& names : table)\n");
+    push(@$outputArray, "        function(names.first->get().localName(), eventNames.*names.second);\n");
+    push(@$outputArray, "}\n\n");
+}
+
</ins><span class="cx"> sub GenerateAttributeGetterBodyDefinition
</span><span class="cx"> {
</span><span class="cx">     my ($outputArray, $interface, $className, $attribute, $attributeGetterBodyName, $conditional) = @_;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsIDLAttributesjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/IDLAttributes.json (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/IDLAttributes.json 2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/bindings/scripts/IDLAttributes.json    2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -227,14 +227,22 @@
</span><span class="cx">                 "url": "https://webidl.spec.whatwg.org/#Exposed"
</span><span class="cx">             }
</span><span class="cx">         },
</span><del>-        "GenerateIsReachable": {
</del><ins>+        "GenerateAddOpaqueRoot": {
</ins><span class="cx">             "contextsAllowed": ["interface"],
</span><del>-            "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplCanvasBase", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"]
</del><ins>+            "values": ["*"]
</ins><span class="cx">         },
</span><del>-        "GenerateAddOpaqueRoot": {
</del><ins>+        "GenerateForEachEventHandlerContentAttribute": {
</ins><span class="cx">             "contextsAllowed": ["interface"],
</span><span class="cx">             "values": ["*"]
</span><span class="cx">         },
</span><ins>+        "GenerateForEachWindowEventHandlerContentAttribute": {
+            "contextsAllowed": ["interface"],
+            "values": ["*"]
+        },
+        "GenerateIsReachable": {
+            "contextsAllowed": ["interface"],
+            "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplCanvasBase", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"]
+        },
</ins><span class="cx">         "Global": {
</span><span class="cx">             "contextsAllowed": ["interface"],
</span><span class="cx">             "values": ["*"],
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAttributeNamesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAttributeNames.in  2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in     2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -4,8 +4,8 @@
</span><span class="cx"> attrsNullNamespace
</span><span class="cx"> 
</span><span class="cx"> abbr
</span><ins>+accept
</ins><span class="cx"> accept_charset
</span><del>-accept
</del><span class="cx"> accesskey
</span><span class="cx"> action
</span><span class="cx"> align
</span><span class="lines">@@ -71,7 +71,9 @@
</span><span class="cx"> attributiondestination
</span><span class="cx"> attributionsourceid
</span><span class="cx"> attributionsourcenonce
</span><ins>+autocapitalize
</ins><span class="cx"> autocomplete
</span><ins>+autocorrect
</ins><span class="cx"> autofocus
</span><span class="cx"> autopictureinpicture
</span><span class="cx"> autoplay
</span><span class="lines">@@ -84,14 +86,14 @@
</span><span class="cx"> border
</span><span class="cx"> bordercolor
</span><span class="cx"> capture
</span><ins>+cellborder
</ins><span class="cx"> cellpadding
</span><span class="cx"> cellspacing
</span><ins>+challenge
</ins><span class="cx"> char
</span><del>-challenge
</del><span class="cx"> charoff
</span><span class="cx"> charset
</span><span class="cx"> checked
</span><del>-cellborder
</del><span class="cx"> cite
</span><span class="cx"> class
</span><span class="cx"> classid
</span><span class="lines">@@ -125,7 +127,6 @@
</span><span class="cx"> download
</span><span class="cx"> draggable
</span><span class="cx"> dropzone
</span><del>-webkitdropzone
</del><span class="cx"> enctype
</span><span class="cx"> end
</span><span class="cx"> enterkeyhint
</span><span class="lines">@@ -178,10 +179,9 @@
</span><span class="cx"> loading
</span><span class="cx"> longdesc
</span><span class="cx"> loop
</span><del>-low
-playcount
</del><span class="cx"> loopend
</span><span class="cx"> loopstart
</span><ins>+low
</ins><span class="cx"> lowsrc
</span><span class="cx"> manifest
</span><span class="cx"> marginheight
</span><span class="lines">@@ -188,12 +188,12 @@
</span><span class="cx"> marginwidth
</span><span class="cx"> max
</span><span class="cx"> maxlength
</span><del>-minlength
</del><span class="cx"> mayscript
</span><span class="cx"> media
</span><span class="cx"> mediagroup
</span><span class="cx"> method
</span><span class="cx"> min
</span><ins>+minlength
</ins><span class="cx"> multiple
</span><span class="cx"> muted
</span><span class="cx"> name
</span><span class="lines">@@ -207,10 +207,10 @@
</span><span class="cx"> object
</span><span class="cx"> onabort
</span><span class="cx"> onafterprint
</span><ins>+onanimationcancel
+onanimationend
+onanimationiteration
</ins><span class="cx"> onanimationstart
</span><del>-onanimationiteration
-onanimationend
-onanimationcancel
</del><span class="cx"> onautocomplete
</span><span class="cx"> onautocompleteerror
</span><span class="cx"> onbeforecopy
</span><span class="lines">@@ -229,6 +229,7 @@
</span><span class="cx"> onclose
</span><span class="cx"> oncontextmenu
</span><span class="cx"> oncopy
</span><ins>+oncuechange
</ins><span class="cx"> oncut
</span><span class="cx"> ondblclick
</span><span class="cx"> ondevicechange
</span><span class="lines">@@ -247,6 +248,10 @@
</span><span class="cx"> onfocusin
</span><span class="cx"> onfocusout
</span><span class="cx"> onformdata
</span><ins>+ongesturechange
+ongestureend
+ongesturestart
+ongotpointercapture
</ins><span class="cx"> onhashchange
</span><span class="cx"> oninput
</span><span class="cx"> oninvalid
</span><span class="lines">@@ -253,10 +258,6 @@
</span><span class="cx"> onkeydown
</span><span class="cx"> onkeypress
</span><span class="cx"> onkeyup
</span><del>-ongesturestart
-ongesturechange
-ongestureend
-ongotpointercapture
</del><span class="cx"> onlanguagechange
</span><span class="cx"> onload
</span><span class="cx"> onloadeddata
</span><span class="lines">@@ -272,8 +273,8 @@
</span><span class="cx"> onmouseover
</span><span class="cx"> onmouseup
</span><span class="cx"> onmousewheel
</span><ins>+onoffline
</ins><span class="cx"> ononline
</span><del>-onoffline
</del><span class="cx"> onorientationchange
</span><span class="cx"> onpagehide
</span><span class="cx"> onpageshow
</span><span class="lines">@@ -281,17 +282,18 @@
</span><span class="cx"> onpause
</span><span class="cx"> onplay
</span><span class="cx"> onplaying
</span><ins>+onpointercancel
</ins><span class="cx"> onpointerdown
</span><ins>+onpointerenter
+onpointerleave
</ins><span class="cx"> onpointermove
</span><ins>+onpointerout
+onpointerover
</ins><span class="cx"> onpointerup
</span><del>-onpointercancel
-onpointerover
-onpointerout
-onpointerenter
-onpointerleave
</del><span class="cx"> onpopstate
</span><span class="cx"> onprogress
</span><span class="cx"> onratechange
</span><ins>+onrejectionhandled
</ins><span class="cx"> onreset
</span><span class="cx"> onresize
</span><span class="cx"> onscroll
</span><span class="lines">@@ -300,32 +302,33 @@
</span><span class="cx"> onseeked
</span><span class="cx"> onseeking
</span><span class="cx"> onselect
</span><ins>+onselectionchange
</ins><span class="cx"> onselectstart
</span><del>-onselectionchange
</del><span class="cx"> onslotchange
</span><del>-onwheel
</del><span class="cx"> onstalled
</span><span class="cx"> onstorage
</span><ins>+onsubmit
</ins><span class="cx"> onsuspend
</span><del>-onsubmit
</del><span class="cx"> ontimeupdate
</span><span class="cx"> ontoggle
</span><ins>+ontouchcancel
+ontouchend
</ins><span class="cx"> ontouchforcechange
</span><ins>+ontouchmove
</ins><span class="cx"> ontouchstart
</span><del>-ontouchmove
-ontouchend
-ontouchcancel
</del><span class="cx"> ontransitioncancel
</span><span class="cx"> ontransitionend
</span><span class="cx"> ontransitionrun
</span><span class="cx"> ontransitionstart
</span><ins>+onunhandledrejection
</ins><span class="cx"> onunload
</span><span class="cx"> onvolumechange
</span><span class="cx"> onwaiting
</span><ins>+onwebkitanimationend
+onwebkitanimationiteration
</ins><span class="cx"> onwebkitanimationstart
</span><del>-onwebkitanimationiteration
-onwebkitanimationend
</del><span class="cx"> onwebkitbeginfullscreen
</span><ins>+onwebkitcurrentplaybacktargetiswirelesschanged
</ins><span class="cx"> onwebkitendfullscreen
</span><span class="cx"> onwebkitfullscreenchange
</span><span class="cx"> onwebkitfullscreenerror
</span><span class="lines">@@ -337,19 +340,23 @@
</span><span class="cx"> onwebkitmouseforceup
</span><span class="cx"> onwebkitmouseforcewillbegin
</span><span class="cx"> onwebkitneedkey
</span><ins>+onwebkitplaybacktargetavailabilitychanged
+onwebkitpresentationmodechanged
</ins><span class="cx"> onwebkitsourceclose
</span><span class="cx"> onwebkitsourceended
</span><span class="cx"> onwebkitsourceopen
</span><span class="cx"> onwebkittransitionend
</span><ins>+onwheel
</ins><span class="cx"> open
</span><span class="cx"> optimum
</span><span class="cx"> part
</span><span class="cx"> pattern
</span><ins>+ping
</ins><span class="cx"> placeholder
</span><ins>+playcount
</ins><span class="cx"> playsinline
</span><span class="cx"> pluginspage
</span><span class="cx"> pluginurl
</span><del>-ping
</del><span class="cx"> poster
</span><span class="cx"> precision
</span><span class="cx"> preload
</span><span class="lines">@@ -385,13 +392,11 @@
</span><span class="cx"> sortable
</span><span class="cx"> sortdirection
</span><span class="cx"> span
</span><del>-x-webkit-speech
-x-webkit-grammar
</del><span class="cx"> spellcheck
</span><span class="cx"> src
</span><del>-srcset
</del><span class="cx"> srcdoc
</span><span class="cx"> srclang
</span><ins>+srcset
</ins><span class="cx"> standby
</span><span class="cx"> start
</span><span class="cx"> step
</span><span class="lines">@@ -416,27 +421,22 @@
</span><span class="cx"> version
</span><span class="cx"> vlink
</span><span class="cx"> vspace
</span><ins>+webkit-playsinline
</ins><span class="cx"> webkitallowfullscreen
</span><ins>+webkitattachmentbloburl
</ins><span class="cx"> webkitattachmentid
</span><span class="cx"> webkitattachmentpath
</span><del>-webkitattachmentbloburl
</del><span class="cx"> webkitdirectory
</span><ins>+webkitdropzone
</ins><span class="cx"> width
</span><span class="cx"> wrap
</span><del>-
-autocorrect
-autocapitalize
-onwebkitcurrentplaybacktargetiswirelesschanged
-onwebkitplaybacktargetavailabilitychanged
-onwebkitpresentationmodechanged
-x-webkit-imagemenu
-webkit-playsinline
-x-webkit-airplay
-x-webkit-wirelessvideoplaybackdisabled
-x-itunes-inherit-uri-query-component
-
</del><span class="cx"> x-apple-data-detectors
</span><ins>+x-apple-data-detectors-result
</ins><span class="cx"> x-apple-data-detectors-type
</span><del>-x-apple-data-detectors-result
-
</del><span class="cx"> x-apple-pdf-annotation
</span><ins>+x-itunes-inherit-uri-query-component
+x-webkit-airplay
+x-webkit-grammar
+x-webkit-imagemenu
+x-webkit-speech
+x-webkit-wirelessvideoplaybackdisabled
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.cpp    2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp       2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx">  *           (C) 2000 Simon Hausmann (hausmann@kde.org)
</span><span class="cx">  *           (C) 2001 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "HTMLIFrameElement.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="cx"> #include "HTMLParserIdioms.h"
</span><ins>+#include "JSHTMLBodyElement.h"
</ins><span class="cx"> #include "StyleProperties.h"
</span><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="lines">@@ -96,46 +97,19 @@
</span><span class="cx">         HTMLElement::collectPresentationalHintsForAttribute(name, value, style);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElement::EventHandlerNameMap HTMLBodyElement::createWindowEventHandlerNameMap()
-{
-    static const QualifiedName* const table[] = {
-        &onafterprintAttr.get(),
-        &onbeforeprintAttr.get(),
-        &onbeforeunloadAttr.get(),
-        &onblurAttr.get(),
-        &onerrorAttr.get(),
-        &onfocusAttr.get(),
-        &onfocusinAttr.get(),
-        &onfocusoutAttr.get(),
-        &onhashchangeAttr.get(),
-        &onlanguagechangeAttr.get(),
-        &onloadAttr.get(),
-        &onmessageAttr.get(),
-        &onofflineAttr.get(),
-        &ononlineAttr.get(),
-        &onorientationchangeAttr.get(),
-        &onpagehideAttr.get(),
-        &onpageshowAttr.get(),
-        &onpopstateAttr.get(),
-        &onresizeAttr.get(),
-        &onscrollAttr.get(),
-        &onstorageAttr.get(),
-        &onunloadAttr.get(),
-        &onwebkitmouseforcechangedAttr.get(),
-        &onwebkitmouseforcedownAttr.get(),
-        &onwebkitmouseforceupAttr.get(),
-        &onwebkitmouseforcewillbeginAttr.get(),
-    };
-
-    EventHandlerNameMap map;
-    populateEventHandlerNameMap(map, table);
-    return map;
-}
-
</del><span class="cx"> const AtomString& HTMLBodyElement::eventNameForWindowEventHandlerAttribute(const QualifiedName& attributeName)
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<EventHandlerNameMap> map = createWindowEventHandlerNameMap();
-    return eventNameForEventHandlerAttribute(attributeName, map.get());
</del><ins>+    static NeverDestroyed map = [] {
+        EventHandlerNameMap map;
+        JSHTMLBodyElement::forEachWindowEventHandlerContentAttribute([&] (const AtomString& attributeName, const AtomString& eventName) {
+            // FIXME: Remove these special cases. These have has an [WindowEventHandler] line in the IDL but were not in this map before, so this preserves behavior.
+            if (attributeName == onrejectionhandledAttr.get().localName() || attributeName == onunhandledrejectionAttr.get().localName())
+                return;
+            map.add(attributeName.impl(), eventName);
+        });
+        return map;
+    }();
+    return eventNameForEventHandlerAttribute(attributeName, map);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void HTMLBodyElement::parseAttribute(const QualifiedName& name, const AtomString& value)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.h (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.h      2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLBodyElement.h 2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -51,8 +51,6 @@
</span><span class="cx">     bool supportsFocus() const final;
</span><span class="cx"> 
</span><span class="cx">     void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
</span><del>-
-    static EventHandlerNameMap createWindowEventHandlerNameMap();
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } //namespace
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLBodyElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLBodyElement.idl (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLBodyElement.idl    2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLBodyElement.idl       2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -19,7 +19,8 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> [
</span><del>-    Exposed=Window
</del><ins>+    Exposed=Window,
+    GenerateForEachWindowEventHandlerContentAttribute,
</ins><span class="cx"> ] interface HTMLBodyElement : HTMLElement {
</span><span class="cx">     [CEReactions=NotNeeded, Reflect] attribute [LegacyNullToEmptyString] DOMString aLink;
</span><span class="cx">     [CEReactions=NotNeeded, Reflect] attribute DOMString background;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.cpp (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.cpp        2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLElement.cpp   2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><del>- * Copyright (C) 2004-2020 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</span><span class="cx">  * Copyright (C) 2011 Motorola Mobility. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #include "HTMLTextAreaElement.h"
</span><span class="cx"> #include "HTMLTextFormControlElement.h"
</span><span class="cx"> #include "ImageOverlay.h"
</span><ins>+#include "JSHTMLElement.h"
</ins><span class="cx"> #include "MediaControlsHost.h"
</span><span class="cx"> #include "NodeTraversal.h"
</span><span class="cx"> #include "RenderElement.h"
</span><span class="lines">@@ -240,167 +241,6 @@
</span><span class="cx">         StyledElement::collectPresentationalHintsForAttribute(name, value, style);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-HTMLElement::EventHandlerNameMap HTMLElement::createEventHandlerNameMap()
-{
-    EventHandlerNameMap map;
-
-    static const QualifiedName* const table[] = {
-        &onabortAttr.get(),
-        &onanimationendAttr.get(),
-        &onanimationiterationAttr.get(),
-        &onanimationstartAttr.get(),
-        &onanimationcancelAttr.get(),
-        &onautocompleteAttr.get(),
-        &onautocompleteerrorAttr.get(),
-        &onbeforecopyAttr.get(),
-        &onbeforecutAttr.get(),
-        &onbeforeinputAttr.get(),
-        &onbeforeloadAttr.get(),
-        &onbeforepasteAttr.get(),
-        &onblurAttr.get(),
-        &oncancelAttr.get(),
-        &oncanplayAttr.get(),
-        &oncanplaythroughAttr.get(),
-        &onchangeAttr.get(),
-        &onclickAttr.get(),
-        &oncloseAttr.get(),
-        &oncontextmenuAttr.get(),
-        &oncopyAttr.get(),
-        &oncutAttr.get(),
-        &ondblclickAttr.get(),
-        &ondragAttr.get(),
-        &ondragendAttr.get(),
-        &ondragenterAttr.get(),
-        &ondragleaveAttr.get(),
-        &ondragoverAttr.get(),
-        &ondragstartAttr.get(),
-        &ondropAttr.get(),
-        &ondurationchangeAttr.get(),
-        &onemptiedAttr.get(),
-        &onendedAttr.get(),
-        &onerrorAttr.get(),
-        &onfocusAttr.get(),
-        &onfocusinAttr.get(),
-        &onfocusoutAttr.get(),
-        &onformdataAttr.get(),
-        &ongesturechangeAttr.get(),
-        &ongestureendAttr.get(),
-        &ongesturestartAttr.get(),
-        &ongotpointercaptureAttr.get(),
-        &oninputAttr.get(),
-        &oninvalidAttr.get(),
-        &onkeydownAttr.get(),
-        &onkeypressAttr.get(),
-        &onkeyupAttr.get(),
-        &onloadAttr.get(),
-        &onloadeddataAttr.get(),
-        &onloadedmetadataAttr.get(),
-        &onloadstartAttr.get(),
-        &onlostpointercaptureAttr.get(),
-        &onmousedownAttr.get(),
-        &onmouseenterAttr.get(),
-        &onmouseleaveAttr.get(),
-        &onmousemoveAttr.get(),
-        &onmouseoutAttr.get(),
-        &onmouseoverAttr.get(),
-        &onmouseupAttr.get(),
-        &onmousewheelAttr.get(),
-        &onpasteAttr.get(),
-        &onpauseAttr.get(),
-        &onplayAttr.get(),
-        &onplayingAttr.get(),
-        &onpointerdownAttr.get(),
-        &onpointermoveAttr.get(),
-        &onpointerupAttr.get(),
-        &onpointercancelAttr.get(),
-        &onpointeroverAttr.get(),
-        &onpointeroutAttr.get(),
-        &onpointerenterAttr.get(),
-        &onpointerleaveAttr.get(),
-        &onprogressAttr.get(),
-        &onratechangeAttr.get(),
-        &onresetAttr.get(),
-        &onresizeAttr.get(),
-        &onscrollAttr.get(),
-        &onsearchAttr.get(),
-        &onsecuritypolicyviolationAttr.get(),
-        &onseekedAttr.get(),
-        &onseekingAttr.get(),
-        &onselectAttr.get(),
-        &onselectionchangeAttr.get(),
-        &onselectstartAttr.get(),
-        &onslotchangeAttr.get(),
-        &onstalledAttr.get(),
-        &onsubmitAttr.get(),
-        &onsuspendAttr.get(),
-        &ontimeupdateAttr.get(),
-        &ontoggleAttr.get(),
-        &ontouchcancelAttr.get(),
-        &ontouchendAttr.get(),
-        &ontouchforcechangeAttr.get(),
-        &ontouchmoveAttr.get(),
-        &ontouchstartAttr.get(),
-        &ontransitioncancelAttr.get(),
-        &ontransitionendAttr.get(),
-        &ontransitionrunAttr.get(),
-        &ontransitionstartAttr.get(),
-        &onvolumechangeAttr.get(),
-        &onwaitingAttr.get(),
-        &onwebkitbeginfullscreenAttr.get(),
-        &onwebkitcurrentplaybacktargetiswirelesschangedAttr.get(),
-        &onwebkitendfullscreenAttr.get(),
-        &onwebkitfullscreenchangeAttr.get(),
-        &onwebkitfullscreenerrorAttr.get(),
-        &onwebkitkeyaddedAttr.get(),
-        &onwebkitkeyerrorAttr.get(),
-        &onwebkitkeymessageAttr.get(),
-        &onwebkitmouseforcechangedAttr.get(),
-        &onwebkitmouseforcedownAttr.get(),
-        &onwebkitmouseforcewillbeginAttr.get(),
-        &onwebkitmouseforceupAttr.get(),
-        &onwebkitneedkeyAttr.get(),
-        &onwebkitplaybacktargetavailabilitychangedAttr.get(),
-        &onwebkitpresentationmodechangedAttr.get(),
-        &onwheelAttr.get(),
-    };
-
-    populateEventHandlerNameMap(map, table);
-
-    struct UnusualMapping {
-        const QualifiedName& attributeName;
-        const AtomString& eventName;
-    };
-
-    const UnusualMapping unusualPairsTable[] = {
-        { onwebkitanimationendAttr, eventNames().webkitAnimationEndEvent },
-        { onwebkitanimationiterationAttr, eventNames().webkitAnimationIterationEvent },
-        { onwebkitanimationstartAttr, eventNames().webkitAnimationStartEvent },
-        { onwebkittransitionendAttr, eventNames().webkitTransitionEndEvent },
-    };
-
-    for (auto& entry : unusualPairsTable)
-        map.add(entry.attributeName.localName().impl(), entry.eventName);
-
-    return map;
-}
-
-void HTMLElement::populateEventHandlerNameMap(EventHandlerNameMap& map, const QualifiedName* const table[], size_t tableSize)
-{
-    for (size_t i = 0; i < tableSize; ++i) {
-        auto* entry = table[i];
-
-        // FIXME: Would be nice to check these against the actual event names in eventNames().
-        // Not obvious how to do that simply, though.
-        auto& attributeName = entry->localName();
-
-        // Remove the "on" prefix. Requires some memory allocation and computing a hash, but by not
-        // using pointers from eventNames(), the passed-in table can be initialized at compile time.
-        AtomString eventName = attributeName.string().substring(2);
-
-        map.add(attributeName.impl(), WTFMove(eventName));
-    }
-}
-
</del><span class="cx"> const AtomString& HTMLElement::eventNameForEventHandlerAttribute(const QualifiedName& attributeName, const EventHandlerNameMap& map)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!attributeName.localName().isNull());
</span><span class="lines">@@ -420,8 +260,43 @@
</span><span class="cx"> 
</span><span class="cx"> const AtomString& HTMLElement::eventNameForEventHandlerAttribute(const QualifiedName& attributeName)
</span><span class="cx"> {
</span><del>-    static NeverDestroyed<EventHandlerNameMap> map = createEventHandlerNameMap();
-    return eventNameForEventHandlerAttribute(attributeName, map.get());
</del><ins>+    static NeverDestroyed map = [] {
+        EventHandlerNameMap map;
+        JSHTMLElement::forEachEventHandlerContentAttribute([&] (const AtomString& attributeName, const AtomString& eventName) {
+            // FIXME: Remove this special case. This has an [EventHandler] line in the IDL but was not historically in this map.
+            if (attributeName == oncuechangeAttr.get().localName())
+                return;
+            map.add(attributeName.impl(), eventName);
+        });
+        // FIXME: Remove these special cases. These are not in IDL with [EventHandler] but were historically in this map.
+        static constexpr const LazyNeverDestroyed<const QualifiedName>* table[] = {
+            &onautocompleteAttr,
+            &onautocompleteerrorAttr,
+            &onbeforeloadAttr,
+            &onfocusinAttr,
+            &onfocusoutAttr,
+            &ongesturechangeAttr,
+            &ongestureendAttr,
+            &ongesturestartAttr,
+            &onwebkitbeginfullscreenAttr,
+            &onwebkitcurrentplaybacktargetiswirelesschangedAttr,
+            &onwebkitendfullscreenAttr,
+            &onwebkitfullscreenchangeAttr,
+            &onwebkitfullscreenerrorAttr,
+            &onwebkitkeyaddedAttr,
+            &onwebkitkeyerrorAttr,
+            &onwebkitkeymessageAttr,
+            &onwebkitneedkeyAttr,
+            &onwebkitplaybacktargetavailabilitychangedAttr,
+            &onwebkitpresentationmodechangedAttr,
+        };
+        for (auto& entry : table) {
+            auto* name = entry->get().localName().impl();
+            map.add(name, AtomString { name, 2, String::MaxLength });
+        }
+        return map;
+    }();
+    return eventNameForEventHandlerAttribute(attributeName, map);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node::Editability HTMLElement::editabilityFromContentEditableAttr(const Node& node)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.h (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.h  2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLElement.h     2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -161,8 +161,7 @@
</span><span class="cx">     void childrenChanged(const ChildChange&) override;
</span><span class="cx">     void calculateAndAdjustDirectionality();
</span><span class="cx"> 
</span><del>-    typedef HashMap<AtomStringImpl*, AtomString> EventHandlerNameMap;
-    template<size_t tableSize> static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const (&table)[tableSize]);
</del><ins>+    using EventHandlerNameMap = HashMap<AtomStringImpl*, AtomString>;
</ins><span class="cx">     static const AtomString& eventNameForEventHandlerAttribute(const QualifiedName& attributeName, const EventHandlerNameMap&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -175,9 +174,6 @@
</span><span class="cx">     void adjustDirectionalityIfNeededAfterChildrenChanged(Element* beforeChange, ChildChange::Type);
</span><span class="cx">     TextDirection directionality(Node** strongDirectionalityTextNode= 0) const;
</span><span class="cx"> 
</span><del>-    static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const table[], size_t tableSize);
-    static EventHandlerNameMap createEventHandlerNameMap();
-
</del><span class="cx">     enum class AllowPercentage : bool { No, Yes };
</span><span class="cx">     enum class UseCSSPXAsUnitType : bool { No, Yes };
</span><span class="cx">     enum class IsMultiLength : bool { No, Yes };
</span><span class="lines">@@ -190,11 +186,6 @@
</span><span class="cx">     ASSERT(tagName.localName().impl());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template<size_t tableSize> inline void HTMLElement::populateEventHandlerNameMap(EventHandlerNameMap& map, const QualifiedName* const (&table)[tableSize])
-{
-    populateEventHandlerNameMap(map, table, tableSize);
-}
-
</del><span class="cx"> inline bool Node::hasTagName(const HTMLQualifiedName& name) const
</span><span class="cx"> {
</span><span class="cx">     return is<HTMLElement>(*this) && downcast<HTMLElement>(*this).hasTagName(name);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLElement.idl (287018 => 287019)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLElement.idl        2021-12-14 10:13:54 UTC (rev 287018)
+++ trunk/Source/WebCore/html/HTMLElement.idl   2021-12-14 10:29:29 UTC (rev 287019)
</span><span class="lines">@@ -21,8 +21,9 @@
</span><span class="cx"> [
</span><span class="cx">     CustomPushEventHandlerScope,
</span><span class="cx">     ExportMacro=WEBCORE_EXPORT,
</span><ins>+    Exposed=Window,
+    GenerateForEachEventHandlerContentAttribute,
</ins><span class="cx">     JSGenerateToNativeObject,
</span><del>-    Exposed=Window
</del><span class="cx"> ] interface HTMLElement : Element {
</span><span class="cx">     [Custom] constructor();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>