haikuwebkit/LayoutTests/platform/win/fast
Yusuke Suzuki dff5f5ddfa Skip shadow-root creation for input element if it is not necessary
https://bugs.webkit.org/show_bug.cgi?id=227189

Reviewed by Maciej Stachowiak.

Source/WebCore:

Test: fast/forms/checkbox-child-hidden.html

Cherry-pick Chromium optimizations[1,2] for input element and extend the coverage for more types.

Some of input element (e.g. checkbox) do not need to create a shadow-root since they do not have shadow-subtree.
This patch optimizes input element creation by skipping creation of shadow-root for these input types.

Since HTMLTextFormControlElement::childShouldCreateRenderer creates renderer only for children under shadow-root,
we do not need to consider about the case appending an element to checkbox etc. They will not get renderers.

We also replace HTMLInputElement related class' override with final if they are final to make class-hierarchy more explicit
and not to miss the change that needs to be done in the derived classes.

On M1 MBP, this patch improves Speedometer2 by 0.8%.

[1]: https://chromium-review.googlesource.com/c/chromium/src/+/773180
[2]: https://chromium-review.googlesource.com/c/chromium/src/+/826426 (but this is not necessary in WebKit since HTMLTextFormControlElement::childShouldCreateRenderer does the right thing elegantly)

* dom/Element.cpp:
(WebCore::Element::ensureUserAgentShadowRoot):
(WebCore::Element::createUserAgentShadowRoot):
* dom/Element.h:
* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):
* html/BaseDateAndTimeInputType.h:
(WebCore::BaseDateAndTimeInputType::BaseDateAndTimeInputType):
* html/ColorInputType.cpp:
(WebCore::ColorInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):
* html/ColorInputType.h:
* html/FileInputType.cpp:
(WebCore::FileInputType::FileInputType):
(WebCore::FileInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::create):
(WebCore::HTMLInputElement::createShadowSubtreeAndUpdateInnerTextElementEditability):
(WebCore::HTMLInputElement::updateType): It is possible that shadow root is already created for the previous InputType.
So we should use ensureUserAgentShadowRoot.
(WebCore::HTMLInputElement::initializeInputType): Since this is called at initialization time, we can use createUserAgentShadowRoot
instead of ensureUserAgentShadowRoot.
(WebCore::HTMLInputElement::didAddUserAgentShadowRoot): Deleted. Clean up the logic instead of relying on this callback.
Since HTMLInputElement can replace InputType, while we need to create shadow-subtree when InputType is replaced,
this callback could not be called since shadow-root is already created for the previous InputType. Not relying on this
callback makes the logic much simpler: explicitly create shadow-root and shadow-subtree.
* html/HTMLInputElement.h:
* html/InputType.h:
(WebCore::InputType::needsShadowSubtree const): Since this is in the critical path, we need this super optimized implementation.
Button, checkbox, hidden, image, radio, reset, and submit do not require shadow root.
* html/RangeInputType.cpp:
(WebCore::RangeInputType::RangeInputType):
(WebCore::RangeInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):
* html/SearchInputType.cpp:
(WebCore::SearchInputType::SearchInputType):
(WebCore::SearchInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::TextFieldInputType):
(WebCore::TextFieldInputType::createShadowSubtreeAndUpdateInnerTextElementEditability):

LayoutTests:

* fast/forms/checkbox-and-pseudo-expected.txt: Added.
* fast/forms/checkbox-and-pseudo.html: Added.
* fast/forms/checkbox-child-hidden-expected.html: Added.
* fast/forms/checkbox-child-hidden.html: Added.

Canonical link: https://commits.webkit.org/238974@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279054 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-20 10:53:42 +00:00
..
attachment
backgrounds
block
body-propagation
borders
box-shadow
box-sizing
canvas
clip
compact
css
css-generated-content
css3-text/css3-text-decoration
doctypes
dom Tools: 2020-10-16 14:46:00 +00:00
dynamic
encoding
events
fast-mobile-scrolling
flexbox
forms Skip shadow-root creation for input element if it is not necessary 2021-06-20 10:53:42 +00:00
frames
gradients
harness
hidpi Remove unused JS and CSS files of media controls 2021-03-22 22:17:49 +00:00
html
images
inline
inline-block
inspector-support
invalid
layers Remove unused JS and CSS files of media controls 2021-03-22 22:17:49 +00:00
layoutformattingcontext
line-grid
lists
loader
media/w3c
multicol
overflow
parser
reflections
regions
repaint Remove duplicate layout test results 2020-08-03 17:27:52 +00:00
replaced
ruby
scrolling
selectors
shrink-wrap
spatial-navigation
sub-pixel
table [AutoTableLayout] REGRESSION(r263855) Paypal email is rendered right aligned on Safari 2020-08-11 16:40:49 +00:00
text Make fast/text/international/complex-character-based-fallback.html more robust by migrating it to be a reftest instead of a DRT test 2021-01-12 23:13:15 +00:00
tokenizer
transforms
url
writing-mode
xmlhttprequest
xsl
ondrop-text-html-expected.txt
render-tree-as-text-options-expected.txt