Bug 121161 - Rework CSS parser, eliminating "floating" concept and using %destructor
Summary: Rework CSS parser, eliminating "floating" concept and using %destructor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-11 07:17 PDT by Darin Adler
Modified: 2013-10-15 18:26 PDT (History)
9 users (show)

See Also:


Attachments
Patch (96.41 KB, patch)
2013-09-11 08:01 PDT, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2013-09-11 07:17:09 PDT
Rework CSS parser, eliminating "floating" concept and using %destructor.
Comment 1 Darin Adler 2013-09-11 08:01:03 PDT
Created attachment 211314 [details]
Patch
Comment 2 WebKit Commit Bot 2013-09-11 08:04:03 PDT
Attachment 211314 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCore/css/CSSGrammar.y.in', u'Source/WebCore/css/CSSParser.cpp', u'Source/WebCore/css/CSSParser.h', u'Source/WebCore/css/CSSParserValues.cpp', u'Source/WebCore/css/CSSParserValues.h']" exit_code: 1
Source/WebCore/css/CSSParser.cpp:11630:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/CSSParser.cpp:11744:  The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:11744:  The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:11744:  The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:11764:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:11787:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/CSSParser.cpp:11796:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:11796:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/CSSParser.cpp:11847:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.cpp:12088:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.h:304:  The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.h:305:  The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.h:314:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/CSSParser.h:317:  Missing spaces around >>  [whitespace/operators] [3]
Source/WebCore/css/CSSParser.h:340:  The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.h:340:  The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Source/WebCore/css/CSSParser.h:340:  The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
Total errors found: 17 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Sam Weinig 2013-09-11 09:15:00 PDT
Comment on attachment 211314 [details]
Patch

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

>> Source/WebCore/css/CSSParser.h:304
>> +    OwnPtr<Vector<OwnPtr<CSSParserSelector>>> createSelectorVector();
> 
> The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]

Should this return a PassOwnPtr?

>> Source/WebCore/css/CSSParser.h:305
>> +    void recycleSelectorVector(OwnPtr<Vector<OwnPtr<CSSParserSelector>>>);
> 
> The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]

Should this take a PassOwnPtr?

>>>> Source/WebCore/css/CSSParser.h:340
>>>> +    OwnPtr<CSSParserSelector> rewriteSpecifiers(OwnPtr<CSSParserSelector>, OwnPtr<CSSParserSelector>);
>>> 
>>> The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
>> 
>> The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
> 
> The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]

PassOwnPtr?
Comment 4 Antti Koivisto 2013-09-11 09:23:10 PDT
Comment on attachment 211314 [details]
Patch

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

r=me

> Source/WebCore/css/CSSGrammar.y.in:188
> +%union { StyleRuleBase* rule; }

Is there still no way to use safe types in grammar? All these leakRefs and leakPtrs are bit scary.

>>>> Source/WebCore/css/CSSParser.cpp:11744
>>>> +    specifiers->appendTagHistory(CSSSelector::SubSelector, newSpecifier.release());
>>> 
>>> The return type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
>> 
>> The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]
> 
> The parameter type should use PassOwnPtr instead of OwnPtr.  [readability/pass_ptr] [5]

style bot needs to learn that PassOwnPtr is obsolete
Comment 5 Sam Weinig 2013-09-11 09:24:08 PDT
(In reply to comment #4)
> style bot needs to learn that PassOwnPtr is obsolete

Sam needs to learn that PassOwnPtr is obsolete :(.
Comment 6 Darin Adler 2013-09-11 09:45:58 PDT
Comment on attachment 211314 [details]
Patch

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

>> Source/WebCore/css/CSSGrammar.y.in:188
>> +%union { StyleRuleBase* rule; }
> 
> Is there still no way to use safe types in grammar? All these leakRefs and leakPtrs are bit scary.

I’ll keep looking for a way to do it without having to write leakRef/leakPtr/adoptRef/adoptPtr/new/delete directly and if I find one I will switch to it.

The fact that so much CSS parsing doesn’t use the union at all and instead using state inside CSSParser seems to point to a possible direction, but I am unclear how that works during the parsing process.
Comment 7 WebKit Commit Bot 2013-09-11 09:47:23 PDT
Comment on attachment 211314 [details]
Patch

Clearing flags on attachment: 211314

Committed r155536: <http://trac.webkit.org/changeset/155536>
Comment 8 WebKit Commit Bot 2013-09-11 09:47:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Ryosuke Niwa 2013-10-15 02:10:11 PDT
Looks like this may have caused 3-4% performance regression on SVG/Bamboo:Time?
https://perf.webkit.org/#mode=charts&chartList=%5B%5B%22mac-mountainlion%22%2C%22SVG%2FBamboo%3ATime%22%5D%2C%5B%22mac-lion%22%2C%22SVG%2FBamboo%3ATime%22%5D%5D&days=56
Comment 10 Ryosuke Niwa 2013-10-15 18:26:42 PDT
(In reply to comment #9)
> Looks like this may have caused 3-4% performance regression on SVG/Bamboo:Time?
> https://perf.webkit.org/#mode=charts&chartList=%5B%5B%22mac-mountainlion%22%2C%22SVG%2FBamboo%3ATime%22%5D%2C%5B%22mac-lion%22%2C%22SVG%2FBamboo%3ATime%22%5D%5D&days=56

Oops, this was a 3% perf. improvement!