Bug 117481 - Make sure to use CSSValueID and CSSPropertyID rather than integers
Summary: Make sure to use CSSValueID and CSSPropertyID rather than integers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexis Menard (darktears)
URL:
Keywords: BlinkMergeCandidate
Depends on:
Blocks: 117715
  Show dependency treegraph
 
Reported: 2013-06-10 21:12 PDT by Ryosuke Niwa
Modified: 2013-06-19 15:07 PDT (History)
10 users (show)

See Also:


Attachments
Patch (48.16 KB, patch)
2013-06-19 11:01 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
attempt to fix efl build (48.69 KB, patch)
2013-06-19 11:21 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
with benjamin's comments (49.24 KB, patch)
2013-06-19 13:19 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff
Patch for landing (49.27 KB, patch)
2013-06-19 13:46 PDT, Alexis Menard (darktears)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2013-06-10 21:12:19 PDT
Consider merging https://chromium.googlesource.com/chromium/blink/+/cdf054eda8bdc38052421f32c62738dc7aa5e097

This will ensure that types are enforced when passing arguments in various
css functions. Having a compile time check make sure that no mistakes
will be done over the type.

The parser was also patched to directly use CSSValueID over integers.
This patch also fixes various call sites abusing the usage of integers.
Comment 2 Alexis Menard (darktears) 2013-06-19 11:01:51 PDT
Created attachment 205018 [details]
Patch
Comment 3 EFL EWS Bot 2013-06-19 11:15:40 PDT
Comment on attachment 205018 [details]
Patch

Attachment 205018 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/945270
Comment 4 Alexis Menard (darktears) 2013-06-19 11:21:37 PDT
Created attachment 205020 [details]
attempt to fix efl build
Comment 5 Benjamin Poulain 2013-06-19 12:55:12 PDT
Comment on attachment 205020 [details]
attempt to fix efl build

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

> Source/WebCore/css/CSSParser.cpp:5646
> +            addProperty(CSSPropertyFontWeight, cssValuePool().createIdentifierValue(static_cast<CSSValueID>(CSSValue100 + weight / 100 - 1)), important);

I reeeeaaally don't like this.

I would make it a separate function, with pre and post assertions, and a comment.

> Source/WebCore/css/CSSParser.cpp:12236
> -            return 0; // illegal character
> +            return CSSValueInvalid; // illegal character

Fix the comment.

> Source/WebCore/css/CSSValuePool.cpp:55
> -    if (ident <= 0 || ident >= numCSSValueKeywords)
> +    if (ident <= 0)
>          return CSSPrimitiveValue::createIdentifier(ident);

1) Why would that happen with valid CSSValueID? Shouldn't you instead have two constructors?: one taking an int, the other taking a CSSValueID.

> Source/WebCore/css/CSSValuePool.cpp:57
>      if (!m_identifierValueCache[ident])

2) Because of this, you should have a Release Assert for the range of ident!
Comment 6 Alexis Menard (darktears) 2013-06-19 13:19:24 PDT
Created attachment 205030 [details]
with benjamin's comments
Comment 7 Benjamin Poulain 2013-06-19 13:45:20 PDT
Comment on attachment 205030 [details]
with benjamin's comments

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

LGTM

> Source/WebCore/css/CSSValuePool.cpp:58
> +    ASSERT(ident < numCSSValueKeywords);
>      if (!m_identifierValueCache[ident])

You should have a full bound checking release assert here.
Comment 8 Alexis Menard (darktears) 2013-06-19 13:46:55 PDT
Created attachment 205031 [details]
Patch for landing
Comment 9 WebKit Commit Bot 2013-06-19 15:07:47 PDT
Comment on attachment 205031 [details]
Patch for landing

Clearing flags on attachment: 205031

Committed r151754: <http://trac.webkit.org/changeset/151754>
Comment 10 WebKit Commit Bot 2013-06-19 15:07:52 PDT
All reviewed patches have been landed.  Closing bug.