RESOLVED FIXED 142253
Implement -apple-trailing-word: -apple-partially-balanced
https://bugs.webkit.org/show_bug.cgi?id=142253
Summary Implement -apple-trailing-word: -apple-partially-balanced
Myles C. Maxfield
Reported 2015-03-03 20:15:41 PST
Implement -apple-trailing-word: -apple-partially-balanced
Attachments
Patch (130.17 KB, patch)
2015-03-03 20:33 PST, Myles C. Maxfield
no flags
Patch (45.76 KB, patch)
2015-03-03 20:47 PST, Myles C. Maxfield
no flags
Patch (45.87 KB, patch)
2015-03-03 20:50 PST, Myles C. Maxfield
no flags
Patch (26.35 KB, patch)
2015-03-04 12:41 PST, Myles C. Maxfield
hyatt: review+
Myles C. Maxfield
Comment 1 2015-03-03 20:33:07 PST
Myles C. Maxfield
Comment 2 2015-03-03 20:47:50 PST
Myles C. Maxfield
Comment 3 2015-03-03 20:50:02 PST
Myles C. Maxfield
Comment 4 2015-03-04 11:16:38 PST
Dave Hyatt
Comment 5 2015-03-04 11:49:21 PST
Comment on attachment 247833 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=247833&action=review Just one change. > Source/WebCore/rendering/line/BreakingContextInlineHeaders.h:1185 > +#if ENABLE(CSS_TRAILING_WORD) > + if (m_blockStyle.trailingWord() == TrailingWord::PartiallyBalanced) { > + InlineIterator lineBreak = m_lineBreakHistory.current(); > + if (lineBreak.renderer() && m_lineInfo.isFirstLine() && !bidiNextSkippingEmptyInlines(*lineBreak.root(), lineBreak.renderer()) && is<RenderText>(lineBreak.renderer())) { > + RenderText& renderText = downcast<RenderText>(*lineBreak.renderer()); > + // Don't even bother measuring if our remaining line has many characters > + if (renderText.textLength() == lineBreak.offset() || renderText.textLength() - lineBreak.offset() > 20) > + return lineBreak; > + bool isLooseCJKMode = m_renderTextInfo.m_text != &renderText && m_renderTextInfo.m_lineBreakIterator.isLooseCJKMode(); > + bool breakNBSP = m_autoWrap && m_currentStyle->nbspMode() == SPACE; > + int nextBreakablePosition = lineBreak.nextBreakablePosition(); > + isBreakable(m_renderTextInfo.m_lineBreakIterator, lineBreak.offset() + 1, nextBreakablePosition, breakNBSP, isLooseCJKMode); > + if (nextBreakablePosition < 0 || static_cast<unsigned>(nextBreakablePosition) != renderText.textLength()) > + return lineBreak; > + const RenderStyle& style = lineStyle(renderText, m_lineInfo); > + const FontCascade& font = style.fontCascade(); > + HashSet<const Font*> dummyFonts; > + InlineIterator best = lineBreak; > + for (size_t i = 1; i < m_lineBreakHistory.historyLength(); ++i) { > + const InlineIterator& candidate = m_lineBreakHistory.get(i); > + if (candidate.renderer() != lineBreak.renderer()) > + return best; > + float width = textWidth(renderText, candidate.offset(), renderText.textLength() - candidate.offset(), font, 0, font.isFixedPitch(), m_collapseWhiteSpace, dummyFonts); > + if (width > m_width.availableWidth()) > + return best; > + if (width / m_width.availableWidth() > 0.1) // Subsequent line is long enough > + return candidate; > + best = candidate; > + } > + return best; > + } > + } > +#endif This is long enough that it should just be put in its own helper function.
Myles C. Maxfield
Comment 6 2015-03-04 12:41:09 PST
Dave Hyatt
Comment 7 2015-03-04 12:43:21 PST
Comment on attachment 247882 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=247882&action=review r=me > Source/WebCore/rendering/line/BreakingContextInlineHeaders.h:1172 > + if (renderText.textLength() == lineBreak.offset() || renderText.textLength() - lineBreak.offset() > 20) > + return lineBreak; You should use a defined constant for the value 20 rather than just putting the raw number in this function.
Myles C. Maxfield
Comment 8 2015-03-04 12:48:30 PST
Note You need to log in before you can comment on or make changes to this bug.