Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readonly attribute should only apply on certain input types #3115

Merged
merged 1 commit into from Aug 11, 2022

Conversation

nt1m
Copy link
Member

@nt1m nt1m commented Aug 8, 2022

af43ca3

readonly attribute should only apply on certain input types
https://bugs.webkit.org/show_bug.cgi?id=240343
<rdar://93173726>

Reviewed by Chris Dumez.

We should only apply the readonly attribute on certain input types: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
Except in the constraint validation case (willValidate) for compat reasons, since it affects the :in-range/:out-of-range pseudo-classes, the relevant test has been updated to reflect that.
This also was the resolution of whatwg/html#8133 in the HTML spec triage meeting.

Also introduce isMutable() which corresponds to the spec concept of mutable form control.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt: Added.
* Source/WebCore/html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::valueMissing const):
(WebCore::BaseDateAndTimeInputType::handleDOMActivateEvent):
* Source/WebCore/html/ColorInputType.cpp:
(WebCore::ColorInputType::isKeyboardFocusable const):
* Source/WebCore/html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::HTMLFormControlElement):
(WebCore::HTMLFormControlElement::parseAttribute):
(WebCore::HTMLFormControlElement::computeWillValidate const):
* Source/WebCore/html/HTMLFormControlElement.h:
(WebCore::HTMLFormControlElement::supportsReadOnly const):
(WebCore::HTMLFormControlElement::isReadOnly const):
(WebCore::HTMLFormControlElement::isMutable const):
(WebCore::HTMLFormControlElement::isDisabledOrReadOnly const): Deleted.
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
(WebCore::HTMLInputElement::supportsReadOnly const):
(WebCore::HTMLInputElement::showPicker):
(WebCore::HTMLInputElement::matchesReadWritePseudoClass const):
(WebCore::HTMLInputElement::createInnerTextStyle):
* Source/WebCore/html/HTMLInputElement.h:
* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::matchesReadWritePseudoClass const):
* Source/WebCore/html/HTMLTextAreaElement.h:
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::isInnerTextElementEditable const):
* Source/WebCore/html/SearchInputType.cpp:
(WebCore::SearchInputType::handleKeydownEvent):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::valueMissing const):
(WebCore::TextFieldInputType::handleKeydownEventForSpinButton):
(WebCore::TextFieldInputType::shouldSpinButtonRespondToMouseEvents const):
(WebCore::TextFieldInputType::shouldDrawCapsLockIndicator const):
(WebCore::TextFieldInputType::shouldDrawAutoFillButton const):
* Source/WebCore/html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::handleTouchEvent):
* Source/WebCore/html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
(WebCore::SearchFieldCancelButtonElement::willRespondToMouseClickEventsWithEditability const):

Canonical link: https://commits.webkit.org/253321@main

@nt1m nt1m requested review from cdumez and rniwa as code owners August 8, 2022 21:37
@nt1m nt1m self-assigned this Aug 8, 2022
@nt1m nt1m added Forms For bugs specific to form elements (checkboxes, buttons, text fields, etc.) WebKit Nightly Build labels Aug 8, 2022
@nt1m nt1m force-pushed the readonly branch 2 times, most recently from 865802e to 0a800d6 Compare August 8, 2022 21:40
@nt1m nt1m requested a review from pxlcoder August 8, 2022 21:48
Copy link
Member

@pxlcoder pxlcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to run this against perf bots, since I believe that HTMLInputElement::updateType is a hot codepath.

Source/WebCore/html/HTMLInputElement.cpp Outdated Show resolved Hide resolved
Source/WebCore/html/HTMLInputElement.cpp Outdated Show resolved Hide resolved
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 9, 2022
@nt1m nt1m removed the merging-blocked Applied to prevent a change from being merged label Aug 9, 2022
@nt1m nt1m force-pushed the readonly branch 2 times, most recently from ca7e887 to 5b53401 Compare August 9, 2022 15:13
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 9, 2022
@nt1m nt1m removed the merging-blocked Applied to prevent a change from being merged label Aug 9, 2022
Copy link
Contributor

@cdumez cdumez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

https://bugs.webkit.org/show_bug.cgi?id=240343
<rdar://93173726>

Reviewed by Chris Dumez.

We should only apply the readonly attribute on certain input types: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
Except in the constraint validation case (willValidate) for compat reasons, since it affects the :in-range/:out-of-range pseudo-classes, the relevant test has been updated to reflect that.
This also was the resolution of whatwg/html#8133 in the HTML spec triage meeting.

Also introduce isMutable() which corresponds to the spec concept of mutable form control.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate.html:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-willValidate-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/show-picker-disabled-readonly-expected.txt: Added.
* Source/WebCore/html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::valueMissing const):
(WebCore::BaseDateAndTimeInputType::handleDOMActivateEvent):
* Source/WebCore/html/ColorInputType.cpp:
(WebCore::ColorInputType::isKeyboardFocusable const):
* Source/WebCore/html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::HTMLFormControlElement):
(WebCore::HTMLFormControlElement::parseAttribute):
(WebCore::HTMLFormControlElement::computeWillValidate const):
* Source/WebCore/html/HTMLFormControlElement.h:
(WebCore::HTMLFormControlElement::supportsReadOnly const):
(WebCore::HTMLFormControlElement::isReadOnly const):
(WebCore::HTMLFormControlElement::isMutable const):
(WebCore::HTMLFormControlElement::isDisabledOrReadOnly const): Deleted.
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
(WebCore::HTMLInputElement::supportsReadOnly const):
(WebCore::HTMLInputElement::showPicker):
(WebCore::HTMLInputElement::matchesReadWritePseudoClass const):
(WebCore::HTMLInputElement::createInnerTextStyle):
* Source/WebCore/html/HTMLInputElement.h:
* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::matchesReadWritePseudoClass const):
* Source/WebCore/html/HTMLTextAreaElement.h:
* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::isInnerTextElementEditable const):
* Source/WebCore/html/SearchInputType.cpp:
(WebCore::SearchInputType::handleKeydownEvent):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::valueMissing const):
(WebCore::TextFieldInputType::handleKeydownEventForSpinButton):
(WebCore::TextFieldInputType::shouldSpinButtonRespondToMouseEvents const):
(WebCore::TextFieldInputType::shouldDrawCapsLockIndicator const):
(WebCore::TextFieldInputType::shouldDrawAutoFillButton const):
* Source/WebCore/html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::handleTouchEvent):
* Source/WebCore/html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler):
(WebCore::SearchFieldCancelButtonElement::willRespondToMouseClickEventsWithEditability const):

Canonical link: https://commits.webkit.org/253321@main
@webkit-commit-queue
Copy link
Collaborator

Committed 253321@main (af43ca3): https://commits.webkit.org/253321@main

Reviewed commits have been landed. Closing PR #3115 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit af43ca3 into WebKit:main Aug 11, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Aug 11, 2022
@nt1m nt1m deleted the readonly branch August 11, 2022 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Forms For bugs specific to form elements (checkboxes, buttons, text fields, etc.)
Projects
None yet
6 participants