Bug 84551 - CSS3 calc: Implement CSSOM support
Summary: CSS3 calc: Implement CSSOM support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mike Lawther
URL: http://result.dabblet.com/gist/2467073
Keywords:
Depends on:
Blocks: 16662
  Show dependency treegraph
 
Reported: 2012-04-22 14:41 PDT by Lea Verou
Modified: 2012-05-30 00:01 PDT (History)
9 users (show)

See Also:


Attachments
Patch (6.30 KB, patch)
2012-05-22 22:37 PDT, Mike Lawther
no flags Details | Formatted Diff | Diff
Patch (6.29 KB, patch)
2012-05-29 23:22 PDT, Mike Lawther
no flags Details | Formatted Diff | Diff
Patch for landing (6.37 KB, patch)
2012-05-29 23:42 PDT, Mike Lawther
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lea Verou 2012-04-22 14:41:58 PDT
Check the few lines of JavaScript in the testcase, it should be self-explanatory. IE and Firefox show the function, WebKit drops everything.
Comment 1 Nathaniel Higgins 2012-04-22 15:03:51 PDT
Yup, WebKit drops it in Chrome Version 20.0.1105.0 dev
Comment 2 Mike Lawther 2012-04-22 22:14:39 PDT
Thanks for the textcase.
Comment 3 Mike Lawther 2012-05-22 22:37:53 PDT
Created attachment 143464 [details]
Patch
Comment 4 Ryosuke Niwa 2012-05-29 22:08:38 PDT
Comment on attachment 143464 [details]
Patch

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

> Source/WebCore/css/CSSCalculationValue.cpp:82
> +    if (expression[0] != '(')
> +        result.append('(');

Do we have a test case for this? But I'm somewhat puzzled by this.
What we had something like (100px) + 200px ?

> LayoutTests/css3/calc/cssom.html:10
> +    if (window.layoutTestController) {
> +        window.layoutTestController.dumpAsText();
> +    }    
> +

No curly brackets around a single statement.
Also it's unnecessary to indent the script content like this.

> LayoutTests/css3/calc/cssom.html:30
> +    document.body.style.width = '100%';

Wouldn't be it cleaner to create a new element of which you change the style?
Comment 5 Mike Lawther 2012-05-29 23:22:44 PDT
Created attachment 144714 [details]
Patch
Comment 6 Mike Lawther 2012-05-29 23:25:18 PDT
Comment on attachment 143464 [details]
Patch

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

>> Source/WebCore/css/CSSCalculationValue.cpp:82
>> +        result.append('(');
> 
> Do we have a test case for this? But I'm somewhat puzzled by this.
> What we had something like (100px) + 200px ?

I've added a test case for what you suggest. LIne 265 and 271 wrap every expression with an operator in brackets. So the expression "(100px) + 200px" will come out as "(100px + 200px)" - hence in this case we will *not* need to wrap in an extra pair of brackets, This result of "(100px) + 200px" => "(100px + 200px" is the same as what Firefox does.

The only time we need the extra brackets is when there is only a single term in the expression, eg "100px" will come out as "100px".

>> LayoutTests/css3/calc/cssom.html:10
>> +
> 
> No curly brackets around a single statement.
> Also it's unnecessary to indent the script content like this.

Done.

>> LayoutTests/css3/calc/cssom.html:30
>> +    document.body.style.width = '100%';
> 
> Wouldn't be it cleaner to create a new element of which you change the style?

Done.
Comment 7 Mike Lawther 2012-05-29 23:30:04 PDT
>This result of "(100px) + 200px" => "(100px + 200px" is the same as what Firefox does.

Argh - I meant

  This result of "(100px) + 200px" => "(100px + 200px)" is the same as what Firefox does.

(I missed a closing bracket the first time).
Comment 8 Ryosuke Niwa 2012-05-29 23:33:49 PDT
Comment on attachment 144714 [details]
Patch

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

> Source/WebCore/css/CSSCalculationValue.cpp:82
> +    if (expression[0] != '(')
> +        result.append('(');

(In reply to comment #6)
> The only time we need the extra brackets is when there is only a single term in the expression, eg "100px" will come out as "100px".

It would be good to codify this information. e.g.
bool expressionHasSingleTerm = expression[0] != '(';
if (expressionHasSingleTerm)
...
Comment 9 Mike Lawther 2012-05-29 23:42:47 PDT
Created attachment 144726 [details]
Patch for landing
Comment 10 WebKit Review Bot 2012-05-30 00:01:28 PDT
Comment on attachment 144726 [details]
Patch for landing

Clearing flags on attachment: 144726

Committed r118900: <http://trac.webkit.org/changeset/118900>
Comment 11 WebKit Review Bot 2012-05-30 00:01:34 PDT
All reviewed patches have been landed.  Closing bug.