Changeset 199156 in webkit
- Timestamp:
- Apr 7, 2016 7:55:54 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199154 r199156 1 2016-04-07 Zalan Bujtas <zalan@apple.com> 2 3 REGRESSION (197987): Ingredient lists on smittenkitchen.com are full justified instead of left justified. 4 https://bugs.webkit.org/show_bug.cgi?id=156326 5 <rdar://problem/25519393> 6 7 Reviewed by Antti Koivisto. 8 9 According to the spec (https://drafts.csswg.org/css-text-3/#text-align-property) 10 unless otherwise specified by text-align-last, the last line before 11 a forced break or the end of the block is start-aligned. 12 13 In this patch we check if a forced break is present and we apply text alignment accordingly. 14 15 Test: fast/css3-text/css3-text-justify/text-justify-last-line-simple-line-layout.html 16 17 * fast/css3-text/css3-text-justify/text-justify-last-line-simple-line-layout-expected.html: Added. 18 * fast/css3-text/css3-text-justify/text-justify-last-line-simple-line-layout.html: Added. 19 1 20 2016-04-07 Antti Koivisto <antti@apple.com> 2 21 -
trunk/Source/WebCore/ChangeLog
r199155 r199156 1 2016-04-07 Zalan Bujtas <zalan@apple.com> 2 3 REGRESSION (197987): Ingredient lists on smittenkitchen.com are full justified instead of left justified. 4 https://bugs.webkit.org/show_bug.cgi?id=156326 5 <rdar://problem/25519393> 6 7 Reviewed by Antti Koivisto. 8 9 According to the spec (https://drafts.csswg.org/css-text-3/#text-align-property) 10 unless otherwise specified by text-align-last, the last line before 11 a forced break or the end of the block is start-aligned. 12 13 In this patch we check if a forced break is present and we apply text alignment accordingly. 14 15 Test: fast/css3-text/css3-text-justify/text-justify-last-line-simple-line-layout.html 16 17 * rendering/SimpleLineLayout.cpp: 18 (WebCore::SimpleLineLayout::LineState::lastFragment): Make it optional so that we don't just check against a default fragment. 19 (WebCore::SimpleLineLayout::createLineRuns): 20 (WebCore::SimpleLineLayout::justifyRuns): Do not compute first run index on the current line twice. 21 (WebCore::SimpleLineLayout::textAlignForLine): 22 (WebCore::SimpleLineLayout::closeLineEndingAndAdjustRuns): 23 1 24 2016-04-07 Antti Koivisto <antti@apple.com> 2 25 -
trunk/Source/WebCore/rendering/SimpleLineLayout.cpp
r198074 r199156 403 403 const TextFragmentIterator::TextFragment& overflowedFragment() const { return m_overflowedFragment; } 404 404 bool hasTrailingWhitespace() const { return m_trailingWhitespaceLength; } 405 TextFragmentIterator::TextFragment lastFragment() const { return m_fragments.last(); } 405 Optional<TextFragmentIterator::TextFragment> lastFragment() const 406 { 407 if (m_fragments.size()) 408 return m_fragments.last(); 409 return Nullopt; 410 } 406 411 bool isWhitespaceOnly() const { return m_trailingWhitespaceWidth && m_runsWidth == m_trailingWhitespaceWidth; } 407 412 bool fits(float extra) const { return m_availableWidth >= m_runsWidth + extra; } … … 734 739 } 735 740 // Non-breakable non-whitespace fragment when there's already content on the line. Push it to the next line. 736 if (line.lastFragment().overlapsToNextRenderer()) { 741 ASSERT(line.lastFragment()); 742 if (line.lastFragment().value().overlapsToNextRenderer()) { 737 743 // Check if this fragment is a continuation of a previous segment. In such cases, we need to remove them all. 738 744 const auto& lastCompleteFragment = line.revertToLastCompleteFragment(runs); … … 758 764 } 759 765 760 static void justifyRuns(const LineState& line, Layout::RunVector& runs, Optional<unsigned> lastRunIndexOfPreviousLine)766 static void justifyRuns(const LineState& line, Layout::RunVector& runs, unsigned firstRunIndex) 761 767 { 762 768 ASSERT(runs.size()); … … 765 771 return; 766 772 767 auto firstRunIndex = lastRunIndexOfPreviousLine ? lastRunIndexOfPreviousLine.value() + 1 : 0;768 773 auto lastRunIndex = runs.size() - 1; 769 774 ASSERT(firstRunIndex <= lastRunIndex); … … 795 800 } 796 801 802 static ETextAlign textAlignForLine(const TextFragmentIterator::Style& style, bool lastLine) 803 { 804 // Fallback to LEFT (START) alignment for non-collapsable content and for the last line before a forced break or the end of the block. 805 auto textAlign = style.textAlign; 806 if (textAlign == JUSTIFY && (!style.collapseWhitespace || lastLine)) 807 textAlign = LEFT; 808 return textAlign; 809 } 810 797 811 static void closeLineEndingAndAdjustRuns(LineState& line, Layout::RunVector& runs, Optional<unsigned> lastRunIndexOfPreviousLine, unsigned& lineCount, 798 const TextFragmentIterator& textFragmentIterator, bool lastLine )812 const TextFragmentIterator& textFragmentIterator, bool lastLineInFlow) 799 813 { 800 814 if (!runs.size() || (lastRunIndexOfPreviousLine && runs.size() - 1 == lastRunIndexOfPreviousLine.value())) … … 805 819 // Adjust runs' position by taking line's alignment into account. 806 820 const auto& style = textFragmentIterator.style(); 807 auto textAlign = style.textAlign; 808 // Fallback to LEFT alignment both for non-collapsable content and for the last line. 809 if (textAlign == JUSTIFY && (!style.collapseWhitespace || lastLine)) 810 textAlign = LEFT; 811 821 auto firstRunIndex = lastRunIndexOfPreviousLine ? lastRunIndexOfPreviousLine.value() + 1 : 0; 812 822 auto lineLogicalLeft = line.logicalLeftOffset(); 823 auto textAlign = textAlignForLine(style, lastLineInFlow || (line.lastFragment() && line.lastFragment().value().type() == TextFragmentIterator::TextFragment::HardLineBreak)); 813 824 if (textAlign == JUSTIFY) 814 justifyRuns(line, runs, lastRunIndexOfPreviousLine);825 justifyRuns(line, runs, firstRunIndex); 815 826 else 816 827 lineLogicalLeft = computeLineLeft(textAlign, line.availableWidth(), line.width(), line.logicalLeftOffset()); 817 auto firstRunIndex = lastRunIndexOfPreviousLine ? lastRunIndexOfPreviousLine.value() + 1 : 0;818 828 for (auto i = firstRunIndex; i < runs.size(); ++i) { 819 829 runs[i].logicalLeft += lineLogicalLeft;
Note: See TracChangeset
for help on using the changeset viewer.