Bug 190303 - Properly determine if css custom property values are computationally independent
Summary: Properly determine if css custom property values are computationally independent
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Justin Michaud
URL:
Keywords: InRadar
Depends on:
Blocks: 189692
  Show dependency treegraph
 
Reported: 2018-10-04 22:52 PDT by Justin Michaud
Modified: 2018-10-06 06:58 PDT (History)
7 users (show)

See Also:


Attachments
Patch (25.27 KB, patch)
2018-10-04 23:12 PDT, Justin Michaud
no flags Details | Formatted Diff | Diff
Patch (24.78 KB, patch)
2018-10-05 11:13 PDT, Justin Michaud
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Michaud 2018-10-04 22:52:46 PDT
Currently, in order to avoid computationally dependent initial values, a simple substring check is used. This should be replaced with something that can actually parse the value.
Comment 1 Justin Michaud 2018-10-04 23:12:11 PDT
Created attachment 351657 [details]
Patch
Comment 2 Justin Michaud 2018-10-04 23:13:33 PDT
I moved the serialization code because this change uncovered a bug in the way I was parsing initial values.
Comment 3 Antti Koivisto 2018-10-05 03:12:05 PDT
Comment on attachment 351657 [details]
Patch

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

Looks generally fine, but one more round would be good.

> Source/WebCore/css/CSSCalculationValue.cpp:282
> +    void getDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const final
> +    {
> +        auto dependencies = m_value->getDirectComputationalDependencies();
> +        values.add(dependencies.begin(), dependencies.end());
> +    }
> +
> +    void getDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const final
> +    {
> +        auto dependencies = m_value->getDirectRootComputationalDependencies();
> +        values.add(dependencies.begin(), dependencies.end());
> +    }

Maybe all versions of these functions should take the HashSet as an argument?  It would avoid moving values from one hash to another.

> Source/WebCore/css/CSSCalculationValue.h:73
> +    virtual void getDirectComputationalDependencies(HashSet<CSSPropertyID>&) const = 0;
> +    virtual void getDirectRootComputationalDependencies(HashSet<CSSPropertyID>&) const = 0;

collect* instead of get* would be better names for these.

> Source/WebCore/css/CSSCalculationValue.h:108
> +    HashSet<CSSPropertyID> getDirectComputationalDependencies() const;
> +    HashSet<CSSPropertyID> getDirectRootComputationalDependencies() const;

Here too. It signals they are not cheap accessors.

> Source/WebCore/css/CSSCustomPropertyValue.cpp:51
> +Vector<CSSParserToken>& CSSCustomPropertyValue::tokens(const CSSRegisteredCustomPropertySet& registeredProperties, const RenderStyle& style) const
> +{
> +    m_tokensReturnValue.clear();

It appears m_tokensReturnValue is only needed so you can return a reference? It is not clear to me how that is better than just returning the vector as a value and it is certainly more bug prone. Move semantics should keep it cheap. An alternative is the pass the vector in as a reference parameter (and call this something like collectTokens).

> Source/WebCore/css/CSSPrimitiveValue.cpp:1231
> +        return HashSet<CSSPropertyID>({CSSPropertyFontSize});

I think you can just say

return { CSSPropertyFontSize };

> Source/WebCore/css/CSSPrimitiveValue.cpp:1235
> +    return HashSet<CSSPropertyID>();

return { };

> Source/WebCore/css/CSSPrimitiveValue.cpp:1246
> +    return HashSet<CSSPropertyID>();

return { };

> Source/WebCore/css/CSSValue.cpp:124
> +    return HashSet<CSSPropertyID>();

return { };

> Source/WebCore/css/CSSValue.cpp:131
> +    return HashSet<CSSPropertyID>();

return { };
Comment 4 Justin Michaud 2018-10-05 11:13:38 PDT
Created attachment 351682 [details]
Patch
Comment 5 WebKit Commit Bot 2018-10-06 06:57:23 PDT
Comment on attachment 351682 [details]
Patch

Clearing flags on attachment: 351682

Committed r236895: <https://trac.webkit.org/changeset/236895>
Comment 6 WebKit Commit Bot 2018-10-06 06:57:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2018-10-06 06:58:30 PDT
<rdar://problem/45067859>