Bug 140501

Summary: Generate StylePropertyShorthand.* from CSSPropertyNames.in
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: CSSAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, commit-queue, darin, dino, kling, koivisto, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 140568    
Bug Blocks: 140556, 140599    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2015-01-15 10:41:16 PST
Most of StylePropertyShorthand.* is boilerplate code that could easily be generated from CSSProperties.in file if we included in it the longhands for each shorthand property.
Comment 1 Chris Dumez 2015-01-15 15:37:27 PST
Created attachment 244719 [details]
Patch
Comment 2 Chris Dumez 2015-01-15 16:38:12 PST
Created attachment 244724 [details]
Patch
Comment 3 Chris Dumez 2015-01-15 16:53:18 PST
Created attachment 244729 [details]
Patch
Comment 4 Chris Dumez 2015-01-15 17:27:44 PST
Comment on attachment 244729 [details]
Patch

Patch is ready for review.
Comment 5 Darin Adler 2015-01-16 09:32:31 PST
Comment on attachment 244729 [details]
Patch

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

> Source/WebCore/css/makeprop.pl:956
> +  print SHORTHANDS_CPP "    return StylePropertyShorthand(CSSProperty" . $nameToId{$name} . ", " . $lowercaseId . "Properties, WTF_ARRAY_LENGTH(" . $lowercaseId . "Properties));\n";

Seems like we could avoid this WTF_ARRAY_LENGTH if we made the constructor a template that takes an array and deduces its length, like StringBuilder::appendLiteral, for example. Anything that reduces the amount of generated code and puts more of the code in normal C++ header files seems like a win to me. To state the obvious, we want the code generator to generate things that need to be repeated but make the actual code generated as minimal as we can.
Comment 6 Chris Dumez 2015-01-16 10:48:23 PST
Created attachment 244773 [details]
Patch
Comment 7 Chris Dumez 2015-01-16 11:28:20 PST
(In reply to comment #5)
> Comment on attachment 244729 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=244729&action=review
> 
> > Source/WebCore/css/makeprop.pl:956
> > +  print SHORTHANDS_CPP "    return StylePropertyShorthand(CSSProperty" . $nameToId{$name} . ", " . $lowercaseId . "Properties, WTF_ARRAY_LENGTH(" . $lowercaseId . "Properties));\n";
> 
> Seems like we could avoid this WTF_ARRAY_LENGTH if we made the constructor a
> template that takes an array and deduces its length, like
> StringBuilder::appendLiteral, for example. Anything that reduces the amount
> of generated code and puts more of the code in normal C++ header files seems
> like a win to me. To state the obvious, we want the code generator to
> generate things that need to be repeated but make the actual code generated
> as minimal as we can.

I made the suggested change before landing.
Comment 8 WebKit Commit Bot 2015-01-16 11:39:01 PST
Comment on attachment 244773 [details]
Patch

Clearing flags on attachment: 244773

Committed r178586: <http://trac.webkit.org/changeset/178586>
Comment 9 WebKit Commit Bot 2015-01-16 11:39:07 PST
All reviewed patches have been landed.  Closing bug.