Skip to content

Commit

Permalink
rename Invokers features from invoke to command
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=276616

Reviewed by NOBODY (OOPS!).

This renames the attributes invoketarget->commandfor and invokeaction->command,
as well as renaming the InvokeEvent to CommandEvent, and it's action property
to command. It also drops the `auto` action, requiring explicit
`command` attribute for each action.

Lastly, this also adds the logic preventing invokers from being triggered within
a form without an explicit type=button attribute.

These changes are based on a set of discussions around the proposals
naming and semantics, which starts here: whatwg/html#9625 (comment)
and concludes here; whatwg/html#9625 (comment)

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/idlharness.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invokeelement-interface.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invokeevent-dispatch-shadow.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invokeevent-interface.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-button-event-dispatch.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-on-popover-behavior.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-on-popover-invalid-behavior.tentative-expected.txt:
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/html/semantics/invokers/invoketarget-on-dialog-behavior.tentative-expected.txt.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Headers.cmake:
* Source/WebCore/SmartPointerExpectations/UncountedLocalVarsCheckerExpectations:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/dom/CommandEvent.cpp: Renamed from Source/WebCore/dom/InvokeEvent.cpp.
(WebCore::CommandEvent::CommandEvent):
(WebCore::CommandEvent::create):
(WebCore::CommandEvent::createForBindings):
(WebCore::CommandEvent::isCommandEvent const):
(WebCore::CommandEvent::invoker const):
* Source/WebCore/dom/CommandEvent.h: Renamed from Source/WebCore/dom/InvokeEvent.h.
* Source/WebCore/dom/CommandEvent.idl: Renamed from Source/WebCore/dom/InvokeEvent.idl.
* Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::handlePopoverLightDismiss):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::isElementReflectionAttribute):
* Source/WebCore/dom/Element.h:
(WebCore::Element::isValidCommandType):
(WebCore::Element::handleCommandInternal):
(WebCore::Element::isValidInvokeAction): Deleted.
(WebCore::Element::handleInvokeInternal): Deleted.
* Source/WebCore/dom/Event.h:
(WebCore::Event::isCommandEvent const):
(WebCore::Event::isInputEvent const):
(WebCore::Event::isInvokeEvent const): Deleted.
* Source/WebCore/dom/EventInterfaces.in:
* Source/WebCore/dom/EventNames.json:
* Source/WebCore/html/HTMLAttributeNames.in:
* Source/WebCore/html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):
* Source/WebCore/html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::isValidCommandType):
(WebCore::HTMLDialogElement::handleCommandInternal):
(WebCore::HTMLDialogElement::isValidInvokeAction): Deleted.
(WebCore::HTMLDialogElement::handleInvokeInternal): Deleted.
* Source/WebCore/html/HTMLDialogElement.h:
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::isValidCommandType):
(WebCore::HTMLElement::handleCommandInternal):
(WebCore::HTMLElement::isValidInvokeAction): Deleted.
(WebCore::HTMLElement::handleInvokeInternal): Deleted.
* Source/WebCore/html/HTMLElement.h:
* Source/WebCore/html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::commandForElement const):
(WebCore::HTMLFormControlElement::commandType const):
(WebCore::HTMLFormControlElement::handleCommand):
(WebCore::HTMLFormControlElement::invokeTargetElement const): Deleted.
(WebCore::HTMLFormControlElement::invokeAction const): Deleted.
(WebCore::HTMLFormControlElement::handleInvokeAction): Deleted.
* Source/WebCore/html/HTMLFormControlElement.h:
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler):
* Source/WebCore/html/InvokerElement.idl:
* Source/WebCore/page/FragmentDirective.h:
  • Loading branch information
keithamus committed Jul 25, 2024
1 parent ea5a4b0 commit 7e04cee
Show file tree
Hide file tree
Showing 40 changed files with 271 additions and 241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ PASS Element includes ParentNode: member names are unique
PASS Element includes NonDocumentTypeChildNode: member names are unique
PASS Element includes ChildNode: member names are unique
PASS Element includes Slottable: member names are unique
FAIL CommandEvent interface: existence and properties of interface object assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface object length assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface object name assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface: existence and properties of interface prototype object assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface: attribute invoker assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent interface: attribute command assert_own_property: self does not have own property "CommandEvent" expected property "CommandEvent" missing
FAIL CommandEvent must be primary interface of new CommandEvent("invoke") assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: CommandEvent"
FAIL Stringification of new CommandEvent("invoke") assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: CommandEvent"
FAIL CommandEvent interface: new CommandEvent("invoke") must inherit property "invoker" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: CommandEvent"
FAIL CommandEvent interface: new CommandEvent("invoke") must inherit property "command" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: CommandEvent"
PASS CommandEvent interface: existence and properties of interface object
PASS CommandEvent interface object length
PASS CommandEvent interface object name
PASS CommandEvent interface: existence and properties of interface prototype object
PASS CommandEvent interface: existence and properties of interface prototype object's "constructor" property
PASS CommandEvent interface: existence and properties of interface prototype object's @@unscopables property
PASS CommandEvent interface: attribute invoker
PASS CommandEvent interface: attribute command
PASS CommandEvent must be primary interface of new CommandEvent("invoke")
PASS Stringification of new CommandEvent("invoke")
PASS CommandEvent interface: new CommandEvent("invoke") must inherit property "invoker" with the proper type
PASS CommandEvent interface: new CommandEvent("invoke") must inherit property "command" with the proper type

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@


FAIL commandForElement reflects invokee HTML element assert_equals: expected (object) Element node <div id="invokee"></div> but got (undefined) undefined
FAIL commandForElement reflects set value assert_equals: expected "" but got "invokee"
FAIL commandForElement reflects set value across shadow root into light dom assert_equals: expected "" but got "invokee"
FAIL commandForElement does not reflect set value inside shadowroot assert_equals: expected null but got Element node <div></div>
FAIL commandForElement throws error on assignment of non Element assert_throws_js: commandForElement attribute must be an instance of Element function "function () {
invoker.commandForElement = {};
}" did not throw
FAIL command reflects '' when attribute empty, setAttribute version assert_equals: expected (string) "" but got (undefined) undefined
FAIL command reflects same casing assert_equals: expected "fooBarBaz" but got ""
PASS commandForElement reflects invokee HTML element
PASS commandForElement reflects set value
PASS commandForElement reflects set value across shadow root into light dom
PASS commandForElement does not reflect set value inside shadowroot
PASS commandForElement throws error on assignment of non Element
PASS command reflects '' when attribute empty, setAttribute version
PASS command reflects same casing
PASS command reflects '' when attribute empty, IDL version
FAIL command reflects tostring value assert_equals: expected "1,2,3" but got ""
FAIL command reflects '' when attribute set to [] assert_equals: expected (string) "" but got (object) []
FAIL command reflects tostring value 2 assert_equals: expected (string) "[object Object]" but got (object) object "[object Object]"
PASS command reflects tostring value
PASS command reflects '' when attribute set to []
PASS command reflects tostring value 2

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


FAIL CommandEvent propagates across shadow boundaries retargeting invoker Can't find variable: CommandEvent
FAIL cross shadow CommandEvent retargets invoker to host element Can't find variable: CommandEvent
PASS CommandEvent propagates across shadow boundaries retargeting invoker
PASS cross shadow CommandEvent retargets invoker to host element

Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@


FAIL command is a readonly defaulting to '' Can't find variable: CommandEvent
FAIL invoker is readonly defaulting to null Can't find variable: CommandEvent
FAIL command reflects initialized attribute Can't find variable: CommandEvent
FAIL command set to undefined Can't find variable: CommandEvent
FAIL command set to null Can't find variable: CommandEvent
FAIL command set to false Can't find variable: CommandEvent
FAIL command explicitly set to empty string Can't find variable: CommandEvent
FAIL command set to true Can't find variable: CommandEvent
FAIL command set to a number Can't find variable: CommandEvent
FAIL command set to [] Can't find variable: CommandEvent
FAIL command set to [1, 2, 3] Can't find variable: CommandEvent
FAIL command set to an object Can't find variable: CommandEvent
FAIL command set to an object with a toString function Can't find variable: CommandEvent
FAIL CommandEventInit properties set value Can't find variable: CommandEvent
FAIL CommandEventInit properties set value 2 Can't find variable: CommandEvent
FAIL CommandEventInit properties set value 3 Can't find variable: CommandEvent
FAIL invoker set to undefined Can't find variable: CommandEvent
FAIL invoker set to null Can't find variable: CommandEvent
FAIL invoker set to false assert_throws_js: invoker is not an object function "function () {
new CommandEvent("test", { invoker: false });
}" threw object "ReferenceError: Can't find variable: CommandEvent" ("ReferenceError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL invoker set to true assert_throws_js: invoker is not an object function "function () {
const event = new CommandEvent("test", { invoker: true });
}" threw object "ReferenceError: Can't find variable: CommandEvent" ("ReferenceError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL invoker set to {} assert_throws_js: invoker is not an object function "function () {
const event = new CommandEvent("test", { invoker: {} });
}" threw object "ReferenceError: Can't find variable: CommandEvent" ("ReferenceError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL invoker set to non-Element EventTarget assert_throws_js: invoker is not an Element function "function () {
const eventInit = { command: "closed", invoker: new XMLHttpRequest() };
const event = new CommandEvent("toggle", eventInit);
}" threw object "ReferenceError: Can't find variable: CommandEvent" ("ReferenceError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
PASS command is a readonly defaulting to ''
PASS invoker is readonly defaulting to null
PASS command reflects initialized attribute
PASS command set to undefined
PASS command set to null
PASS command set to false
PASS command explicitly set to empty string
PASS command set to true
PASS command set to a number
PASS command set to []
PASS command set to [1, 2, 3]
PASS command set to an object
PASS command set to an object with a toString function
PASS CommandEventInit properties set value
PASS CommandEventInit properties set value 2
PASS CommandEventInit properties set value 3
PASS invoker set to undefined
PASS invoker set to null
PASS invoker set to false
PASS invoker set to true
PASS invoker set to {}
PASS invoker set to non-Element EventTarget

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@


FAIL event dispatches on click promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to -foo (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to -foo (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to foo- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to foo- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to cAsE-cArRiEs (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to cAsE-cArRiEs (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to - (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to - (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to -a- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to -a- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to a-b (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to a-b (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to --- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to --- (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command property to show-picker (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
FAIL setting custom command attribute to show-picker (must include dash) sets event command promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: CommandEvent"
PASS event dispatches on click
PASS setting custom command property to -foo (must include dash) sets event command
PASS setting custom command attribute to -foo (must include dash) sets event command
PASS setting custom command property to foo- (must include dash) sets event command
PASS setting custom command attribute to foo- (must include dash) sets event command
PASS setting custom command property to cAsE-cArRiEs (must include dash) sets event command
PASS setting custom command attribute to cAsE-cArRiEs (must include dash) sets event command
PASS setting custom command property to - (must include dash) sets event command
PASS setting custom command attribute to - (must include dash) sets event command
PASS setting custom command property to -a- (must include dash) sets event command
PASS setting custom command attribute to -a- (must include dash) sets event command
PASS setting custom command property to a-b (must include dash) sets event command
PASS setting custom command attribute to a-b (must include dash) sets event command
PASS setting custom command property to --- (must include dash) sets event command
PASS setting custom command attribute to --- (must include dash) sets event command
PASS setting custom command property to show-picker (must include dash) sets event command
PASS setting custom command attribute to show-picker (must include dash) sets event command
PASS setting custom command property to foo (no dash) did not dispatch an event
PASS setting custom command attribute to foo (no dash) did not dispatch an event
PASS setting custom command property to foobar (no dash) did not dispatch an event
Expand All @@ -30,6 +30,6 @@ PASS setting custom command attribute to hidedocument (no dash) did not dispatch
PASS event does not dispatch if click:preventDefault is called
PASS event does not dispatch if invoker is disabled
PASS event does not dispatch if invoker is form associated without `type`
FAIL event dispatches if invoker is form associated with `type=button` assert_true: event was not called expected true got false
FAIL event dispatches if invokee is non-HTML Element assert_equals: expected (object) Element node <svg id="svg-invokee"></svg> but got (undefined) undefined
PASS event dispatches if invoker is form associated with `type=button`
PASS event dispatches if invokee is non-HTML Element

Loading

0 comments on commit 7e04cee

Please sign in to comment.