Commit b792b5e1 authored by eae@chromium.org's avatar eae@chromium.org

Remove textDirection parameter from min/maxLogicalWidth

Remove unnecessary textDirection parameter from the min/maxLogicalWidth
methods and computePreferredLogicalWidths and instead use the resolved
text directionality.

BUG=333004
R=dglazkov@chromium.org

Review URL: https://codereview.chromium.org/183013005

git-svn-id: svn://svn.chromium.org/blink/trunk@168449 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c82e415c
......@@ -312,9 +312,9 @@ void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, Ren
// and no more than half the font size.
int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2;
if (startOverhang)
startOverhang = min<int>(startOverhang, min<int>(toRenderText(startRenderer)->minLogicalWidth(style()->direction()), halfWidthOfFontSize));
startOverhang = min<int>(startOverhang, min<int>(toRenderText(startRenderer)->minLogicalWidth(), halfWidthOfFontSize));
if (endOverhang)
endOverhang = min<int>(endOverhang, min<int>(toRenderText(endRenderer)->minLogicalWidth(style()->direction()), halfWidthOfFontSize));
endOverhang = min<int>(endOverhang, min<int>(toRenderText(endRenderer)->minLogicalWidth(), halfWidthOfFontSize));
}
} // namespace WebCore
......@@ -781,7 +781,7 @@ void RenderText::trimmedPrefWidths(float leadWidth,
stripFrontSpaces = false;
if (m_hasTab || preferredLogicalWidthsDirty())
computePreferredLogicalWidths(leadWidth, direction);
computePreferredLogicalWidths(leadWidth);
hasBreakableStart = !stripFrontSpaces && m_hasBreakableStart;
hasBreakableEnd = m_hasBreakableEnd;
......@@ -860,27 +860,27 @@ void RenderText::trimmedPrefWidths(float leadWidth,
}
}
float RenderText::minLogicalWidth(TextDirection textDirection) const
float RenderText::minLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0, textDirection);
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0);
return m_minWidth;
}
float RenderText::maxLogicalWidth(TextDirection textDirection) const
float RenderText::maxLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0, textDirection);
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0);
return m_maxWidth;
}
void RenderText::computePreferredLogicalWidths(float leadWidth, TextDirection textDirection)
void RenderText::computePreferredLogicalWidths(float leadWidth)
{
HashSet<const SimpleFontData*> fallbackFonts;
GlyphOverflow glyphOverflow;
computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow, textDirection);
computePreferredLogicalWidths(leadWidth, fallbackFonts, glyphOverflow);
if (fallbackFonts.isEmpty() && !glyphOverflow.left && !glyphOverflow.right && !glyphOverflow.top && !glyphOverflow.bottom)
m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
......@@ -891,7 +891,7 @@ static inline float hyphenWidth(RenderText* renderer, const Font& font, TextDire
return font.width(RenderBlockFlow::constructTextRun(renderer, font, style->hyphenString().string(), style, direction));
}
void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow, TextDirection textDirection)
void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
{
ASSERT(m_hasTab || preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts);
......@@ -924,10 +924,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
bool firstLine = true;
int nextBreakable = -1;
int lastWordBoundary = 0;
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
float wordTrailingSpaceWidth = f.fontDescription().typesettingFeatures() & Kerning ? f.width(RenderBlockFlow::constructTextRun(this, f, &space, 1, styleToUse, textDirection)) + wordSpacing : 0;
float cachedWordTrailingSpaceWidth[2] = { 0, 0 }; // LTR, RTL
// 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.
......@@ -1027,6 +1024,17 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
int wordLen = j - i;
if (wordLen) {
bool isSpace = (j < len) && c == ' ';
// Non-zero only when kerning is enabled, in which case we measure words with their trailing
// space, then subtract its width.
float wordTrailingSpaceWidth = 0;
if (isSpace && (f.fontDescription().typesettingFeatures() & Kerning)) {
ASSERT(textDirection >=0 && textDirection <= 1);
if (!cachedWordTrailingSpaceWidth[textDirection])
cachedWordTrailingSpaceWidth[textDirection] = f.width(RenderBlockFlow::constructTextRun(this, f, &space, 1, styleToUse, textDirection)) + wordSpacing;
wordTrailingSpaceWidth = cachedWordTrailingSpaceWidth[textDirection];
}
float w;
if (wordTrailingSpaceWidth && isSpace)
w = widthFromCache(f, i, wordLen + 1, leadWidth + currMaxWidth, textDirection, &fallbackFonts, &glyphOverflow) - wordTrailingSpaceWidth;
......@@ -1491,13 +1499,13 @@ float RenderText::width(unsigned from, unsigned len, const Font& f, float xPos,
if (fallbackFonts) {
ASSERT(glyphOverflow);
if (preferredLogicalWidthsDirty() || !m_knownToHaveNoOverflowAndNoFallbackFonts) {
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0, *fallbackFonts, *glyphOverflow, textDirection);
const_cast<RenderText*>(this)->computePreferredLogicalWidths(0, *fallbackFonts, *glyphOverflow);
if (fallbackFonts->isEmpty() && !glyphOverflow->left && !glyphOverflow->right && !glyphOverflow->top && !glyphOverflow->bottom)
m_knownToHaveNoOverflowAndNoFallbackFonts = true;
}
w = m_maxWidth;
} else {
w = maxLogicalWidth(textDirection);
w = maxLogicalWidth();
}
} else {
w = widthFromCache(f, from, len, xPos, textDirection, fallbackFonts, glyphOverflow);
......
......@@ -87,9 +87,8 @@ public:
virtual float width(unsigned from, unsigned len, const Font&, float xPos, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
virtual float width(unsigned from, unsigned len, float xPos, TextDirection, bool firstLine = false, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
// TextDirection required as these compute the preferred width if dirty.
float minLogicalWidth(TextDirection) const;
float maxLogicalWidth(TextDirection) const;
float minLogicalWidth() const;
float maxLogicalWidth() const;
void trimmedPrefWidths(float leadWidth,
float& firstLineMinWidth, bool& hasBreakableStart,
......@@ -151,7 +150,7 @@ public:
PassRefPtr<AbstractInlineTextBox> firstAbstractInlineTextBox();
protected:
virtual void computePreferredLogicalWidths(float leadWidth, TextDirection);
virtual void computePreferredLogicalWidths(float leadWidth);
virtual void willBeDestroyed() OVERRIDE;
virtual void styleWillChange(StyleDifference, const RenderStyle*) OVERRIDE FINAL { }
......@@ -165,7 +164,7 @@ protected:
virtual InlineTextBox* createTextBox(); // Subclassed by SVG.
private:
void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow&, TextDirection);
void computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow&);
bool computeCanUseSimpleFontCodePath() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment