Bug 145860 - [CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces
Summary: [CSS Grid Layout] Fix grid-template-areas parsing to avoid spaces
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Manuel Rego Casasnovas
URL:
Keywords:
Depends on: 145927
Blocks: 60731
  Show dependency treegraph
 
Reported: 2015-06-10 15:28 PDT by Manuel Rego Casasnovas
Modified: 2015-06-12 18:33 PDT (History)
6 users (show)

See Also:


Attachments
Patch (8.35 KB, patch)
2015-06-10 15:38 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (9.93 KB, patch)
2015-06-11 07:07 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-mavericks-wk2 (904.08 KB, application/zip)
2015-06-11 08:43 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews101 for mac-mavericks (696.47 KB, application/zip)
2015-06-11 08:46 PDT, Build Bot
no flags Details
Patch (10.48 KB, patch)
2015-06-11 11:38 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.51 KB, patch)
2015-06-11 13:38 PDT, Manuel Rego Casasnovas
no flags Details | Formatted Diff | Diff
Patch (10.38 KB, patch)
2015-06-12 13:52 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 2015-06-10 15:28:58 PDT
We should allow to remove the spaces between the dots and the idents (for reference see discussion at CSS WG mailing list: https://lists.w3.org/Archives/Public/www-style/2015May/0239.html).

So, the following example:
  grid-template-areas: ". title ."
                       "nav main aside";
should be equivalent to:
  grid-template-areas: "....title....."
                       "nav main aside";
and:
  grid-template-areas: ".title."
                       "nav main aside";
Comment 1 Manuel Rego Casasnovas 2015-06-10 15:38:50 PDT
Created attachment 254686 [details]
Patch
Comment 2 Sergio Villar Senin 2015-06-11 02:08:23 PDT
Comment on attachment 254686 [details]
Patch

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

Looking good but I think we can improve the tokenization...

> Source/WebCore/css/CSSParser.cpp:5994
> +        areaName.append(text[i]);

Instead of appending one by one, I think it would be better to keep track of the index of the start of the area name, and then just simply do a substring() call (perhaps even substringSharingImpl()) as gridRowNames will be valid throughout the whole life of columnNames I think)

> LayoutTests/fast/css-grid-layout/grid-template-areas-get-set.html:80
> +}

Although you already consider some of them I think we should have separate test cases for the following situations:
a) ....A
b) A..
c) ...A..
d) A.B
e) ..A.B
f) A.B..
g) ..A..B...
Comment 3 Manuel Rego Casasnovas 2015-06-11 07:07:34 PDT
Created attachment 254720 [details]
Patch
Comment 4 Manuel Rego Casasnovas 2015-06-11 07:10:42 PDT
Thanks for the review!

(In reply to comment #2)
> > Source/WebCore/css/CSSParser.cpp:5994
> > +        areaName.append(text[i]);
> 
> Instead of appending one by one, I think it would be better to keep track of
> the index of the start of the area name, and then just simply do a
> substring() call (perhaps even substringSharingImpl()) as gridRowNames will
> be valid throughout the whole life of columnNames I think)

Yeah I think this approach makes the code a bit simpler.

> > LayoutTests/fast/css-grid-layout/grid-template-areas-get-set.html:80
> > +}
> 
> Although you already consider some of them I think we should have separate
> test cases for the following situations:
> a) ....A
> b) A..
> c) ...A..
> d) A.B
> e) ..A.B
> f) A.B..
> g) ..A..B...

I've added more cases like these ones and other too.
Comment 5 Sergio Villar Senin 2015-06-11 08:35:53 PDT
Comment on attachment 254720 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:5971
> +    while (index < text.length()) {

let's cache text.length() in a local variable in order not to repeat the same call over and over again.

> Source/WebCore/css/CSSParser.cpp:5975
> +                index++;

I think it's ok to use a single line for this.

> Source/WebCore/css/CSSParser.cpp:5982
> +                index++;

Ditto.

> LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt:21
> +PASS getComputedStyle(gridWithDotsNoSpace).getPropertyValue('-webkit-grid-template-areas') is "\". title . nav . . main test\""

Seems like you forgot to upload all the new expectations?
Comment 6 Build Bot 2015-06-11 08:43:32 PDT
Comment on attachment 254720 [details]
Patch

Attachment 254720 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5739303049101312

New failing tests:
fast/css-grid-layout/grid-template-areas-get-set.html
Comment 7 Build Bot 2015-06-11 08:43:34 PDT
Created attachment 254722 [details]
Archive of layout-test-results from ews107 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 8 Build Bot 2015-06-11 08:46:04 PDT
Comment on attachment 254720 [details]
Patch

Attachment 254720 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4917405222436864

New failing tests:
fast/css-grid-layout/grid-template-areas-get-set.html
Comment 9 Build Bot 2015-06-11 08:46:07 PDT
Created attachment 254723 [details]
Archive of layout-test-results from ews101 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 10 Manuel Rego Casasnovas 2015-06-11 11:38:24 PDT
Created attachment 254735 [details]
Patch
Comment 11 WebKit Commit Bot 2015-06-11 11:42:06 PDT
Attachment 254735 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:5975:  More than one command on the same line in while  [whitespace/parens] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:5981:  More than one command on the same line in while  [whitespace/parens] [4]
Total errors found: 2 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Manuel Rego Casasnovas 2015-06-11 13:38:18 PDT
Created attachment 254754 [details]
Patch
Comment 13 Manuel Rego Casasnovas 2015-06-12 00:30:49 PDT
Thanks for the review.

(In reply to comment #5)
> Comment on attachment 254720 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=254720&action=review
> 
> > Source/WebCore/css/CSSParser.cpp:5971
> > +    while (index < text.length()) {
> 
> let's cache text.length() in a local variable in order not to repeat the
> same call over and over again.

Done.

> > Source/WebCore/css/CSSParser.cpp:5975
> > +                index++;
> 
> I think it's ok to use a single line for this.

It seems the style checker didn't like it.

> > LayoutTests/fast/css-grid-layout/grid-template-areas-get-set-expected.txt:21
> > +PASS getComputedStyle(gridWithDotsNoSpace).getPropertyValue('-webkit-grid-template-areas') is "\". title . nav . . main test\""
> 
> Seems like you forgot to upload all the new expectations?

True :-)
Comment 14 WebKit Commit Bot 2015-06-12 01:20:12 PDT
Comment on attachment 254754 [details]
Patch

Clearing flags on attachment: 254754

Committed r185492: <http://trac.webkit.org/changeset/185492>
Comment 15 WebKit Commit Bot 2015-06-12 01:20:16 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Csaba Osztrogonác 2015-06-12 04:37:42 PDT
(In reply to comment #14)
> Comment on attachment 254754 [details]
> Patch
> 
> Clearing flags on attachment: 254754
> 
> Committed r185492: <http://trac.webkit.org/changeset/185492>

It caused 11 assertions on Apple's debug bots:
https://build.webkit.org/builders/Apple%20Mavericks%20Debug%20WK2%20%28Tests%29/builds/12379
Comment 17 WebKit Commit Bot 2015-06-12 05:45:10 PDT
Re-opened since this is blocked by bug 145927
Comment 18 Manuel Rego Casasnovas 2015-06-12 13:52:54 PDT
Created attachment 254817 [details]
Patch
Comment 19 Manuel Rego Casasnovas 2015-06-12 13:56:26 PDT
(In reply to comment #16)
> (In reply to comment #14)
> > Comment on attachment 254754 [details]
> > Patch
> > 
> > Clearing flags on attachment: 254754
> > 
> > Committed r185492: <http://trac.webkit.org/changeset/185492>
> 
> It caused 11 assertions on Apple's debug bots:
> https://build.webkit.org/builders/
> Apple%20Mavericks%20Debug%20WK2%20%28Tests%29/builds/12379

Yes it was a silly mistake "index < length" was the last condition at:
  while (text[index] != ' ' && text[index] != '.' && index < length)

When it should be the first one. :-(
Comment 20 Manuel Rego Casasnovas 2015-06-12 14:01:57 PDT
Comment on attachment 254817 [details]
Patch

Clearing flags on attachment: 254817

Committed r185520: <http://trac.webkit.org/changeset/185520>
Comment 21 Manuel Rego Casasnovas 2015-06-12 14:02:07 PDT
All reviewed patches have been landed.  Closing bug.
Comment 22 Darin Adler 2015-06-12 18:33:38 PDT
Comment on attachment 254817 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:5964
> +static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNames)

Could save some memory allocation by making this take a StringView and return a Vector<StringView>. Then can convert to a string when we need to. Probably a bit of a project, though.