Changeset 289722 in webkit for trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
- Timestamp:
- Feb 13, 2022, 5:52:40 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r289588 r289722 858 858 virtual void collectLineNamesForIndex(CSSGridLineNamesValue&, unsigned index) const; 859 859 860 virtual int namedGridLineCount() const { return m_orderedNamedGridLines.size(); } 861 860 862 protected: 861 863 … … 875 877 876 878 void collectLineNamesForIndex(CSSGridLineNamesValue&, unsigned index) const override; 879 880 int namedGridLineCount() const override { return m_orderedNamedAutoRepeatGridLines.size(); } 877 881 }; 878 882 … … 952 956 } 953 957 954 static void addValuesForNamedGridLinesAtIndex(OrderedNamedLinesCollector& collector, unsigned i, CSSValueList& list )958 static void addValuesForNamedGridLinesAtIndex(OrderedNamedLinesCollector& collector, unsigned i, CSSValueList& list, bool renderEmpty = false) 955 959 { 956 960 if (collector.isEmpty()) … … 959 963 auto lineNames = CSSGridLineNamesValue::create(); 960 964 collector.collectLineNamesForIndex(lineNames.get(), i); 961 if (lineNames->length() )965 if (lineNames->length() || renderEmpty) 962 966 list.append(WTFMove(lineNames)); 963 967 } … … 994 998 } 995 999 1000 static void populateSubgridLineNameList(CSSValueList& list, OrderedNamedLinesCollector& collector, int start, int end) 1001 { 1002 for (int i = start; i < end; i++) 1003 addValuesForNamedGridLinesAtIndex(collector, i, list, true); 1004 } 1005 1006 static void populateSubgridLineNameList(CSSValueList& list, OrderedNamedLinesCollector& collector) 1007 { 1008 populateSubgridLineNameList(list, collector, 0, collector.namedGridLineCount()); 1009 } 1010 996 1011 static Ref<CSSValue> valueForGridTrackList(GridTrackSizingDirection direction, RenderObject* renderer, const RenderStyle& style) 997 1012 { 998 1013 bool isRowAxis = direction == ForColumns; 999 1014 bool isRenderGrid = is<RenderGrid>(renderer); 1015 bool isSubgrid = isRowAxis ? style.gridSubgridColumns() : style.gridSubgridRows(); 1000 1016 auto& trackSizes = isRowAxis ? style.gridColumns() : style.gridRows(); 1001 1017 auto& autoRepeatTrackSizes = isRowAxis ? style.gridAutoRepeatColumns() : style.gridAutoRepeatRows(); … … 1011 1027 } 1012 1028 1013 if (trackListIsEmpty )1029 if (trackListIsEmpty && !isSubgrid) 1014 1030 return CSSValuePool::singleton().createIdentifierValue(CSSValueNone); 1015 1031 1016 1032 auto list = CSSValueList::createSpaceSeparated(); 1033 if (isSubgrid) 1034 list->append(CSSValuePool::singleton().createIdentifierValue(CSSValueSubgrid)); 1017 1035 1018 1036 // If the element is a grid container, the resolved value is the used value, 1019 1037 // specifying track sizes in pixels and expanding the repeat() notation. 1020 1038 if (isRenderGrid) { 1039 // FIXME: We need to handle computed subgrid here. 1021 1040 auto* grid = downcast<RenderGrid>(renderer); 1022 1041 OrderedNamedLinesCollectorInGridLayout collector(style, isRowAxis, grid->autoRepeatCountForDirection(direction), autoRepeatTrackSizes.size()); … … 1036 1055 }; 1037 1056 1057 OrderedNamedLinesCollectorInsideRepeat repeatCollector(style, isRowAxis); 1058 if (isSubgrid) { 1059 if (!repeatCollector.namedGridLineCount()) { 1060 populateSubgridLineNameList(list.get(), collector); 1061 return list; 1062 } 1063 1064 // Add the line names that precede the auto repeat(). 1065 int autoRepeatInsertionPoint = isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint(); 1066 autoRepeatInsertionPoint = std::clamp<int>(autoRepeatInsertionPoint, 0, collector.namedGridLineCount()); 1067 populateSubgridLineNameList(list.get(), collector, 0, autoRepeatInsertionPoint); 1068 1069 // Add a CSSGridAutoRepeatValue with the contents of the auto repeat(). 1070 ASSERT((isRowAxis ? style.gridAutoRepeatColumnsType() : style.gridAutoRepeatRowsType()) == AutoRepeatType::Fill); 1071 auto repeatedValues = CSSGridAutoRepeatValue::create(CSSValueAutoFill); 1072 populateSubgridLineNameList(repeatedValues.get(), repeatCollector); 1073 list->append(repeatedValues.get()); 1074 1075 // Add the line names that follow the auto repeat(). 1076 populateSubgridLineNameList(list.get(), collector, autoRepeatInsertionPoint, collector.namedGridLineCount()); 1077 return list; 1078 } 1079 1038 1080 if (autoRepeatTrackSizes.isEmpty()) { 1039 1081 // If there's no auto repeat(), just add all the line names and track sizes. … … 1043 1085 1044 1086 // Add the line names and track sizes that precede the auto repeat(). 1045 int autoRepeatInsertionPoint = std::clamp<int>(isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint(), 0, trackSizes.size()); 1087 int autoRepeatInsertionPoint = isRowAxis ? style.gridAutoRepeatColumnsInsertionPoint() : style.gridAutoRepeatRowsInsertionPoint(); 1088 autoRepeatInsertionPoint = std::clamp<int>(autoRepeatInsertionPoint, 0, trackSizes.size()); 1046 1089 populateGridTrackList(list.get(), collector, trackSizes, getTrackSize, 0, autoRepeatInsertionPoint); 1047 1090 … … 1049 1092 AutoRepeatType autoRepeatType = isRowAxis ? style.gridAutoRepeatColumnsType() : style.gridAutoRepeatRowsType(); 1050 1093 auto repeatedValues = CSSGridAutoRepeatValue::create(autoRepeatType == AutoRepeatType::Fill ? CSSValueAutoFill : CSSValueAutoFit); 1051 OrderedNamedLinesCollectorInsideRepeat repeatCollector(style, isRowAxis); 1094 1052 1095 populateGridTrackList(repeatedValues.get(), repeatCollector, autoRepeatTrackSizes, getTrackSize); 1053 1096 list->append(repeatedValues.get());
Note:
See TracChangeset
for help on using the changeset viewer.