Changeset 247199 in webkit
- Timestamp:
- Jul 7, 2019 6:49:57 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247198 r247199 1 2019-07-07 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Introduce splitPosition to LineLayout 4 https://bugs.webkit.org/show_bug.cgi?id=199558 5 <rdar://problem/52737649> 6 7 Reviewed by Antti Koivisto. 8 9 This is in preparation for breaking runs at line end. 10 11 * layout/inlineformatting/InlineFormattingContext.h: 12 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 13 (WebCore::Layout::InlineFormattingContext::LineLayout::LineInput::LineInput): 14 (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): 15 (WebCore::Layout::InlineFormattingContext::LineLayout::layout const): 16 (WebCore::Layout::InlineFormattingContext::LineLayout::computedIntrinsicWidth const): 17 1 18 2019-07-07 Zalan Bujtas <zalan@apple.com> 2 19 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r246634 r247199 60 60 LayoutState& layoutState() const { return m_formattingContext.layoutState(); } 61 61 62 struct LineContent { 63 Optional<unsigned> lastInlineItemIndex; 64 Vector<WeakPtr<InlineItem>> floats; 65 std::unique_ptr<Line::Content> runs; 62 struct InlineIndexAndSplitPosition { 63 unsigned index { 0 }; 64 Optional<unsigned> splitPosition; 66 65 }; 67 66 68 67 struct LineInput { 69 LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, Line::SkipVerticalAligment, unsigned firstInlineItemIndex, const InlineItems&);68 LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, Line::SkipVerticalAligment, InlineIndexAndSplitPosition firstToProcess, const InlineItems&); 70 69 struct HorizontalConstraint { 71 70 HorizontalConstraint(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth); … … 77 76 // FIXME Alternatively we could just have a second pass with vertical positioning (preferred width computation opts out) 78 77 Line::SkipVerticalAligment skipVerticalAligment; 79 unsigned firstInlineItemIndex { 0 };78 InlineIndexAndSplitPosition firstInlineItem; 80 79 const InlineItems& inlineItems; 81 80 Optional<LayoutUnit> floatMinimumLogicalBottom; 81 }; 82 83 struct LineContent { 84 Optional<InlineIndexAndSplitPosition> lastCommitted; 85 Vector<WeakPtr<InlineItem>> floats; 86 std::unique_ptr<Line::Content> runs; 82 87 }; 83 88 LineContent placeInlineItems(const LineInput&) const; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r246634 r247199 79 79 } 80 80 81 InlineFormattingContext::LineLayout::LineInput::LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, Line::SkipVerticalAligment skipVerticalAligment, unsigned firstInlineItemIndex, const InlineItems& inlineItems)81 InlineFormattingContext::LineLayout::LineInput::LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, Line::SkipVerticalAligment skipVerticalAligment, InlineIndexAndSplitPosition firstToProcess, const InlineItems& inlineItems) 82 82 : horizontalConstraint(logicalTopLeft, availableLogicalWidth) 83 83 , skipVerticalAligment(skipVerticalAligment) 84 , firstInlineItem Index(firstInlineItemIndex)84 , firstInlineItem(firstToProcess) 85 85 , inlineItems(inlineItems) 86 86 { … … 137 137 Vector<WeakPtr<InlineItem>> floats; 138 138 unsigned committedInlineItemCount = 0; 139 Optional<unsigned> splitPosition; 139 140 140 141 UncommittedContent uncommittedContent; … … 151 152 auto closeLine = [&] { 152 153 ASSERT(committedInlineItemCount || lineHasFloatBox); 153 auto lastCommittedIndex = committedInlineItemCount ? Optional<unsigned> { lineInput.firstInlineItemIndex + (committedInlineItemCount - 1) } : WTF::nullopt; 154 return LineContent { lastCommittedIndex, WTFMove(floats), line.close() }; 154 if (!committedInlineItemCount) 155 return LineContent { WTF::nullopt, WTFMove(floats), line.close() }; 156 auto lastCommitedItem = InlineIndexAndSplitPosition { lineInput.firstInlineItem.index + (committedInlineItemCount - 1), splitPosition }; 157 return LineContent { lastCommitedItem, WTFMove(floats), line.close() }; 155 158 }; 156 159 LineBreaker lineBreaker; 157 160 // Iterate through the inline content and place the inline boxes on the current line. 158 for (auto inlineItemIndex = lineInput.firstInlineItem Index; inlineItemIndex < lineInput.inlineItems.size(); ++inlineItemIndex) {161 for (auto inlineItemIndex = lineInput.firstInlineItem.index; inlineItemIndex < lineInput.inlineItems.size(); ++inlineItemIndex) { 159 162 auto availableWidth = line.availableWidth() - uncommittedContent.width(); 160 163 auto currentLogicalRight = line.contentLogicalRight() + uncommittedContent.width(); … … 249 252 250 253 auto& inlineItems = m_formattingState.inlineItems(); 251 unsigned currentInlineItemIndex = 0;252 while (currentInlineItem Index < inlineItems.size()) {253 auto lineInput = LineInput { { lineLogicalLeft, lineLogicalTop }, widthConstraint, Line::SkipVerticalAligment::No, currentInlineItem Index, inlineItems };254 InlineIndexAndSplitPosition currentInlineItem; 255 while (currentInlineItem.index < inlineItems.size()) { 256 auto lineInput = LineInput { { lineLogicalLeft, lineLogicalTop }, widthConstraint, Line::SkipVerticalAligment::No, currentInlineItem, inlineItems }; 254 257 applyFloatConstraint(lineInput); 255 258 auto lineContent = placeInlineItems(lineInput); 256 259 createDisplayRuns(*lineContent.runs, lineContent.floats, widthConstraint); 257 if (!lineContent.last InlineItemIndex) {260 if (!lineContent.lastCommitted) { 258 261 // Floats prevented us putting any content on the line. 259 262 ASSERT(lineInput.floatMinimumLogicalBottom); … … 261 264 lineLogicalTop = *lineInput.floatMinimumLogicalBottom; 262 265 } else { 263 currentInlineItem Index = *lineContent.lastInlineItemIndex + 1;266 currentInlineItem = { lineContent.lastCommitted->index + 1, WTF::nullopt }; 264 267 lineLogicalTop = lineContent.runs->logicalBottom(); 265 268 } … … 271 274 LayoutUnit maximumLineWidth; 272 275 auto& inlineItems = m_formattingState.inlineItems(); 273 unsigned currentInlineItemIndex = 0;274 while (currentInlineItem Index < inlineItems.size()) {275 auto lineContent = placeInlineItems({ { }, widthConstraint, Line::SkipVerticalAligment::Yes, currentInlineItem Index, inlineItems });276 currentInlineItem Index = *lineContent.lastInlineItemIndex + 1;276 InlineIndexAndSplitPosition currentInlineItem; 277 while (currentInlineItem.index < inlineItems.size()) { 278 auto lineContent = placeInlineItems({ { }, widthConstraint, Line::SkipVerticalAligment::Yes, currentInlineItem, inlineItems }); 279 currentInlineItem = { lineContent.lastCommitted->index + 1, WTF::nullopt }; 277 280 LayoutUnit floatsWidth; 278 281 for (auto& floatItem : lineContent.floats)
Note: See TracChangeset
for help on using the changeset viewer.