Title: [215325] trunk/Source/WebCore
- Revision
- 215325
- Author
- za...@apple.com
- Date
- 2017-04-13 10:39:03 -0700 (Thu, 13 Apr 2017)
Log Message
BreakingContext::WordTrailingSpace cleanup.
https://bugs.webkit.org/show_bug.cgi?id=170750
Reviewed by Myles C. Maxfield.
No change in functionality.
* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths):
* rendering/line/BreakingContext.h:
(WebCore::WordTrailingSpace::WordTrailingSpace):
(WebCore::WordTrailingSpace::width):
(WebCore::BreakingContext::handleText):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (215324 => 215325)
--- trunk/Source/WebCore/ChangeLog 2017-04-13 17:29:43 UTC (rev 215324)
+++ trunk/Source/WebCore/ChangeLog 2017-04-13 17:39:03 UTC (rev 215325)
@@ -1,3 +1,19 @@
+2017-04-13 Zalan Bujtas <za...@apple.com>
+
+ BreakingContext::WordTrailingSpace cleanup.
+ https://bugs.webkit.org/show_bug.cgi?id=170750
+
+ Reviewed by Myles C. Maxfield.
+
+ No change in functionality.
+
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::computePreferredLogicalWidths):
+ * rendering/line/BreakingContext.h:
+ (WebCore::WordTrailingSpace::WordTrailingSpace):
+ (WebCore::WordTrailingSpace::width):
+ (WebCore::BreakingContext::handleText):
+
2017-04-13 Romain Bellessort <romain.belless...@crf.canon.fr>
[Readable Streams API] Implement cloneArrayBuffer in WebCore
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (215324 => 215325)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2017-04-13 17:29:43 UTC (rev 215324)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2017-04-13 17:39:03 UTC (rev 215325)
@@ -820,8 +820,6 @@
std::optional<unsigned> nextBreakable;
unsigned lastWordBoundary = 0;
- // Non-zero only when kerning is enabled, in which case we measure words with their trailing
- // space, then subtract its width.
WordTrailingSpace wordTrailingSpace(style);
// If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
// fragment) encountered so far, and only try hyphenating words that are wider.
Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (215324 => 215325)
--- trunk/Source/WebCore/rendering/line/BreakingContext.h 2017-04-13 17:29:43 UTC (rev 215324)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h 2017-04-13 17:39:03 UTC (rev 215325)
@@ -64,30 +64,29 @@
};
struct WordTrailingSpace {
- WordTrailingSpace(const RenderStyle& style, TextLayout* textLayout = nullptr)
+ WordTrailingSpace(const RenderStyle& style, bool measuringWithTrailingWhitespaceEnabled = true)
: m_style(style)
- , m_textLayout(textLayout)
{
+ if (!measuringWithTrailingWhitespaceEnabled || !m_style.fontCascade().enableKerning())
+ m_state = WordTrailingSpaceState::Initialized;
}
std::optional<float> width(HashSet<const Font*>& fallbackFonts)
{
- if (m_state == WordTrailingSpaceState::Computed)
+ if (m_state == WordTrailingSpaceState::Initialized)
return m_width;
- const FontCascade& font = m_style.fontCascade();
- if (font.enableKerning() && !m_textLayout)
- m_width = font.width(RenderBlock::constructTextRun(&space, 1, m_style), &fallbackFonts) + font.wordSpacing();
- m_state = WordTrailingSpaceState::Computed;
+ auto& font = m_style.fontCascade();
+ m_width = font.width(RenderBlock::constructTextRun(&space, 1, m_style), &fallbackFonts) + font.wordSpacing();
+ m_state = WordTrailingSpaceState::Initialized;
return m_width;
}
private:
- enum class WordTrailingSpaceState { Uninitialized, Computed };
+ enum class WordTrailingSpaceState { Uninitialized, Initialized };
+ const RenderStyle& m_style;
WordTrailingSpaceState m_state { WordTrailingSpaceState::Uninitialized };
std::optional<float> m_width;
- const RenderStyle& m_style;
- TextLayout* m_textLayout { nullptr };
};
class BreakingContext {
@@ -825,15 +824,14 @@
m_renderTextInfo.layout = font.createLayout(renderText, m_width.currentWidth(), m_collapseWhiteSpace);
}
- TextLayout* textLayout = m_renderTextInfo.layout.get();
-
- // Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
- // words with their trailing space, then subtract its width.
HashSet<const Font*> fallbackFonts;
UChar lastCharacterFromPreviousRenderText = m_renderTextInfo.lineBreakIterator.lastCharacter();
UChar lastCharacter = m_renderTextInfo.lineBreakIterator.lastCharacter();
UChar secondToLastCharacter = m_renderTextInfo.lineBreakIterator.secondToLastCharacter();
- WordTrailingSpace wordTrailingSpace(style, textLayout);
+ // Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
+ // words with their trailing space, then subtract its width.
+ TextLayout* textLayout = m_renderTextInfo.layout.get();
+ WordTrailingSpace wordTrailingSpace(style, !textLayout);
for (; m_current.offset() < renderText.textLength(); m_current.fastIncrementInTextNode()) {
bool previousCharacterIsSpace = m_currentCharacterIsSpace;
bool previousCharacterIsWS = m_currentCharacterIsWS;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes