Changeset 246206 in webkit
- Timestamp:
- Jun 7, 2019 10:15:49 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246205 r246206 1 2019-06-07 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Line should skip all vertical adjustment when running preferred width computation 4 https://bugs.webkit.org/show_bug.cgi?id=198642 5 <rdar://problem/51511043> 6 7 Reviewed by Antti Koivisto. 8 9 While layout triggers both horizontal and vertical aligment, preferred width computation should only do (logical)horizontal. 10 Make all vertical alignment computation optional in Line. 11 12 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 13 (WebCore::Layout::UncommittedContent::add): 14 (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): 15 (WebCore::Layout::InlineFormattingContext::LineLayout::computedIntrinsicWidth const): 16 (WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const): 17 (WebCore::Layout::inlineItemHeight): Deleted. 18 * layout/inlineformatting/InlineLine.cpp: 19 (WebCore::Layout::Line::Content::Run::Run): 20 (WebCore::Layout::Line::Line): 21 (WebCore::Layout::Line::close): 22 (WebCore::Layout::Line::removeTrailingTrimmableContent): 23 (WebCore::Layout::Line::moveLogicalLeft): 24 (WebCore::Layout::Line::trailingTrimmableWidth const): 25 (WebCore::Layout::Line::appendNonBreakableSpace): 26 (WebCore::Layout::Line::appendInlineContainerStart): 27 (WebCore::Layout::Line::appendInlineContainerEnd): 28 (WebCore::Layout::Line::appendTextContent): 29 (WebCore::Layout::Line::appendNonReplacedInlineBox): 30 (WebCore::Layout::Line::appendReplacedInlineBox): 31 (WebCore::Layout::Line::appendHardLineBreak): 32 (WebCore::Layout::Line::inlineItemHeight const): 33 * layout/inlineformatting/InlineLine.h: 34 1 35 2019-06-07 Antoine Quint <graouts@apple.com> 2 36 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r246154 r246206 45 45 struct Run { 46 46 const InlineItem& inlineItem; 47 L ine::InlineItemSize size;47 LayoutUnit logicalWidth; 48 48 // FIXME: add optional breaking context (start and end position) for split text content. 49 49 }; 50 void add(const InlineItem&, const Line::InlineItemSize&);50 void add(const InlineItem&, LayoutUnit logicalWidth); 51 51 void reset(); 52 52 … … 61 61 }; 62 62 63 void UncommittedContent::add(const InlineItem& inlineItem, const Line::InlineItemSize& size)64 { 65 m_uncommittedRuns.append({ inlineItem, size});66 m_width += size.logicalWidth;63 void UncommittedContent::add(const InlineItem& inlineItem, LayoutUnit logicalWidth) 64 { 65 m_uncommittedRuns.append({ inlineItem, logicalWidth }); 66 m_width += logicalWidth; 67 67 } 68 68 … … 126 126 } 127 127 128 static LayoutUnit inlineItemHeight(const LayoutState& layoutState, const InlineItem& inlineItem)129 {130 auto& fontMetrics = inlineItem.style().fontMetrics();131 if (inlineItem.isLineBreak() || is<InlineTextItem>(inlineItem))132 return fontMetrics.height();133 134 auto& layoutBox = inlineItem.layoutBox();135 ASSERT(layoutState.hasDisplayBox(layoutBox));136 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);137 138 if (layoutBox.isFloatingPositioned())139 return displayBox.marginBox().height();140 141 if (layoutBox.isReplaced())142 return displayBox.height();143 144 if (inlineItem.isContainerStart() || inlineItem.isContainerEnd())145 return fontMetrics.height() + displayBox.verticalBorder() + displayBox.verticalPadding().valueOr(0);146 147 // Non-replaced inline box (e.g. inline-block)148 return displayBox.height();149 }150 151 128 InlineFormattingContext::LineLayout::LineContent InlineFormattingContext::LineLayout::placeInlineItems(const LineInput& lineInput) const 152 129 { 153 auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight(); 154 auto baselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).height; 155 auto line = Line { layoutState(), lineInput.horizontalConstraint.logicalTopLeft, lineInput.horizontalConstraint.availableLogicalWidth, mimimumLineHeight, baselineOffset }; 130 std::unique_ptr<Line> line; 131 if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No) { 132 auto mimimumLineHeight = m_formattingRoot.style().computedLineHeight(); 133 auto baselineOffset = Line::halfLeadingMetrics(m_formattingRoot.style().fontMetrics(), mimimumLineHeight).height; 134 line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft, lineInput.horizontalConstraint.availableLogicalWidth, mimimumLineHeight, baselineOffset); 135 } else 136 line = std::make_unique<Line>(layoutState(), lineInput.horizontalConstraint.logicalTopLeft.x(), lineInput.horizontalConstraint.availableLogicalWidth); 156 137 157 138 Vector<WeakPtr<InlineItem>> floats; … … 166 147 auto& inlineItem = uncommittedRun.inlineItem; 167 148 if (inlineItem.isHardLineBreak()) 168 line .appendHardLineBreak(inlineItem);149 line->appendHardLineBreak(inlineItem); 169 150 else if (is<InlineTextItem>(inlineItem)) 170 line .appendTextContent(downcast<InlineTextItem>(inlineItem), uncommittedRun.size);151 line->appendTextContent(downcast<InlineTextItem>(inlineItem), uncommittedRun.logicalWidth); 171 152 else if (inlineItem.isContainerStart()) 172 line .appendInlineContainerStart(inlineItem, uncommittedRun.size);153 line->appendInlineContainerStart(inlineItem, uncommittedRun.logicalWidth); 173 154 else if (inlineItem.isContainerEnd()) 174 line .appendInlineContainerEnd(inlineItem, uncommittedRun.size);155 line->appendInlineContainerEnd(inlineItem, uncommittedRun.logicalWidth); 175 156 else if (inlineItem.layoutBox().isReplaced()) 176 line .appendReplacedInlineBox(inlineItem, uncommittedRun.size);157 line->appendReplacedInlineBox(inlineItem, uncommittedRun.logicalWidth); 177 158 else 178 line .appendNonReplacedInlineBox(inlineItem, uncommittedRun.size);159 line->appendNonReplacedInlineBox(inlineItem, uncommittedRun.logicalWidth); 179 160 } 180 161 uncommittedContent.reset(); … … 184 165 // This might change at some point. 185 166 ASSERT(committedInlineItemCount); 186 return LineContent { lineInput.firstInlineItemIndex + (committedInlineItemCount - 1), WTFMove(floats), line .close() };167 return LineContent { lineInput.firstInlineItemIndex + (committedInlineItemCount - 1), WTFMove(floats), line->close() }; 187 168 }; 188 169 LineBreaker lineBreaker; 189 170 // Iterate through the inline content and place the inline boxes on the current line. 190 171 for (auto inlineItemIndex = lineInput.firstInlineItemIndex; inlineItemIndex < lineInput.inlineItems.size(); ++inlineItemIndex) { 191 auto availableWidth = line .availableWidth() - uncommittedContent.width();192 auto currentLogicalRight = line .contentLogicalRight() + uncommittedContent.width();172 auto availableWidth = line->availableWidth() - uncommittedContent.width(); 173 auto currentLogicalRight = line->contentLogicalRight() + uncommittedContent.width(); 193 174 auto& inlineItem = lineInput.inlineItems[inlineItemIndex]; 194 175 auto itemLogicalWidth = inlineItemWidth(layoutState(), *inlineItem, currentLogicalRight); 195 176 196 177 // FIXME: Ensure LineContext::trimmableWidth includes uncommitted content if needed. 197 auto breakingContext = lineBreaker.breakingContext(*inlineItem, itemLogicalWidth, { availableWidth, currentLogicalRight, line .trailingTrimmableWidth(), !line.hasContent() });178 auto breakingContext = lineBreaker.breakingContext(*inlineItem, itemLogicalWidth, { availableWidth, currentLogicalRight, line->trailingTrimmableWidth(), !line->hasContent() }); 198 179 if (breakingContext.isAtBreakingOpportunity) 199 180 commitPendingContent(); … … 217 198 // Shrink availble space for current line and move existing inline runs. 218 199 auto floatBoxWidth = layoutState().displayBoxForLayoutBox(floatBox).marginBoxWidth(); 219 floatBox.isLeftFloatingPositioned() ? line .moveLogicalLeft(floatBoxWidth) : line.moveLogicalRight(floatBoxWidth);200 floatBox.isLeftFloatingPositioned() ? line->moveLogicalLeft(floatBoxWidth) : line->moveLogicalRight(floatBoxWidth); 220 201 floats.append(makeWeakPtr(*inlineItem)); 221 202 ++committedInlineItemCount; … … 223 204 } 224 205 225 Optional<LayoutUnit> itemLogicalHeight; 226 if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No) 227 itemLogicalHeight = inlineItemHeight(layoutState(), *inlineItem); 228 uncommittedContent.add(*inlineItem, { itemLogicalWidth, itemLogicalHeight }); 229 206 uncommittedContent.add(*inlineItem, itemLogicalWidth); 230 207 if (breakingContext.isAtBreakingOpportunity) 231 208 commitPendingContent(); … … 342 319 343 320 auto& inlineItem = lineRun->inlineItem; 344 auto& inlineRun = lineRun->inlineRun;321 auto& logicalRect = lineRun->logicalRect; 345 322 auto& layoutBox = inlineItem.layoutBox(); 346 323 auto& displayBox = layoutState().displayBoxForLayoutBox(layoutBox); 347 324 348 325 if (inlineItem.isHardLineBreak()) { 349 displayBox.setTopLeft( inlineRun.logicalTopLeft());350 displayBox.setContentBoxWidth( inlineRun.logicalWidth());351 displayBox.setContentBoxHeight( inlineRun.logicalHeight());352 m_formattingState.addInlineRun(std::make_unique<Display::Run>( inlineRun));326 displayBox.setTopLeft(logicalRect.topLeft()); 327 displayBox.setContentBoxWidth(logicalRect.width()); 328 displayBox.setContentBoxHeight(logicalRect.height()); 329 m_formattingState.addInlineRun(std::make_unique<Display::Run>(logicalRect)); 353 330 continue; 354 331 } … … 356 333 // Inline level box (replaced or inline-block) 357 334 if (inlineItem.isBox()) { 358 auto topLeft = inlineRun.logicalTopLeft();335 auto topLeft = logicalRect.topLeft(); 359 336 if (layoutBox.isInFlowPositioned()) 360 337 topLeft += Geometry::inFlowPositionedPositionOffset(layoutState(), layoutBox); 361 338 displayBox.setTopLeft(topLeft); 362 lineBox.expandHorizontally( inlineRun.logicalWidth());363 m_formattingState.addInlineRun(std::make_unique<Display::Run>( inlineRun));339 lineBox.expandHorizontally(logicalRect.width()); 340 m_formattingState.addInlineRun(std::make_unique<Display::Run>(logicalRect)); 364 341 continue; 365 342 } … … 367 344 // Inline level container start (<span>) 368 345 if (inlineItem.isContainerStart()) { 369 displayBox.setTopLeft( inlineRun.logicalTopLeft());370 lineBox.expandHorizontally( inlineRun.logicalWidth());346 displayBox.setTopLeft(logicalRect.topLeft()); 347 lineBox.expandHorizontally(logicalRect.width()); 371 348 continue; 372 349 } … … 379 356 displayBox.moveVertically(inflowOffset.height()); 380 357 } 381 auto marginBoxWidth = inlineRun.logicalLeft() - displayBox.left();358 auto marginBoxWidth = logicalRect.left() - displayBox.left(); 382 359 auto contentBoxWidth = marginBoxWidth - (displayBox.marginStart() + displayBox.borderLeft() + displayBox.paddingLeft().valueOr(0)); 383 360 // FIXME fix it for multiline. 384 361 displayBox.setContentBoxWidth(contentBoxWidth); 385 displayBox.setContentBoxHeight( inlineRun.logicalHeight());386 lineBox.expandHorizontally( inlineRun.logicalWidth());362 displayBox.setContentBoxHeight(logicalRect.height()); 363 lineBox.expandHorizontally(logicalRect.width()); 387 364 continue; 388 365 } 389 366 390 367 // Text content. Try to join multiple text runs when possible. 391 ASSERT( inlineRun.textContext());368 ASSERT(lineRun->textContext); 392 369 const Line::Content::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get(); 393 370 if (!lineRun->isCollapsed) { … … 395 372 auto requiresNewRun = !index || !previousRunCanBeExtended || &layoutBox != &previousLineRun->inlineItem.layoutBox(); 396 373 if (requiresNewRun) 397 m_formattingState.addInlineRun(std::make_unique<Display::Run>( inlineRun));374 m_formattingState.addInlineRun(std::make_unique<Display::Run>(logicalRect, Display::Run::TextContext { lineRun->textContext->start, lineRun->textContext->length })); 398 375 else { 399 376 auto& lastDisplayRun = m_formattingState.inlineRuns().last(); 400 lastDisplayRun->expandHorizontally( inlineRun.logicalWidth());401 lastDisplayRun->textContext()->expand( inlineRun.textContext()->length());377 lastDisplayRun->expandHorizontally(logicalRect.width()); 378 lastDisplayRun->textContext()->expand(lineRun->textContext->length); 402 379 } 403 lineBox.expandHorizontally( inlineRun.logicalWidth());380 lineBox.expandHorizontally(logicalRect.width()); 404 381 } 405 382 // FIXME take content breaking into account when part of the layout box is on the previous line. … … 407 384 if (firstInlineRunForLayoutBox) { 408 385 // Setup display box for the associated layout box. 409 displayBox.setTopLeft( inlineRun.logicalTopLeft());410 displayBox.setContentBoxWidth(lineRun->isCollapsed ? LayoutUnit() : inlineRun.logicalWidth());411 displayBox.setContentBoxHeight( inlineRun.logicalHeight());386 displayBox.setTopLeft(logicalRect.topLeft()); 387 displayBox.setContentBoxWidth(lineRun->isCollapsed ? LayoutUnit() : logicalRect.width()); 388 displayBox.setContentBoxHeight(logicalRect.height()); 412 389 } else if (!lineRun->isCollapsed) { 413 390 // FIXME fix it for multirun/multiline. 414 displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + inlineRun.logicalWidth());391 displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalRect.width()); 415 392 } 416 393 } -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r246158 r246206 48 48 } 49 49 50 Line::Content::Run::Run(Display::Run inlineRun, const InlineItem& inlineItem, bool isCollapsed, bool canBeExtended) 51 : inlineRun(inlineRun) 52 , inlineItem(inlineItem) 50 Line::Content::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect, TextContext textContext, bool isCollapsed, bool canBeExtended) 51 : inlineItem(inlineItem) 52 , logicalRect(logicalRect) 53 , textContext(textContext) 53 54 , isCollapsed(isCollapsed) 54 55 , canBeExtended(canBeExtended) 56 { 57 } 58 59 Line::Line(const LayoutState& layoutState, LayoutUnit logicalLeft, LayoutUnit availableWidth) 60 : m_layoutState(layoutState) 61 , m_content(std::make_unique<Line::Content>()) 62 , m_logicalTopLeft(logicalLeft, 0) 63 , m_lineLogicalWidth(availableWidth) 64 , m_skipVerticalAligment(true) 55 65 { 56 66 } … … 68 78 { 69 79 removeTrailingTrimmableContent(); 70 // Convert inline run geometry from relative to the baseline to relative to logical top. 71 for (auto& run : m_content->runs()) { 72 auto adjustedLogicalTop = run->inlineRun.logicalTop() + m_logicalHeight.height + m_logicalTopLeft.y(); 73 run->inlineRun.setLogicalTop(adjustedLogicalTop); 80 if (!m_skipVerticalAligment) { 81 // Convert inline run geometry from relative to the baseline to relative to logical top. 82 for (auto& run : m_content->runs()) { 83 auto adjustedLogicalTop = run->logicalRect.top() + m_logicalHeight.height + m_logicalTopLeft.y(); 84 run->logicalRect.setTop(adjustedLogicalTop); 85 } 74 86 } 75 87 m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() }); … … 83 95 for (auto* trimmableRun : m_trimmableContent) { 84 96 trimmableRun->isCollapsed = true; 85 trimmableWidth += trimmableRun-> inlineRun.logicalWidth();97 trimmableWidth += trimmableRun->logicalRect.width(); 86 98 } 87 99 m_contentLogicalWidth -= trimmableWidth; … … 97 109 m_lineLogicalWidth -= delta; 98 110 for (auto& run : m_content->runs()) 99 run-> inlineRun.moveHorizontally(delta);111 run->logicalRect.moveHorizontally(delta); 100 112 } 101 113 … … 110 122 LayoutUnit trimmableWidth; 111 123 for (auto* trimmableRun : m_trimmableContent) 112 trimmableWidth += trimmableRun-> inlineRun.logicalWidth();124 trimmableWidth += trimmableRun->logicalRect.width(); 113 125 return trimmableWidth; 114 126 } … … 116 128 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect) 117 129 { 118 m_content->runs().append(std::make_unique<Content::Run>( Display::Run { logicalRect }, inlineItem, false, false));130 m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false)); 119 131 m_contentLogicalWidth += logicalRect.width(); 120 132 } 121 133 122 void Line::appendInlineContainerStart(const InlineItem& inlineItem, InlineItemSize runSize) 123 { 124 if (runSize.logicalHeight) 125 adjustBaselineAndLineHeight(inlineItem, *runSize.logicalHeight); 126 127 auto& layoutBox = inlineItem.layoutBox(); 128 auto& fontMetrics = layoutBox.style().fontMetrics(); 129 auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox); 130 131 auto logicalTop = -fontMetrics.ascent() - displayBox.borderTop() - displayBox.paddingTop().valueOr(0); 132 auto logicalRect = Display::Rect { logicalTop, contentLogicalRight(), runSize.logicalWidth, runSize.logicalHeight.valueOr(0) }; 134 void Line::appendInlineContainerStart(const InlineItem& inlineItem, LayoutUnit logicalWidth) 135 { 136 auto logicalRect = Display::Rect { }; 137 logicalRect.setLeft(contentLogicalRight()); 138 logicalRect.setWidth(logicalWidth); 139 140 if (!m_skipVerticalAligment) { 141 auto logicalHeight = inlineItemHeight(inlineItem); 142 adjustBaselineAndLineHeight(inlineItem, logicalHeight); 143 144 auto& displayBox = m_layoutState.displayBoxForLayoutBox(inlineItem.layoutBox()); 145 auto logicalTop = -inlineItem.style().fontMetrics().ascent() - displayBox.borderTop() - displayBox.paddingTop().valueOr(0); 146 logicalRect.setTop(logicalTop); 147 logicalRect.setHeight(logicalHeight); 148 } 133 149 appendNonBreakableSpace(inlineItem, logicalRect); 134 150 } 135 151 136 void Line::appendInlineContainerEnd(const InlineItem& inlineItem, InlineItemSize runSize)152 void Line::appendInlineContainerEnd(const InlineItem& inlineItem, LayoutUnit logicalWidth) 137 153 { 138 154 // This is really just a placeholder to mark the end of the inline level container. 139 auto logicalRect = Display::Rect { 0, contentLogicalRight(), runSize.logicalWidth, runSize.logicalHeight.valueOr(0)};155 auto logicalRect = Display::Rect { 0, contentLogicalRight(), logicalWidth, 0 }; 140 156 appendNonBreakableSpace(inlineItem, logicalRect); 141 157 } 142 158 143 void Line::appendTextContent(const InlineTextItem& inlineItem, InlineItemSize runSize)159 void Line::appendTextContent(const InlineTextItem& inlineItem, LayoutUnit logicalWidth) 144 160 { 145 161 auto isTrimmable = TextUtil::isTrimmableContent(inlineItem); … … 169 185 auto isCompletelyCollapsed = shouldCollapseCompletely(); 170 186 auto canBeExtended = !isCompletelyCollapsed && !inlineItem.isCollapsed(); 171 auto logicalRect = Display::Rect { -inlineItem.style().fontMetrics().ascent(), contentLogicalRight(), runSize.logicalWidth, runSize.logicalHeight.valueOr(0) }; 172 auto textContext = Display::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() }; 173 auto displayRun = Display::Run(logicalRect, textContext); 174 175 auto lineItem = std::make_unique<Content::Run>(displayRun, inlineItem, isCompletelyCollapsed, canBeExtended); 187 188 auto logicalRect = Display::Rect { }; 189 logicalRect.setLeft(contentLogicalRight()); 190 logicalRect.setWidth(logicalWidth); 191 if (!m_skipVerticalAligment) { 192 logicalRect.setTop(-inlineItem.style().fontMetrics().ascent()); 193 logicalRect.setHeight(inlineItemHeight(inlineItem)); 194 } 195 196 auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() }; 197 auto lineItem = std::make_unique<Content::Run>(inlineItem, logicalRect, textContext, isCompletelyCollapsed, canBeExtended); 176 198 if (isTrimmable) 177 199 m_trimmableContent.add(lineItem.get()); 178 200 179 201 m_content->runs().append(WTFMove(lineItem)); 180 m_contentLogicalWidth += isCompletelyCollapsed ? LayoutUnit() : runSize.logicalWidth; 181 } 182 183 void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, InlineItemSize runSize) 184 { 185 if (runSize.logicalHeight) 186 adjustBaselineAndLineHeight(inlineItem, *runSize.logicalHeight); 187 188 auto inlineBoxHeight = runSize.logicalHeight.valueOr(0); 202 m_contentLogicalWidth += isCompletelyCollapsed ? LayoutUnit() : logicalWidth; 203 } 204 205 void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth) 206 { 189 207 auto& displayBox = m_layoutState.displayBoxForLayoutBox(inlineItem.layoutBox()); 190 auto logicalTop = -inlineBoxHeight; 191 auto horizontalMargin = displayBox.horizontalMargin(); 192 auto logicalRect = Display::Rect { logicalTop, contentLogicalRight() + horizontalMargin.start, runSize.logicalWidth, inlineBoxHeight }; 193 194 m_content->runs().append(std::make_unique<Content::Run>(Display::Run { logicalRect }, inlineItem, false, false)); 195 m_contentLogicalWidth += (runSize.logicalWidth + horizontalMargin.start + horizontalMargin.end); 208 auto horizontalMargin = displayBox.horizontalMargin(); 209 auto logicalRect = Display::Rect { }; 210 211 logicalRect.setLeft(contentLogicalRight() + horizontalMargin.start); 212 logicalRect.setWidth(logicalWidth); 213 if (!m_skipVerticalAligment) { 214 auto logicalHeight = inlineItemHeight(inlineItem); 215 adjustBaselineAndLineHeight(inlineItem, logicalHeight); 216 217 logicalRect.setTop(-logicalHeight); 218 logicalRect.setHeight(logicalHeight); 219 } 220 221 m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false)); 222 m_contentLogicalWidth += (logicalWidth + horizontalMargin.start + horizontalMargin.end); 196 223 m_trimmableContent.clear(); 197 224 } 198 225 199 void Line::appendReplacedInlineBox(const InlineItem& inlineItem, InlineItemSize runSize)226 void Line::appendReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth) 200 227 { 201 228 // FIXME Surely replaced boxes behave differently. 202 appendNonReplacedInlineBox(inlineItem, runSize);229 appendNonReplacedInlineBox(inlineItem, logicalWidth); 203 230 } 204 231 … … 207 234 auto ascent = inlineItem.layoutBox().style().fontMetrics().ascent(); 208 235 auto logicalRect = Display::Rect { -ascent, contentLogicalRight(), { }, logicalHeight() }; 209 m_content->runs().append(std::make_unique<Content::Run>( Display::Run { logicalRect }, inlineItem, false, false));236 m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false)); 210 237 } 211 238 … … 240 267 } 241 268 269 LayoutUnit Line::inlineItemHeight(const InlineItem& inlineItem) const 270 { 271 ASSERT(!m_skipVerticalAligment); 272 auto& fontMetrics = inlineItem.style().fontMetrics(); 273 if (inlineItem.isLineBreak() || is<InlineTextItem>(inlineItem)) 274 return fontMetrics.height(); 275 276 auto& layoutBox = inlineItem.layoutBox(); 277 ASSERT(m_layoutState.hasDisplayBox(layoutBox)); 278 auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox); 279 280 if (layoutBox.isFloatingPositioned()) 281 return displayBox.marginBox().height(); 282 283 if (layoutBox.isReplaced()) 284 return displayBox.height(); 285 286 if (inlineItem.isContainerStart() || inlineItem.isContainerEnd()) 287 return fontMetrics.height() + displayBox.verticalBorder() + displayBox.verticalPadding().valueOr(0); 288 289 // Non-replaced inline box (e.g. inline-block) 290 return displayBox.height(); 291 } 292 242 293 Line::UsedHeightAndDepth Line::halfLeadingMetrics(const FontMetrics& fontMetrics, LayoutUnit lineLogicalHeight) 243 294 { -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r246158 r246206 40 40 public: 41 41 Line(const LayoutState&, const LayoutPoint& topLeft, LayoutUnit availableWidth, LayoutUnit minimumLineHeight, LayoutUnit baselineOffset); 42 Line(const LayoutState&, LayoutUnit logicalLeft, LayoutUnit availableWidth); 42 43 43 44 class Content { 44 45 public: 45 46 struct Run { 46 Run(Display::Run, const InlineItem&, bool isCollapsed, bool canBeExtended); 47 struct TextContext { 48 unsigned start { 0 }; 49 unsigned length { 0 }; 50 }; 51 Run(const InlineItem&, const Display::Rect&, TextContext, bool isCollapsed, bool canBeExtended); 47 52 53 const InlineItem& inlineItem; 48 54 // Relative to the baseline. 49 Display::R un inlineRun;50 const InlineItem& inlineItem;55 Display::Rect logicalRect; 56 Optional<TextContext> textContext; 51 57 bool isCollapsed { false }; 52 58 bool canBeExtended { false }; … … 76 82 std::unique_ptr<Content> close(); 77 83 78 struct InlineItemSize { 79 LayoutUnit logicalWidth; 80 Optional<LayoutUnit> logicalHeight; 81 }; 82 void appendTextContent(const InlineTextItem&, InlineItemSize); 83 void appendNonReplacedInlineBox(const InlineItem&, InlineItemSize); 84 void appendReplacedInlineBox(const InlineItem&, InlineItemSize); 85 void appendInlineContainerStart(const InlineItem&, InlineItemSize); 86 void appendInlineContainerEnd(const InlineItem&, InlineItemSize); 84 void appendTextContent(const InlineTextItem&, LayoutUnit logicalWidth); 85 void appendNonReplacedInlineBox(const InlineItem&, LayoutUnit logicalWidth); 86 void appendReplacedInlineBox(const InlineItem&, LayoutUnit logicalWidth); 87 void appendInlineContainerStart(const InlineItem&, LayoutUnit logicalWidth); 88 void appendInlineContainerEnd(const InlineItem&, LayoutUnit logicalWidth); 87 89 void appendHardLineBreak(const InlineItem&); 88 90 … … 118 120 119 121 void adjustBaselineAndLineHeight(const InlineItem&, LayoutUnit runHeight); 122 LayoutUnit inlineItemHeight(const InlineItem&) const; 120 123 121 124 const LayoutState& m_layoutState; … … 128 131 UsedHeightAndDepth m_logicalHeight; 129 132 LayoutUnit m_lineLogicalWidth; 133 bool m_skipVerticalAligment { false }; 130 134 }; 131 135
Note: See TracChangeset
for help on using the changeset viewer.