Changeset 58384 in webkit


Ignore:
Timestamp:
Apr 27, 2010 11:45:35 PM (14 years ago)
Author:
yuzo@google.com
Message:

2010-04-27 Yuzo Fujishima <yuzo@google.com>

Reviewed by Dimitri Glazkov.

Enhance CSS parser for Paged Media (Iteration 3)
Implement size parameter parsing for Paged Media.
https://bugs.webkit.org/show_bug.cgi?id=35851

  • printing/page-rule-css-text-expected.txt:
  • printing/page-rule-css-text.html:

2010-04-27 Yuzo Fujishima <yuzo@google.com>

Reviewed by Dimitri Glazkov.

Enhance CSS parser for Paged Media (Iteration 3)
Implement size parameter parsing for Paged Media.
https://bugs.webkit.org/show_bug.cgi?id=35851

I believe size property hasn't been used so far because (1) it hasn't been properly parsed and
(2) a comment in CSSComputedStyleDeclaration::getPropertyCSSValue says so.
Changing the way of parsing it should not cause any regressions -- no existing tests fail because of this change.

  • css/CSSParser.cpp: (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseSize): (WebCore::CSSParser::parseSizeParameter):
  • css/CSSParser.h: (WebCore::CSSParser::):
  • css/CSSValueKeywords.in:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58383 r58384  
     12010-04-27  Yuzo Fujishima  <yuzo@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Enhance CSS parser for Paged Media (Iteration 3)
     6        Implement size parameter parsing for Paged Media.
     7        https://bugs.webkit.org/show_bug.cgi?id=35851
     8
     9        * printing/page-rule-css-text-expected.txt:
     10        * printing/page-rule-css-text.html:
     11
    1122010-04-27  Yuzo Fujishima  <yuzo@google.com>
    213
  • trunk/LayoutTests/printing/page-rule-css-text-expected.txt

    r58383 r58384  
    66@page world:right { color: red; }
    77@media print { @page somepage:first { margin-top: 3cm; margin-right: 3cm; margin-bottom: 3cm; margin-left: 3cm; } }
     8@page auto_page { size: auto; }
     9@page square_page { size: 4in; }
     10@page letter_page { size: letter; }
     11@page page_widht_height { size: 10cm 15cm; }
     12@page page_size_orientation { size: ledger landscape; }
     13@page page_orientation_size { size: a4 portrait; }
     14@page err_empty_size { }
     15@page err_unknow_page_size { }
     16@page err_length_and_page_size { }
     17@page err_length_and_orientation { }
     18@page err_orientations { }
     19@page err_too_many_params { }
    820
  • trunk/LayoutTests/printing/page-rule-css-text.html

    r58383 r58384  
    2727    }
    2828}
    29 /* FIXME: Add the following once size property is implemented.
    30 
    31 @page :left {
    32     size: 4in 6in;
     29@page auto_page {
     30    size: auto;
    3331}
    34 @page :right {
     32@page square_page {
     33    size: 4in;
     34}
     35@page letter_page {
    3536    size: letter;
    3637}
    37 */
     38@page page_widht_height {
     39    size: 10cm 15cm;
     40}
     41@page page_size_orientation {
     42    size: ledger landscape;
     43}
     44@page page_orientation_size {
     45    size: portrait a4;
     46}
     47@page err_empty_size {
     48    size:;
     49}
     50@page err_unknow_page_size {
     51    size: yotsugiri;
     52}
     53@page err_length_and_page_size {
     54    size: 10cm letter;
     55}
     56@page err_length_and_orientation {
     57    size: 10cm landscape;
     58}
     59@page err_orientations {
     60    size: portrait landscape;
     61}
     62@page err_too_many_params {
     63    size: a5 landscape auto;
     64}
     65
    3866/* FIXME: Add the following once margin at-rule is implemented.
    3967
  • trunk/WebCore/ChangeLog

    r58383 r58384  
     12010-04-27  Yuzo Fujishima  <yuzo@google.com>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Enhance CSS parser for Paged Media (Iteration 3)
     6        Implement size parameter parsing for Paged Media.
     7        https://bugs.webkit.org/show_bug.cgi?id=35851
     8
     9        I believe size property hasn't been used so far because (1) it hasn't been properly parsed and
     10        (2) a comment in CSSComputedStyleDeclaration::getPropertyCSSValue says so.
     11        Changing the way of parsing it should not cause any regressions -- no existing tests fail because of this change.
     12
     13        * css/CSSParser.cpp:
     14        (WebCore::CSSParser::parseValue):
     15        (WebCore::CSSParser::parseSize):
     16        (WebCore::CSSParser::parseSizeParameter):
     17        * css/CSSParser.h:
     18        (WebCore::CSSParser::):
     19        * css/CSSValueKeywords.in:
     20
    1212010-04-27  Yuzo Fujishima  <yuzo@google.com>
    222
  • trunk/WebCore/css/CSSParser.cpp

    r58383 r58384  
    593593         */
    594594
    595     case CSSPropertySize:                 // <length>{1,2} | auto | portrait | landscape | inherit
     595    case CSSPropertySize:                 // <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
     596        return parseSize(propId, important);
     597
    596598    case CSSPropertyQuotes:               // [<string> <string>]+ | none | inherit
    597599        if (id)
     
    21092111   
    21102112    return true;
     2113}
     2114
     2115// <length>{1,2} | auto | [ <page-size> || [ portrait | landscape] ]
     2116bool CSSParser::parseSize(int propId, bool important)
     2117{
     2118    ASSERT(propId == CSSPropertySize);
     2119
     2120    if (m_valueList->size() > 2)
     2121        return false;
     2122
     2123    CSSParserValue* value = m_valueList->current();
     2124    if (!value)
     2125        return false;
     2126
     2127    RefPtr<CSSValueList> parsedValues = CSSValueList::createSpaceSeparated();
     2128
     2129    // First parameter.
     2130    SizeParameterType paramType = parseSizeParameter(parsedValues.get(), value, None);
     2131    if (paramType == None)
     2132        return false;
     2133
     2134    // Second parameter, if any.
     2135    value = m_valueList->next();
     2136    if (value) {
     2137        paramType = parseSizeParameter(parsedValues.get(), value, paramType);
     2138        if (paramType == None)
     2139            return false;
     2140    }
     2141
     2142    addProperty(propId, parsedValues.release(), important);
     2143    return true;
     2144}
     2145
     2146CSSParser::SizeParameterType CSSParser::parseSizeParameter(CSSValueList* parsedValues, CSSParserValue* value, SizeParameterType prevParamType)
     2147{
     2148    switch (value->id) {
     2149    case CSSValueAuto:
     2150        if (prevParamType == None) {
     2151            parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
     2152            return Auto;
     2153        }
     2154        return None;
     2155    case CSSValueLandscape:
     2156    case CSSValuePortrait:
     2157        if (prevParamType == None || prevParamType == PageSize) {
     2158            parsedValues->append(CSSPrimitiveValue::createIdentifier(value->id));
     2159            return Orientation;
     2160        }
     2161        return None;
     2162    case CSSValueA3:
     2163    case CSSValueA4:
     2164    case CSSValueA5:
     2165    case CSSValueB4:
     2166    case CSSValueB5:
     2167    case CSSValueLedger:
     2168    case CSSValueLegal:
     2169    case CSSValueLetter:
     2170        if (prevParamType == None || prevParamType == Orientation) {
     2171            // Normalize to Page Size then Orientation order by prepending.
     2172            // This is not specified by the CSS3 Paged Media specification, but for simpler processing hereafter.
     2173            parsedValues->prepend(CSSPrimitiveValue::createIdentifier(value->id));
     2174            return PageSize;
     2175        }
     2176        return None;
     2177    case 0:
     2178        if (validUnit(value, FLength, m_strict) && (prevParamType == None || prevParamType == Length)) {
     2179            parsedValues->append(CSSPrimitiveValue::create(value->fValue, static_cast<CSSPrimitiveValue::UnitTypes>(value->unit)));
     2180            return Length;
     2181        }
     2182        return None;
     2183    default:
     2184        return None;
     2185    }
    21112186}
    21122187
  • trunk/WebCore/css/CSSParser.h

    r58374 r58384  
    253253        void deleteFontFaceOnlyValues();
    254254
     255        enum SizeParameterType {
     256            None,
     257            Auto,
     258            Length,
     259            PageSize,
     260            Orientation,
     261        };
     262
     263        bool parseSize(int propId, bool important);
     264        SizeParameterType parseSizeParameter(CSSValueList* parsedValues, CSSParserValue* value, SizeParameterType prevParamType);
     265
    255266        UChar* m_data;
    256267        UChar* yytext;
  • trunk/WebCore/css/CSSValueKeywords.in

    r58258 r58384  
    381381# Unordered rest
    382382#
     383a3
     384a4
     385a5
    383386above
    384387absolute
    385388always
    386389avoid
     390b4
     391b5
    387392below
    388393bidi-override
     
    399404invert
    400405landscape
     406ledger
     407legal
     408letter
    401409level
    402410line-through
Note: See TracChangeset for help on using the changeset viewer.