WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
222159
Avoid tree traversals to look for form and canvas elements
https://bugs.webkit.org/show_bug.cgi?id=222159
Summary
Avoid tree traversals to look for form and canvas elements
Ryosuke Niwa
Reported
2021-02-18 21:58:42 PST
We can avoid traversing DOM tree up to find canvas/form elements.
Attachments
WIP
(11.58 KB, patch)
2021-02-18 21:59 PST
,
Ryosuke Niwa
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
WIP2 - alternative approach
(25.52 KB, patch)
2021-02-23 22:32 PST
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Patch
(31.24 KB, patch)
2021-02-24 18:11 PST
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Updated for trunk
(26.89 KB, patch)
2021-02-25 00:18 PST
,
Ryosuke Niwa
koivisto
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2021-02-18 21:59:13 PST
Created
attachment 420921
[details]
WIP
Ryosuke Niwa
Comment 2
2021-02-23 22:32:58 PST
Created
attachment 421386
[details]
WIP2 - alternative approach
Radar WebKit Bug Importer
Comment 3
2021-02-23 22:35:45 PST
<
rdar://problem/74680265
>
Ryosuke Niwa
Comment 4
2021-02-24 18:11:36 PST
Created
attachment 421490
[details]
Patch
Simon Fraser (smfr)
Comment 5
2021-02-24 22:09:52 PST
Comment on
attachment 421490
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=421490&action=review
> Source/WebCore/dom/Element.cpp:2404 > + if (init.delegatesFocus) > + setDelegatesFocusToShadowRoot();
Would be nice to split these changes into another patch.
> Source/WebCore/dom/Node.h:927 > + if (states.contains(AncestorState::Canvas))
I'd prefer a blank line above this.
> Source/WebCore/html/HTMLFormElement.cpp:915 > + if (UNLIKELY(is<HTMLFormElement>(startElement))) { > + auto* parentElement = startElement.parentElement(); > + if (!parentElement || !parentElement->inclusiveAncestorStates().contains(AncestorState::Form)) { > + ASSERT(!ancestorsOfType<HTMLFormElement>(startElement).first()); > + return nullptr; > + } > + }
Why don't we add firstAncestorsOfType<> and use it everywhere we do ancestorsOfType<>().first()?
Ryosuke Niwa
Comment 6
2021-02-24 23:35:02 PST
(In reply to Simon Fraser (smfr) from
comment #5
)
> Comment on
attachment 421490
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=421490&action=review
> > > Source/WebCore/dom/Element.cpp:2404 > > + if (init.delegatesFocus) > > + setDelegatesFocusToShadowRoot(); > > Would be nice to split these changes into another patch.
Done that in the
bug 222404
.
> > Source/WebCore/dom/Node.h:927 > > + if (states.contains(AncestorState::Canvas)) > > I'd prefer a blank line above this.
Done.
> > Source/WebCore/html/HTMLFormElement.cpp:915 > > + if (UNLIKELY(is<HTMLFormElement>(startElement))) { > > + auto* parentElement = startElement.parentElement(); > > + if (!parentElement || !parentElement->inclusiveAncestorStates().contains(AncestorState::Form)) { > > + ASSERT(!ancestorsOfType<HTMLFormElement>(startElement).first()); > > + return nullptr; > > + } > > + } > > Why don't we add firstAncestorsOfType<> and use it everywhere we do > ancestorsOfType<>().first()?
That sounds like a good idea. Probably in a separate patch though.
Ryosuke Niwa
Comment 7
2021-02-25 00:18:33 PST
Created
attachment 421508
[details]
Updated for trunk
Antti Koivisto
Comment 8
2021-02-25 00:49:34 PST
Comment on
attachment 421508
[details]
Updated for trunk View in context:
https://bugs.webkit.org/attachment.cgi?id=421508&action=review
> Source/WebCore/html/HTMLFormElement.cpp:912 > + if (!parentElement || !parentElement->inclusiveAncestorStates().contains(AncestorState::Form)) { > + ASSERT(!ancestorsOfType<HTMLFormElement>(startElement).first());
Maybe you should make ancestorsOfType and pals to do these checks (based on the type obv) so all future code benefits too.
Ryosuke Niwa
Comment 9
2021-02-25 00:51:18 PST
(In reply to Antti Koivisto from
comment #8
)
> Comment on
attachment 421508
[details]
> Updated for trunk > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=421508&action=review
> > > Source/WebCore/html/HTMLFormElement.cpp:912 > > + if (!parentElement || !parentElement->inclusiveAncestorStates().contains(AncestorState::Form)) { > > + ASSERT(!ancestorsOfType<HTMLFormElement>(startElement).first()); > > Maybe you should make ancestorsOfType and pals to do these checks (based on > the type obv) so all future code benefits too.
Oh you mean as a type specialization for HTMLFormElement? That might be a neat idea. If we spot a few more of these, it might be worth doing.
Ryosuke Niwa
Comment 10
2021-02-25 00:51:41 PST
Thanks for the reviews, Antti & Simon!
Antti Koivisto
Comment 11
2021-02-25 00:51:54 PST
> > Why don't we add firstAncestorsOfType<> and use it everywhere we do > > ancestorsOfType<>().first()? > > That sounds like a good idea. Probably in a separate patch though.
Please don't increase complexity for no gain. That literally just saves one '.' of typing.
Antti Koivisto
Comment 12
2021-02-25 00:58:49 PST
> Oh you mean as a type specialization for HTMLFormElement? That might be a > neat idea. If we spot a few more of these, it might be worth doing.
Or maybe have a static field that gives the bit to test.
Ryosuke Niwa
Comment 13
2021-02-25 00:59:47 PST
(In reply to Antti Koivisto from
comment #11
)
> > > Why don't we add firstAncestorsOfType<> and use it everywhere we do > > > ancestorsOfType<>().first()? > > > > That sounds like a good idea. Probably in a separate patch though. > > Please don't increase complexity for no gain. That literally just saves one > '.' of typing.
I think it's more to do with the fact "first" comes at the end split with (~). Maybe what we need if something like firstIfExists(ancestorsOfType<>(~))
Ryosuke Niwa
Comment 14
2021-02-25 01:01:41 PST
(In reply to Antti Koivisto from
comment #12
)
> > Oh you mean as a type specialization for HTMLFormElement? That might be a > > neat idea. If we spot a few more of these, it might be worth doing. > > Or maybe have a static field that gives the bit to test.
Yeah, but I'm imagining it's a template specialization based on whether that bit is available or not. I agree we don't want to repeat all this code for each element type.
Ryosuke Niwa
Comment 15
2021-02-25 01:02:59 PST
Committed
r273479
(
234558@main
): <
https://commits.webkit.org/234558@main
>
Antti Koivisto
Comment 16
2021-02-25 01:17:44 PST
> Yeah, but I'm imagining it's a template specialization based on whether that > bit is available or not. I agree we don't want to repeat all this code for > each element type.
if constexpr () is probably all that is needed
WebKit Commit Bot
Comment 17
2021-02-27 01:27:29 PST
Re-opened since this is blocked by
bug 222510
Ryosuke Niwa
Comment 18
2021-02-27 01:32:37 PST
This was not an overall speed up after all.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug