Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 23472008: [CSS Grid Layout] Support calc() breadth track size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@103761-wk
Patch Set: Use isSpecified() and added a FIXME Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 default: 990 default:
991 filterValue = CSSFilterValue::create(CSSFilterValue::UnknownFilterOp eration); 991 filterValue = CSSFilterValue::create(CSSFilterValue::UnknownFilterOp eration);
992 break; 992 break;
993 } 993 }
994 list->append(filterValue.release()); 994 list->append(filterValue.release());
995 } 995 }
996 996
997 return list.release(); 997 return list.release();
998 } 998 }
999 999
1000 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const GridLength& trackBrea dth, const RenderStyle* style, RenderView* renderView) 1000 static PassRefPtr<CSSValue> valueForGridTrackBreadth(const GridLength& trackBrea dth, const RenderStyle* style, const LayoutUnit& maxSize, RenderView* renderView )
1001 { 1001 {
1002 // FIXME: according to the specs we must always return the used value http:/ /crbug.com/297158
1002 if (!trackBreadth.isLength()) 1003 if (!trackBreadth.isLength())
1003 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR); 1004 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR);
1004 1005
1005 const Length& trackBreadthLength = trackBreadth.length(); 1006 const Length& trackBreadthLength = trackBreadth.length();
1006 if (trackBreadthLength.isAuto()) 1007 if (trackBreadthLength.isAuto())
1007 return cssValuePool().createIdentifierValue(CSSValueAuto); 1008 return cssValuePool().createIdentifierValue(CSSValueAuto);
1008 if (trackBreadthLength.isViewportPercentage()) 1009 if (trackBreadthLength.isViewportPercentage())
1009 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, rend erView), style); 1010 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, rend erView), style);
1011 if (trackBreadthLength.isCalculated())
1012 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, maxSize , renderView), style);
1010 return zoomAdjustedPixelValueForLength(trackBreadthLength, style); 1013 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
1011 } 1014 }
1012 1015
1013 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize , const RenderStyle* style, RenderView* renderView) 1016 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize , const RenderStyle* style, const LayoutUnit& maxSize, RenderView* renderView)
1014 { 1017 {
1015 switch (trackSize.type()) { 1018 switch (trackSize.type()) {
1016 case LengthTrackSizing: 1019 case LengthTrackSizing:
1017 return valueForGridTrackBreadth(trackSize.length(), style, renderView); 1020 return valueForGridTrackBreadth(trackSize.length(), style, maxSize, rend erView);
1018 case MinMaxTrackSizing: 1021 case MinMaxTrackSizing:
1019 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated(); 1022 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated();
1020 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, renderView)); 1023 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, maxSize, renderView));
1021 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, renderView)); 1024 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, maxSize, renderView));
1022 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths); 1025 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1023 } 1026 }
1024 ASSERT_NOT_REACHED(); 1027 ASSERT_NOT_REACHED();
1025 return 0; 1028 return 0;
1026 } 1029 }
1027 1030
1028 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list) 1031 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list)
1029 { 1032 {
1030 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i); 1033 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i);
1031 for (size_t j = 0; j < namedGridLines.size(); ++j) 1034 for (size_t j = 0; j < namedGridLines.size(); ++j)
1032 list.append(cssValuePool().createValue(namedGridLines[j], CSSPrimitiveVa lue::CSS_STRING)); 1035 list.append(cssValuePool().createValue(namedGridLines[j], CSSPrimitiveVa lue::CSS_STRING));
1033 } 1036 }
1034 1037
1035 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const OrderedNamedGridLines& orderedNamedGridLines, const RenderStyle * style, RenderView* renderView) 1038 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const OrderedNamedGridLines& orderedNamedGridLines, const RenderStyle * style, const LayoutUnit& maxSize, RenderView* renderView)
1036 { 1039 {
1037 // Handle the 'none' case here. 1040 // Handle the 'none' case here.
1038 if (!trackSizes.size()) { 1041 if (!trackSizes.size()) {
1039 ASSERT(orderedNamedGridLines.isEmpty()); 1042 ASSERT(orderedNamedGridLines.isEmpty());
1040 return cssValuePool().createIdentifierValue(CSSValueNone); 1043 return cssValuePool().createIdentifierValue(CSSValueNone);
1041 } 1044 }
1042 1045
1043 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1046 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1044 for (size_t i = 0; i < trackSizes.size(); ++i) { 1047 for (size_t i = 0; i < trackSizes.size(); ++i) {
1045 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list); 1048 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
1046 list->append(valueForGridTrackSize(trackSizes[i], style, renderView)); 1049 list->append(valueForGridTrackSize(trackSizes[i], style, maxSize, render View));
1047 } 1050 }
1048 // Those are the trailing <string>* allowed in the syntax. 1051 // Those are the trailing <string>* allowed in the syntax.
1049 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list); 1052 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list);
1050 return list.release(); 1053 return list.release();
1051 } 1054 }
1052 1055
1053 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position) 1056 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1054 { 1057 {
1055 if (position.isAuto()) 1058 if (position.isAuto())
1056 return cssValuePool().createIdentifierValue(CSSValueAuto); 1059 return cssValuePool().createIdentifierValue(CSSValueAuto);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 1557
1555 static bool isLayoutDependent(CSSPropertyID propertyID, PassRefPtr<RenderStyle> style, RenderObject* renderer) 1558 static bool isLayoutDependent(CSSPropertyID propertyID, PassRefPtr<RenderStyle> style, RenderObject* renderer)
1556 { 1559 {
1557 // Some properties only depend on layout in certain conditions which 1560 // Some properties only depend on layout in certain conditions which
1558 // are specified in the main switch statement below. So we can avoid 1561 // are specified in the main switch statement below. So we can avoid
1559 // forcing layout in those conditions. The conditions in this switch 1562 // forcing layout in those conditions. The conditions in this switch
1560 // statement must remain in sync with the conditions in the main switch. 1563 // statement must remain in sync with the conditions in the main switch.
1561 // FIXME: Some of these cases could be narrowed down or optimized better. 1564 // FIXME: Some of these cases could be narrowed down or optimized better.
1562 switch (propertyID) { 1565 switch (propertyID) {
1563 case CSSPropertyBottom: 1566 case CSSPropertyBottom:
1567 case CSSPropertyGridDefinitionColumns:
1568 case CSSPropertyGridDefinitionRows:
1564 case CSSPropertyHeight: 1569 case CSSPropertyHeight:
1565 case CSSPropertyLeft: 1570 case CSSPropertyLeft:
1566 case CSSPropertyRight: 1571 case CSSPropertyRight:
1567 case CSSPropertyTop: 1572 case CSSPropertyTop:
1568 case CSSPropertyWebkitPerspectiveOrigin: 1573 case CSSPropertyWebkitPerspectiveOrigin:
1569 case CSSPropertyWebkitTransform: 1574 case CSSPropertyWebkitTransform:
1570 case CSSPropertyWebkitTransformOrigin: 1575 case CSSPropertyWebkitTransformOrigin:
1571 case CSSPropertyWidth: 1576 case CSSPropertyWidth:
1572 case CSSPropertyWebkitFilter: 1577 case CSSPropertyWebkitFilter:
1573 return true; 1578 return true;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 return cssValuePool().createIdentifierValue(CSSValueNormal); 2032 return cssValuePool().createIdentifierValue(CSSValueNormal);
2028 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 2033 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2029 for (unsigned i = 0; i < featureSettings->size(); ++i) { 2034 for (unsigned i = 0; i < featureSettings->size(); ++i) {
2030 const FontFeature& feature = featureSettings->at(i); 2035 const FontFeature& feature = featureSettings->at(i);
2031 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create (feature.tag(), feature.value()); 2036 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create (feature.tag(), feature.value());
2032 list->append(featureValue.release()); 2037 list->append(featureValue.release());
2033 } 2038 }
2034 return list.release(); 2039 return list.release();
2035 } 2040 }
2036 case CSSPropertyGridAutoColumns: 2041 case CSSPropertyGridAutoColumns:
2037 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView()); 2042 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), sizingBox(renderer).width(), m_node->document().renderView());
2038 case CSSPropertyGridAutoFlow: 2043 case CSSPropertyGridAutoFlow:
2039 return cssValuePool().createValue(style->gridAutoFlow()); 2044 return cssValuePool().createValue(style->gridAutoFlow());
2040 case CSSPropertyGridAutoRows: 2045 case CSSPropertyGridAutoRows:
2041 return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_n ode->document().renderView()); 2046 return valueForGridTrackSize(style->gridAutoRows(), style.get(), siz ingBox(renderer).height(), m_node->document().renderView());
2042 case CSSPropertyGridDefinitionColumns: 2047 case CSSPropertyGridDefinitionColumns:
2043 return valueForGridTrackList(style->gridDefinitionColumns(), style-> orderedNamedGridColumnLines(), style.get(), m_node->document().renderView()); 2048 return valueForGridTrackList(style->gridDefinitionColumns(), style-> orderedNamedGridColumnLines(), style.get(), sizingBox(renderer).width(), m_node- >document().renderView());
2044 case CSSPropertyGridDefinitionRows: 2049 case CSSPropertyGridDefinitionRows:
2045 return valueForGridTrackList(style->gridDefinitionRows(), style->ord eredNamedGridRowLines(), style.get(), m_node->document().renderView()); 2050 return valueForGridTrackList(style->gridDefinitionRows(), style->ord eredNamedGridRowLines(), style.get(), sizingBox(renderer).height(), m_node->docu ment().renderView());
2046 2051
2047 case CSSPropertyGridColumnStart: 2052 case CSSPropertyGridColumnStart:
2048 return valueForGridPosition(style->gridColumnStart()); 2053 return valueForGridPosition(style->gridColumnStart());
2049 case CSSPropertyGridColumnEnd: 2054 case CSSPropertyGridColumnEnd:
2050 return valueForGridPosition(style->gridColumnEnd()); 2055 return valueForGridPosition(style->gridColumnEnd());
2051 case CSSPropertyGridRowStart: 2056 case CSSPropertyGridRowStart:
2052 return valueForGridPosition(style->gridRowStart()); 2057 return valueForGridPosition(style->gridRowStart());
2053 case CSSPropertyGridRowEnd: 2058 case CSSPropertyGridRowEnd:
2054 return valueForGridPosition(style->gridRowEnd()); 2059 return valueForGridPosition(style->gridRowEnd());
2055 case CSSPropertyGridColumn: 2060 case CSSPropertyGridColumn:
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3200 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3196 CSSPropertyB ackgroundClip }; 3201 CSSPropertyB ackgroundClip };
3197 3202
3198 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3203 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3199 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator)))); 3204 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator))));
3200 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator)))); 3205 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator))));
3201 return list.release(); 3206 return list.release();
3202 } 3207 }
3203 3208
3204 } // namespace WebCore 3209 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698