Modified: trunk/Source/WebCore/ChangeLog (94777 => 94778)
--- trunk/Source/WebCore/ChangeLog 2011-09-08 18:54:33 UTC (rev 94777)
+++ trunk/Source/WebCore/ChangeLog 2011-09-08 19:18:43 UTC (rev 94778)
@@ -1,3 +1,18 @@
+2011-09-08 Ned Holbrook <nholbr...@apple.com>
+
+ Refactor hyphen measurement
+ https://bugs.webkit.org/show_bug.cgi?id=67728
+
+ Reviewed by Darin Adler.
+
+ No new tests, purely refactoring.
+
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::measureHyphenWidth): Added.
+ (WebCore::setLogicalWidthForTextRun): Use measureHyphenWidth().
+ (WebCore::tryHyphenating): Ditto.
+ (WebCore::RenderBlock::LineBreaker::nextLineBreak): Ditto.
+
2011-09-08 Julien Chaffraix <jchaffr...@webkit.org>
Remove LayoutStateDisabler instances from RenderLayer
Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (94777 => 94778)
--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2011-09-08 18:54:33 UTC (rev 94777)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2011-09-08 19:18:43 UTC (rev 94778)
@@ -478,6 +478,12 @@
setMarginEndForChild(renderer, -endOverhang);
}
+static inline float measureHyphenWidth(RenderText* renderer, const Font& font)
+{
+ RenderStyle* style = renderer->style();
+ return font.width(RenderBlock::constructTextRun(renderer, font, style->hyphenString().string(), style));
+}
+
static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* run, RenderText* renderer, float xPos, const LineInfo& lineInfo,
GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache)
{
@@ -500,9 +506,8 @@
int hyphenWidth = 0;
if (toInlineTextBox(run->m_box)->hasHyphen()) {
- const AtomicString& hyphenString = renderer->style()->hyphenString();
const Font& font = renderer->style(lineInfo.isFirstLine())->font();
- hyphenWidth = font.width(RenderBlock::constructTextRun(renderer, font, hyphenString.string(), renderer->style()));
+ hyphenWidth = measureHyphenWidth(renderer, font);
}
run->m_box->setLogicalWidth(renderer->width(run->m_start, run->m_stop - run->m_start, xPos, lineInfo.isFirstLine(), &fallbackFonts, &glyphOverflow) + hyphenWidth);
if (!fallbackFonts.isEmpty()) {
@@ -1753,8 +1758,7 @@
if (consecutiveHyphenatedLinesLimit >= 0 && consecutiveHyphenatedLines >= static_cast<unsigned>(consecutiveHyphenatedLinesLimit))
return;
- const AtomicString& hyphenString = text->style()->hyphenString();
- int hyphenWidth = font.width(RenderBlock::constructTextRun(text, font, hyphenString.string(), text->style()));
+ int hyphenWidth = measureHyphenWidth(text, font);
float maxPrefixWidth = availableWidth - xPos - hyphenWidth - lastSpaceWordSpacing;
// If the maximum width available for the prefix before the hyphen is small, then it is very unlikely
@@ -2254,8 +2258,7 @@
lineInfo.setEmpty(false);
if (c == softHyphen && autoWrap && !hyphenWidth && style->hyphens() != HyphensNone) {
- const AtomicString& hyphenString = style->hyphenString();
- hyphenWidth = f.width(constructTextRun(t, f, hyphenString.string(), current.m_obj->style()));
+ hyphenWidth = measureHyphenWidth(t, f);
width.addUncommittedWidth(hyphenWidth);
}