Bug 139334 - Get rid of error-prone ReleaseParsedCalcValueCondition argument in CSSParser
Summary: Get rid of error-prone ReleaseParsedCalcValueCondition argument in CSSParser
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-05 21:23 PST by Chris Dumez
Modified: 2014-12-21 17:52 PST (History)
4 users (show)

See Also:


Attachments
Patch (110.26 KB, patch)
2014-12-05 21:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (111.23 KB, patch)
2014-12-05 23:20 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (113.10 KB, patch)
2014-12-06 10:20 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (116.41 KB, patch)
2014-12-08 21:07 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (116.40 KB, patch)
2014-12-16 16:08 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (117.92 KB, patch)
2014-12-20 13:41 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (118.39 KB, patch)
2014-12-20 14:02 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (1.45 KB, patch)
2014-12-20 22:23 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2014-12-05 21:23:15 PST
Get rid of error-prone ReleaseParsedCalcValueCondition argument in CSSParser.
Comment 1 Chris Dumez 2014-12-05 21:53:08 PST
Created attachment 242702 [details]
Patch
Comment 2 WebKit Commit Bot 2014-12-05 21:55:24 PST
Attachment 242702 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1641:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:9357:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.h:705:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Chris Dumez 2014-12-05 23:20:28 PST
Created attachment 242704 [details]
Patch
Comment 4 WebKit Commit Bot 2014-12-05 23:22:16 PST
Attachment 242704 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1641:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:9358:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.h:705:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Chris Dumez 2014-12-06 10:20:05 PST
Created attachment 242718 [details]
Patch
Comment 6 WebKit Commit Bot 2014-12-06 10:21:26 PST
Attachment 242718 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1641:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:9358:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.h:705:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Darin Adler 2014-12-08 18:10:43 PST
Comment on attachment 242718 [details]
Patch

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

> Source/WebCore/ChangeLog:14
> +        the parsed calculation value is not associated with its CSSParserValue.

"is associated" rather than is *not* associated

> Source/WebCore/css/CSSParser.h:695
> +class CSSParserValueWithState {

What does “with state” mean? I am having trouble coming up with a good name, but the current name does not make sense to me. Maybe: CSSParserValueOrCalculation, CSSParserValueAndCalculation, or CSSParserValueWithCalculation.

Maybe we should consider making this a member of the CSSParser class to make the class name shorter in most of the code.

> Source/WebCore/css/CSSParser.h:704
> +    CSSCalcValue* parsedCalculation() const { return m_parsedCalculation.get(); }

Why the word “parsed” here? I don’t see how the calculation is any more “parsed” than the value is.

> Source/WebCore/css/CSSParser.h:705
> +    void setParsedCalculation(RefPtr<CSSCalcValue> calculation) { m_parsedCalculation = calculation; }

This should take PassRefPtr or a raw pointer, or alternatively use WTF::move in the function body.

> Source/WebCore/css/CSSParser.h:709
> +    private:
> +        CSSParserValue& m_value;
> +        RefPtr<CSSCalcValue> m_parsedCalculation;

This is not our normal indentation.
Comment 8 Chris Dumez 2014-12-08 19:01:11 PST
Comment on attachment 242718 [details]
Patch

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

>> Source/WebCore/css/CSSParser.h:705
>> +    void setParsedCalculation(RefPtr<CSSCalcValue> calculation) { m_parsedCalculation = calculation; }
> 
> This should take PassRefPtr or a raw pointer, or alternatively use WTF::move in the function body.

I hear we are transitioning away from PassRefPtr, which is why I used a RefPtr<> argument. I will add the WTF::move().
Comment 9 Chris Dumez 2014-12-08 21:07:55 PST
Created attachment 242877 [details]
Patch
Comment 10 WebKit Commit Bot 2014-12-08 21:09:56 PST
Attachment 242877 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1641:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:9356:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.h:93:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Chris Dumez 2014-12-16 16:08:18 PST
Created attachment 243402 [details]
Patch
Comment 12 WebKit Commit Bot 2014-12-16 16:11:04 PST
Attachment 243402 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1641:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:9356:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 2 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Darin Adler 2014-12-16 21:32:24 PST
Comment on attachment 243402 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:1584
> +bool CSSParser::validCalculationUnit(ValueWithCalculation& valueWithCalculation, Units unitflags)

I find this function very strange.

It’s name is “valid calculation unit”, so it should return a “calculation unit”. But also it has a side effect of filling in the calculation. That’s really unclear from the name of the function. I have the same problem with the function validUnit and the many other functions that store the calculation into the ValueWithCalculation as a side effect. I think these functions should be named “validate” instead of “valid”, but also, I think they may want to be more explicit about how they fill in the calculation.

It’s also wrong capitalization to have an argument named “unitflags” with all lower case.

> Source/WebCore/css/CSSParser.cpp:1711
> +        ASSERT(isCalculation(valueWithCalculation));

Seems to me that this assertion should be moved into the ValueWithCalculation class instead of done at this call site.

> Source/WebCore/css/CSSParser.cpp:1781
> +    if (isCalculation(valueWithCalculation))

I think this maybe should be checking valueWithCalculation.calculation() for null instead of calling isCalculation.

> Source/WebCore/css/CSSParser.h:90
> +        CSSParserValue& value() const { return m_value; }
> +        operator CSSParserValue&() { return m_value; }

There’s no reason for the CSSParserValue& operator to be non-const. It should be const too.
Comment 14 Chris Dumez 2014-12-20 13:41:01 PST
Created attachment 243608 [details]
Patch
Comment 15 WebKit Commit Bot 2014-12-20 13:43:39 PST
Attachment 243608 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1642:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:1651:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/css/CSSParser.cpp:9359:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 16 Chris Dumez 2014-12-20 14:02:52 PST
Created attachment 243609 [details]
Patch
Comment 17 WebKit Commit Bot 2014-12-20 14:05:02 PST
Attachment 243609 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSParser.cpp:1642:  Multi line control clauses should use braces.  [whitespace/braces] [4]
ERROR: Source/WebCore/css/CSSParser.cpp:1651:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/css/CSSParser.cpp:9359:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 3 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 WebKit Commit Bot 2014-12-20 18:56:26 PST
Comment on attachment 243609 [details]
Patch

Clearing flags on attachment: 243609

Committed r177623: <http://trac.webkit.org/changeset/177623>
Comment 19 WebKit Commit Bot 2014-12-20 18:56:30 PST
All reviewed patches have been landed.  Closing bug.
Comment 20 Darin Adler 2014-12-20 19:33:25 PST
Chris, in the r177623 patch in ValueWithCalculation::setCalculation, it says isCalculation(m_value) where I think we wanted ASSERT(isCalculation(m_value)).
Comment 21 Chris Dumez 2014-12-20 22:23:43 PST
Reopening to attach new patch.
Comment 22 Chris Dumez 2014-12-20 22:23:46 PST
Created attachment 243612 [details]
Patch
Comment 23 Chris Dumez 2014-12-20 22:25:39 PST
(In reply to comment #20)
> Chris, in the r177623 patch in ValueWithCalculation::setCalculation, it says
> isCalculation(m_value) where I think we wanted
> ASSERT(isCalculation(m_value)).

Yes indeed. Thanks for double checking and catching it. I uploaded a tiny patch to fix this.
Comment 24 WebKit Commit Bot 2014-12-21 17:52:28 PST
Comment on attachment 243612 [details]
Patch

Clearing flags on attachment: 243612

Committed r177628: <http://trac.webkit.org/changeset/177628>
Comment 25 WebKit Commit Bot 2014-12-21 17:52:34 PST
All reviewed patches have been landed.  Closing bug.