Bug 73000 - Implement CSSPropertySize in CSSStyleApplyProperty.
Summary: Implement CSSPropertySize in CSSStyleApplyProperty.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Luke Macpherson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 20:55 PST by Luke Macpherson
Modified: 2011-11-28 19:25 PST (History)
5 users (show)

See Also:


Attachments
Patch (15.59 KB, patch)
2011-11-22 21:01 PST, Luke Macpherson
no flags Details | Formatted Diff | Diff
Patch (15.51 KB, patch)
2011-11-27 19:41 PST, Luke Macpherson
no flags Details | Formatted Diff | Diff
Patch for landing (15.13 KB, patch)
2011-11-28 15:11 PST, Luke Macpherson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Macpherson 2011-11-22 20:55:12 PST
Implement CSSPropertySize in CSSStyleApplyProperty.
Comment 1 Luke Macpherson 2011-11-22 21:01:20 PST
Created attachment 116311 [details]
Patch
Comment 2 Andreas Kling 2011-11-27 06:05:49 PST
Comment on attachment 116311 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        This refactoring moves the implementation of the page size calculation into CSSStyleApplyPropwerty

Typo: CSSStyleApplyProperty.

> Source/WebCore/ChangeLog:11
> +        No new tests / refactoing only.

Typo: refactoring.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:680
> +    static bool pageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)

I believe this function should be called getPageSizeFromName() since it doesn't return a "page size" directly, but rather fills in out arguments.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:692
> +        if (!pageSizeName || pageSizeName->primitiveType() != CSSPrimitiveValue::CSS_IDENT)
> +            return false;

The primitiveType() check here is redundant, since getIdent() would return 0 for non-CSS_IDENT values below and bail via the default case.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:733
> +            if (pageOrientation->primitiveType() != CSSPrimitiveValue::CSS_IDENT)
> +                return false;

Ditto.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:756
> +        CSSValueListInspector inspector = value;

We should use constructor syntax here:
CSSValueListInspector inspector(value);

Also, it appears that this site is the only user of the CSSValueListInspector class. Are there plans to expand its usage? Otherwise I think we could use CSSValueList methods directly here and remove the class.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:762
> +            pageSizeType = PAGE_SIZE_RESOLVED;
> +            if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPrimitiveValue())
> +                return;

Nit: We should move the pageSizeType assignment to after the if statement to avoid unnecessary work in the early-return case.

> Source/WebCore/css/CSSStyleApplyProperty.cpp:773
> +                // The value order is guaranteed. See CSSParser::parseSizeParameter.

Does this mean we could replace the primitive type checks in pageSizeFromName() with assertions?

> Source/WebCore/css/CSSStyleSelector.h:339
>      Length mmLength(double mm) const;
>      Length inchLength(double inch) const;

These declarations should be removed now as well.
Comment 3 Luke Macpherson 2011-11-27 19:18:12 PST
Comment on attachment 116311 [details]
Patch

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

>> Source/WebCore/ChangeLog:8
>> +        This refactoring moves the implementation of the page size calculation into CSSStyleApplyPropwerty
> 
> Typo: CSSStyleApplyProperty.

done.

>> Source/WebCore/ChangeLog:11
>> +        No new tests / refactoing only.
> 
> Typo: refactoring.

done.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:680
>> +    static bool pageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
> 
> I believe this function should be called getPageSizeFromName() since it doesn't return a "page size" directly, but rather fills in out arguments.

done.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:692
>> +            return false;
> 
> The primitiveType() check here is redundant, since getIdent() would return 0 for non-CSS_IDENT values below and bail via the default case.

Nice. I recall noticing this earlier but appear to forgotten to include that cleanup. Done.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:733
>> +                return false;
> 
> Ditto.

done.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:756
>> +        CSSValueListInspector inspector = value;
> 
> We should use constructor syntax here:
> CSSValueListInspector inspector(value);
> 
> Also, it appears that this site is the only user of the CSSValueListInspector class. Are there plans to expand its usage? Otherwise I think we could use CSSValueList methods directly here and remove the class.

Switched to constructor syntax. I think the rest of the discussion is beyond the scope of this refactoring though.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:762
>> +                return;
> 
> Nit: We should move the pageSizeType assignment to after the if statement to avoid unnecessary work in the early-return case.

I've moved it much further down.

>> Source/WebCore/css/CSSStyleApplyProperty.cpp:773
>> +                // The value order is guaranteed. See CSSParser::parseSizeParameter.
> 
> Does this mean we could replace the primitive type checks in pageSizeFromName() with assertions?

Already removed.

>> Source/WebCore/css/CSSStyleSelector.h:339
>>      Length inchLength(double inch) const;
> 
> These declarations should be removed now as well.

done.
Comment 4 Luke Macpherson 2011-11-27 19:41:52 PST
Created attachment 116693 [details]
Patch
Comment 5 Andreas Kling 2011-11-27 19:46:49 PST
Comment on attachment 116693 [details]
Patch

r=me
Comment 6 WebKit Review Bot 2011-11-28 14:15:39 PST
Comment on attachment 116693 [details]
Patch

Rejecting attachment 116693 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
 succeeded at 1312 with fuzz 2 (offset 108 lines).
patching file Source/WebCore/css/CSSStyleSelector.cpp
Hunk #1 succeeded at 3626 (offset -132 lines).
Hunk #2 FAILED at 4021.
Hunk #3 succeeded at 3949 (offset -122 lines).
1 out of 3 hunks FAILED -- saving rejects to file Source/WebCore/css/CSSStyleSelector.cpp.rej
patching file Source/WebCore/css/CSSStyleSelector.h

Failed to run "[u'/mnt/git/webkit-commit-queue/Tools/Scripts/svn-apply', u'--reviewer', u'Andreas Kling', u'--fo..." exit_code: 1

Full output: http://queues.webkit.org/results/10668887
Comment 7 Luke Macpherson 2011-11-28 15:11:03 PST
Created attachment 116837 [details]
Patch for landing
Comment 8 WebKit Review Bot 2011-11-28 19:24:59 PST
Comment on attachment 116837 [details]
Patch for landing

Clearing flags on attachment: 116837

Committed r101317: <http://trac.webkit.org/changeset/101317>
Comment 9 WebKit Review Bot 2011-11-28 19:25:04 PST
All reviewed patches have been landed.  Closing bug.