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

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: Created 7 years, 3 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 if (!trackBreadth.isLength()) 1002 if (!trackBreadth.isLength())
Julien - ping for review 2013/09/24 19:09:16 There should be FIXME as this is wrong. We should
1003 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR); 1003 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR);
1004 1004
1005 const Length& trackBreadthLength = trackBreadth.length(); 1005 const Length& trackBreadthLength = trackBreadth.length();
1006 if (trackBreadthLength.isAuto()) 1006 if (trackBreadthLength.isAuto())
1007 return cssValuePool().createIdentifierValue(CSSValueAuto); 1007 return cssValuePool().createIdentifierValue(CSSValueAuto);
1008 if (trackBreadthLength.isViewportPercentage()) 1008 if (trackBreadthLength.isViewportPercentage())
1009 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, rend erView), style); 1009 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, rend erView), style);
1010 if (trackBreadthLength.isCalculated())
1011 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, maxSize , renderView), style);
1010 return zoomAdjustedPixelValueForLength(trackBreadthLength, style); 1012 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
1011 } 1013 }
1012 1014
1013 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize , const RenderStyle* style, RenderView* renderView) 1015 static PassRefPtr<CSSValue> valueForGridTrackSize(const GridTrackSize& trackSize , const RenderStyle* style, const LayoutUnit& maxSize, RenderView* renderView)
1014 { 1016 {
1015 switch (trackSize.type()) { 1017 switch (trackSize.type()) {
1016 case LengthTrackSizing: 1018 case LengthTrackSizing:
1017 return valueForGridTrackBreadth(trackSize.length(), style, renderView); 1019 return valueForGridTrackBreadth(trackSize.length(), style, maxSize, rend erView);
1018 case MinMaxTrackSizing: 1020 case MinMaxTrackSizing:
1019 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated(); 1021 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated();
1020 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, renderView)); 1022 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.minTrackB readth(), style, maxSize, renderView));
1021 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, renderView)); 1023 minMaxTrackBreadths->append(valueForGridTrackBreadth(trackSize.maxTrackB readth(), style, maxSize, renderView));
1022 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths); 1024 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
1023 } 1025 }
1024 ASSERT_NOT_REACHED(); 1026 ASSERT_NOT_REACHED();
1025 return 0; 1027 return 0;
1026 } 1028 }
1027 1029
1028 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list) 1030 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list)
1029 { 1031 {
1030 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i); 1032 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i);
1031 for (size_t j = 0; j < namedGridLines.size(); ++j) 1033 for (size_t j = 0; j < namedGridLines.size(); ++j)
1032 list.append(cssValuePool().createValue(namedGridLines[j], CSSPrimitiveVa lue::CSS_STRING)); 1034 list.append(cssValuePool().createValue(namedGridLines[j], CSSPrimitiveVa lue::CSS_STRING));
1033 } 1035 }
1034 1036
1035 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const OrderedNamedGridLines& orderedNamedGridLines, const RenderStyle * style, RenderView* renderView) 1037 static PassRefPtr<CSSValue> valueForGridTrackList(const Vector<GridTrackSize>& t rackSizes, const OrderedNamedGridLines& orderedNamedGridLines, const RenderStyle * style, const LayoutUnit& maxSize, RenderView* renderView)
1036 { 1038 {
1037 // Handle the 'none' case here. 1039 // Handle the 'none' case here.
1038 if (!trackSizes.size()) { 1040 if (!trackSizes.size()) {
1039 ASSERT(orderedNamedGridLines.isEmpty()); 1041 ASSERT(orderedNamedGridLines.isEmpty());
1040 return cssValuePool().createIdentifierValue(CSSValueNone); 1042 return cssValuePool().createIdentifierValue(CSSValueNone);
1041 } 1043 }
1042 1044
1043 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1045 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1044 for (size_t i = 0; i < trackSizes.size(); ++i) { 1046 for (size_t i = 0; i < trackSizes.size(); ++i) {
1045 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list); 1047 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
1046 list->append(valueForGridTrackSize(trackSizes[i], style, renderView)); 1048 list->append(valueForGridTrackSize(trackSizes[i], style, maxSize, render View));
1047 } 1049 }
1048 // Those are the trailing <string>* allowed in the syntax. 1050 // Those are the trailing <string>* allowed in the syntax.
1049 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list); 1051 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list);
1050 return list.release(); 1052 return list.release();
1051 } 1053 }
1052 1054
1053 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position) 1055 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1054 { 1056 {
1055 if (position.isAuto()) 1057 if (position.isAuto())
1056 return cssValuePool().createIdentifierValue(CSSValueAuto); 1058 return cssValuePool().createIdentifierValue(CSSValueAuto);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 1556
1555 static bool isLayoutDependent(CSSPropertyID propertyID, PassRefPtr<RenderStyle> style, RenderObject* renderer) 1557 static bool isLayoutDependent(CSSPropertyID propertyID, PassRefPtr<RenderStyle> style, RenderObject* renderer)
1556 { 1558 {
1557 // Some properties only depend on layout in certain conditions which 1559 // Some properties only depend on layout in certain conditions which
1558 // are specified in the main switch statement below. So we can avoid 1560 // are specified in the main switch statement below. So we can avoid
1559 // forcing layout in those conditions. The conditions in this switch 1561 // forcing layout in those conditions. The conditions in this switch
1560 // statement must remain in sync with the conditions in the main switch. 1562 // 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. 1563 // FIXME: Some of these cases could be narrowed down or optimized better.
1562 switch (propertyID) { 1564 switch (propertyID) {
1563 case CSSPropertyBottom: 1565 case CSSPropertyBottom:
1566 case CSSPropertyGridDefinitionColumns:
1567 case CSSPropertyGridDefinitionRows:
1564 case CSSPropertyHeight: 1568 case CSSPropertyHeight:
1565 case CSSPropertyLeft: 1569 case CSSPropertyLeft:
1566 case CSSPropertyRight: 1570 case CSSPropertyRight:
1567 case CSSPropertyTop: 1571 case CSSPropertyTop:
1568 case CSSPropertyWebkitPerspectiveOrigin: 1572 case CSSPropertyWebkitPerspectiveOrigin:
1569 case CSSPropertyWebkitTransform: 1573 case CSSPropertyWebkitTransform:
1570 case CSSPropertyWebkitTransformOrigin: 1574 case CSSPropertyWebkitTransformOrigin:
1571 case CSSPropertyWidth: 1575 case CSSPropertyWidth:
1572 case CSSPropertyWebkitFilter: 1576 case CSSPropertyWebkitFilter:
1573 return true; 1577 return true;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 return cssValuePool().createIdentifierValue(CSSValueNormal); 2031 return cssValuePool().createIdentifierValue(CSSValueNormal);
2028 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 2032 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
2029 for (unsigned i = 0; i < featureSettings->size(); ++i) { 2033 for (unsigned i = 0; i < featureSettings->size(); ++i) {
2030 const FontFeature& feature = featureSettings->at(i); 2034 const FontFeature& feature = featureSettings->at(i);
2031 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create (feature.tag(), feature.value()); 2035 RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create (feature.tag(), feature.value());
2032 list->append(featureValue.release()); 2036 list->append(featureValue.release());
2033 } 2037 }
2034 return list.release(); 2038 return list.release();
2035 } 2039 }
2036 case CSSPropertyGridAutoColumns: 2040 case CSSPropertyGridAutoColumns:
2037 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), m_node->document().renderView()); 2041 return valueForGridTrackSize(style->gridAutoColumns(), style.get(), sizingBox(renderer).width(), m_node->document().renderView());
2038 case CSSPropertyGridAutoFlow: 2042 case CSSPropertyGridAutoFlow:
2039 return cssValuePool().createValue(style->gridAutoFlow()); 2043 return cssValuePool().createValue(style->gridAutoFlow());
2040 case CSSPropertyGridAutoRows: 2044 case CSSPropertyGridAutoRows:
2041 return valueForGridTrackSize(style->gridAutoRows(), style.get(), m_n ode->document().renderView()); 2045 return valueForGridTrackSize(style->gridAutoRows(), style.get(), siz ingBox(renderer).height(), m_node->document().renderView());
2042 case CSSPropertyGridDefinitionColumns: 2046 case CSSPropertyGridDefinitionColumns:
2043 return valueForGridTrackList(style->gridDefinitionColumns(), style-> orderedNamedGridColumnLines(), style.get(), m_node->document().renderView()); 2047 return valueForGridTrackList(style->gridDefinitionColumns(), style-> orderedNamedGridColumnLines(), style.get(), sizingBox(renderer).width(), m_node- >document().renderView());
2044 case CSSPropertyGridDefinitionRows: 2048 case CSSPropertyGridDefinitionRows:
2045 return valueForGridTrackList(style->gridDefinitionRows(), style->ord eredNamedGridRowLines(), style.get(), m_node->document().renderView()); 2049 return valueForGridTrackList(style->gridDefinitionRows(), style->ord eredNamedGridRowLines(), style.get(), sizingBox(renderer).height(), m_node->docu ment().renderView());
2046 2050
2047 case CSSPropertyGridColumnStart: 2051 case CSSPropertyGridColumnStart:
2048 return valueForGridPosition(style->gridColumnStart()); 2052 return valueForGridPosition(style->gridColumnStart());
2049 case CSSPropertyGridColumnEnd: 2053 case CSSPropertyGridColumnEnd:
2050 return valueForGridPosition(style->gridColumnEnd()); 2054 return valueForGridPosition(style->gridColumnEnd());
2051 case CSSPropertyGridRowStart: 2055 case CSSPropertyGridRowStart:
2052 return valueForGridPosition(style->gridRowStart()); 2056 return valueForGridPosition(style->gridRowStart());
2053 case CSSPropertyGridRowEnd: 2057 case CSSPropertyGridRowEnd:
2054 return valueForGridPosition(style->gridRowEnd()); 2058 return valueForGridPosition(style->gridRowEnd());
2055 case CSSPropertyGridColumn: 2059 case CSSPropertyGridColumn:
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3199 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3196 CSSPropertyB ackgroundClip }; 3200 CSSPropertyB ackgroundClip };
3197 3201
3198 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3202 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3199 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator)))); 3203 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)))); 3204 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator))));
3201 return list.release(); 3205 return list.release();
3202 } 3206 }
3203 3207
3204 } // namespace WebCore 3208 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698