haikuwebkit/LayoutTests/fast/text/hanging-punctuation-allow-e...

24 lines
643 B
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/173991@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-25 19:25:05 +00:00
<head>
<style>
body { font-family: 'Ahem'; color:green }
.hang { white-space:pre; margin:1em; width:5em; border:2px solid black }
</style>
</head>
<body>
<div style="float:left; width:auto" class="hang">12 34,</div>
<div style="clear:both">
<div class="hang">12 34,<span></span>
1234,</div>
<div class="hang">12
34,<span style="border-left:1em solid black"></span>
1234,</div>
<div class="hang">12
34,<span style="border-right:1em solid black"></span>
1234,</div>
<div class="hang"><span style="border-right:1em solid black">12
34,</span>
2345</div>
<div class="hang">12
34<span style="border-left:1em solid black">,</span>
2345</div>