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

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp

Issue 2287113004: [css-grid] Implement fit-content track size (Closed)
Patch Set: Patch for landing Created 4 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSPropertyParser.h" 5 #include "core/css/parser/CSSPropertyParser.h"
6 6
7 #include "core/StylePropertyShorthand.h" 7 #include "core/StylePropertyShorthand.h"
8 #include "core/css/CSSBasicShapeValues.h" 8 #include "core/css/CSSBasicShapeValues.h"
9 #include "core/css/CSSBorderImage.h" 9 #include "core/css/CSSBorderImage.h"
10 #include "core/css/CSSContentDistributionValue.h" 10 #include "core/css/CSSContentDistributionValue.h"
(...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 CSSPrimitiveValue* positionKeyword = consumeIdent<CSSValueCenter, CSSValueLe ft, CSSValueRight>(rangeCopy); 2707 CSSPrimitiveValue* positionKeyword = consumeIdent<CSSValueCenter, CSSValueLe ft, CSSValueRight>(rangeCopy);
2708 if (!legacy) 2708 if (!legacy)
2709 legacy = consumeIdent<CSSValueLegacy>(rangeCopy); 2709 legacy = consumeIdent<CSSValueLegacy>(rangeCopy);
2710 if (legacy && positionKeyword) { 2710 if (legacy && positionKeyword) {
2711 range = rangeCopy; 2711 range = rangeCopy;
2712 return CSSValuePair::create(legacy, positionKeyword, CSSValuePair::DropI denticalValues); 2712 return CSSValuePair::create(legacy, positionKeyword, CSSValuePair::DropI denticalValues);
2713 } 2713 }
2714 return consumeSelfPositionOverflowPosition(range); 2714 return consumeSelfPositionOverflowPosition(range);
2715 } 2715 }
2716 2716
2717 static CSSValue* consumeFitContent(CSSParserTokenRange& range, CSSParserMode css ParserMode)
2718 {
2719 CSSParserTokenRange rangeCopy = range;
2720 CSSParserTokenRange args = consumeFunction(rangeCopy);
2721 CSSPrimitiveValue* length = consumeLengthOrPercent(args, cssParserMode, Valu eRangeNonNegative, UnitlessQuirk::Allow);
2722 if (!length || !args.atEnd())
2723 return nullptr;
2724 range = rangeCopy;
2725 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueFitContent);
2726 result->append(*length);
2727 return result;
2728 }
2729
2717 static CSSCustomIdentValue* consumeCustomIdentForGridLine(CSSParserTokenRange& r ange) 2730 static CSSCustomIdentValue* consumeCustomIdentForGridLine(CSSParserTokenRange& r ange)
2718 { 2731 {
2719 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan) 2732 if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan)
2720 return nullptr; 2733 return nullptr;
2721 return consumeCustomIdent(range); 2734 return consumeCustomIdent(range);
2722 } 2735 }
2723 2736
2724 static CSSValue* consumeGridLine(CSSParserTokenRange& range) 2737 static CSSValue* consumeGridLine(CSSParserTokenRange& range)
2725 { 2738 {
2726 if (range.peek().id() == CSSValueAuto) 2739 if (range.peek().id() == CSSValueAuto)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2777 return false; 2790 return false;
2778 2791
2779 return true; 2792 return true;
2780 } 2793 }
2781 2794
2782 static bool isGridTrackFixedSized(const CSSValue& value) 2795 static bool isGridTrackFixedSized(const CSSValue& value)
2783 { 2796 {
2784 if (value.isPrimitiveValue()) 2797 if (value.isPrimitiveValue())
2785 return isGridTrackFixedSized(toCSSPrimitiveValue(value)); 2798 return isGridTrackFixedSized(toCSSPrimitiveValue(value));
2786 2799
2787 const CSSPrimitiveValue& minPrimitiveValue = toCSSPrimitiveValue(toCSSFuncti onValue(value).item(0)); 2800 DCHECK(value.isFunctionValue());
2788 const CSSPrimitiveValue& maxPrimitiveValue = toCSSPrimitiveValue(toCSSFuncti onValue(value).item(1)); 2801 auto& function = toCSSFunctionValue(value);
2802 if (function.functionType() == CSSValueFitContent)
2803 return false;
2804
2805 const CSSPrimitiveValue& minPrimitiveValue = toCSSPrimitiveValue(function.it em(0));
2806 const CSSPrimitiveValue& maxPrimitiveValue = toCSSPrimitiveValue(function.it em(1));
2789 return isGridTrackFixedSized(minPrimitiveValue) || isGridTrackFixedSized(max PrimitiveValue); 2807 return isGridTrackFixedSized(minPrimitiveValue) || isGridTrackFixedSized(max PrimitiveValue);
2790 } 2808 }
2791 2809
2792 static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNam es) 2810 static Vector<String> parseGridTemplateAreasColumnNames(const String& gridRowNam es)
2793 { 2811 {
2794 ASSERT(!gridRowNames.isEmpty()); 2812 ASSERT(!gridRowNames.isEmpty());
2795 Vector<String> columnNames; 2813 Vector<String> columnNames;
2796 // Using StringImpl to avoid checks and indirection in every call to String: :operator[]. 2814 // Using StringImpl to avoid checks and indirection in every call to String: :operator[].
2797 StringImpl& text = *gridRowNames.impl(); 2815 StringImpl& text = *gridRowNames.impl();
2798 2816
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 return nullptr; 2928 return nullptr;
2911 CSSPrimitiveValue* maxTrackBreadth = consumeGridBreadth(args, cssParserM ode); 2929 CSSPrimitiveValue* maxTrackBreadth = consumeGridBreadth(args, cssParserM ode);
2912 if (!maxTrackBreadth || !args.atEnd()) 2930 if (!maxTrackBreadth || !args.atEnd())
2913 return nullptr; 2931 return nullptr;
2914 range = rangeCopy; 2932 range = rangeCopy;
2915 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueMinmax); 2933 CSSFunctionValue* result = CSSFunctionValue::create(CSSValueMinmax);
2916 result->append(*minTrackBreadth); 2934 result->append(*minTrackBreadth);
2917 result->append(*maxTrackBreadth); 2935 result->append(*maxTrackBreadth);
2918 return result; 2936 return result;
2919 } 2937 }
2938
2939 if (token.functionId() == CSSValueFitContent)
2940 return consumeFitContent(range, cssParserMode);
2941
2920 return consumeGridBreadth(range, cssParserMode); 2942 return consumeGridBreadth(range, cssParserMode);
2921 } 2943 }
2922 2944
2923 // Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a ne w one. 2945 // Appends to the passed in CSSGridLineNamesValue if any, otherwise creates a ne w one.
2924 static CSSGridLineNamesValue* consumeGridLineNames(CSSParserTokenRange& range, C SSGridLineNamesValue* lineNames = nullptr) 2946 static CSSGridLineNamesValue* consumeGridLineNames(CSSParserTokenRange& range, C SSGridLineNamesValue* lineNames = nullptr)
2925 { 2947 {
2926 CSSParserTokenRange rangeCopy = range; 2948 CSSParserTokenRange rangeCopy = range;
2927 if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken) 2949 if (rangeCopy.consumeIncludingWhitespace().type() != LeftBracketToken)
2928 return nullptr; 2950 return nullptr;
2929 if (!lineNames) 2951 if (!lineNames)
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 case CSSPropertyGridTemplate: 4719 case CSSPropertyGridTemplate:
4698 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); 4720 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
4699 case CSSPropertyGrid: 4721 case CSSPropertyGrid:
4700 return consumeGridShorthand(important); 4722 return consumeGridShorthand(important);
4701 default: 4723 default:
4702 return false; 4724 return false;
4703 } 4725 }
4704 } 4726 }
4705 4727
4706 } // namespace blink 4728 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698