Changeset 201373 in webkit for trunk/Source/WebCore/css/CSSParser.cpp
- Timestamp:
- May 25, 2016, 2:22:37 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
r201325 r201373 5818 5818 } 5819 5819 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 } 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()); 5839 5831 return true; 5840 5832 } … … 5858 5850 bool seenTrackSizeOrRepeatFunction = false; 5859 5851 bool seenAutoRepeat = false; 5852 bool allTracksAreFixedSized = true; 5860 5853 while (CSSParserValue* currentValue = m_valueList->current()) { 5861 5854 if (isForwardSlashOperator(*currentValue)) … … 5863 5856 if (currentValue->unit == CSSParserValue::Function && equalLettersIgnoringASCIICase(currentValue->function->name, "repeat(")) { 5864 5857 bool isAutoRepeat; 5865 if (!parseGridTrackRepeatFunction(values, isAutoRepeat ))5858 if (!parseGridTrackRepeatFunction(values, isAutoRepeat, allTracksAreFixedSized)) 5866 5859 return nullptr; 5867 5860 if (isAutoRepeat && seenAutoRepeat) … … 5869 5862 seenAutoRepeat = seenAutoRepeat || isAutoRepeat; 5870 5863 } else { 5871 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList , seenAutoRepeat ? FixedSizeOnly : AllowAll);5864 RefPtr<CSSValue> value = parseGridTrackSize(*m_valueList); 5872 5865 if (!value) 5873 5866 return nullptr; 5867 if (allTracksAreFixedSized) 5868 allTracksAreFixedSized = isGridTrackFixedSized(*value); 5874 5869 values->append(value.releaseNonNull()); 5875 5870 } 5876 5871 seenTrackSizeOrRepeatFunction = true; 5872 5873 if (seenAutoRepeat && !allTracksAreFixedSized) 5874 return nullptr; 5877 5875 5878 5876 // This will handle the trailing <custom-ident>* in the grammar. … … 5885 5883 return nullptr; 5886 5884 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 5892 5885 return WTFMove(values); 5893 5886 } 5894 5887 5895 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list, bool& isAutoRepeat )5888 bool CSSParser::parseGridTrackRepeatFunction(CSSValueList& list, bool& isAutoRepeat, bool& allTracksAreFixedSized) 5896 5889 { 5897 5890 ASSERT(isCSSGridLayoutEnabled()); … … 5923 5916 5924 5917 unsigned numberOfTracks = 0; 5925 TrackSizeRestriction restriction = isAutoRepeat ? FixedSizeOnly : AllowAll;5926 5918 while (arguments->current()) { 5927 5919 if (isAutoRepeat && numberOfTracks) 5928 5920 return false; 5929 5921 5930 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments , restriction);5922 RefPtr<CSSValue> trackSize = parseGridTrackSize(*arguments); 5931 5923 if (!trackSize) 5932 5924 return false; 5925 if (allTracksAreFixedSized) 5926 allTracksAreFixedSized = isGridTrackFixedSized(*trackSize); 5933 5927 5934 5928 repeatedValues->append(trackSize.releaseNonNull()); … … 5962 5956 } 5963 5957 5964 RefPtr<CSSValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList , TrackSizeRestriction restriction)5958 RefPtr<CSSValue> CSSParser::parseGridTrackSize(CSSParserValueList& inputList) 5965 5959 { 5966 5960 ASSERT(isCSSGridLayoutEnabled()); … … 5978 5972 return nullptr; 5979 5973 5980 TrackSizeRestriction minTrackBreadthRestriction = restriction == AllowAll ? InflexibleSizeOnly : restriction; 5981 RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(*arguments->valueAt(0), minTrackBreadthRestriction); 5982 if (!minTrackBreadth) 5974 RefPtr<CSSPrimitiveValue> minTrackBreadth = parseGridBreadth(*arguments->valueAt(0)); 5975 if (!minTrackBreadth || minTrackBreadth->isFlex()) 5983 5976 return nullptr; 5984 5977 … … 5993 5986 } 5994 5987 5995 return parseGridBreadth(currentValue , restriction);5996 } 5997 5998 RefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue& value , TrackSizeRestriction restriction)5988 return parseGridBreadth(currentValue); 5989 } 5990 5991 RefPtr<CSSPrimitiveValue> CSSParser::parseGridBreadth(CSSParserValue& value) 5999 5992 { 6000 5993 ASSERT(isCSSGridLayoutEnabled()); 6001 5994 6002 if (value.id == CSSValueWebkitMinContent || value.id == CSSValueWebkitMaxContent || value.id == CSSValueAuto) { 6003 if (restriction == FixedSizeOnly) 6004 return nullptr; 5995 if (value.id == CSSValueWebkitMinContent || value.id == CSSValueWebkitMaxContent || value.id == CSSValueAuto) 6005 5996 return CSSValuePool::singleton().createIdentifierValue(value.id); 6006 }6007 5997 6008 5998 if (value.unit == CSSPrimitiveValue::CSS_FR) { 6009 if (restriction == FixedSizeOnly || restriction == InflexibleSizeOnly)6010 return nullptr;6011 6012 5999 double flexValue = value.fValue; 6013 6000
Note:
See TracChangeset
for help on using the changeset viewer.