[webkit-changes] [WebKit/WebKit] 958618: Improve <textarea> validation performance

Darin Adler noreply at github.com
Tue Dec 6 10:37:09 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 95861845546f13626a0ea23d6eab4e513ff6f760
      https://github.com/WebKit/WebKit/commit/95861845546f13626a0ea23d6eab4e513ff6f760
  Author: Darin Adler <darin at apple.com>
  Date:   2022-12-06 (Tue, 06 Dec 2022)

  Changed paths:
    M Source/WebCore/html/FileInputType.cpp
    M Source/WebCore/html/FormController.cpp
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLInputElement.h
    M Source/WebCore/html/HTMLTextAreaElement.cpp
    M Source/WebCore/html/HTMLTextAreaElement.h
    M Source/WebCore/html/HTMLTextFormControlElement.cpp
    M Source/WebCore/html/HTMLTextFormControlElement.h
    M Source/WebCore/html/InputType.h
    M Source/WebCore/html/TextFieldInputType.cpp
    M Source/WebCore/html/TextFieldInputType.h
    M Source/WebCore/loader/EmptyClients.cpp
    M Source/WebCore/page/Chrome.cpp
    M Source/WebCore/platform/FileChooser.cpp
    M Source/WebCore/platform/FileChooser.h
    M Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm
    M Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElement.mm

  Log Message:
  -----------
  Improve <textarea> validation performance
https://bugs.webkit.org/show_bug.cgi?id=248447
rdar://problem/102909909

Reviewed by Ryosuke Niwa.

Added laziness to the HTMLTextAreaElement computation of validity. Also did style
tweaks and minor reorganization of the two text form element classes.

* Source/WebCore/html/FileInputType.cpp: Added include of FileChooser.h.
(WebCore::FileInputType::applyFileChooserSettings): Update to pass reference.

* Source/WebCore/html/FormController.cpp: Added include of FileChooser.h.

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::capsLockIndicatorElement const): Deleted.
(WebCore::HTMLInputElement::accept const): Deleted.
(WebCore::HTMLInputElement::isInRequiredRadioButtonGroup): Deleted.
(WebCore::HTMLInputElement::setRangeText): Removed unneeded overload and let
the base class version of setRangeText call the virtual one.

* Source/WebCore/html/HTMLInputElement.h: Removed unneeded includes.
Moved the functions for the IDL file to the top of the class, sorted in the
order that matches the IDL. Removed a few unused functions. Made three
public functions private. Tweaked comments.

* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::HTMLTextAreaElement): Removed the tag name argument.
(WebCore::HTMLTextAreaElement::create): Updated to not pass the tag name to the constructor.
(WebCore::HTMLTextAreaElement::formControlType const): Use textareaTag so we don't need a global.
(WebCore::HTMLTextAreaElement::collectPresentationalHintsForAttribute): Moved body of the
shouldWrapText in.
(WebCore::HTMLTextAreaElement::parseAttribute): Moved the bodies of maxLengthAttributeChanged,
and minLengthAttributeChanged in.
(WebCore::HTMLTextAreaElement::maxLengthAttributeChanged): Deleted.
(WebCore::HTMLTextAreaElement::minLengthAttributeChanged): Deleted.
(WebCore::HTMLTextAreaElement::appendFormData): Tweaked coding style.
(WebCore::HTMLTextAreaElement::hasCustomFocusLogic const): Moved to the class definition.
(WebCore::HTMLTextAreaElement::defaultTabIndex const): Ditto.
(WebCore::HTMLTextAreaElement::isKeyboardFocusable const): Ditto.
(WebCore::HTMLTextAreaElement::isMouseFocusable const): Ditto.
(WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent const): Call maxLength. Merge in the
sanitizeUserInputValue function.
(WebCore::HTMLTextAreaElement::sanitizeUserInputValue): Deleted.
(WebCore::HTMLTextAreaElement::rendererWillBeDestroyed): Moved to the class definition.
(WebCore::HTMLTextAreaElement::validationMessage const): Call maxLength.
(WebCore::HTMLTextAreaElement::valueMissing const): Pass null string for value, so the value will
be computed lazily. In the overload that takes a StringView, get the value lazily.
(WebCore::HTMLTextAreaElement::tooShort const): Ditto.
(WebCore::HTMLTextAreaElement::tooLong const): Ditto.
(WebCore::HTMLTextAreaElement::isValidValue const): Change type to StringView.
(WebCore::HTMLTextAreaElement::shouldUseInputMethod): Moved to the class definition.
(WebCore::HTMLTextAreaElement::placeholderElement const): Ditto.
(WebCore::HTMLTextAreaElement::matchesReadWritePseudoClass const): Ditto.
(WebCore::HTMLTextAreaElement::willRespondToMouseClickEventsWithEditability const): Ditto.

* Source/WebCore/html/HTMLTextAreaElement.h: Removed unneeded include. Moved the functions for the
IDL file to the top of the class, sorted in the order that matches the IDL. Removed some functions.
Moved some function bodies here. Use StringView more often.

* Source/WebCore/html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setRangeText): Take StringView.

* Source/WebCore/html/HTMLTextFormControlElement.h: Changed setRangeText to take a StringView.
Also made the single argument form non-virtual.

* Source/WebCore/html/InputType.h:
(WebCore::InputType::capsLockIndicatorElement const): Deleted.
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::capsLockIndicatorElement const): Deleted.
* Source/WebCore/html/TextFieldInputType.h: Deleted capsLockIndicatorElement.

* Source/WebCore/loader/EmptyClients.cpp: Deleted unneeded includes.
* Source/WebCore/page/Chrome.cpp: Ditto.

* Source/WebCore/platform/FileChooser.cpp:
(WebCore::FileChooser::FileChooser): Take a reference.
(WebCore::FileChooser::create): Ditto.

* Source/WebCore/platform/FileChooser.h: Updated for the above.

* Source/WebKitLegacy/mac/DOM/DOMHTMLInputElement.mm:
(-[DOMHTMLInputElement setRangeText:]): Create a String explicitly since the function now
takes a StringView.
(-[DOMHTMLInputElement setRangeText:start:end:selectionMode:]): Ditto.
* Source/WebKitLegacy/mac/DOM/DOMHTMLTextAreaElement.mm:
(-[DOMHTMLTextAreaElement setRangeText:]): Ditto.
(-[DOMHTMLTextAreaElement setRangeText:start:end:selectionMode:]): Ditto.

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




More information about the webkit-changes mailing list