Bug 143248 - [CSS MultiColumn] Parse "columns: auto <length>" shorthand property value properly
Summary: [CSS MultiColumn] Parse "columns: auto <length>" shorthand property value pro...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-30 19:24 PDT by Joonghun Park
Modified: 2015-04-02 01:52 PDT (History)
6 users (show)

See Also:


Attachments
Patch (15.24 KB, patch)
2015-03-31 02:10 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Patch (15.23 KB, patch)
2015-03-31 02:14 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Patch (15.23 KB, patch)
2015-03-31 02:25 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (610.21 KB, application/zip)
2015-03-31 02:45 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews105 for mac-mavericks-wk2 (590.08 KB, application/zip)
2015-03-31 03:03 PDT, Build Bot
no flags Details
Patch (15.23 KB, patch)
2015-03-31 03:32 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Patch (12.70 KB, patch)
2015-03-31 21:08 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (586.08 KB, application/zip)
2015-03-31 21:35 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews105 for mac-mavericks-wk2 (561.51 KB, application/zip)
2015-03-31 21:44 PDT, Build Bot
no flags Details
Patch (18.64 KB, patch)
2015-03-31 21:46 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff
Patch (18.46 KB, patch)
2015-04-01 22:54 PDT, Joonghun Park
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joonghun Park 2015-03-30 19:24:50 PDT
CSS multicolumn 'columns' shorthand property does not work properly when setting "auto <column-width>" to it.
According to http://www.w3.org/TR/2011/CR-css3-multicol-20110412/#columns,
setting 'columns' property to "auto(column-count) <column-width>" should work properly.
Comment 1 Joonghun Park 2015-03-31 02:10:18 PDT
Created attachment 249808 [details]
Patch
Comment 2 Joonghun Park 2015-03-31 02:14:21 PDT
Created attachment 249809 [details]
Patch
Comment 3 Joonghun Park 2015-03-31 02:25:00 PDT
Created attachment 249810 [details]
Patch
Comment 4 Build Bot 2015-03-31 02:45:04 PDT
Comment on attachment 249810 [details]
Patch

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

New failing tests:
fast/multicol/columns-shorthand-parsing-2.html
Comment 5 Build Bot 2015-03-31 02:45:08 PDT
Created attachment 249812 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 6 Build Bot 2015-03-31 03:03:10 PDT
Comment on attachment 249810 [details]
Patch

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

New failing tests:
fast/multicol/columns-shorthand-parsing-2.html
Comment 7 Build Bot 2015-03-31 03:03:17 PDT
Created attachment 249813 [details]
Archive of layout-test-results from ews105 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 8 Joonghun Park 2015-03-31 03:32:19 PDT
Created attachment 249815 [details]
Patch
Comment 9 Darin Adler 2015-03-31 10:39:57 PDT
Comment on attachment 249815 [details]
Patch

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

Where is the test case that covers “implicit” vs. “explicit”?

> Source/WebCore/css/CSSParser.cpp:3641
> +            return false; // Too many vlaues for this shorthand. Invalid declaration.

Typo "vlaues"

> Source/WebCore/css/CSSParser.cpp:3665
> +        // Time to assign the previously skipped 'auto' values to a property.
> +        // If both properties are unassigned at this point (i.e. 'columns:auto'),
> +        // it doesn't matter that much which one we set.
> +        // The one we don't set here will get an implicit 'auto' value further down.

If the implicit vs. explicit distinction matters, I don’t understand why it doesn’t matter in this case and an implicit auto is sufficient. To put it another way, if the implicit vs. explicit distinction did not matter, then we wouldn’t need hasPendingExplicitAuto at all!

> Source/WebCore/css/CSSParser.cpp:3680
> +        addProperty(CSSPropertyColumnWidth, cssValuePool().createIdentifierValue(CSSValueAuto), important, true /* implicit */);

I think this code should just pass !hasPendingExplicitAuto instead of passing "true" for implicit. Then we could get rid of the entire if statement above.

> Source/WebCore/css/CSSParser.cpp:3685
> +        addProperty(CSSPropertyColumnCount, cssValuePool().createIdentifierValue(CSSValueAuto), important, true /* implicit */);

Ditto.

> Source/WebCore/css/CSSParser.h:196
> +    PassRefPtr<CSSValue> parseColumnWidth();
> +    PassRefPtr<CSSValue> parseColumnCount();

For new functions, return type should just be RefPtr. There is no reason to use PassRefPtr for return values any more.
Comment 10 Joonghun Park 2015-03-31 21:08:29 PDT
Created attachment 249884 [details]
Patch
Comment 11 Joonghun Park 2015-03-31 21:11:28 PDT
(In reply to comment #9)
> Comment on attachment 249815 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=249815&action=review
> 
> Where is the test case that covers “implicit” vs. “explicit”?
> 
> > Source/WebCore/css/CSSParser.cpp:3641
> > +            return false; // Too many vlaues for this shorthand. Invalid declaration.
> 
> Typo "vlaues"
> 
> > Source/WebCore/css/CSSParser.cpp:3665
> > +        // Time to assign the previously skipped 'auto' values to a property.
> > +        // If both properties are unassigned at this point (i.e. 'columns:auto'),
> > +        // it doesn't matter that much which one we set.
> > +        // The one we don't set here will get an implicit 'auto' value further down.
> 
> If the implicit vs. explicit distinction matters, I don’t understand why it
> doesn’t matter in this case and an implicit auto is sufficient. To put it
> another way, if the implicit vs. explicit distinction did not matter, then
> we wouldn’t need hasPendingExplicitAuto at all!
> 
> > Source/WebCore/css/CSSParser.cpp:3680
> > +        addProperty(CSSPropertyColumnWidth, cssValuePool().createIdentifierValue(CSSValueAuto), important, true /* implicit */);
> 
> I think this code should just pass !hasPendingExplicitAuto instead of
> passing "true" for implicit. Then we could get rid of the entire if
> statement above.
> 
> > Source/WebCore/css/CSSParser.cpp:3685
> > +        addProperty(CSSPropertyColumnCount, cssValuePool().createIdentifierValue(CSSValueAuto), important, true /* implicit */);
> 
> Ditto.
> 
> > Source/WebCore/css/CSSParser.h:196
> > +    PassRefPtr<CSSValue> parseColumnWidth();
> > +    PassRefPtr<CSSValue> parseColumnCount();
> 
> For new functions, return type should just be RefPtr. There is no reason to
> use PassRefPtr for return values any more.

I applied your valuable comments in a new patch, so would you please review this patch again?
Comment 12 Build Bot 2015-03-31 21:35:19 PDT
Comment on attachment 249884 [details]
Patch

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

New failing tests:
fast/css/getPropertyValue-columns.html
Comment 13 Build Bot 2015-03-31 21:35:21 PDT
Created attachment 249887 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 14 Build Bot 2015-03-31 21:44:56 PDT
Comment on attachment 249884 [details]
Patch

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

New failing tests:
fast/css/getPropertyValue-columns.html
Comment 15 Build Bot 2015-03-31 21:44:59 PDT
Created attachment 249889 [details]
Archive of layout-test-results from ews105 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 16 Joonghun Park 2015-03-31 21:46:15 PDT
Created attachment 249890 [details]
Patch
Comment 17 Darin Adler 2015-04-01 09:27:27 PDT
Comment on attachment 249890 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:3618
> +RefPtr<CSSValue> CSSParser::parseColumnWidth()
> +{
> +    ValueWithCalculation valueWithCalculation(*m_valueList->current());
> +    CSSValueID id = valueWithCalculation.value().id;
> +    // Always parse this property in strict mode, since it would be ambiguous otherwise when used in the 'columns' shorthand property.
> +    if (id == CSSValueAuto || (validateUnit(valueWithCalculation, FLength | FNonNeg, CSSStrictMode) && parsedDouble(valueWithCalculation))) {
> +        RefPtr<CSSValue> parsedValue = parseValidPrimitive(id, valueWithCalculation);
> +        m_valueList->next();
> +        return parsedValue;
> +    }
> +
> +    return nullptr;
> +}

I think these functions would read better with early return (check for error and return nullptr) rather than nesting the normal code path inside an if.

> Source/WebCore/css/CSSParser.cpp:3661
> +    ASSERT(columnCount || coulmnWidth);

This will fail to compile because of the typo: coulmnWidth.

> LayoutTests/fast/css/getPropertyValue-columns.html:38
> +      shouldBeEqualToString('columnsValue("columns4")', 'auto auto');

Is this serialization of "auto" as "auto auto" correct behavior, or a bug?
Comment 18 Joonghun Park 2015-04-01 22:44:50 PDT
(In reply to comment #17)
> Comment on attachment 249890 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=249890&action=review
> 
> > Source/WebCore/css/CSSParser.cpp:3618
> > +RefPtr<CSSValue> CSSParser::parseColumnWidth()
> > +{
> > +    ValueWithCalculation valueWithCalculation(*m_valueList->current());
> > +    CSSValueID id = valueWithCalculation.value().id;
> > +    // Always parse this property in strict mode, since it would be ambiguous otherwise when used in the 'columns' shorthand property.
> > +    if (id == CSSValueAuto || (validateUnit(valueWithCalculation, FLength | FNonNeg, CSSStrictMode) && parsedDouble(valueWithCalculation))) {
> > +        RefPtr<CSSValue> parsedValue = parseValidPrimitive(id, valueWithCalculation);
> > +        m_valueList->next();
> > +        return parsedValue;
> > +    }
> > +
> > +    return nullptr;
> > +}
> 
> I think these functions would read better with early return (check for error
> and return nullptr) rather than nesting the normal code path inside an if.
> Yes, I'd apply it.
> > Source/WebCore/css/CSSParser.cpp:3661
> > +    ASSERT(columnCount || coulmnWidth);
> 
> This will fail to compile because of the typo: coulmnWidth.
> After applying your feedback, I found this assert statment is not safisfied when we are in "columns: auto" case. So I removed it.
> > LayoutTests/fast/css/getPropertyValue-columns.html:38
> > +      shouldBeEqualToString('columnsValue("columns4")', 'auto auto');
> 
> Is this serialization of "auto" as "auto auto" correct behavior, or a bug?
Hmm, it seems that spec doesn't say anything about it. In my opinion, 'auto auto' looks more consistent, but I choose to maintain current state.
Comment 19 Joonghun Park 2015-04-01 22:54:44 PDT
Created attachment 249962 [details]
Patch
Comment 20 Gyuyoung Kim 2015-04-01 23:52:58 PDT
Comment on attachment 249962 [details]
Patch

cq=me. It looks GTK ews is broken.
Comment 21 Gyuyoung Kim 2015-04-01 23:57:26 PDT
Comment on attachment 249890 [details]
Patch

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

>> Source/WebCore/css/CSSParser.cpp:3661
>> +    ASSERT(columnCount || coulmnWidth);
> 
> This will fail to compile because of the typo: coulmnWidth.

I missed this one. Why do you remove this ASSERT ?

Don't you need to add below ?

ASSERT(columnCount || columnWidth);
Comment 22 Joonghun Park 2015-04-02 00:09:21 PDT
(In reply to comment #21)
> Comment on attachment 249890 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=249890&action=review
> 
> >> Source/WebCore/css/CSSParser.cpp:3661
> >> +    ASSERT(columnCount || coulmnWidth);
> > 
> > This will fail to compile because of the typo: coulmnWidth.
> 
> I missed this one. Why do you remove this ASSERT ?
> 
> Don't you need to add below ?
> 
> ASSERT(columnCount || columnWidth);

As you can see in https://bugs.webkit.org/attachment.cgi?id=249815&action=review,
this patch originally included 'if (hasPendingExplicitAuto) clause' in CSSParser.cpp:3661.
But Darin pointed out that this is not necessary and can be more simplified, and told me how to do that. So I removed the assert statement applying darin's feedback. :)
Comment 23 WebKit Commit Bot 2015-04-02 01:52:13 PDT
Comment on attachment 249962 [details]
Patch

Clearing flags on attachment: 249962

Committed r182270: <http://trac.webkit.org/changeset/182270>
Comment 24 WebKit Commit Bot 2015-04-02 01:52:18 PDT
All reviewed patches have been landed.  Closing bug.