Changeset 171010 in webkit


Ignore:
Timestamp:
Jul 11, 2014 1:26:00 PM (10 years ago)
Author:
jfernandez@igalia.com
Message:

[CSS Grid Layout] Implement justify-self css property
https://bugs.webkit.org/show_bug.cgi?id=134419

Reviewed by Dean Jackson.

This change adds the justify-self property from CSS 3 Box Alignment
and implements the parsing.

From Blink r164685 by <jchaffraix@chromium.org>

Source/WebCore:
Test: fast/css/parse-justify-self.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::isValidKeywordPropertyAndValue):
(WebCore::CSSParser::parseValue):
(WebCore::isItemPositionKeyword):
(WebCore::CSSParser::parseJustifySelf):

  • css/CSSParser.h:
  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EJustifySelf):
(WebCore::CSSPrimitiveValue::operator EJustifySelfOverflowAlignment):

  • css/CSSPropertyNames.in:
  • css/CSSValueKeywords.in:
  • css/DeprecatedStyleBuilder.cpp:

(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyProperty):

  • rendering/style/RenderStyle.h:
  • rendering/style/RenderStyleConstants.h:
  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):

  • rendering/style/StyleRareNonInheritedData.h:

LayoutTests:

  • fast/css/parse-justify-self-expected.txt: Added.
  • fast/css/parse-justify-self.html: Added.
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r171004 r171010  
     12014-07-11  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Implement justify-self css property
     4        https://bugs.webkit.org/show_bug.cgi?id=134419
     5
     6        Reviewed by Dean Jackson.
     7
     8        This change adds the justify-self property from CSS 3 Box Alignment
     9        and implements the parsing.
     10
     11        From Blink r164685 by <jchaffraix@chromium.org>
     12
     13        * fast/css/parse-justify-self-expected.txt: Added.
     14        * fast/css/parse-justify-self.html: Added.
     15
    1162014-07-11  Brent Fulgham  <bfulgham@apple.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r171008 r171010  
     12014-07-11  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        [CSS Grid Layout] Implement justify-self css property
     4        https://bugs.webkit.org/show_bug.cgi?id=134419
     5
     6        Reviewed by Dean Jackson.
     7
     8        This change adds the justify-self property from CSS 3 Box Alignment
     9        and implements the parsing.
     10
     11        From Blink r164685 by <jchaffraix@chromium.org>
     12
     13        Test: fast/css/parse-justify-self.html
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore::ComputedStyleExtractor::propertyValue):
     17        * css/CSSParser.cpp:
     18        (WebCore::isValidKeywordPropertyAndValue):
     19        (WebCore::CSSParser::parseValue):
     20        (WebCore::isItemPositionKeyword):
     21        (WebCore::CSSParser::parseJustifySelf):
     22        * css/CSSParser.h:
     23        * css/CSSPrimitiveValueMappings.h:
     24        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     25        (WebCore::CSSPrimitiveValue::operator EJustifySelf):
     26        (WebCore::CSSPrimitiveValue::operator EJustifySelfOverflowAlignment):
     27        * css/CSSPropertyNames.in:
     28        * css/CSSValueKeywords.in:
     29        * css/DeprecatedStyleBuilder.cpp:
     30        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
     31        * css/StyleResolver.cpp:
     32        (WebCore::StyleResolver::applyProperty):
     33        * rendering/style/RenderStyle.h:
     34        * rendering/style/RenderStyleConstants.h:
     35        * rendering/style/StyleRareNonInheritedData.cpp:
     36        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     37        (WebCore::StyleRareNonInheritedData::operator==):
     38        * rendering/style/StyleRareNonInheritedData.h:
     39
    1402014-07-11  Bear Travis  <betravis@adobe.com>
    241
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r170996 r171010  
    284284    CSSPropertyWebkitFlexWrap,
    285285    CSSPropertyWebkitJustifyContent,
     286    CSSPropertyWebkitJustifySelf,
    286287    CSSPropertyWebkitFontKerning,
    287288    CSSPropertyWebkitFontSmoothing,
     
    20072008        case CSSPropertyWebkitJustifyContent:
    20082009            return cssValuePool().createValue(style->justifyContent());
     2010        case CSSPropertyWebkitJustifySelf: {
     2011            RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated();
     2012            result->append(CSSPrimitiveValue::create(style->justifySelf()));
     2013            if (style->justifySelf() >= JustifySelfCenter && style->justifySelfOverflowAlignment() != JustifySelfOverflowAlignmentDefault)
     2014                result->append(CSSPrimitiveValue::create(style->justifySelfOverflowAlignment()));
     2015            return result.release();
     2016        }
    20092017        case CSSPropertyWebkitOrder:
    20102018            return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
  • trunk/Source/WebCore/css/CSSParser.cpp

    r170996 r171010  
    849849        break;
    850850    case CSSPropertyWebkitAlignContent:
    851          if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch)
    852              return true;
    853          break;
     851        // FIXME: Per CSS alignment, this property should accept an optional <overflow-position>. We should share this parsing code with 'justify-self'.
     852        if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch)
     853            return true;
     854        break;
    854855    case CSSPropertyWebkitAlignItems:
     856        // FIXME: Per CSS alignment, this property should accept the same arguments as 'justify-self' so we should share its parsing code.
    855857        if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
    856858            return true;
    857859        break;
    858860    case CSSPropertyWebkitAlignSelf:
     861        // FIXME: Per CSS alignment, this property should accept the same arguments as 'justify-self' so we should share its parsing code.
    859862        if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
    860863            return true;
     
    869872        break;
    870873    case CSSPropertyWebkitJustifyContent:
     874        // FIXME: Per CSS alignment, this property should accept an optional <overflow-position>. We should share this parsing code with 'justify-self'.
    871875        if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround)
     876            return true;
     877        break;
     878    case CSSPropertyWebkitJustifySelf:
     879        if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch)
    872880            return true;
    873881        break;
     
    25672575        return false;
    25682576    }
     2577    case CSSPropertyWebkitJustifySelf:
     2578        return parseJustifySelf(propId, important);
    25692579#if ENABLE(CSS_GRID_LAYOUT)
    25702580    case CSSPropertyWebkitGridAutoColumns:
     
    30683078    else
    30693079        lval = rval;
     3080}
     3081
     3082static bool isItemPositionKeyword(CSSValueID id)
     3083{
     3084    return id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter
     3085        || id == CSSValueSelfStart || id == CSSValueSelfEnd || id == CSSValueFlexStart
     3086        || id == CSSValueFlexEnd || id == CSSValueLeft || id == CSSValueRight;
     3087}
     3088
     3089bool CSSParser::parseJustifySelf(CSSPropertyID propId, bool important)
     3090{
     3091    // auto | baseline | stretch | [<item-position> && <overflow-position>? ]
     3092    // <item-position> = center | start | end | self-start | self-end | flex-start | flex-end | left | right;
     3093    // <overflow-position> = true | safe
     3094
     3095    CSSParserValue* value = m_valueList->current();
     3096
     3097    if (value->id == CSSValueAuto || value->id == CSSValueBaseline || value->id == CSSValueStretch) {
     3098        if (m_valueList->next())
     3099            return false;
     3100
     3101        addProperty(propId, cssValuePool().createIdentifierValue(value->id), important);
     3102        return true;
     3103    }
     3104
     3105    RefPtr<CSSPrimitiveValue> position = 0;
     3106    RefPtr<CSSPrimitiveValue> overflowAlignmentKeyword = 0;
     3107    if (isItemPositionKeyword(value->id)) {
     3108        position = cssValuePool().createIdentifierValue(value->id);
     3109        value = m_valueList->next();
     3110        if (value) {
     3111            if (value->id != CSSValueTrue && value->id != CSSValueSafe)
     3112                return false;
     3113            overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id);
     3114        }
     3115    } else if (value->id != CSSValueTrue && value->id != CSSValueSafe)
     3116        return false;
     3117    else {
     3118        overflowAlignmentKeyword = cssValuePool().createIdentifierValue(value->id);
     3119        value = m_valueList->next();
     3120        if (value) {
     3121            if (!isItemPositionKeyword(value->id))
     3122                return false;
     3123            position = cssValuePool().createIdentifierValue(value->id);
     3124        }
     3125    }
     3126
     3127    if (m_valueList->next())
     3128        return false;
     3129
     3130    ASSERT(position);
     3131    if (overflowAlignmentKeyword)
     3132        addProperty(propId, createPrimitiveValuePair(position.release(), overflowAlignmentKeyword.release()), important);
     3133    else
     3134        addProperty(propId, position.release(), important);
     3135
     3136    return true;
    30703137}
    30713138
  • trunk/Source/WebCore/css/CSSParser.h

    r170996 r171010  
    184184    bool parseClipShape(CSSPropertyID, bool important);
    185185
     186    bool parseJustifySelf(CSSPropertyID, bool important);
     187
    186188#if ENABLE(CSS_SHAPES)
    187189    PassRefPtr<CSSValue> parseShapeProperty(CSSPropertyID);
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r170996 r171010  
    50905090}
    50915091
     5092template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EJustifySelf justifySelf)
     5093    : CSSValue(PrimitiveClass)
     5094{
     5095    m_primitiveUnitType = CSS_VALUE_ID;
     5096    switch (justifySelf) {
     5097    case JustifySelfAuto:
     5098        m_value.valueID = CSSValueAuto;
     5099        break;
     5100    case JustifySelfStretch:
     5101        m_value.valueID = CSSValueStretch;
     5102        break;
     5103    case JustifySelfBaseline:
     5104        m_value.valueID = CSSValueBaseline;
     5105        break;
     5106    case JustifySelfCenter:
     5107        m_value.valueID = CSSValueCenter;
     5108        break;
     5109    case JustifySelfStart:
     5110        m_value.valueID = CSSValueStart;
     5111        break;
     5112    case JustifySelfEnd:
     5113        m_value.valueID = CSSValueEnd;
     5114        break;
     5115    case JustifySelfSelfStart:
     5116        m_value.valueID = CSSValueSelfStart;
     5117        break;
     5118    case JustifySelfSelfEnd:
     5119        m_value.valueID = CSSValueSelfEnd;
     5120        break;
     5121    case JustifySelfFlexStart:
     5122        m_value.valueID = CSSValueFlexStart;
     5123        break;
     5124    case JustifySelfFlexEnd:
     5125        m_value.valueID = CSSValueFlexEnd;
     5126        break;
     5127    case JustifySelfLeft:
     5128        m_value.valueID = CSSValueLeft;
     5129        break;
     5130    case JustifySelfRight:
     5131        m_value.valueID = CSSValueRight;
     5132        break;
     5133    default:
     5134        m_value.valueID = CSSValueAuto;
     5135        break;
     5136    }
     5137}
     5138
     5139template<> inline CSSPrimitiveValue::operator EJustifySelf() const
     5140{
     5141    switch (m_value.valueID) {
     5142    case CSSValueAuto:
     5143        return JustifySelfAuto;
     5144    case CSSValueStretch:
     5145        return JustifySelfStretch;
     5146    case CSSValueBaseline:
     5147        return JustifySelfBaseline;
     5148    case CSSValueCenter:
     5149        return JustifySelfCenter;
     5150    case CSSValueStart:
     5151        return JustifySelfStart;
     5152    case CSSValueEnd:
     5153        return JustifySelfEnd;
     5154    case CSSValueSelfStart:
     5155        return JustifySelfSelfStart;
     5156    case CSSValueSelfEnd:
     5157        return JustifySelfSelfEnd;
     5158    case CSSValueFlexStart:
     5159        return JustifySelfFlexStart;
     5160    case CSSValueFlexEnd:
     5161        return JustifySelfFlexEnd;
     5162    case CSSValueLeft:
     5163        return JustifySelfLeft;
     5164    case CSSValueRight:
     5165        return JustifySelfRight;
     5166    default:
     5167        break;
     5168    }
     5169    ASSERT_NOT_REACHED();
     5170    return JustifySelfAuto;
     5171}
     5172
     5173template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EJustifySelfOverflowAlignment overflowAlignment)
     5174    : CSSValue(PrimitiveClass)
     5175{
     5176    m_primitiveUnitType = CSS_VALUE_ID;
     5177    switch (overflowAlignment) {
     5178    case JustifySelfOverflowAlignmentDefault:
     5179        m_value.valueID = CSSValueDefault;
     5180        break;
     5181    case JustifySelfOverflowAlignmentTrue:
     5182        m_value.valueID = CSSValueTrue;
     5183        break;
     5184    case JustifySelfOverflowAlignmentSafe:
     5185        m_value.valueID = CSSValueSafe;
     5186        break;
     5187    }
     5188}
     5189
     5190template<> inline CSSPrimitiveValue::operator EJustifySelfOverflowAlignment() const
     5191{
     5192    switch (m_value.valueID) {
     5193    case CSSValueTrue:
     5194        return JustifySelfOverflowAlignmentTrue;
     5195    case CSSValueSafe:
     5196        return JustifySelfOverflowAlignmentSafe;
     5197    default:
     5198        break;
     5199    }
     5200    ASSERT_NOT_REACHED();
     5201    return JustifySelfOverflowAlignmentTrue;
     5202}
     5203
    50925204}
    50935205
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r169349 r171010  
    304304-webkit-flex-wrap
    305305-webkit-justify-content
     306-webkit-justify-self
    306307-webkit-font-size-delta
    307308#if defined(ENABLE_CSS_GRID_LAYOUT) && ENABLE_CSS_GRID_LAYOUT
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r170996 r171010  
    545545// space-around
    546546
     547// CSS_PROP_JUSTIFY_SELF
     548// auto
     549// stretch
     550// baseline
     551// center
     552// start
     553// end
     554self-start
     555self-end
     556// flex-start
     557// flex-end
     558// left
     559// right
     560true
     561safe
     562
    547563// CSS_PROP_FLEX_FLOW
    548564row
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r170996 r171010  
    28282828    }
    28292829#endif /* ENABLE(CSS_GRID_LAYOUT) */
     2830    case CSSPropertyWebkitJustifySelf: {
     2831        HANDLE_INHERIT_AND_INITIAL(justifySelf, JustifySelf);
     2832        CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value);
     2833        if (Pair* pairValue = primitiveValue->getPairValue()) {
     2834            state.style()->setJustifySelf(*pairValue->first());
     2835            state.style()->setJustifySelfOverflowAlignment(*pairValue->second());
     2836        } else
     2837            state.style()->setJustifySelf(*primitiveValue);
     2838        return;
     2839    }
    28302840    // These properties are aliased and DeprecatedStyleBuilder already applied the property on the prefixed version.
    28312841    case CSSPropertyTransitionDelay:
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r170996 r171010  
    915915    EFlexWrap flexWrap() const { return static_cast<EFlexWrap>(rareNonInheritedData->m_flexibleBox->m_flexWrap); }
    916916    EJustifyContent justifyContent() const { return static_cast<EJustifyContent>(rareNonInheritedData->m_justifyContent); }
     917    EJustifySelf justifySelf() const { return static_cast<EJustifySelf>(rareNonInheritedData->m_justifySelf); }
     918    EJustifySelfOverflowAlignment justifySelfOverflowAlignment() const { return static_cast<EJustifySelfOverflowAlignment>(rareNonInheritedData->m_justifySelfOverflowAlignment); }
    917919
    918920#if ENABLE(CSS_GRID_LAYOUT)
     
    14621464    void setFlexWrap(EFlexWrap w) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexWrap, w); }
    14631465    void setJustifyContent(EJustifyContent p) { SET_VAR(rareNonInheritedData, m_justifyContent, p); }
     1466    void setJustifySelf(EJustifySelf p) { SET_VAR(rareNonInheritedData, m_justifySelf, p); }
     1467    void setJustifySelfOverflowAlignment(EJustifySelfOverflowAlignment overflowAlignment) { SET_VAR(rareNonInheritedData, m_justifySelfOverflowAlignment, overflowAlignment); }
    14641468#if ENABLE(CSS_GRID_LAYOUT)
    14651469    void setGridAutoColumns(const GridTrackSize& length) { SET_VAR(rareNonInheritedData.access()->m_grid, m_gridAutoColumns, length); }
     
    18261830    static EFlexWrap initialFlexWrap() { return FlexNoWrap; }
    18271831    static EJustifyContent initialJustifyContent() { return JustifyFlexStart; }
     1832    static EJustifySelf initialJustifySelf() { return JustifySelfAuto; }
     1833    static EJustifySelfOverflowAlignment initialJustifySelfOverflowAlignment() { return JustifySelfOverflowAlignmentDefault; }
    18281834    static int initialMarqueeLoopCount() { return -1; }
    18291835    static int initialMarqueeSpeed() { return 85; }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r170996 r171010  
    185185enum EFlexWrap { FlexNoWrap, FlexWrap, FlexWrapReverse };
    186186enum EJustifyContent { JustifyFlexStart, JustifyFlexEnd, JustifyCenter, JustifySpaceBetween, JustifySpaceAround };
     187enum EJustifySelf {JustifySelfAuto, JustifySelfStretch, JustifySelfBaseline, JustifySelfCenter, JustifySelfStart, JustifySelfEnd, JustifySelfSelfStart, JustifySelfSelfEnd, JustifySelfFlexStart, JustifySelfFlexEnd, JustifySelfLeft, JustifySelfRight};
     188enum EJustifySelfOverflowAlignment {JustifySelfOverflowAlignmentDefault, JustifySelfOverflowAlignmentTrue, JustifySelfOverflowAlignmentSafe};
     189
    187190
    188191enum ETextSecurity {
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r166618 r171010  
    7777    , m_alignSelf(RenderStyle::initialAlignSelf())
    7878    , m_justifyContent(RenderStyle::initialJustifyContent())
     79    , m_justifySelf(RenderStyle::initialJustifySelf())
     80    , m_justifySelfOverflowAlignment(RenderStyle::initialJustifySelfOverflowAlignment())
    7981    , userDrag(RenderStyle::initialUserDrag())
    8082    , textOverflow(RenderStyle::initialTextOverflow())
     
    154156    , m_alignSelf(o.m_alignSelf)
    155157    , m_justifyContent(o.m_justifyContent)
     158    , m_justifySelf(o.m_justifySelf)
     159    , m_justifySelfOverflowAlignment(o.m_justifySelfOverflowAlignment)
    156160    , userDrag(o.userDrag)
    157161    , textOverflow(o.textOverflow)
     
    256260#endif
    257261        && m_aspectRatioType == o.m_aspectRatioType
    258         && m_objectFit == o.m_objectFit;
     262        && m_objectFit == o.m_objectFit
     263        && m_justifySelf == o.m_justifySelf
     264        && m_justifySelfOverflowAlignment == o.m_justifySelfOverflowAlignment;
    259265}
    260266
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r166618 r171010  
    177177    unsigned m_justifyContent : 3; // EJustifyContent
    178178
     179    unsigned m_justifySelf : 4; // EJustifySelf
     180    unsigned m_justifySelfOverflowAlignment : 2; // EJustifySelfOverflowAlignment
     181
    179182    unsigned userDrag : 2; // EUserDrag
    180183    unsigned textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
Note: See TracChangeset for help on using the changeset viewer.