Implement the allow-end value of the hanging-punctuation CSS property.
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2016 19:25:05 +0000 (19:25 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Mar 2016 19:25:05 +0000 (19:25 +0000)
commit6ac0576ca41248ef248356be96304314b016dc92
tree1c68f01c9a98472bd364a960bd4428df6633df91
parent0054a072b25e27862b2bc66ddc2c4666d1804ac7
Implement the allow-end value of the hanging-punctuation CSS property.
https://bugs.webkit.org/show_bug.cgi?id=104996

Reviewed by Simon Fraser.

Source/WebCore:

Added new tests in fast/text.

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::constructLine):
Fix a bug where empty RenderInlines were incorrectly excluding their end borders if
they occurred at the end of a line. Needed to adequately test allow-end and empty
inline borders.

* rendering/RenderText.cpp:
(WebCore::RenderText::isHangableStopOrComma):
Helper function that identifies the hangable stops and commas.

* rendering/RenderText.h:
Add new isHangableStopOrComma function to RenderText.

* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::lineBreak):
(WebCore::BreakingContext::lineWidth):
(WebCore::BreakingContext::atEnd):
(WebCore::BreakingContext::fitsOnLineOrHangsAtEnd):
(WebCore::BreakingContext::clearLineBreakIfFitsOnLine):
(WebCore::BreakingContext::commitLineBreakAtCurrentWidth):
(WebCore::BreakingContext::handleBR):
(WebCore::BreakingContext::handleEmptyInline):
(WebCore::BreakingContext::handleReplaced):
(WebCore::tryHyphenating):
(WebCore::BreakingContext::computeAdditionalBetweenWordsWidth):
(WebCore::BreakingContext::handleText):
(WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):
Modified breaking rules to handle allow-end. The basic idea is to see if you can
fit without the comma and only hang if you do, and if nothing else gets added to the
line after the comma. This involves tracking a new state, m_hangsAtEnd, that can
be set/cleared while iterating over the objects that will end up on the line.

LayoutTests:

* fast/text/hanging-punctuation-allow-end-basic-expected.html: Added.
* fast/text/hanging-punctuation-allow-end-basic.html: Added.
* fast/text/hanging-punctuation-allow-end-expected.html: Added.
* fast/text/hanging-punctuation-allow-end-inlines-expected.html: Added.
* fast/text/hanging-punctuation-allow-end-inlines.html: Added.
* fast/text/hanging-punctuation-allow-end.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/hanging-punctuation-allow-end-basic-expected.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-allow-end-basic.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-allow-end-expected.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-allow-end-inlines-expected.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-allow-end-inlines.html [new file with mode: 0644]
LayoutTests/fast/text/hanging-punctuation-allow-end.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/line/BreakingContext.h