Ignore:
Timestamp:
Aug 6, 2013, 8:08:21 AM (12 years ago)
Author:
sergio@webkit.org
Message:

[CSS Grid Layout] Allow defining named grid lines on the grid element
https://bugs.webkit.org/show_bug.cgi?id=118255

Reviewed by Andreas Kling.

From Blink r149798 by <jchaffraix@chromium.org>

Source/WebCore:

This change adds parsing, style resolution and getComputedStyle
support for named grid lines at the grid element level
(i.e. extends our <track-list> support). Per the specification, we
allow multiple grid lines with the same name.

To fully support resolving the grid lines to a position on our
grid, we need to add the parsing at the grid item's level (which
means extending our <grid-line> support). This will be done in a
follow-up change.

Test: fast/css-grid-layout/named-grid-line-get-set.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::addValuesForNamedGridLinesAtIndex):
(WebCore::valueForGridTrackList):
(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseGridTrackList):

  • css/StyleResolver.cpp:

(WebCore::createGridTrackList):
(WebCore::StyleResolver::applyProperty):

  • rendering/style/RenderStyle.h:
  • rendering/style/StyleGridData.cpp:

(WebCore::StyleGridData::StyleGridData):

  • rendering/style/StyleGridData.h:

(WebCore::StyleGridData::operator==):

LayoutTests:

  • fast/css-grid-layout/named-grid-line-get-set-expected.txt: Added.
  • fast/css-grid-layout/named-grid-line-get-set.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r153748 r153752  
    10841084}
    10851085
    1086 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const RenderStyle* style, RenderView *renderView)
     1086static void addValuesForNamedGridLinesAtIndex(const NamedGridLinesMap& namedGridLines, size_t i, CSSValueList& list)
     1087{
     1088    // Note that this won't return the results in the order specified in the style sheet,
     1089    // which is probably fine as we still *do* return all the expected values.
     1090    NamedGridLinesMap::const_iterator it = namedGridLines.begin();
     1091    NamedGridLinesMap::const_iterator end = namedGridLines.end();
     1092    for (; it != end; ++it) {
     1093        const Vector<size_t>& linesIndexes = it->value;
     1094        for (size_t j = 0; j < linesIndexes.size(); ++j) {
     1095            if (linesIndexes[j] != i)
     1096                continue;
     1097
     1098            list.append(cssValuePool().createValue(it->key, CSSPrimitiveValue::CSS_STRING));
     1099            break;
     1100        }
     1101    }
     1102}
     1103
     1104static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& trackSizes, const NamedGridLinesMap& namedGridLines, const RenderStyle* style, RenderView* renderView)
    10871105{
    10881106    // Handle the 'none' case here.
    1089     if (!trackSizes.size())
     1107    if (!trackSizes.size()) {
     1108        ASSERT(namedGridLines.isEmpty());
    10901109        return cssValuePool().createIdentifierValue(CSSValueNone);
     1110    }
    10911111
    10921112    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    1093     for (size_t i = 0; i < trackSizes.size(); ++i)
     1113    for (size_t i = 0; i < trackSizes.size(); ++i) {
     1114        addValuesForNamedGridLinesAtIndex(namedGridLines, i, *list);
    10941115        list->append(valueForGridTrackSize(trackSizes[i], style, renderView));
     1116    }
     1117    // Those are the trailing <string>* allowed in the syntax.
     1118    addValuesForNamedGridLinesAtIndex(namedGridLines, trackSizes.size(), *list);
    10951119    return list.release();
    10961120}
     
    20452069            return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_node->document()->renderView());
    20462070        case CSSPropertyWebkitGridDefinitionColumns:
    2047             return valueForGridTrackList(style->gridColumns(), style.get(), m_node->document()->renderView());
     2071            return valueForGridTrackList(style->gridColumns(), style->namedGridColumnLines(), style.get(), m_node->document()->renderView());
    20482072        case CSSPropertyWebkitGridDefinitionRows:
    2049             return valueForGridTrackList(style->gridRows(), style.get(), m_node->document()->renderView());
     2073            return valueForGridTrackList(style->gridRows(), style->namedGridRowLines(), style.get(), m_node->document()->renderView());
    20502074
    20512075        case CSSPropertyWebkitGridColumnStart:
Note: See TracChangeset for help on using the changeset viewer.