Bug 207438

Summary: Optimize Style::determineChange()
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: CSSAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, ews-watchlist, glenn, koivisto, kondapallykalyan, pdr, sabouhallawa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
koivisto: review+
Patch none

Description Simon Fraser (smfr) 2020-02-08 21:15:54 PST
Optimize Style::determineChange()
Comment 1 Simon Fraser (smfr) 2020-02-08 21:19:52 PST
Created attachment 390194 [details]
Patch
Comment 2 Antti Koivisto 2020-02-09 05:50:31 PST
Comment on attachment 390194 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390194&action=review

> Source/WebCore/rendering/style/RenderStyle.cpp:451
> +bool RenderStyle::alignItemsEqual(const RenderStyle& other) const
> +{
> +    return m_rareNonInheritedData.ptr() == other.m_rareNonInheritedData.ptr()
> +        || m_rareNonInheritedData->alignItems == other.m_rareNonInheritedData->alignItems;
> +}
> +
> +bool RenderStyle::justifyItemsEqual(const RenderStyle& other) const
> +{
> +    return m_rareNonInheritedData.ptr() == other.m_rareNonInheritedData.ptr()
> +        || m_rareNonInheritedData->justifyItems == other.m_rareNonInheritedData->justifyItems;
> +}

Combining these ("alignAndJustifyItemsEqual") would eliminate one m_rareNonInheritedData comparison.
Comment 3 Simon Fraser (smfr) 2020-02-09 07:51:52 PST
(In reply to Antti Koivisto from comment #2)
> Comment on attachment 390194 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=390194&action=review
> 
> > Source/WebCore/rendering/style/RenderStyle.cpp:451
> > +bool RenderStyle::alignItemsEqual(const RenderStyle& other) const
> > +{
> > +    return m_rareNonInheritedData.ptr() == other.m_rareNonInheritedData.ptr()
> > +        || m_rareNonInheritedData->alignItems == other.m_rareNonInheritedData->alignItems;
> > +}
> > +
> > +bool RenderStyle::justifyItemsEqual(const RenderStyle& other) const
> > +{
> > +    return m_rareNonInheritedData.ptr() == other.m_rareNonInheritedData.ptr()
> > +        || m_rareNonInheritedData->justifyItems == other.m_rareNonInheritedData->justifyItems;
> > +}
> 
> Combining these ("alignAndJustifyItemsEqual") would eliminate one
> m_rareNonInheritedData comparison.

I thought about that. Wasn't sure what to name the function.
Comment 4 Simon Fraser (smfr) 2020-02-09 08:19:29 PST
Created attachment 390204 [details]
Patch
Comment 5 Antti Koivisto 2020-02-09 09:24:23 PST
Comment on attachment 390204 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390204&action=review

> Source/WebCore/style/StyleChange.cpp:56
> +    if (!s1.childAffectingFlexPropertiesEqual(s2))
> +        return Inherit;

Seems like this also affects grid.

Could also be something more generic like descendantStyleAffectingNonInheritedPropertiesEqual
Comment 6 Simon Fraser (smfr) 2020-02-09 20:11:10 PST
https://trac.webkit.org/changeset/256102/webkit
Comment 7 Radar WebKit Bug Importer 2020-02-09 20:12:13 PST
<rdar://problem/59300384>