Changeset 294463 in webkit
- Timestamp:
- May 18, 2022 8:05:09 PM (2 years ago)
- Location:
- trunk/Source/WebCore/layout
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
r294412 r294463 198 198 } 199 199 flexItemGeometry.setLogicalTopLeft(topLeft); 200 if (direction == FlexDirection::Row || direction == FlexDirection::RowReverse) 201 flexItemGeometry.setContentBoxWidth(logicalFlexItem.rect.width() - flexItemGeometry.horizontalMarginBorderAndPadding()); 202 else 203 flexItemGeometry.setContentBoxHeight(logicalFlexItem.rect.width() - flexItemGeometry.verticalMarginBorderAndPadding()); 200 204 } 201 205 } … … 204 208 { 205 209 auto logicalFlexItemList = convertFlexItemsToLogicalSpace(); 210 211 auto totalGrowth = 0.f; 212 auto totalFixedWidth = LayoutUnit { }; 213 214 for (auto& logicalFlexItem : logicalFlexItemList) { 215 totalGrowth += logicalFlexItem.layoutBox->style().flexGrow(); 216 // FIXME: Use min/max here. 217 totalFixedWidth += logicalFlexItem.rect.width(); 218 } 206 219 207 220 auto logicalLeft = LayoutUnit { }; 208 221 auto logicalTop = LayoutUnit { }; 222 auto availableWidth = constraints.horizontal().logicalWidth; 223 auto flexibleWidth = availableWidth - totalFixedWidth; 209 224 210 225 for (auto& logicalFlexItem : logicalFlexItemList) { 211 226 logicalFlexItem.rect.setTopLeft({ logicalLeft, logicalTop }); 212 227 logicalLeft = logicalFlexItem.rect.right(); 228 auto growFlexItemIfApplicable = [&] { 229 if (flexibleWidth <= 0) 230 return; 231 auto grow = logicalFlexItem.layoutBox->style().flexGrow(); 232 if (!grow) 233 return; 234 // This value specifies the flex grow factor, which determines how much the flex item will grow relative to the 235 // rest of the flex items in the flex container when positive free space is distributed. 236 logicalFlexItem.rect.setWidth(LayoutUnit { availableWidth * grow / totalGrowth }); 237 // FIXME: constrain logical width on min width. 238 }; 239 growFlexItemIfApplicable(); 213 240 } 214 241 setFlexItemsGeometry(logicalFlexItemList, constraints); -
trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp
r294210 r294463 132 132 133 133 auto& renderer = downcast<RenderBox>(*boxAndRenderer.renderer); 134 renderer.setLocation(Layout::BoxGeometry::borderBoxTopLeft(m_flexFormattingState.boxGeometry(layoutBox))); 134 auto& flexItemGeometry = m_flexFormattingState.boxGeometry(layoutBox); 135 auto borderBox = Layout::BoxGeometry::borderBoxRect(flexItemGeometry); 136 renderer.setLocation(borderBox.topLeft()); 137 renderer.setWidth(borderBox.width()); 135 138 } 136 139 }
Note: See TracChangeset
for help on using the changeset viewer.