Bug 55351 - Add templatized CSSMutableStyleDeclaration::get{ShorthandValue, CommonValue, LayeredShorthandValue}()
Summary: Add templatized CSSMutableStyleDeclaration::get{ShorthandValue, CommonValue, ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-27 22:26 PST by Daniel Bates
Modified: 2011-03-09 21:02 PST (History)
2 users (show)

See Also:


Attachments
Patch (14.49 KB, patch)
2011-02-27 22:36 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (14.55 KB, patch)
2011-03-06 20:09 PST, Daniel Bates
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2011-02-27 22:26:47 PST
We should add template variants of CSSMutableStyleDeclaration::get{ShorthandValue, CommonValue, LayeredShorthandValue}() that are capable of determining the size of the passed array so that the caller does not need to provide such information. This helps improve the readability of the code (by removing redundant information) as well as makes usage of these functions less error prone (since the caller doesn't need to provide the size of the array).

For completeness, we've used this technique before for functions RenderListMarker::to{Alphabetic, Numeric, Symbolic}.
Comment 1 Daniel Bates 2011-02-27 22:36:51 PST
Created attachment 84018 [details]
Patch
Comment 2 Daniel Bates 2011-03-06 20:09:18 PST
Created attachment 84915 [details]
Patch
Comment 3 Darin Adler 2011-03-07 09:57:49 PST
Comment on attachment 84915 [details]
Patch

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

> Source/WebCore/css/CSSMutableStyleDeclaration.h:163
> +    template <size_t size> String getShorthandValue(const int (&properties)[size]) const { return getShorthandValue(properties, size); }
> +    template <size_t size> String getCommonValue(const int (&properties)[size]) const { return getCommonValue(properties, size); }
> +    template <size_t size> String getLayeredShorthandValue(const int (&properties)[size]) const { return getLayeredShorthandValue(properties, size); }

I like to leave out the space between “template” and “<” by analogy with function calls. Not sure others like that style.
Comment 4 Daniel Bates 2011-03-08 21:51:49 PST
(In reply to comment #3)
> I like to leave out the space between “template” and “<” by analogy with function calls. Not sure others like that style.

Will change before landing.
Comment 5 Daniel Bates 2011-03-09 21:02:12 PST
Committed r80620: <http://trac.webkit.org/changeset/80620>