Changeset 201378 in webkit for trunk/Source/WebCore/css/CSSParser.cpp
- Timestamp:
- May 25, 2016, 4:17:38 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/Source/WebCore/css/CSSParser.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSParser.cpp
r201373 r201378 5818 5818 } 5819 5819 5820 static bool isGridTrackFixedSized(const CSSValue& value) 5821 { 5822 ASSERT(value.isPrimitiveValue() || (value.isFunctionValue() && downcast<CSSFunctionValue>(value).arguments())); 5823 const auto& primitiveValue = value.isPrimitiveValue() 5824 ? downcast<CSSPrimitiveValue>(value) 5825 : downcast<CSSPrimitiveValue>(*downcast<CSSFunctionValue>(value).arguments()->item(0)); 5826 CSSValueID valueID = primitiveValue.getValueID(); 5827 if (valueID == CSSValueWebkitMinContent || valueID == CSSValueWebkitMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex()) 5828 return false; 5829 5830 ASSERT(primitiveValue.isLength()); 5820 static bool allTracksAreFixedSized(CSSValueList& valueList) 5821 { 5822 for (auto& value : valueList) { 5823 if (is<CSSGridLineNamesValue>(value)) 5824 continue; 5825 // The auto-repeat value holds a <fixed-size> = <fixed-breadth> | minmax( <fixed-breadth>, <track-breadth> ) 5826 if (is<CSSGridAutoRepeatValue>(value)) { 5827 if (!allTracksAreFixedSized(downcast<CSSValueList>(value.get()))) 5828 return false; 5829 continue; 5830 } 5831 ASSERT(value->isPrimitiveValue() || (value->isFunctionValue() && downcast<CSSFunctionValue>(value.get()).arguments())); 5832 const CSSPrimitiveValue& primitiveValue = value->isPrimitiveValue() 5833 ? downcast<CSSPrimitiveValue>(value.get()) 5834 : downcast<CSSPrimitiveValue>(*downcast<CSSFunctionValue>(value.get()).arguments()->item(0)); 5835 CSSValueID valueID = primitiveValue.getValueID(); 5836 if (valueID == CSSValueWebkitMinContent || valueID == CSSValueWebkitMaxContent || valueID == CSSValueAuto || primitiveValue.isFlex()) 5837 return false; 5838 } 5831 5839 return true; 5832 5840 } … … 5850 5858 bool seenTrackSizeOrRepeatFunction = false; 5851 5859 bool seenAutoRepeat = false; 5852 bool allTracksAreFixedSized = true;5853 5860 while (CSSParserValue* currentValue = m_valueList->current()) { 5854 5861 if (isForwardSlashOperator(*currentValue)) … … 5856 5863 if (currentValue->unit == CSSParserValue::Function && equalLettersIgnoringASCIICase(currentValue->function->name, "repeat(")) { 5857 5864 bool isAutoRepeat; 5858 if (!parseGridTrackRepeatFunction(values, isAutoRepeat , allTracksAreFixedSized))5865 if (!parseGridTrackRepeatFunction(values, isAutoRepeat)) 5859 5866 return nullptr; 5860 5867 if (isAutoRepeat && seenAutoRepeat) … … 5862 5869 seenAutoRepeat = seenAutoRepeat || isAutoRepeat; 5863 5870 } else { 5864 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList );5871 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList, seenAutoRepeat ? FixedSizeOnly : AllowAll); 5865 5872 if (!value) 5866 5873 return nullptr; 5867 if (allTracksAreFixedSized)5868 allTracksAreFixedSized = isGridTrackFixedSized(*value);5869 5874 values->append(value.releaseNonNull()); 5870 5875 } 5871 5876 seenTrackSizeOrRepeatFunction = true; 5872 5873 if (seenAutoRepeat && !allTracksAreFixedSized)5874 return nullptr;5875 5877 5876 5878 // This will handle the trailing <custom-ident>* in the grammar. … … 5883 5885 return nullptr; 5884 5886 5887 // <auto-repeat> requires definite minimum track sizes in order to compute the number of repetitions. 5888 // The above while loop detects those appearances after the <auto-repeat> but not the ones before. 5889 if (seenAutoRepeat && !allTracksAreFixedSized(values)) 5890 return nullptr; 5891 5885 5892 return WTFMove(values); 5886 5893 } 5887 5894 5888 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list, bool& isAutoRepeat , bool& allTracksAreFixedSized)5895 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list, bool& isAutoRepeat) 5889 5896 { 5890 5897 ASSERT(isCSSGridLayoutEnabled()); … … 5916 5923 5917 5924 unsigned numberOfTracks = 0; 5925 TrackSizeRestriction restriction = isAutoRepeat ? FixedSizeOnly : AllowAll; 5918 5926 while (arguments->current()) { 5919 5927 if (isAutoRepeat && numberOfTracks) 5920 5928 return false; 5921 5929 5922 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments );5930 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments, restriction); 5923 5931 if (!trackSize) 5924 5932 return false; 5925 if (allTracksAreFixedSized)5926 allTracksAreFixedSized = isGridTrackFixedSized(*trackSize);5927 5933 5928 5934 repeatedValues->append(trackSize.releaseNonNull()); … … 5956 5962 } 5957 5963 5958 RefPtr<CSSValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList )5964 RefPtr<CSSValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList, TrackSizeRestriction restriction) 5959 5965 { 5960 5966 ASSERT(isCSSGridLayoutEnabled()); … … 5972 5978 return nullptr; 5973 5979 5974 RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(*arguments->valueAt(0)); 5975 if (!minTrackBreadth || minTrackBreadth->isFlex()) 5980 TrackSizeRestriction minTrackBreadthRestriction = restriction == AllowAll ? InflexibleSizeOnly : restriction; 5981 RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(*arguments->valueAt(0), minTrackBreadthRestriction); 5982 if (!minTrackBreadth) 5976 5983 return nullptr; 5977 5984 … … 5986 5993 } 5987 5994 5988 return parseGridBreadth(currentValue );5989 } 5990 5991 RefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue& value )5995 return parseGridBreadth(currentValue, restriction); 5996 } 5997 5998 RefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue& value, TrackSizeRestriction restriction) 5992 5999 { 5993 6000 ASSERT(isCSSGridLayoutEnabled()); 5994 6001 5995 if (value.id == CSSValueWebkitMinContent || value.id == CSSValueWebkitMaxContent || value.id == CSSValueAuto) 6002 if (value.id == CSSValueWebkitMinContent || value.id == CSSValueWebkitMaxContent || value.id == CSSValueAuto) { 6003 if (restriction == FixedSizeOnly) 6004 return nullptr; 5996 6005 return CSSValuePool::singleton().createIdentifierValue(value.id); 6006 } 5997 6007 5998 6008 if (value.unit == CSSPrimitiveValue::CSS_FR) { 6009 if (restriction == FixedSizeOnly || restriction == InflexibleSizeOnly) 6010 return nullptr; 6011 5999 6012 double flexValue = value.fValue; 6000 6013
Note:
See TracChangeset
for help on using the changeset viewer.