Changeset 287019 in webkit
- Timestamp:
- Dec 14, 2021, 2:29:29 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/NeverDestroyed.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bindings/scripts/CodeGeneratorJS.pm (modified) (5 diffs)
-
WebCore/bindings/scripts/IDLAttributes.json (modified) (1 diff)
-
WebCore/html/HTMLAttributeNames.in (modified) (17 diffs)
-
WebCore/html/HTMLBodyElement.cpp (modified) (3 diffs)
-
WebCore/html/HTMLBodyElement.h (modified) (1 diff)
-
WebCore/html/HTMLBodyElement.idl (modified) (1 diff)
-
WebCore/html/HTMLElement.cpp (modified) (4 diffs)
-
WebCore/html/HTMLElement.h (modified) (3 diffs)
-
WebCore/html/HTMLElement.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r286994 r287019 1 2021-12-14 Darin Adler <darin@apple.com> 2 3 Automatically generate event handler content attribute maps so they are easier to maintain 4 https://bugs.webkit.org/show_bug.cgi?id=234254 5 6 Reviewed by Alexey Shvayka. 7 8 * wtf/NeverDestroyed.h: Add a deduction guide for NeverDestroyed. 9 In the future we can use this instead of makeNeverDestroyed or writing 10 out the entire template class type including template arguments. 11 1 12 2021-12-13 Saam Barati <sbarati@apple.com> 2 13 -
trunk/Source/WTF/wtf/NeverDestroyed.h
r274241 r287019 180 180 }; 181 181 182 template<typename T> NeverDestroyed(T) -> NeverDestroyed<T>; 183 184 // FIXME: Remove this function, relying instead on the deduction guide for NeverDestroyed above. 182 185 template<typename T, typename AccessTraits> inline NeverDestroyed<T, AccessTraits> makeNeverDestroyed(T&& argument) 183 186 { -
trunk/Source/WebCore/ChangeLog
r287018 r287019 1 2021-12-14 Darin Adler <darin@apple.com> 2 3 Automatically generate event handler content attribute maps so they are easier to maintain 4 https://bugs.webkit.org/show_bug.cgi?id=234254 5 6 Reviewed by Alexey Shvayka. 7 8 * bindings/scripts/CodeGeneratorJS.pm: 9 (GenerateHeader): Declare forEachEventHandlerContentAttribute 10 and forEachWindowEventHandlerContentAttribute as needed. 11 (GenerateImplementation): Call GenerateForEachEventHandlerContentAttribute 12 as needed. 13 (GenerateForEachEventHandlerContentAttribute): Define 14 forEachEventHandlerContentAttribute or forEachWindowEventHandlerContentAttribute. 15 16 * bindings/scripts/IDLAttributes.json: Added 17 GenerateForEachEventHandlerContentAttribute and 18 GenerateForEachWindowEventHandlerContentAttribute. Even though each 19 is used in only one class, it's still better to not hard-code the class names. 20 21 * html/HTMLAttributeNames.in: Added oncuechange, onrejectionhandled, and 22 onunhandledrejection even though we are not yet implementing any of them in 23 this behavior-preserving patch. They need to be present so the automatically 24 generated code compiles. But added explicit exceptions as mentioned below to 25 make sure no changes are implemented in this patch, and will take those exceptions 26 out later in a patch intended to produce a progression, likely with new test cases. 27 Re-sorted alphabetically, rather an arbitrary semi-sorted order. 28 29 * html/HTMLBodyElement.cpp: 30 (WebCore::HTMLBodyElement::createWindowEventHandlerNameMap): Deleted. 31 (WebCore::HTMLBodyElement::eventNameForWindowEventHandlerAttribute): Use 32 JSHTMLBodyElement::forEachWindowEventHandlerContentAttribute to create the map. 33 Use a lambda instead of a separate function and take advantage of the 34 deduction guide for NeverDestroyed. Added exceptions for onrejectionhandled 35 and onunhandledrejection, which are both in the IDL file but were not handled 36 here, along with a FIXME suggesting we remove the exceptions. 37 * html/HTMLElement.h: Removed createWindowEventHandlerNameMap. 38 * html/HTMLBodyElement.idl: Added GenerateForEachWindowEventHandlerContentAttribute. 39 40 * html/HTMLElement.cpp: 41 (WebCore::HTMLElement::createEventHandlerNameMap): Deleted. 42 (WebCore::HTMLElement::populateEventHandlerNameMap): Deleted. 43 (WebCore::HTMLElement::eventNameForEventHandlerAttribute): Use 44 JSHTMLElement::forEachEventHandlerContentAttribute to create the map. 45 Use a lambda instead of a separate function and take advantage of the 46 deduction guide for NeverDestroyed. Added exception for oncuechange, 47 which is in the IDL file but was not handled here, and for 19 other attributes, 48 which are not in the IDL file but were handled here, along with two FIXMEs 49 suggesting we remove the exceptions. 50 * html/HTMLElement.h: Removed populateEventHandlerNameMap and 51 createEventHandlerNameMap. 52 * html/HTMLElement.idl: Added GenerateForEachEventHandlerContentAttribute. 53 1 54 2021-12-14 Antti Koivisto <antti@apple.com> 2 55 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r286895 r287019 488 488 } 489 489 490 sub EventHandlerAttribute EventName490 sub EventHandlerAttributeShortEventName 491 491 { 492 492 my $attribute = shift; … … 496 496 $eventType = substr($eventType, 2); 497 497 498 return "eventNames().${eventType}Event"; 498 return "${eventType}Event"; 499 } 500 501 sub EventHandlerAttributeEventName 502 { 503 my $attribute = shift; 504 return "eventNames()." . EventHandlerAttributeShortEventName($attribute); 499 505 } 500 506 … … 3028 3034 push(@headerContent, " JSC::JSScope* pushEventHandlerScope(JSC::JSGlobalObject*, JSC::JSScope*) const;\n\n"); 3029 3035 } 3030 3036 3031 3037 # Constructor object getter 3032 3038 unless ($interface->extendedAttributes->{LegacyNoInterfaceObject}) { 3033 3039 push(@headerContent, " static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);\n"); 3034 3040 push(@headerContent, " static JSC::JSValue getLegacyFactoryFunction(JSC::VM&, JSC::JSGlobalObject*);\n") if $interface->extendedAttributes->{LegacyFactoryFunction}; 3041 } 3042 3043 if ($interface->extendedAttributes->{GenerateForEachEventHandlerContentAttribute}) { 3044 push(@headerContent, " static void forEachEventHandlerContentAttribute(const Function<void(const AtomString& attributeName, const AtomString& eventName)>&);\n\n"); 3045 } 3046 if ($interface->extendedAttributes->{GenerateForEachWindowEventHandlerContentAttribute}) { 3047 push(@headerContent, " static void forEachWindowEventHandlerContentAttribute(const Function<void(const AtomString& attributeName, const AtomString& eventName)>&);\n\n"); 3035 3048 } 3036 3049 … … 4943 4956 push(@implContent, " Base::analyzeHeap(cell, analyzer);\n"); 4944 4957 push(@implContent, "}\n\n"); 4958 } 4959 4960 if ($interface->extendedAttributes->{GenerateForEachEventHandlerContentAttribute}) { 4961 GenerateForEachEventHandlerContentAttribute(\@implContent, $interface, $className, "forEachEventHandlerContentAttribute"); 4962 } 4963 if ($interface->extendedAttributes->{GenerateForEachWindowEventHandlerContentAttribute}) { 4964 GenerateForEachEventHandlerContentAttribute(\@implContent, $interface, $className, "forEachWindowEventHandlerContentAttribute", "WindowEventHandler"); 4945 4965 } 4946 4966 … … 5185 5205 } 5186 5206 5207 sub GenerateForEachEventHandlerContentAttribute 5208 { 5209 my ($outputArray, $interface, $className, $functionName, $eventHandlerExtendedAttributeName) = @_; 5210 AddToImplIncludes("HTMLNames.h"); 5211 push(@$outputArray, "void ${className}::${functionName}(const Function<void(const AtomString& attributeName, const AtomString& eventName)>& function)\n"); 5212 push(@$outputArray, "{\n"); 5213 push(@$outputArray, " static constexpr std::pair<LazyNeverDestroyed<const QualifiedName>*, const AtomString EventNames::*> table[] = {\n"); 5214 foreach my $attribute (@{$interface->attributes}) { 5215 if ($attribute->type->name eq "EventHandler" && (!defined $eventHandlerExtendedAttributeName || $attribute->extendedAttributes->{$eventHandlerExtendedAttributeName})) { 5216 my $attributeName = $attribute->name; 5217 my $eventName = EventHandlerAttributeShortEventName($attribute); 5218 push(@$outputArray, " { &HTMLNames::${attributeName}Attr, &EventNames::${eventName} },\n"); 5219 } 5220 } 5221 push(@$outputArray, " };\n"); 5222 push(@$outputArray, " auto& eventNames = WebCore::eventNames();\n"); 5223 push(@$outputArray, " for (auto& names : table)\n"); 5224 push(@$outputArray, " function(names.first->get().localName(), eventNames.*names.second);\n"); 5225 push(@$outputArray, "}\n\n"); 5226 } 5227 5187 5228 sub GenerateAttributeGetterBodyDefinition 5188 5229 { -
trunk/Source/WebCore/bindings/scripts/IDLAttributes.json
r286916 r287019 228 228 } 229 229 }, 230 "GenerateAddOpaqueRoot": { 231 "contextsAllowed": ["interface"], 232 "values": ["*"] 233 }, 234 "GenerateForEachEventHandlerContentAttribute": { 235 "contextsAllowed": ["interface"], 236 "values": ["*"] 237 }, 238 "GenerateForEachWindowEventHandlerContentAttribute": { 239 "contextsAllowed": ["interface"], 240 "values": ["*"] 241 }, 230 242 "GenerateIsReachable": { 231 243 "contextsAllowed": ["interface"], 232 244 "values": ["", "Impl", "ImplWebGLRenderingContext", "ImplCanvasBase", "ImplDocument", "ImplElementRoot", "ImplOwnerNodeRoot", "ImplScriptExecutionContext", "ReachableFromDOMWindow", "ReachableFromNavigator"] 233 },234 "GenerateAddOpaqueRoot": {235 "contextsAllowed": ["interface"],236 "values": ["*"]237 245 }, 238 246 "Global": { -
trunk/Source/WebCore/html/HTMLAttributeNames.in
r286461 r287019 5 5 6 6 abbr 7 accept 7 8 accept_charset 8 accept9 9 accesskey 10 10 action … … 72 72 attributionsourceid 73 73 attributionsourcenonce 74 autocapitalize 74 75 autocomplete 76 autocorrect 75 77 autofocus 76 78 autopictureinpicture … … 85 87 bordercolor 86 88 capture 89 cellborder 87 90 cellpadding 88 91 cellspacing 92 challenge 89 93 char 90 challenge91 94 charoff 92 95 charset 93 96 checked 94 cellborder95 97 cite 96 98 class … … 126 128 draggable 127 129 dropzone 128 webkitdropzone129 130 enctype 130 131 end … … 179 180 longdesc 180 181 loop 181 low182 playcount183 182 loopend 184 183 loopstart 184 low 185 185 lowsrc 186 186 manifest … … 189 189 max 190 190 maxlength 191 minlength192 191 mayscript 193 192 media … … 195 194 method 196 195 min 196 minlength 197 197 multiple 198 198 muted … … 208 208 onabort 209 209 onafterprint 210 onanimationcancel 211 onanimationend 212 onanimationiteration 210 213 onanimationstart 211 onanimationiteration212 onanimationend213 onanimationcancel214 214 onautocomplete 215 215 onautocompleteerror … … 230 230 oncontextmenu 231 231 oncopy 232 oncuechange 232 233 oncut 233 234 ondblclick … … 248 249 onfocusout 249 250 onformdata 251 ongesturechange 252 ongestureend 253 ongesturestart 254 ongotpointercapture 250 255 onhashchange 251 256 oninput … … 254 259 onkeypress 255 260 onkeyup 256 ongesturestart257 ongesturechange258 ongestureend259 ongotpointercapture260 261 onlanguagechange 261 262 onload … … 273 274 onmouseup 274 275 onmousewheel 276 onoffline 275 277 ononline 276 onoffline277 278 onorientationchange 278 279 onpagehide … … 282 283 onplay 283 284 onplaying 285 onpointercancel 284 286 onpointerdown 285 onpointermove286 onpointerup287 onpointercancel288 onpointerover289 onpointerout290 287 onpointerenter 291 288 onpointerleave 289 onpointermove 290 onpointerout 291 onpointerover 292 onpointerup 292 293 onpopstate 293 294 onprogress 294 295 onratechange 296 onrejectionhandled 295 297 onreset 296 298 onresize … … 301 303 onseeking 302 304 onselect 305 onselectionchange 303 306 onselectstart 304 onselectionchange305 307 onslotchange 306 onwheel307 308 onstalled 308 309 onstorage 310 onsubmit 309 311 onsuspend 310 onsubmit311 312 ontimeupdate 312 313 ontoggle 314 ontouchcancel 315 ontouchend 313 316 ontouchforcechange 317 ontouchmove 314 318 ontouchstart 315 ontouchmove316 ontouchend317 ontouchcancel318 319 ontransitioncancel 319 320 ontransitionend 320 321 ontransitionrun 321 322 ontransitionstart 323 onunhandledrejection 322 324 onunload 323 325 onvolumechange 324 326 onwaiting 327 onwebkitanimationend 328 onwebkitanimationiteration 325 329 onwebkitanimationstart 326 onwebkitanimationiteration327 onwebkitanimationend328 330 onwebkitbeginfullscreen 331 onwebkitcurrentplaybacktargetiswirelesschanged 329 332 onwebkitendfullscreen 330 333 onwebkitfullscreenchange … … 338 341 onwebkitmouseforcewillbegin 339 342 onwebkitneedkey 343 onwebkitplaybacktargetavailabilitychanged 344 onwebkitpresentationmodechanged 340 345 onwebkitsourceclose 341 346 onwebkitsourceended 342 347 onwebkitsourceopen 343 348 onwebkittransitionend 349 onwheel 344 350 open 345 351 optimum 346 352 part 347 353 pattern 354 ping 348 355 placeholder 356 playcount 349 357 playsinline 350 358 pluginspage 351 359 pluginurl 352 ping353 360 poster 354 361 precision … … 386 393 sortdirection 387 394 span 388 x-webkit-speech389 x-webkit-grammar390 395 spellcheck 391 396 src 392 srcset393 397 srcdoc 394 398 srclang 399 srcset 395 400 standby 396 401 start … … 417 422 vlink 418 423 vspace 424 webkit-playsinline 419 425 webkitallowfullscreen 426 webkitattachmentbloburl 420 427 webkitattachmentid 421 428 webkitattachmentpath 422 webkitattachmentbloburl423 429 webkitdirectory 430 webkitdropzone 424 431 width 425 432 wrap 426 427 autocorrect 428 autocapitalize 429 onwebkitcurrentplaybacktargetiswirelesschanged 430 onwebkitplaybacktargetavailabilitychanged 431 onwebkitpresentationmodechanged 433 x-apple-data-detectors 434 x-apple-data-detectors-result 435 x-apple-data-detectors-type 436 x-apple-pdf-annotation 437 x-itunes-inherit-uri-query-component 438 x-webkit-airplay 439 x-webkit-grammar 432 440 x-webkit-imagemenu 433 webkit-playsinline 434 x-webkit-airplay 441 x-webkit-speech 435 442 x-webkit-wirelessvideoplaybackdisabled 436 x-itunes-inherit-uri-query-component437 438 x-apple-data-detectors439 x-apple-data-detectors-type440 x-apple-data-detectors-result441 442 x-apple-pdf-annotation -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r286223 r287019 4 4 * (C) 2000 Simon Hausmann (hausmann@kde.org) 5 5 * (C) 2001 Dirk Mueller (mueller@kde.org) 6 * Copyright (C) 2004-20 19Apple Inc. All rights reserved.6 * Copyright (C) 2004-2021 Apple Inc. All rights reserved. 7 7 * 8 8 * This library is free software; you can redistribute it and/or … … 36 36 #include "HTMLNames.h" 37 37 #include "HTMLParserIdioms.h" 38 #include "JSHTMLBodyElement.h" 38 39 #include "StyleProperties.h" 39 40 #include <wtf/IsoMallocInlines.h> … … 97 98 } 98 99 99 HTMLElement::EventHandlerNameMap HTMLBodyElement::createWindowEventHandlerNameMap()100 {101 static const QualifiedName* const table[] = {102 &onafterprintAttr.get(),103 &onbeforeprintAttr.get(),104 &onbeforeunloadAttr.get(),105 &onblurAttr.get(),106 &onerrorAttr.get(),107 &onfocusAttr.get(),108 &onfocusinAttr.get(),109 &onfocusoutAttr.get(),110 &onhashchangeAttr.get(),111 &onlanguagechangeAttr.get(),112 &onloadAttr.get(),113 &onmessageAttr.get(),114 &onofflineAttr.get(),115 &ononlineAttr.get(),116 &onorientationchangeAttr.get(),117 &onpagehideAttr.get(),118 &onpageshowAttr.get(),119 &onpopstateAttr.get(),120 &onresizeAttr.get(),121 &onscrollAttr.get(),122 &onstorageAttr.get(),123 &onunloadAttr.get(),124 &onwebkitmouseforcechangedAttr.get(),125 &onwebkitmouseforcedownAttr.get(),126 &onwebkitmouseforceupAttr.get(),127 &onwebkitmouseforcewillbeginAttr.get(),128 };129 130 EventHandlerNameMap map;131 populateEventHandlerNameMap(map, table);132 return map;133 }134 135 100 const AtomString& HTMLBodyElement::eventNameForWindowEventHandlerAttribute(const QualifiedName& attributeName) 136 101 { 137 static NeverDestroyed<EventHandlerNameMap> map = createWindowEventHandlerNameMap(); 138 return eventNameForEventHandlerAttribute(attributeName, map.get()); 102 static NeverDestroyed map = [] { 103 EventHandlerNameMap map; 104 JSHTMLBodyElement::forEachWindowEventHandlerContentAttribute([&] (const AtomString& attributeName, const AtomString& eventName) { 105 // 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. 106 if (attributeName == onrejectionhandledAttr.get().localName() || attributeName == onunhandledrejectionAttr.get().localName()) 107 return; 108 map.add(attributeName.impl(), eventName); 109 }); 110 return map; 111 }(); 112 return eventNameForEventHandlerAttribute(attributeName, map); 139 113 } 140 114 -
trunk/Source/WebCore/html/HTMLBodyElement.h
r278277 r287019 52 52 53 53 void addSubresourceAttributeURLs(ListHashSet<URL>&) const final; 54 55 static EventHandlerNameMap createWindowEventHandlerNameMap();56 54 }; 57 55 -
trunk/Source/WebCore/html/HTMLBodyElement.idl
r267935 r287019 20 20 21 21 [ 22 Exposed=Window 22 Exposed=Window, 23 GenerateForEachWindowEventHandlerContentAttribute, 23 24 ] interface HTMLBodyElement : HTMLElement { 24 25 [CEReactions=NotNeeded, Reflect] attribute [LegacyNullToEmptyString] DOMString aLink; -
trunk/Source/WebCore/html/HTMLElement.cpp
r286898 r287019 2 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * Copyright (C) 2004-202 0Apple Inc. All rights reserved.4 * Copyright (C) 2004-2021 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 6 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. … … 62 62 #include "HTMLTextFormControlElement.h" 63 63 #include "ImageOverlay.h" 64 #include "JSHTMLElement.h" 64 65 #include "MediaControlsHost.h" 65 66 #include "NodeTraversal.h" … … 241 242 } 242 243 243 HTMLElement::EventHandlerNameMap HTMLElement::createEventHandlerNameMap()244 {245 EventHandlerNameMap map;246 247 static const QualifiedName* const table[] = {248 &onabortAttr.get(),249 &onanimationendAttr.get(),250 &onanimationiterationAttr.get(),251 &onanimationstartAttr.get(),252 &onanimationcancelAttr.get(),253 &onautocompleteAttr.get(),254 &onautocompleteerrorAttr.get(),255 &onbeforecopyAttr.get(),256 &onbeforecutAttr.get(),257 &onbeforeinputAttr.get(),258 &onbeforeloadAttr.get(),259 &onbeforepasteAttr.get(),260 &onblurAttr.get(),261 &oncancelAttr.get(),262 &oncanplayAttr.get(),263 &oncanplaythroughAttr.get(),264 &onchangeAttr.get(),265 &onclickAttr.get(),266 &oncloseAttr.get(),267 &oncontextmenuAttr.get(),268 &oncopyAttr.get(),269 &oncutAttr.get(),270 &ondblclickAttr.get(),271 &ondragAttr.get(),272 &ondragendAttr.get(),273 &ondragenterAttr.get(),274 &ondragleaveAttr.get(),275 &ondragoverAttr.get(),276 &ondragstartAttr.get(),277 &ondropAttr.get(),278 &ondurationchangeAttr.get(),279 &onemptiedAttr.get(),280 &onendedAttr.get(),281 &onerrorAttr.get(),282 &onfocusAttr.get(),283 &onfocusinAttr.get(),284 &onfocusoutAttr.get(),285 &onformdataAttr.get(),286 &ongesturechangeAttr.get(),287 &ongestureendAttr.get(),288 &ongesturestartAttr.get(),289 &ongotpointercaptureAttr.get(),290 &oninputAttr.get(),291 &oninvalidAttr.get(),292 &onkeydownAttr.get(),293 &onkeypressAttr.get(),294 &onkeyupAttr.get(),295 &onloadAttr.get(),296 &onloadeddataAttr.get(),297 &onloadedmetadataAttr.get(),298 &onloadstartAttr.get(),299 &onlostpointercaptureAttr.get(),300 &onmousedownAttr.get(),301 &onmouseenterAttr.get(),302 &onmouseleaveAttr.get(),303 &onmousemoveAttr.get(),304 &onmouseoutAttr.get(),305 &onmouseoverAttr.get(),306 &onmouseupAttr.get(),307 &onmousewheelAttr.get(),308 &onpasteAttr.get(),309 &onpauseAttr.get(),310 &onplayAttr.get(),311 &onplayingAttr.get(),312 &onpointerdownAttr.get(),313 &onpointermoveAttr.get(),314 &onpointerupAttr.get(),315 &onpointercancelAttr.get(),316 &onpointeroverAttr.get(),317 &onpointeroutAttr.get(),318 &onpointerenterAttr.get(),319 &onpointerleaveAttr.get(),320 &onprogressAttr.get(),321 &onratechangeAttr.get(),322 &onresetAttr.get(),323 &onresizeAttr.get(),324 &onscrollAttr.get(),325 &onsearchAttr.get(),326 &onsecuritypolicyviolationAttr.get(),327 &onseekedAttr.get(),328 &onseekingAttr.get(),329 &onselectAttr.get(),330 &onselectionchangeAttr.get(),331 &onselectstartAttr.get(),332 &onslotchangeAttr.get(),333 &onstalledAttr.get(),334 &onsubmitAttr.get(),335 &onsuspendAttr.get(),336 &ontimeupdateAttr.get(),337 &ontoggleAttr.get(),338 &ontouchcancelAttr.get(),339 &ontouchendAttr.get(),340 &ontouchforcechangeAttr.get(),341 &ontouchmoveAttr.get(),342 &ontouchstartAttr.get(),343 &ontransitioncancelAttr.get(),344 &ontransitionendAttr.get(),345 &ontransitionrunAttr.get(),346 &ontransitionstartAttr.get(),347 &onvolumechangeAttr.get(),348 &onwaitingAttr.get(),349 &onwebkitbeginfullscreenAttr.get(),350 &onwebkitcurrentplaybacktargetiswirelesschangedAttr.get(),351 &onwebkitendfullscreenAttr.get(),352 &onwebkitfullscreenchangeAttr.get(),353 &onwebkitfullscreenerrorAttr.get(),354 &onwebkitkeyaddedAttr.get(),355 &onwebkitkeyerrorAttr.get(),356 &onwebkitkeymessageAttr.get(),357 &onwebkitmouseforcechangedAttr.get(),358 &onwebkitmouseforcedownAttr.get(),359 &onwebkitmouseforcewillbeginAttr.get(),360 &onwebkitmouseforceupAttr.get(),361 &onwebkitneedkeyAttr.get(),362 &onwebkitplaybacktargetavailabilitychangedAttr.get(),363 &onwebkitpresentationmodechangedAttr.get(),364 &onwheelAttr.get(),365 };366 367 populateEventHandlerNameMap(map, table);368 369 struct UnusualMapping {370 const QualifiedName& attributeName;371 const AtomString& eventName;372 };373 374 const UnusualMapping unusualPairsTable[] = {375 { onwebkitanimationendAttr, eventNames().webkitAnimationEndEvent },376 { onwebkitanimationiterationAttr, eventNames().webkitAnimationIterationEvent },377 { onwebkitanimationstartAttr, eventNames().webkitAnimationStartEvent },378 { onwebkittransitionendAttr, eventNames().webkitTransitionEndEvent },379 };380 381 for (auto& entry : unusualPairsTable)382 map.add(entry.attributeName.localName().impl(), entry.eventName);383 384 return map;385 }386 387 void HTMLElement::populateEventHandlerNameMap(EventHandlerNameMap& map, const QualifiedName* const table[], size_t tableSize)388 {389 for (size_t i = 0; i < tableSize; ++i) {390 auto* entry = table[i];391 392 // FIXME: Would be nice to check these against the actual event names in eventNames().393 // Not obvious how to do that simply, though.394 auto& attributeName = entry->localName();395 396 // Remove the "on" prefix. Requires some memory allocation and computing a hash, but by not397 // using pointers from eventNames(), the passed-in table can be initialized at compile time.398 AtomString eventName = attributeName.string().substring(2);399 400 map.add(attributeName.impl(), WTFMove(eventName));401 }402 }403 404 244 const AtomString& HTMLElement::eventNameForEventHandlerAttribute(const QualifiedName& attributeName, const EventHandlerNameMap& map) 405 245 { … … 421 261 const AtomString& HTMLElement::eventNameForEventHandlerAttribute(const QualifiedName& attributeName) 422 262 { 423 static NeverDestroyed<EventHandlerNameMap> map = createEventHandlerNameMap(); 424 return eventNameForEventHandlerAttribute(attributeName, map.get()); 263 static NeverDestroyed map = [] { 264 EventHandlerNameMap map; 265 JSHTMLElement::forEachEventHandlerContentAttribute([&] (const AtomString& attributeName, const AtomString& eventName) { 266 // FIXME: Remove this special case. This has an [EventHandler] line in the IDL but was not historically in this map. 267 if (attributeName == oncuechangeAttr.get().localName()) 268 return; 269 map.add(attributeName.impl(), eventName); 270 }); 271 // FIXME: Remove these special cases. These are not in IDL with [EventHandler] but were historically in this map. 272 static constexpr const LazyNeverDestroyed<const QualifiedName>* table[] = { 273 &onautocompleteAttr, 274 &onautocompleteerrorAttr, 275 &onbeforeloadAttr, 276 &onfocusinAttr, 277 &onfocusoutAttr, 278 &ongesturechangeAttr, 279 &ongestureendAttr, 280 &ongesturestartAttr, 281 &onwebkitbeginfullscreenAttr, 282 &onwebkitcurrentplaybacktargetiswirelesschangedAttr, 283 &onwebkitendfullscreenAttr, 284 &onwebkitfullscreenchangeAttr, 285 &onwebkitfullscreenerrorAttr, 286 &onwebkitkeyaddedAttr, 287 &onwebkitkeyerrorAttr, 288 &onwebkitkeymessageAttr, 289 &onwebkitneedkeyAttr, 290 &onwebkitplaybacktargetavailabilitychangedAttr, 291 &onwebkitpresentationmodechangedAttr, 292 }; 293 for (auto& entry : table) { 294 auto* name = entry->get().localName().impl(); 295 map.add(name, AtomString { name, 2, String::MaxLength }); 296 } 297 return map; 298 }(); 299 return eventNameForEventHandlerAttribute(attributeName, map); 425 300 } 426 301 -
trunk/Source/WebCore/html/HTMLElement.h
r285655 r287019 162 162 void calculateAndAdjustDirectionality(); 163 163 164 typedef HashMap<AtomStringImpl*, AtomString> EventHandlerNameMap; 165 template<size_t tableSize> static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const (&table)[tableSize]); 164 using EventHandlerNameMap = HashMap<AtomStringImpl*, AtomString>; 166 165 static const AtomString& eventNameForEventHandlerAttribute(const QualifiedName& attributeName, const EventHandlerNameMap&); 167 166 … … 175 174 void adjustDirectionalityIfNeededAfterChildrenChanged(Element* beforeChange, ChildChange::Type); 176 175 TextDirection directionality(Node** strongDirectionalityTextNode= 0) const; 177 178 static void populateEventHandlerNameMap(EventHandlerNameMap&, const QualifiedName* const table[], size_t tableSize);179 static EventHandlerNameMap createEventHandlerNameMap();180 176 181 177 enum class AllowPercentage : bool { No, Yes }; … … 191 187 } 192 188 193 template<size_t tableSize> inline void HTMLElement::populateEventHandlerNameMap(EventHandlerNameMap& map, const QualifiedName* const (&table)[tableSize])194 {195 populateEventHandlerNameMap(map, table, tableSize);196 }197 198 189 inline bool Node::hasTagName(const HTMLQualifiedName& name) const 199 190 { -
trunk/Source/WebCore/html/HTMLElement.idl
r283463 r287019 22 22 CustomPushEventHandlerScope, 23 23 ExportMacro=WEBCORE_EXPORT, 24 Exposed=Window, 25 GenerateForEachEventHandlerContentAttribute, 24 26 JSGenerateToNativeObject, 25 Exposed=Window26 27 ] interface HTMLElement : Element { 27 28 [Custom] constructor();
Note:
See TracChangeset
for help on using the changeset viewer.