Changeset 89396 in webkit


Ignore:
Timestamp:
Jun 21, 2011 5:26:01 PM (13 years ago)
Author:
tony@chromium.org
Message:

2011-06-21 Tony Chang <tony@chromium.org>

Reviewed by Eric Seidel.

add css parsing of flex()
https://bugs.webkit.org/show_bug.cgi?id=62050

Add a new script-test, but skip it on all platforms since we don't
build with ENABLE_CSS3_FLEXBOX anywhere.

  • css3/flexbox/flex-parsing-expected.txt: Added.
  • css3/flexbox/flex-parsing.html: Added.
  • css3/flexbox/script-tests/TEMPLATE.html: Added.
  • css3/flexbox/script-tests/flex-parsing.js: Added. (testFlex):
  • platform/chromium/test_expectations.txt:
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:

2011-06-21 Tony Chang <tony@chromium.org>

Reviewed by Eric Seidel.

add css parsing of flex()
https://bugs.webkit.org/show_bug.cgi?id=62050

Test: css3/flexbox/flex-parsing.html

  • CMakeLists.txt: Add CSSFlexValue.*
  • GNUmakefile.list.am: Ditto.
  • WebCore.gypi: Ditto.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • css/CSSFlexValue.cpp: Added. (WebCore::CSSFlexValue::~CSSFlexValue): (WebCore::CSSFlexValue::cssText):
  • css/CSSFlexValue.h: Added. (WebCore::CSSFlexValue::create): Hold positive flex, negative flex and sizing. (WebCore::CSSFlexValue::CSSFlexValue):
  • css/CSSParser.cpp: (WebCore::CSSParser::parseValidPrimitive): Pull out code from parseValue. (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFlex): Parse the different version of flex().
  • css/CSSParser.h:

2011-06-21 Tony Chang <tony@chromium.org>

Reviewed by Eric Seidel.

add css parsing of flex()
https://bugs.webkit.org/show_bug.cgi?id=62050

  • features.gypi: Add a gyp flag (enable_css3_flexbox) for setting ENABLE_CSS3_FLEXBOX.
Location:
trunk
Files:
8 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r89395 r89396  
     12011-06-21  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        add css parsing of flex()
     6        https://bugs.webkit.org/show_bug.cgi?id=62050
     7
     8        Add a new script-test, but skip it on all platforms since we don't
     9        build with ENABLE_CSS3_FLEXBOX anywhere.
     10
     11        * css3/flexbox/flex-parsing-expected.txt: Added.
     12        * css3/flexbox/flex-parsing.html: Added.
     13        * css3/flexbox/script-tests/TEMPLATE.html: Added.
     14        * css3/flexbox/script-tests/flex-parsing.js: Added.
     15        (testFlex):
     16        * platform/chromium/test_expectations.txt:
     17        * platform/gtk/Skipped:
     18        * platform/mac/Skipped:
     19        * platform/qt/Skipped:
     20        * platform/win/Skipped:
     21
    1222011-06-21  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r89395 r89396  
    39123912BUGCR85293 LINUX : svg/text/foreignObject-text-clipping-bug.xml = IMAGE PASS
    39133913
     3914// New flexbox is not yet enabled.
     3915BUGWK62048 SKIP : css3/flexbox = PASS
     3916
    39143917BUGCR85394 : fast/js/eval-var-decl.html = FAIL PASS
    39153918BUGCR85755 : fast/js/exception-properties.html = TEXT
  • trunk/LayoutTests/platform/gtk/Skipped

    r89374 r89396  
    15361536http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
    15371537
     1538# New flexbox is not yet enabled. http://webkit.org/b/62048
     1539css3/flexbox
     1540
    15381541# Failing because GTK DumpRenderTree doesn't block external network requests like the
    15391542# willSendRequest method does for other ports (bug 62585).
  • trunk/LayoutTests/platform/mac/Skipped

    r88896 r89396  
    372372svg/zoom/page/zoom-svg-through-object-with-text.xhtml
    373373
     374# New flexbox is not yet enabled. http://webkit.org/b/62048
     375css3/flexbox
     376
    374377# JSC does not support setIsolatedWorldSecurityOrigin (http://webkit.org/b/61540)
    375378http/tests/security/isolatedWorld/cross-origin-xhr.html
  • trunk/LayoutTests/platform/qt/Skipped

    r89341 r89396  
    25422542fast/events/touch/touch-gesture-scroll.html
    25432543
     2544# New flexbox is not yet enabled. http://webkit.org/b/62048
     2545css3/flexbox
     2546
    25442547# https://bugs.webkit.org/show_bug.cgi?id=62278
    25452548# The profiler test is entirely unrelated to the original change r88337
  • trunk/LayoutTests/platform/win/Skipped

    r88801 r89396  
    13401340http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
    13411341
     1342# New flexbox is not yet enabled. http://webkit.org/b/62048
     1343css3/flexbox
     1344
    13421345# Causes a SyntaxError (http://webkit.org/b/62595).
    13431346fast/workers/worker-crash-with-invalid-location.html
  • trunk/Source/WebCore/CMakeLists.txt

    r89364 r89396  
    430430    css/CSSComputedStyleDeclaration.cpp
    431431    css/CSSCursorImageValue.cpp
     432    css/CSSFlexValue.cpp
    432433    css/CSSFontFace.cpp
    433434    css/CSSFontFaceRule.cpp
  • trunk/Source/WebCore/ChangeLog

    r89394 r89396  
     12011-06-21  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        add css parsing of flex()
     6        https://bugs.webkit.org/show_bug.cgi?id=62050
     7
     8        Test: css3/flexbox/flex-parsing.html
     9
     10        * CMakeLists.txt: Add CSSFlexValue.*
     11        * GNUmakefile.list.am: Ditto.
     12        * WebCore.gypi: Ditto.
     13        * WebCore.pro: Ditto.
     14        * WebCore.vcproj/WebCore.vcproj: Ditto.
     15        * WebCore.xcodeproj/project.pbxproj: Ditto.
     16        * css/CSSFlexValue.cpp: Added.
     17        (WebCore::CSSFlexValue::~CSSFlexValue):
     18        (WebCore::CSSFlexValue::cssText):
     19        * css/CSSFlexValue.h: Added.
     20        (WebCore::CSSFlexValue::create): Hold positive flex, negative flex and sizing.
     21        (WebCore::CSSFlexValue::CSSFlexValue):
     22        * css/CSSParser.cpp:
     23        (WebCore::CSSParser::parseValidPrimitive): Pull out code from parseValue.
     24        (WebCore::CSSParser::parseValue):
     25        (WebCore::CSSParser::parseFlex): Parse the different version of flex().
     26        * css/CSSParser.h:
     27
    1282011-06-21  Adrienne Walker  <enne@google.com>
    229
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89321 r89396  
    923923        Source/WebCore/css/CSSCursorImageValue.cpp \
    924924        Source/WebCore/css/CSSCursorImageValue.h \
     925        Source/WebCore/css/CSSFlexValue.cpp \
     926        Source/WebCore/css/CSSFlexValue.h \
    925927        Source/WebCore/css/CSSFontFace.cpp \
    926928        Source/WebCore/css/CSSFontFace.h \
  • trunk/Source/WebCore/WebCore.gypi

    r89386 r89396  
    22892289            'css/CSSComputedStyleDeclaration.cpp',
    22902290            'css/CSSCursorImageValue.cpp',
     2291            'css/CSSFlexValue.cpp',
     2292            'css/CSSFlexValue.h',
    22912293            'css/CSSFontFace.cpp',
    22922294            'css/CSSFontFace.h',
  • trunk/Source/WebCore/WebCore.pro

    r89321 r89396  
    388388    css/CSSComputedStyleDeclaration.cpp \
    389389    css/CSSCursorImageValue.cpp \
     390    css/CSSFlexValue.cpp \
    390391    css/CSSFontFace.cpp \
    391392    css/CSSFontFaceRule.cpp \
     
    13771378    css/CSSComputedStyleDeclaration.h \
    13781379    css/CSSCursorImageValue.h \
     1380    css/CSSFlexValue.h \
    13791381    css/CSSFontFace.h \
    13801382    css/CSSFontFaceRule.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r89386 r89396  
    3240732407                        </File>
    3240832408                        <File
     32409                                RelativePath="..\css\CSSFlexValue.cpp"
     32410                                >
     32411                        </File>
     32412                        <File
     32413                                RelativePath="..\css\CSSFlexValue.h"
     32414                                >
     32415                        </File>
     32416                        <File
    3240932417                                RelativePath="..\css\CSSFontFace.cpp"
    3241032418                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89325 r89396  
    14131413                521D46F611AEC98100514613 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 521D46F511AEC98100514613 /* KillRingMac.mm */; };
    14141414                521D46F811AEC9B100514613 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = 521D46F711AEC9B100514613 /* KillRing.h */; };
     1415                5325E4D713A6C88B00404A36 /* CSSFlexValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5325E4D513A6C88B00404A36 /* CSSFlexValue.cpp */; };
     1416                5325E4D813A6C88B00404A36 /* CSSFlexValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 5325E4D613A6C88B00404A36 /* CSSFlexValue.h */; };
    14151417                54C50F7B0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54C50F7A0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp */; };
    14161418                550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 550A0BC7085F6039007353D6 /* QualifiedName.cpp */; };
     
    79327934                521D46F511AEC98100514613 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KillRingMac.mm; sourceTree = "<group>"; };
    79337935                521D46F711AEC9B100514613 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
     7936                5325E4D513A6C88B00404A36 /* CSSFlexValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFlexValue.cpp; sourceTree = "<group>"; };
     7937                5325E4D613A6C88B00404A36 /* CSSFlexValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFlexValue.h; sourceTree = "<group>"; };
    79347938                54C50F7A0E801DF3009832A0 /* XMLDocumentParserLibxml2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLDocumentParserLibxml2.cpp; sourceTree = "<group>"; };
    79357939                550A0BC7085F6039007353D6 /* QualifiedName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = QualifiedName.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    1904119045                                AA0978ED0ABAA6E100874480 /* CSSCursorImageValue.cpp */,
    1904219046                                AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */,
     19047                                5325E4D513A6C88B00404A36 /* CSSFlexValue.cpp */,
     19048                                5325E4D613A6C88B00404A36 /* CSSFlexValue.h */,
    1904319049                                BC64B4CD0CB4298A005F2B62 /* CSSFontFace.cpp */,
    1904419050                                BC64B4CE0CB4298A005F2B62 /* CSSFontFace.h */,
     
    2028820294                                BCEA4790097CAAC80094C9E4 /* CSSComputedStyleDeclaration.h in Headers */,
    2028920295                                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */,
     20296                                5325E4D813A6C88B00404A36 /* CSSFlexValue.h in Headers */,
    2029020297                                BC64B4D60CB4298A005F2B62 /* CSSFontFace.h in Headers */,
    2029120298                                A80E6CFD0A1989CA007FB8C5 /* CSSFontFaceRule.h in Headers */,
     
    2353223539                                BCEA478F097CAAC80094C9E4 /* CSSComputedStyleDeclaration.cpp in Sources */,
    2353323540                                AA21ECCA0ABF0FBA002B834C /* CSSCursorImageValue.cpp in Sources */,
     23541                                5325E4D713A6C88B00404A36 /* CSSFlexValue.cpp in Sources */,
    2353423542                                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */,
    2353523543                                A80E6CE70A1989CA007FB8C5 /* CSSFontFaceRule.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSParser.cpp

    r88448 r89396  
    3030#include "CSSCharsetRule.h"
    3131#include "CSSCursorImageValue.h"
     32#include "CSSFlexValue.h"
    3233#include "CSSFontFaceRule.h"
    3334#include "CSSFontFaceSrcValue.h"
     
    780781}
    781782
     783inline PassRefPtr<CSSValue> CSSParser::parseValidPrimitive(int id, CSSParserValue* value)
     784{
     785    if (id)
     786        return primitiveValueCache()->createIdentifierValue(id);
     787    if (value->unit == CSSPrimitiveValue::CSS_STRING)
     788        return primitiveValueCache()->createValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
     789    if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
     790        return primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     791    if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
     792        return primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
     793    if (value->unit >= CSSParserValue::Q_EMS)
     794        return CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
     795    return 0;
     796}
     797
    782798bool CSSParser::parseValue(int propId, bool important)
    783799{
     
    12861302    case CSSPropertyHeight:               // <length> | <percentage> | auto | inherit
    12871303    case CSSPropertyWidth:                // <length> | <percentage> | auto | inherit
    1288     case CSSPropertyWebkitLogicalWidth: 
     1304    case CSSPropertyWebkitLogicalWidth:
    12891305    case CSSPropertyWebkitLogicalHeight:
    12901306        if (id == CSSValueAuto || id == CSSValueIntrinsic || id == CSSValueMinIntrinsic)
    12911307            validPrimitive = true;
    1292         else
     1308        else if (!id && validUnit(value, FLength | FPercent | FNonNeg, m_strict))
    12931309            // ### handle multilength case where we allow relative units
    1294             validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg, m_strict));
     1310            validPrimitive = true;
     1311        else if (value->unit == CSSParserValue::Function)
     1312            return parseFlex(propId, important);
    12951313        break;
    12961314
     
    20462064
    20472065    if (validPrimitive) {
    2048         if (id != 0)
    2049             parsedValue = primitiveValueCache()->createIdentifierValue(id);
    2050         else if (value->unit == CSSPrimitiveValue::CSS_STRING)
    2051             parsedValue = primitiveValueCache()->createValue(value->string, (CSSPrimitiveValue::UnitTypes) value->unit);
    2052         else if (value->unit >= CSSPrimitiveValue::CSS_NUMBER && value->unit <= CSSPrimitiveValue::CSS_KHZ)
    2053             parsedValue = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    2054         else if (value->unit >= CSSPrimitiveValue::CSS_TURN && value->unit <= CSSPrimitiveValue::CSS_REMS)
    2055             parsedValue = primitiveValueCache()->createValue(value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit);
    2056         else if (value->unit >= CSSParserValue::Q_EMS)
    2057             parsedValue = CSSQuirkPrimitiveValue::create(value->fValue, CSSPrimitiveValue::CSS_EMS);
     2066        parsedValue = parseValidPrimitive(id, value);
    20582067        m_valueList->next();
    20592068    }
     
    47664775}
    47674776
     4777bool CSSParser::parseFlex(int propId, bool important)
     4778{
     4779#if ENABLE(CSS3_FLEXBOX)
     4780    CSSParserValue* value = m_valueList->current();
     4781    CSSParserValueList* args = value->function->args.get();
     4782    if (!equalIgnoringCase(value->function->name, "-webkit-flex(") || !args || args->size() > 3 || m_valueList->next())
     4783        return false;
     4784
     4785    static const double unsetValue = -1;
     4786    double positiveFlex = unsetValue;
     4787    double negativeFlex = unsetValue;
     4788    RefPtr<CSSValue> preferredSize;
     4789
     4790    while (CSSParserValue* arg = args->current()) {
     4791        if (validUnit(arg, FNumber | FNonNeg, m_strict)) {
     4792            if (positiveFlex == unsetValue)
     4793                positiveFlex = arg->fValue;
     4794            else if (negativeFlex == unsetValue)
     4795                negativeFlex = arg->fValue;
     4796            else if (!arg->fValue) {
     4797                // flex() only allows a size of 0 if the positive and negative flex values have already been set.
     4798                preferredSize = primitiveValueCache()->createValue(0, CSSPrimitiveValue::CSS_PX);
     4799            } else {
     4800                // We only allow 3 numbers without units if the last value is 0. E.g., flex(1 1 1) is invalid.
     4801                return false;
     4802            }
     4803        } else if (!preferredSize && (arg->id == CSSValueAuto || validUnit(arg, FLength | FPercent | FNonNeg, m_strict)))
     4804            preferredSize = parseValidPrimitive(arg->id, arg);
     4805        else {
     4806            // Not a valid arg for flex().
     4807            return false;
     4808        }
     4809        args->next();
     4810    }
     4811
     4812    if (positiveFlex == unsetValue)
     4813        positiveFlex = 1;
     4814    if (negativeFlex == unsetValue)
     4815        negativeFlex = 0;
     4816    if (!preferredSize)
     4817        preferredSize = primitiveValueCache()->createIdentifierValue(CSSValueAuto);
     4818
     4819    RefPtr<CSSFlexValue> flex = CSSFlexValue::create(positiveFlex, negativeFlex, preferredSize);
     4820    addProperty(propId, flex.release(), important);
     4821    return true;
     4822#else
     4823    UNUSED_PARAM(propId);
     4824    UNUSED_PARAM(important);
     4825#endif // ENABLE(CSS3_FLEXBOX)
     4826    return false;
     4827}
     4828
    47684829struct BorderImageParseContext {
    47694830    BorderImageParseContext(CSSPrimitiveValueCache* primitiveValueCache)
  • trunk/Source/WebCore/css/CSSParser.h

    r86135 r89396  
    6565        static bool parseColor(RGBA32& color, const String&, bool strict = false);
    6666        static bool parseSystemColor(RGBA32& color, const String&, Document*);
     67        PassRefPtr<CSSValue> parseValidPrimitive(int propId, CSSParserValue*);
    6768        bool parseColor(CSSMutableStyleDeclaration*, const String&);
    6869        bool parseDeclaration(CSSMutableStyleDeclaration*, const String&, RefPtr<CSSStyleSourceData>* styleSourceData = 0);
     
    162163
    163164        bool parseReflect(int propId, bool important);
     165
     166        bool parseFlex(int propId, bool important);
    164167
    165168        // Image generators
  • trunk/Source/WebKit/chromium/ChangeLog

    r89393 r89396  
     12011-06-21  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        add css parsing of flex()
     6        https://bugs.webkit.org/show_bug.cgi?id=62050
     7
     8        * features.gypi: Add a gyp flag (enable_css3_flexbox) for setting ENABLE_CSS3_FLEXBOX.
     9
    1102011-06-21  Zhenyao Mo  <zmo@google.com>
    211
  • trunk/Source/WebKit/chromium/features.gypi

    r89305 r89396  
    109109      'enable_touch_icon_loading%' : 0,
    110110      'enable_smooth_scrolling%': 0,
     111      'enable_css3_flexbox%': 0,
    111112    },
    112113    'use_accelerated_compositing%': '<(use_accelerated_compositing)',
     
    159160        ],
    160161      }],
     162      ['enable_css3_flexbox==1', {
     163        'feature_defines': [
     164          'ENABLE_CSS3_FLEXBOX=1',
     165        ],
     166      }],
    161167    ],
    162168  },
Note: See TracChangeset for help on using the changeset viewer.