[webkit-changes] [WebKit/WebKit] b691e0: ElementInternals.setFormValue(<nullish value>) doe...
Commit Queue
noreply at github.com
Tue Jul 18 07:31:30 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: b691e0b9a450ba727548c89af3a44b011deae058
https://github.com/WebKit/WebKit/commit/b691e0b9a450ba727548c89af3a44b011deae058
Author: Alexey Shvayka <ashvayka at apple.com>
Date: 2023-07-18 (Tue, 18 Jul 2023)
Changed paths:
A LayoutTests/fast/forms/state-restore-form-associated-custom-elements-2-expected.txt
A LayoutTests/fast/forms/state-restore-form-associated-custom-elements-2.html
M LayoutTests/fast/forms/state-restore-form-associated-custom-elements.html
A LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-setFormValue-nullish-value-expected.txt
A LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-setFormValue-nullish-value.html
M Source/WebCore/bindings/js/JSCustomElementInterface.cpp
M Source/WebCore/bindings/js/JSElementInternalsCustom.cpp
M Source/WebCore/dom/ElementInternals.cpp
M Source/WebCore/dom/ElementInternals.h
M Source/WebCore/dom/ElementInternals.idl
M Source/WebCore/html/CustomElementFormValue.h
M Source/WebCore/html/FormAssociatedCustomElement.cpp
M Source/WebCore/html/FormAssociatedCustomElement.h
Log Message:
-----------
ElementInternals.setFormValue(<nullish value>) doesn't clear submission value
https://bugs.webkit.org/show_bug.cgi?id=258870
<rdar://problem/111802198>
Reviewed by Ryosuke Niwa.
With current bindings implementation, given an optional nullish interface / union type without default value,
it's impossible to distiungish in DOM code whether a null / undefined was passed or an argument was missing:
both compile to std::nullopt.
This was causing two bugs in ElementInternals.setFormValue() [1]:
1) nullish `value` parameter was not clearing the submission value;
2) nullish `state` parameter was perceived as missing and the `value` was used instead.
On one hand, we could revise all WebIDL files with optional nullish interface / union types to ensure that
we don't have extra / missing default values (oftentimes we do), and then make ones without defaults values
compile to std::nullopt (for missing argument) / std::nullptr_t (for nullish argument).
On the other, that would be quite massive change and this distinction isn't current needed anywhere but
ElementInternals.setFormValue(), so this change hand-rolls custom bindings just for this method, fixing
both issues by checking argument count and leveraging std::nullptr_t.
[1] https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-setformvalue
* LayoutTests/fast/forms/state-restore-form-associated-custom-elements-2-expected.txt: Added.
* LayoutTests/fast/forms/state-restore-form-associated-custom-elements-2.html: Added.
* LayoutTests/fast/forms/state-restore-form-associated-custom-elements.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-setFormValue-nullish-value-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/ElementInternals-setFormValue-nullish-value.html: Added.
* Source/WebCore/bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::invokeFormStateRestoreCallback):
* Source/WebCore/bindings/js/JSElementInternalsCustom.cpp:
(WebCore::JSElementInternals::setFormValue):
* Source/WebCore/dom/ElementInternals.cpp:
(WebCore::ElementInternals::setFormValue):
* Source/WebCore/dom/ElementInternals.h:
* Source/WebCore/dom/ElementInternals.idl:
* Source/WebCore/html/CustomElementFormValue.h:
* Source/WebCore/html/FormAssociatedCustomElement.cpp:
(WebCore::FormAssociatedCustomElement::setFormValue):
(WebCore::FormAssociatedCustomElement::appendFormData):
(WebCore::FormAssociatedCustomElement::saveFormControlState const):
* Source/WebCore/html/FormAssociatedCustomElement.h:
Canonical link: https://commits.webkit.org/266126@main
More information about the webkit-changes
mailing list