Changeset 13673 in webkit


Ignore:
Timestamp:
Apr 3, 2006 10:21:08 PM (18 years ago)
Author:
ap
Message:

Reviewed by Darin.

Tests: fast/css/invalidation-errors.html

fast/css/invalidation-errors-2.html
fast/css/invalidation-errors-3.html

  • css/CSSGrammar.y: Rollback the properties added by parseValue() when it returns false.
  • css/cssparser.h: Moved shorthand counting to ShorthandScope, a new class in cssparser.cpp.
  • css/cssparser.cpp: (WebCore::CSSParser::rollbackLastProperties): Added. (WebCore::CSSParser::parseValue): Return false if there are too many properties in the list. (WebCore::CSSParser::parseBackgroundShorthand): Use ShorthandScope. (WebCore::CSSParser::parseShorthand): Ditto. (WebCore::CSSParser::parse4Values): Ditto.
Location:
trunk
Files:
12 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r13666 r13673  
     12006-04-03  Alexey Proskuryakov  <ap@nypop.com>
     2
     3        Reviewed by Darin.
     4
     5        - tests for http://bugzilla.opendarwin.org/show_bug.cgi?id=7118
     6          Property values with extra items do not get treated as invalid (they should)
     7
     8        * fast/block/margin-collapse/103-expected.checksum: Corrected the results.
     9        * fast/block/margin-collapse/103-expected.png:
     10        * fast/block/margin-collapse/103-expected.txt:
     11        * fast/css/invalidation-errors-2-expected.checksum: Added.
     12        * fast/css/invalidation-errors-2-expected.png: Added.
     13        * fast/css/invalidation-errors-2-expected.txt: Added.
     14        * fast/css/invalidation-errors-2.html: Added.
     15        * fast/css/invalidation-errors-3-expected.checksum: Added.
     16        * fast/css/invalidation-errors-3-expected.png: Added.
     17        * fast/css/invalidation-errors-3-expected.txt: Added.
     18        * fast/css/invalidation-errors-3.html: Added.
     19        * fast/css/invalidation-errors-expected.checksum: Added.
     20        * fast/css/invalidation-errors-expected.png: Added.
     21        * fast/css/invalidation-errors-expected.txt: Added.
     22        * fast/css/invalidation-errors.html: Added.
     23
    1242006-04-03  Darin Adler  <darin@apple.com>
    225
  • trunk/LayoutTests/fast/block/margin-collapse/103-expected.checksum

    r12842 r13673  
    1 b0a4b15bd1c0de763dc4ca23f39b934e
     1193b74a67961c892e96709f3ce75b5b2
  • trunk/LayoutTests/fast/block/margin-collapse/103-expected.txt

    r13567 r13673  
    1111              text run at (0,2) width 520: "We are trying to understand how UVic students perform Shakespeare related research for"
    1212              text run at (0,22) width 265: "classes as well as for their own interest. The "
    13             RenderInline {A} at (0,0) size 173x16 [border: (1px dashed #333333) none]
     13            RenderInline {A} at (0,0) size 173x15
    1414              RenderText {TEXT} at (265,22) size 173x20
    1515                text run at (265,22) width 173: "Internet Shakespeare Editions"
  • trunk/WebCore/ChangeLog

    r13671 r13673  
     12006-04-03  Alexey Proskuryakov  <ap@nypop.com>
     2
     3        Reviewed by Darin.
     4
     5        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7118
     6          Property values with extra items do not get treated as invalid (they should)
     7
     8        Tests: fast/css/invalidation-errors.html
     9               fast/css/invalidation-errors-2.html
     10               fast/css/invalidation-errors-3.html
     11
     12        * css/CSSGrammar.y: Rollback the properties added by parseValue() when it returns false.
     13        * css/cssparser.h: Moved shorthand counting to ShorthandScope, a new class in cssparser.cpp.
     14        * css/cssparser.cpp:
     15        (WebCore::CSSParser::rollbackLastProperties): Added.
     16        (WebCore::CSSParser::parseValue): Return false if there are too many properties in the list.
     17        (WebCore::CSSParser::parseBackgroundShorthand): Use ShorthandScope.
     18        (WebCore::CSSParser::parseShorthand): Ditto.
     19        (WebCore::CSSParser::parse4Values): Ditto.
     20
    1212006-04-03  Darin Adler  <darin@apple.com>
    222
  • trunk/WebCore/css/CSSGrammar.y

    r13560 r13673  
    285285        if ($4) {
    286286            p->valueList = p->sinkFloatingValueList($4);
    287             p->parseValue(p->id, p->important);
     287            int oldParsedProperties = p->numParsedProperties;
     288            if (!p->parseValue(p->id, p->important))
     289                p->rollbackLastProperties(p->numParsedProperties - oldParsedProperties);
    288290            delete p->valueList;
    289291            p->valueList = 0;
     
    805807        if ($1 && $4) {
    806808            p->valueList = p->sinkFloatingValueList($4);
     809            int oldParsedProperties = p->numParsedProperties;
    807810            $$ = p->parseValue($1, $5);
     811            if (!$$)
     812                p->rollbackLastProperties(p->numParsedProperties - oldParsedProperties);
    808813            delete p->valueList;
    809814            p->valueList = 0;
  • trunk/WebCore/css/cssparser.cpp

    r13639 r13673  
    5656}
    5757
     58namespace {
     59    class ShorthandScope {
     60    public:
     61        ShorthandScope(CSSParser* parser, int propId) : m_parser(parser)
     62        {
     63            if (!(m_parser->m_inParseShorthand++))
     64                m_parser->m_currentShorthand = propId;
     65        }
     66        ~ShorthandScope()
     67        {
     68            if (!(--m_parser->m_inParseShorthand))
     69                m_parser->m_currentShorthand = 0;
     70        }
     71
     72    private:
     73        CSSParser* m_parser;
     74    };
     75}
     76
    5877CSSParser* CSSParser::currentParser = 0;
    5978
     
    261280    }
    262281    parsedProperties[numParsedProperties++] = prop;
     282}
     283
     284void CSSParser::rollbackLastProperties(int num)
     285{
     286    ASSERT(num >= 0);
     287    ASSERT(numParsedProperties >= num);
     288
     289    for (int i = 0; i < num; ++i)
     290        delete parsedProperties[--numParsedProperties];
    263291}
    264292
     
    340368    int id = value->id;
    341369
     370    int num = inShorthand() ? 1 : valueList->size();
     371
    342372    if (id == CSS_VAL_INHERIT) {
     373        if (num != 1)
     374            return false;
    343375        addProperty(propId, new CSSInheritedValue(), important);
    344376        return true;
    345377    }
    346378    else if (id == CSS_VAL_INITIAL) {
     379        if (num != 1)
     380            return false;
    347381        addProperty(propId, new CSSInitialValue(), important);
    348382        return true;
     
    543577        const int properties[2] = { CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING,
    544578                                    CSS_PROP__KHTML_BORDER_VERTICAL_SPACING };
    545         int num = valueList->size();
    546579        if (num == 1) {
    547             if (!parseValue(properties[0], important)) return false;
     580            ShorthandScope scope(this, CSS_PROP_BORDER_SPACING);
     581            if (!parseValue(properties[0], important))
     582                return false;
    548583            CSSValue* value = parsedProperties[numParsedProperties-1]->value();
    549584            addProperty(properties[1], value, important);
     
    551586        }
    552587        else if (num == 2) {
    553             if (!parseValue(properties[0], important)) return false;
    554             if (!parseValue(properties[1], important)) return false;
     588            ShorthandScope scope(this, CSS_PROP_BORDER_SPACING);
     589            if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
     590                return false;
    555591            return true;
    556592        }
     
    679715
    680716    case CSS_PROP__KHTML_FONT_SIZE_DELTA:           // <length>
    681            valid_primitive = validUnit(value, FLength, strict);
     717        valid_primitive = validUnit(value, FLength, strict);
    682718        break;
    683719
     
    882918    case CSS_PROP_BORDER_BOTTOM_RIGHT_RADIUS:
    883919    case CSS_PROP_BORDER_RADIUS: {
    884         int num = valueList->size();
    885920        if (num != 1 && num != 2)
    886921            return false;
     
    10121047        const int properties[2] = { CSS_PROP__KHTML_MARGIN_TOP_COLLAPSE,
    10131048            CSS_PROP__KHTML_MARGIN_BOTTOM_COLLAPSE };
    1014         int num = valueList->size();
    10151049        if (num == 1) {
    1016             if (!parseValue(properties[0], important)) return false;
     1050            ShorthandScope scope(this, CSS_PROP__KHTML_MARGIN_COLLAPSE);
     1051            if (!parseValue(properties[0], important))
     1052                return false;
    10171053            CSSValue* value = parsedProperties[numParsedProperties-1]->value();
    10181054            addProperty(properties[1], value, important);
     
    10201056        }
    10211057        else if (num == 2) {
    1022             if (!parseValue(properties[0], important)) return false;
    1023             if (!parseValue(properties[1], important)) return false;
     1058            ShorthandScope scope(this, CSS_PROP__KHTML_MARGIN_COLLAPSE);
     1059            if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
     1060                return false;
    10241061            return true;
    10251062        }
     
    11871224    }
    11881225    if (parsedValue) {
    1189         addProperty(propId, parsedValue, important);
    1190         return true;
     1226        if (!valueList->current() || inShorthand()) {
     1227            addProperty(propId, parsedValue, important);
     1228            return true;
     1229        }
     1230        delete parsedValue;
    11911231    }
    11921232    return false;
     
    12191259        CSS_PROP_BACKGROUND_ORIGIN, CSS_PROP_BACKGROUND_COLOR };
    12201260   
    1221     enterShorthand(CSS_PROP_BACKGROUND);
     1261    ShorthandScope scope(this, CSS_PROP_BACKGROUND);
    12221262
    12231263    bool parsedProperty[numProperties] = { false }; // compiler will repeat false as necessary
     
    12871327    }
    12881328   
    1289     exitShorthand();
    12901329    return true;
    12911330
    12921331fail:
    1293     exitShorthand();
    12941332    for (int k = 0; k < numProperties; k++)
    12951333        delete values[k];
     
    13031341    // We set up an array of booleans to mark which property has been found,
    13041342    // and we try to search for properties until it makes no longer any sense.
    1305     enterShorthand(propId);
     1343    ShorthandScope scope(this, propId);
    13061344
    13071345    bool found = false;
     
    13211359        // if we didn't find at least one match, this is an
    13221360        // invalid shorthand and we have to ignore it
    1323         if (!found) {
    1324             exitShorthand();
     1361        if (!found)
    13251362            return false;
    1326         }
    13271363    }
    13281364   
     
    13351371    m_implicitShorthand = false;
    13361372
    1337     exitShorthand();
    13381373    return true;
    13391374}
     
    13511386    int num = inShorthand() ? 1 : valueList->size();
    13521387   
    1353     enterShorthand(propId);
     1388    ShorthandScope scope(this, propId);
    13541389
    13551390    // the order is top, right, bottom, left
    13561391    switch (num) {
    13571392        case 1: {
    1358             if (!parseValue(properties[0], important)) {
    1359                 exitShorthand();
     1393            if (!parseValue(properties[0], important))
    13601394                return false;
    1361             }
    13621395            CSSValue *value = parsedProperties[numParsedProperties-1]->value();
    13631396            m_implicitShorthand = true;
     
    13691402        }
    13701403        case 2: {
    1371             if (!parseValue(properties[0], important) || !parseValue(properties[1], important)) {
    1372                 exitShorthand();
     1404            if (!parseValue(properties[0], important) || !parseValue(properties[1], important))
    13731405                return false;
    1374             }
    13751406            CSSValue *value = parsedProperties[numParsedProperties-2]->value();
    13761407            m_implicitShorthand = true;
     
    13821413        }
    13831414        case 3: {
    1384             if (!parseValue(properties[0], important) || !parseValue(properties[1], important) ||
    1385                 !parseValue(properties[2], important)) {
    1386                 exitShorthand();
     1415            if (!parseValue(properties[0], important) || !parseValue(properties[1], important) || !parseValue(properties[2], important))
    13871416                return false;
    1388             }
    13891417            CSSValue *value = parsedProperties[numParsedProperties-2]->value();
    13901418            m_implicitShorthand = true;
     
    13951423        case 4: {
    13961424            if (!parseValue(properties[0], important) || !parseValue(properties[1], important) ||
    1397                 !parseValue(properties[2], important) || !parseValue(properties[3], important)) {
    1398                 exitShorthand();
     1425                !parseValue(properties[2], important) || !parseValue(properties[3], important))
    13991426                return false;
    1400             }
    14011427            break;
    14021428        }
    14031429        default: {
    1404             exitShorthand();
    14051430            return false;
    14061431        }
    14071432    }
    14081433   
    1409     exitShorthand();
    14101434    return true;
    14111435}
  • trunk/WebCore/css/cssparser.h

    r13444 r13673  
    124124
    125125        void addProperty(int propId, CSSValue*, bool important);
     126        void rollbackLastProperties(int num);
    126127        bool hasProperties() const { return numParsedProperties > 0; }
    127128
     
    213214
    214215        void setupParser(const char* prefix, const String&, const char* suffix);
    215         void enterShorthand(int propId)
    216         {
    217             if (!(m_inParseShorthand++))
    218                 m_currentShorthand = propId;
    219         }
    220         void exitShorthand()
    221         {
    222             if (!(--m_inParseShorthand))
    223                 m_currentShorthand = 0;
    224         }
     216
    225217        bool inShorthand() const { return m_inParseShorthand; }
    226218
Note: See TracChangeset for help on using the changeset viewer.