Changeset 256490 in webkit
- Timestamp:
- Feb 12, 2020 4:24:44 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r256487 r256490 1 2020-02-12 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] LineBuilder should be able to take a partial trailing inline text item 4 https://bugs.webkit.org/show_bug.cgi?id=207640 5 <rdar://problem/59390284> 6 7 Reviewed by Antti Koivisto. 8 9 With this patch, now the trailing run on the line has the needsHyphen bit set. 10 When constructing the final Display:Runs in InlineFormattingContext::setDisplayBoxesForLine using 11 the line runs, we transfer the needsHyphen bit instead of explicitly set on the trailing run. 12 13 * layout/displaytree/DisplayRun.h: 14 (WebCore::Display::Run::TextContent::TextContent): 15 * layout/inlineformatting/InlineFormattingContext.cpp: 16 (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine): 17 * layout/inlineformatting/InlineLineBuilder.cpp: 18 (WebCore::Layout::LineBuilder::appendPartialTrailingTextItem): 19 (WebCore::Layout::LineBuilder::appendTextContent): 20 (WebCore::Layout::m_textContent): 21 (WebCore::Layout::LineBuilder::Run::Run): 22 * layout/inlineformatting/InlineLineBuilder.h: 23 (WebCore::Layout::LineBuilder::Run::setNeedsHyphen): 24 * layout/inlineformatting/LineLayoutContext.cpp: 25 (WebCore::Layout::LineLayoutContext::close): 26 (WebCore::Layout::LineLayoutContext::tryAddingInlineItems): 27 (WebCore::Layout::LineLayoutContext::commitPartialContent): 28 * layout/inlineformatting/LineLayoutContext.h: 29 1 30 2020-02-12 Basuke Suzuki <basuke.suzuki@sony.com> 2 31 -
trunk/Source/WebCore/layout/displaytree/DisplayRun.h
r256458 r256490 44 44 WTF_MAKE_STRUCT_FAST_ALLOCATED; 45 45 public: 46 TextContent(unsigned position, unsigned length, const String& );46 TextContent(unsigned position, unsigned length, const String&, bool needsHyphen); 47 47 48 48 unsigned start() const { return m_start; } … … 117 117 } 118 118 119 inline Run::TextContent::TextContent(unsigned start, unsigned length, const String& contentString )119 inline Run::TextContent::TextContent(unsigned start, unsigned length, const String& contentString, bool needsHyphen) 120 120 : m_start(start) 121 121 , m_length(length) 122 , m_needsHyphen(needsHyphen) 122 123 , m_contentString(contentString) 123 124 { -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r256466 r256490 455 455 auto lineIndex = inlineContent.lineBoxes.size(); 456 456 auto lineInkOverflow = lineBox.scrollableOverflow(); 457 Optional<unsigned> lastTextItemIndex;458 457 // Compute box final geometry. 459 458 auto& lineRuns = lineContent.runList; … … 487 486 inlineContent.runs.append({ lineIndex, lineRun.layoutBox(), logicalRect, inkOverflow, lineRun.expansion(), lineRun.textContent() }); 488 487 } 488 489 if (lineRun.isText()) 490 continue; 489 491 490 492 if (lineRun.isLineBreak()) { … … 526 528 } 527 529 528 if (lineRun.isText()) {529 // Anonymous inline text boxes do not create display boxes.530 lastTextItemIndex = inlineContent.runs.size() - 1;531 continue;532 }533 530 ASSERT_NOT_REACHED(); 534 531 } 535 // Make sure the trailing text run gets a hyphen when it needs one.536 if (lineContent.partialContent && lineContent.partialContent->trailingContentNeedsHyphen)537 inlineContent.runs[*lastTextItemIndex].textContent()->setNeedsHyphen();538 532 // FIXME: This is where the logical to physical translate should happen. 539 533 auto& baseline = lineBox.baseline(); -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
r256437 r256490 394 394 void LineBuilder::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth) 395 395 { 396 appendWith(inlineItem, { logicalWidth, false }); 397 } 398 399 void LineBuilder::appendPartialTrailingTextItem(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth, bool needsHyphen) 400 { 401 appendWith(inlineTextItem, { logicalWidth, needsHyphen }); 402 } 403 404 void LineBuilder::appendWith(const InlineItem& inlineItem, const InlineRunDetails& inlineRunDetails) 405 { 396 406 if (inlineItem.isText()) 397 appendTextContent(downcast<InlineTextItem>(inlineItem), logicalWidth);407 appendTextContent(downcast<InlineTextItem>(inlineItem), inlineRunDetails.logicalWidth, inlineRunDetails.needsHyphen); 398 408 else if (inlineItem.isLineBreak()) 399 409 appendLineBreak(inlineItem); 400 410 else if (inlineItem.isContainerStart()) 401 appendInlineContainerStart(inlineItem, logicalWidth);411 appendInlineContainerStart(inlineItem, inlineRunDetails.logicalWidth); 402 412 else if (inlineItem.isContainerEnd()) 403 appendInlineContainerEnd(inlineItem, logicalWidth);413 appendInlineContainerEnd(inlineItem, inlineRunDetails.logicalWidth); 404 414 else if (inlineItem.layoutBox().isReplacedBox()) 405 appendReplacedInlineBox(inlineItem, logicalWidth);415 appendReplacedInlineBox(inlineItem, inlineRunDetails.logicalWidth); 406 416 else if (inlineItem.isBox()) 407 appendNonReplacedInlineBox(inlineItem, logicalWidth);417 appendNonReplacedInlineBox(inlineItem, inlineRunDetails.logicalWidth); 408 418 else 409 419 ASSERT_NOT_REACHED(); … … 440 450 } 441 451 442 void LineBuilder::appendTextContent(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth )452 void LineBuilder::appendTextContent(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalWidth, bool needsHyphen) 443 453 { 444 454 auto willCollapseCompletely = [&] { … … 471 481 auto& lastRun = m_runs.last(); 472 482 inlineTextItemNeedsNewRun = lastRun.hasCollapsedTrailingWhitespace() || !lastRun.isText() || &lastRun.layoutBox() != &inlineTextItem.layoutBox(); 473 if (!inlineTextItemNeedsNewRun) 483 if (!inlineTextItemNeedsNewRun) { 474 484 lastRun.expand(inlineTextItem, logicalWidth); 485 if (needsHyphen) { 486 ASSERT(!lastRun.textContent()->needsHyphen()); 487 lastRun.setNeedsHyphen(); 488 } 489 } 475 490 } 476 491 if (inlineTextItemNeedsNewRun) 477 m_runs.append({ inlineTextItem, contentLogicalWidth(), logicalWidth });492 m_runs.append({ inlineTextItem, contentLogicalWidth(), logicalWidth, needsHyphen }); 478 493 479 494 m_lineBox.expandHorizontally(logicalWidth); … … 751 766 , m_layoutBox(&softLineBreakItem.layoutBox()) 752 767 , m_logicalRect({ 0, logicalLeft, 0, 0 }) 753 , m_textContent({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content() })754 { 755 } 756 757 LineBuilder::Run::Run(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth )768 , m_textContent({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content(), false }) 769 { 770 } 771 772 LineBuilder::Run::Run(const InlineTextItem& inlineTextItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth, bool needsHyphen) 758 773 : m_type(InlineItem::Type::Text) 759 774 , m_layoutBox(&inlineTextItem.layoutBox()) 760 775 , m_logicalRect({ 0, logicalLeft, logicalWidth, 0 }) 761 776 , m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem)) 762 , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content() })777 , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content(), needsHyphen }) 763 778 { 764 779 if (m_trailingWhitespaceType != TrailingWhitespace::None) { -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
r256437 r256490 62 62 void initialize(const Constraints&); 63 63 void append(const InlineItem&, InlineLayoutUnit logicalWidth); 64 void appendPartialTrailingTextItem(const InlineTextItem&, InlineLayoutUnit logicalWidth, bool needsHypen); 64 65 void resetContent(); 65 66 bool isVisuallyEmpty() const { return m_lineBox.isConsideredEmpty(); } … … 94 95 friend class LineBuilder; 95 96 96 Run(const InlineTextItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth );97 Run(const InlineTextItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth, bool needsHypen); 97 98 Run(const InlineSoftLineBreakItem&, InlineLayoutUnit logicalLeft); 98 99 Run(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth); … … 114 115 void setComputedHorizontalExpansion(InlineLayoutUnit logicalExpansion); 115 116 void setExpansionBehavior(ExpansionBehavior); 117 118 void setNeedsHyphen() { m_textContent->setNeedsHyphen(); } 116 119 117 120 enum class TrailingWhitespace { … … 162 165 InlineLayoutUnit baselineOffset() const { return m_lineBox.baselineOffset(); } 163 166 167 struct InlineRunDetails { 168 InlineLayoutUnit logicalWidth { 0 }; 169 bool needsHyphen { false }; 170 }; 171 void appendWith(const InlineItem&, const InlineRunDetails&); 164 172 void appendNonBreakableSpace(const InlineItem&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth); 165 void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth );173 void appendTextContent(const InlineTextItem&, InlineLayoutUnit logicalWidth, bool needsHyphen); 166 174 void appendNonReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth); 167 175 void appendReplacedInlineBox(const InlineItem&, InlineLayoutUnit logicalWidth); -
trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
r256417 r256490 312 312 313 313 // Adjust hyphenated line count. 314 if (partialContent && partialContent->trailingContent NeedsHyphen)314 if (partialContent && partialContent->trailingContentHasHyphen) 315 315 ++m_successiveHyphenatedLineCount; 316 316 else 317 317 m_successiveHyphenatedLineCount = 0; 318 319 318 unsigned trailingInlineItemIndex = layoutRange.start + committedInlineItemCount - 1; 320 319 ASSERT(trailingInlineItemIndex < layoutRange.end); … … 468 467 ASSERT(!m_partialTrailingTextItem); 469 468 m_partialTrailingTextItem = trailingInlineTextItem.left(partialRun->length); 470 line.append (*m_partialTrailingTextItem, partialRun->logicalWidth);469 line.appendPartialTrailingTextItem(*m_partialTrailingTextItem, partialRun->logicalWidth, partialRun->needsHyphen); 471 470 return; 472 471 } -
trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h
r256417 r256490 42 42 struct LineContent { 43 43 struct PartialContent { 44 bool trailingContent NeedsHyphen { false };44 bool trailingContentHasHyphen { false }; 45 45 unsigned overflowContentLength { 0 }; 46 46 };
Note: See TracChangeset
for help on using the changeset viewer.