Bug 158021 - [css-grid] Simplify grid track sizes parsing
Summary: [css-grid] Simplify grid track sizes parsing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Manuel Rego Casasnovas
URL:
Keywords: BlinkMergeCandidate
Depends on: 158064
Blocks: 60731 158063
  Show dependency treegraph
 
Reported: 2016-05-24 04:18 PDT by Manuel Rego Casasnovas
Modified: 2016-05-25 07:43 PDT (History)
4 users (show)

See Also:


Attachments
Patch (10.78 KB, patch)
2016-05-24 04:36 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
=Patch for landing (10.92 KB, patch)
2016-05-25 01:50 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.92 KB, patch)
2016-05-25 06:12 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.90 KB, patch)
2016-05-25 07:11 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Rego Casasnovas 2016-05-24 04:18:47 PDT
This is a port from a Blink patch:
https://codereview.chromium.org/1998033003/
Comment 1 Manuel Rego Casasnovas 2016-05-24 04:36:14 PDT
Created attachment 279644 [details]
Patch
Comment 2 Sergio Villar Senin 2016-05-25 00:47:57 PDT
Comment on attachment 279644 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:5823
> +    const CSSPrimitiveValue& primitiveValue = value.isPrimitiveValue()

I think we could use here auto& as it's pretty clear from the right side that we have a CSSPrimitiveValue.

> Source/WebCore/css/CSSParser.cpp:5830
>      return true;

Perhaps adding and ASSERT just before the return here?

> Source/WebCore/css/CSSParser.cpp:5867
> +                allTracksAreFixedSized = isGridTrackFixedSized(*value);

What about

allTracksAreFixedSized = allTracksAreFixedSized && isGridTrackFixedSized(*value);

> Source/WebCore/css/CSSParser.cpp:5925
> +            allTracksAreFixedSized = isGridTrackFixedSized(*trackSize);

Ditto.

> Source/WebCore/css/CSSParser.cpp:5995
>          return CSSValuePool::singleton().createIdentifierValue(value.id);

You should remove the braces as there is only one instruction in the if block.
Comment 3 Manuel Rego Casasnovas 2016-05-25 01:50:49 PDT
Created attachment 279748 [details]
=Patch for landing
Comment 4 Manuel Rego Casasnovas 2016-05-25 01:51:27 PDT
Comment on attachment 279644 [details]
Patch

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

Thanks for the quick review!

>> Source/WebCore/css/CSSParser.cpp:5823
>> +    const CSSPrimitiveValue& primitiveValue = value.isPrimitiveValue()
> 
> I think we could use here auto& as it's pretty clear from the right side that we have a CSSPrimitiveValue.

Done.

>> Source/WebCore/css/CSSParser.cpp:5830
>>      return true;
> 
> Perhaps adding and ASSERT just before the return here?

Yeah, I'll add it.

>> Source/WebCore/css/CSSParser.cpp:5867
>> +                allTracksAreFixedSized = isGridTrackFixedSized(*value);
> 
> What about
> 
> allTracksAreFixedSized = allTracksAreFixedSized && isGridTrackFixedSized(*value);

In that case, even when allTracksAreFixedSized is FALSE, we'll be calling isGridTrackFixedSized() over and over.
With the current code, once allTracksAreFixedSized is FALSE, we don't call isGridTrackFixedSized() anymore.

>> Source/WebCore/css/CSSParser.cpp:5925
>> +            allTracksAreFixedSized = isGridTrackFixedSized(*trackSize);
> 
> Ditto.

Ditto. :-)

>> Source/WebCore/css/CSSParser.cpp:5995
>>          return CSSValuePool::singleton().createIdentifierValue(value.id);
> 
> You should remove the braces as there is only one instruction in the if block.

Done.
Comment 5 WebKit Commit Bot 2016-05-25 02:21:29 PDT
Comment on attachment 279748 [details]
=Patch for landing

Clearing flags on attachment: 279748

Committed r201373: <http://trac.webkit.org/changeset/201373>
Comment 6 WebKit Commit Bot 2016-05-25 02:21:32 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Darin Adler 2016-05-25 03:52:57 PDT
Comment on attachment 279748 [details]
=Patch for landing

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

> Source/WebCore/css/CSSParser.cpp:5822
> +    ASSERT(value.isPrimitiveValue() || (value.isFunctionValue() && downcast<CSSFunctionValue>(value).arguments()));

After this landed, we are hitting this assertion in isGridTrackFixedSized in parseGridTrackList in multiple tests. Because of that we will probably need to roll this change out.

The problem is that parseGridTrackList calls parseGridBreadth, which can return a numeric value. Then this function incorrectly asserts that it’s not a numeric value.
Comment 8 WebKit Commit Bot 2016-05-25 04:13:12 PDT
Re-opened since this is blocked by bug 158064
Comment 9 Manuel Rego Casasnovas 2016-05-25 06:12:30 PDT
Created attachment 279762 [details]
Patch
Comment 10 Manuel Rego Casasnovas 2016-05-25 06:13:03 PDT
View in context: https://bugs.webkit.org/attachment.cgi?id=279748&action=review

> Source/WebCore/css/CSSParser.cpp:5830
> +    ASSERT(primitiveValue.isLength());

We were actually hitting this ASSERT, as it's not enough to check that the CSSPrimitiveValue is length,
it doesn't include percentages or calc().

I've modified it to check the 3 cases and now the tests are passing in debug here.
Comment 11 Sergio Villar Senin 2016-05-25 06:33:55 PDT
(In reply to comment #4)
> Comment on attachment 279644 [details]
> >> Source/WebCore/css/CSSParser.cpp:5867
> >> +                allTracksAreFixedSized = isGridTrackFixedSized(*value);
> > 
> > What about
> > 
> > allTracksAreFixedSized = allTracksAreFixedSized && isGridTrackFixedSized(*value);
> 
> In that case, even when allTracksAreFixedSized is FALSE, we'll be calling
> isGridTrackFixedSized() over and over.
> With the current code, once allTracksAreFixedSized is FALSE, we don't call
> isGridTrackFixedSized() anymore.

The && operator in C++ shortcircuits meaning that the second part won't be evaluated.
Comment 12 Manuel Rego Casasnovas 2016-05-25 07:11:43 PDT
Created attachment 279767 [details]
Patch
Comment 13 WebKit Commit Bot 2016-05-25 07:43:40 PDT
Comment on attachment 279767 [details]
Patch

Clearing flags on attachment: 279767

Committed r201382: <http://trac.webkit.org/changeset/201382>
Comment 14 WebKit Commit Bot 2016-05-25 07:43:44 PDT
All reviewed patches have been landed.  Closing bug.