Diff
Modified: trunk/Source/WebCore/ChangeLog (86738 => 86739)
--- trunk/Source/WebCore/ChangeLog 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/ChangeLog 2011-05-18 07:19:48 UTC (rev 86739)
@@ -1,3 +1,53 @@
+2011-05-17 Nikolas Zimmermann <[email protected]>
+
+ Reviewed by Dirk Schulze.
+
+ Refactor TextRun creation
+ https://bugs.webkit.org/show_bug.cgi?id=60255
+
+ Add constructTextRun() methods to RenderBlock/InlineTextBox and use it in various places in rendering/.
+ The long-term goal is to remove the ugly eight parameters catch-it-all TextRun constructor, and
+ replace it with explicit setters/getters. To avoid expanding dozens of callsites, when removing
+ the catch-it-all constructor, these helper functions are introduced, which hide the details of
+ creating a TextRun.
+
+ Furthermore it will be used to remove the platform layering violation, that TextRun stores
+ RenderObject pointers for the sake of SVG Fonts support, see bug 60254.
+
+ No change in functionaliy, no new tests.
+
+ * rendering/EllipsisBox.cpp:
+ (WebCore::EllipsisBox::paint):
+ (WebCore::EllipsisBox::selectionRect):
+ (WebCore::EllipsisBox::paintSelection):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::selectionRect):
+ (WebCore::InlineTextBox::paint):
+ (WebCore::InlineTextBox::paintSelection):
+ (WebCore::InlineTextBox::paintCompositionBackground):
+ (WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
+ (WebCore::InlineTextBox::paintTextMatchMarker):
+ (WebCore::InlineTextBox::computeRectForReplacementMarker):
+ (WebCore::InlineTextBox::offsetForPosition):
+ (WebCore::InlineTextBox::positionForOffset):
+ (WebCore::InlineTextBox::constructTextRun):
+ * rendering/InlineTextBox.h:
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::constructTextRunAllowTrailingExpansion):
+ * rendering/RenderBlock.h:
+ * rendering/RenderEmbeddedObject.cpp:
+ (WebCore::RenderEmbeddedObject::getReplacementTextGeometry):
+ * rendering/RenderFileUploadControl.cpp:
+ (WebCore::RenderFileUploadControl::paintObject):
+ (WebCore::RenderFileUploadControl::computePreferredLogicalWidths):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::setImageSizeForAltText):
+ (WebCore::RenderImage::paintReplaced):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::updateFromElement):
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::getAvgCharWidth):
+
2011-05-17 Jeremy Noble <[email protected]>
Reviewed by Darin Adler.
Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/EllipsisBox.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -24,6 +24,7 @@
#include "GraphicsContext.h"
#include "HitTestResult.h"
#include "PaintInfo.h"
+#include "RenderBlock.h"
#include "RootInlineBox.h"
#include "TextRun.h"
@@ -52,9 +53,8 @@
context->setFillColor(foreground, style->colorSpace());
}
- const String& str = m_str;
- // FIXME: Why is this alwasy LTR?
- context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, TextRun::AllowTrailingExpansion, LTR, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent()));
+ // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
+ context->drawText(style->font(), RenderBlock::constructTextRunAllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + style->fontMetrics().ascent()));
// Restore the regular fill color.
if (textColor != context->fillColor())
@@ -75,9 +75,8 @@
{
RenderStyle* style = m_renderer->style(m_firstLine);
const Font& f = style->font();
- // FIXME: Why is this always LTR?
- return enclosingIntRect(f.selectionRectForText(TextRun(m_str.characters(), m_str.length(), false, 0, 0, TextRun::AllowTrailingExpansion, LTR, style->visuallyOrdered()),
- IntPoint(m_x + tx, m_y + ty + root()->selectionTop()), root()->selectionHeight()));
+ // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
+ return enclosingIntRect(f.selectionRectForText(RenderBlock::constructTextRunAllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + root()->selectionTop()), root()->selectionHeight()));
}
void EllipsisBox::paintSelection(GraphicsContext* context, int tx, int ty, RenderStyle* style, const Font& font)
@@ -96,9 +95,8 @@
int y = root()->selectionTop();
int h = root()->selectionHeight();
context->clip(IntRect(m_x + tx, y + ty, m_logicalWidth, h));
- // FIXME: Why is this always LTR?
- context->drawHighlightForText(font, TextRun(m_str.characters(), m_str.length(), false, 0, 0, TextRun::AllowTrailingExpansion, LTR, style->visuallyOrdered()),
- IntPoint(m_x + tx, m_y + ty + y), h, c, style->colorSpace());
+ // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
+ context->drawHighlightForText(font, RenderBlock::constructTextRunAllowTrailingExpansion(m_str, style), IntPoint(m_x + tx, m_y + ty + y), h, c, style->colorSpace());
}
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, int tx, int ty, int lineTop, int lineBottom)
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -42,6 +42,7 @@
#include "RenderRubyText.h"
#include "RenderTheme.h"
#include "Text.h"
+#include "TextRun.h"
#include "break_lines.h"
#include <wtf/AlwaysInline.h>
@@ -159,8 +160,6 @@
return state;
}
-typedef Vector<UChar, 256> BufferForAppendingHyphen;
-
static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, const UChar*& characters, int& length)
{
const AtomicString& hyphenString = style->hyphenString();
@@ -185,16 +184,13 @@
RenderStyle* styleToUse = textObj->style(m_firstLine);
const Font& f = styleToUse->font();
- const UChar* characters = textObj->text()->characters() + m_start;
- int len = m_len;
BufferForAppendingHyphen charactersWithHyphen;
- if (ePos == len && hasHyphen()) {
- adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, len);
- ePos = len;
- }
+ bool respectHyphen = ePos == m_len && hasHyphen();
+ TextRun textRun = constructTextRun(styleToUse, respectHyphen ? &charactersWithHyphen : 0);
+ if (respectHyphen)
+ endPos = textRun.length();
- IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride),
- FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
+ IntRect r = enclosingIntRect(f.selectionRectForText(textRun, FloatPoint(logicalLeft(), selTop), selHeight, sPos, ePos));
int logicalWidth = r.width();
if (r.x() > logicalRight())
@@ -647,11 +643,10 @@
combinedText->charactersToRender(m_start, characters, length);
BufferForAppendingHyphen charactersWithHyphen;
+ TextRun textRun = constructTextRun(styleToUse, characters, length, hasHyphen() ? &charactersWithHyphen : 0);
if (hasHyphen())
- adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, length);
+ length = textRun.length();
- TextRun textRun(characters, length, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride || styleToUse->visuallyOrdered());
-
int sPos = 0;
int ePos = 0;
if (paintSelectedTextOnly || paintSelectedTextSeparately)
@@ -812,10 +807,10 @@
const UChar* characters = textRenderer()->text()->characters() + m_start;
BufferForAppendingHyphen charactersWithHyphen;
- if (ePos == length && hasHyphen()) {
- adjustCharactersAndLengthForHyphen(charactersWithHyphen, style, characters, length);
- ePos = length;
- }
+ bool respectHyphen = ePos == length && hasHyphen();
+ TextRun textRun = constructTextRun(style, characters, length, respectHyphen ? &charactersWithHyphen : 0);
+ if (respectHyphen)
+ ePos = textRun.length();
int deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
int selHeight = selectionHeight();
@@ -827,9 +822,7 @@
clipRect.setWidth(maxX - clipRect.x());
context->clip(clipRect);
- context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(),
- direction(), m_dirOverride || style->visuallyOrdered()),
- localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+ context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
}
void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, int startPos, int endPos)
@@ -850,9 +843,7 @@
int deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
int selHeight = selectionHeight();
FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
- context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(),
- direction(), m_dirOverride || style->visuallyOrdered()),
- localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+ context->drawHighlightForText(font, constructTextRun(style), localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
}
#if PLATFORM(MAC)
@@ -1010,8 +1001,8 @@
int deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
int selHeight = selectionHeight();
FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
- TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered());
-
+ TextRun run = constructTextRun(style);
+
// FIXME: Convert the document markers to float rects.
IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, selHeight, startPosition, endPosition));
start = markerRect.x() - startPoint.x();
@@ -1055,8 +1046,8 @@
int sPos = max(marker.startOffset - m_start, (unsigned)0);
int ePos = min(marker.endOffset - m_start, (unsigned)m_len);
- TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered());
-
+ TextRun run = constructTextRun(style);
+
// Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, selectionTop()), selHeight, sPos, ePos));
markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
@@ -1082,7 +1073,7 @@
int sPos = max(marker.startOffset - m_start, (unsigned)0);
int ePos = min(marker.endOffset - m_start, (unsigned)m_len);
- TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered());
+ TextRun run = constructTextRun(style);
IntPoint startPoint = IntPoint(m_x, y);
// Compute and store the rect associated with this marker.
@@ -1242,9 +1233,7 @@
RenderText* text = toRenderText(renderer());
RenderStyle* style = text->style(m_firstLine);
const Font* f = &style->font();
- int offset = f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len,
- textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered()),
- lineOffset - logicalLeft(), includePartialGlyphs);
+ int offset = f->offsetForPosition(constructTextRun(style), lineOffset - logicalLeft(), includePartialGlyphs);
if (blockIsInOppositeDirection && (!offset || offset == m_len))
return !offset ? m_len : 0;
return offset;
@@ -1259,12 +1248,13 @@
return logicalLeft();
RenderText* text = toRenderText(renderer());
- const Font& f = text->style(m_firstLine)->font();
+ RenderStyle* styleToUse = text->style(m_firstLine);
+ ASSERT(styleToUse);
+ const Font& f = styleToUse->font();
int from = !isLeftToRightDirection() ? offset - m_start : 0;
int to = !isLeftToRightDirection() ? m_len : offset - m_start;
// FIXME: Do we need to add rightBearing here?
- return f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_expansion, expansionBehavior(), direction(), m_dirOverride),
- IntPoint(logicalLeft(), 0), 0, from, to).maxX();
+ return f.selectionRectForText(constructTextRun(styleToUse), IntPoint(logicalLeft(), 0), 0, from, to).maxX();
}
bool InlineTextBox::containsCaretOffset(int offset) const
@@ -1291,6 +1281,31 @@
return true;
}
+TextRun InlineTextBox::constructTextRun(RenderStyle* style, BufferForAppendingHyphen* charactersWithHyphen) const
+{
+ ASSERT(style);
+
+ RenderText* textRenderer = this->textRenderer();
+ ASSERT(textRenderer);
+ ASSERT(textRenderer->characters());
+
+ return constructTextRun(style, textRenderer->characters() + start(), len(), charactersWithHyphen);
+}
+
+TextRun InlineTextBox::constructTextRun(RenderStyle* style, const UChar* characters, int length, BufferForAppendingHyphen* charactersWithHyphen) const
+{
+ ASSERT(style);
+
+ RenderText* textRenderer = this->textRenderer();
+ ASSERT(textRenderer);
+
+ if (charactersWithHyphen)
+ adjustCharactersAndLengthForHyphen(*charactersWithHyphen, style, characters, length);
+
+ // FIXME: Remove TextRuns all-in-one-constructor and use explicit setters here.
+ return TextRun(characters, length, textRenderer->allowTabs(), textPos(), expansion(), expansionBehavior(), direction(), m_dirOverride || style->visuallyOrdered());
+}
+
#ifndef NDEBUG
const char* InlineTextBox::boxName() const
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (86738 => 86739)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2011-05-18 07:19:48 UTC (rev 86739)
@@ -34,6 +34,7 @@
const unsigned short cNoTruncation = USHRT_MAX;
const unsigned short cFullTruncation = USHRT_MAX - 1;
+typedef Vector<UChar, 256> BufferForAppendingHyphen;
// Helper functions shared by InlineTextBox / SVGRootInlineBox
void updateGraphicsContext(GraphicsContext*, const Color& fillColor, const Color& strokeColor, float strokeThickness, ColorSpace);
@@ -98,6 +99,9 @@
int selectionBottom();
int selectionHeight();
+ TextRun constructTextRun(RenderStyle*, BufferForAppendingHyphen* = 0) const;
+ TextRun constructTextRun(RenderStyle*, const UChar*, int length, BufferForAppendingHyphen* = 0) const;
+
public:
virtual IntRect calculateBoundaries() const { return IntRect(x(), y(), width(), height()); }
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -6316,7 +6316,28 @@
m_rightObjectsCount--;
}
+TextRun RenderBlock::constructTextRunAllowTrailingExpansion(const UChar* characters, int length, RenderStyle* style, TextRunFlags flags)
+{
+ ASSERT(style);
+ TextDirection textDirection = LTR;
+ bool directionalOverride = style->visuallyOrdered();
+ if (flags != DefaultTextRunFlags) {
+ if (flags & RespectDirection)
+ textDirection = style->direction();
+ if (flags & RespectDirectionOverride)
+ directionalOverride |= style->unicodeBidi() == Override;
+ }
+
+ // FIXME: Remove TextRuns all-in-one-constructor and use explicit setters here.
+ return TextRun(characters, length, false, 0, 0, TextRun::AllowTrailingExpansion, textDirection, directionalOverride);
+}
+
+TextRun RenderBlock::constructTextRunAllowTrailingExpansion(const String& string, RenderStyle* style, TextRunFlags flags)
+{
+ return constructTextRunAllowTrailingExpansion(string.characters(), string.length(), style, flags);
+}
+
#ifndef NDEBUG
void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* markedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const RenderObject* obj) const
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2011-05-18 07:19:48 UTC (rev 86739)
@@ -55,6 +55,14 @@
enum CaretType { CursorCaret, DragCaret };
+enum TextRunFlag {
+ DefaultTextRunFlags = 0,
+ RespectDirection = 1 << 0,
+ RespectDirectionOverride = 1 << 1
+};
+
+typedef unsigned TextRunFlags;
+
class RenderBlock : public RenderBox {
public:
RenderBlock(Node*);
@@ -161,6 +169,9 @@
static void appendRunsForObject(BidiRunList<BidiRun>&, int start, int end, RenderObject*, InlineBidiResolver&);
+ static TextRun constructTextRunAllowTrailingExpansion(const String&, RenderStyle*, TextRunFlags = DefaultTextRunFlags);
+ static TextRun constructTextRunAllowTrailingExpansion(const UChar*, int length, RenderStyle*, TextRunFlags = DefaultTextRunFlags);
+
ColumnInfo* columnInfo() const;
int columnGap() const;
Modified: trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -197,7 +197,7 @@
font = Font(fontDescription, 0, 0);
font.update(0);
- run = TextRun(m_replacementText.characters(), m_replacementText.length());
+ run = TextRun(m_replacementText);
textWidth = font.width(run);
replacementTextRect.setSize(FloatSize(textWidth + replacementTextRoundedRectLeftRightTextMargin * 2, replacementTextRoundedRectHeight));
Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -221,10 +221,8 @@
if (paintInfo.phase == PaintPhaseForeground) {
const String& displayedFilename = fileTextValue();
- unsigned length = displayedFilename.length();
- const UChar* string = displayedFilename.characters();
- TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, style()->direction(), style()->unicodeBidi() == Override);
-
+ TextRun textRun = constructTextRunAllowTrailingExpansion(displayedFilename, style(), RespectDirection | RespectDirectionOverride);
+
// Determine where the filename should be placed
int contentLeft = tx + borderLeft() + paddingLeft();
int buttonAndIconWidth = m_button->renderBox()->width() + afterButtonSpacing
@@ -270,27 +268,30 @@
m_minPreferredLogicalWidth = 0;
m_maxPreferredLogicalWidth = 0;
- if (style()->width().isFixed() && style()->width().value() > 0)
- m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeContentBoxLogicalWidth(style()->width().value());
+ RenderStyle* style = this->style();
+ ASSERT(style);
+
+ if (style->width().isFixed() && style->width().value() > 0)
+ m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeContentBoxLogicalWidth(style->width().value());
else {
// Figure out how big the filename space needs to be for a given number of characters
// (using "0" as the nominal character).
const UChar ch = '0';
- float charWidth = style()->font().width(TextRun(&ch, 1, false, 0, 0, TextRun::AllowTrailingExpansion));
+ float charWidth = style->font().width(constructTextRunAllowTrailingExpansion(String(&ch, 1), style));
m_maxPreferredLogicalWidth = (int)ceilf(charWidth * defaultWidthNumChars);
}
- if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
- m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->minWidth().value()));
- m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->minWidth().value()));
- } else if (style()->width().isPercent() || (style()->width().isAuto() && style()->height().isPercent()))
+ if (style->minWidth().isFixed() && style->minWidth().value() > 0) {
+ m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style->minWidth().value()));
+ m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style->minWidth().value()));
+ } else if (style->width().isPercent() || (style->width().isAuto() && style->height().isPercent()))
m_minPreferredLogicalWidth = 0;
else
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth;
- if (style()->maxWidth().isFixed() && style()->maxWidth().value() != undefinedLength) {
- m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
- m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style()->maxWidth().value()));
+ if (style->maxWidth().isFixed() && style->maxWidth().value() != undefinedLength) {
+ m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value()));
+ m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, computeContentBoxLogicalWidth(style->maxWidth().value()));
}
int toAdd = borderAndPaddingWidth();
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -104,7 +104,7 @@
// we have an alt and the user meant it (its not a text we invented)
if (!m_altText.isEmpty()) {
const Font& font = style()->font();
- IntSize textSize(min(font.width(TextRun(m_altText.characters(), m_altText.length())), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight));
+ IntSize textSize(min(font.width(TextRun(m_altText)), maxAltTextWidth), min(font.fontMetrics().height(), maxAltTextHeight));
imageSize = imageSize.expandedTo(textSize);
}
@@ -286,7 +286,7 @@
// Only draw the alt text if it'll fit within the content box,
// and only if it fits above the error image.
- TextRun textRun(text.characters(), text.length());
+ TextRun textRun(text);
int textWidth = font.width(textRun);
if (errorPictureDrawn) {
if (usableWidth >= textWidth && fontMetrics.height() <= imageY)
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -120,7 +120,7 @@
if (!text.isEmpty()) {
// FIXME: Why is this always LTR? Can't text direction affect the width?
- float textWidth = itemFont.width(TextRun(text.impl(), false, 0, 0, TextRun::AllowTrailingExpansion, LTR));
+ float textWidth = itemFont.width(constructTextRunAllowTrailingExpansion(text, style()));
width = max(width, textWidth);
}
}
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (86738 => 86739)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-05-18 06:16:29 UTC (rev 86738)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-05-18 07:19:48 UTC (rev 86739)
@@ -542,7 +542,7 @@
return roundf(style()->font().primaryFont()->avgCharWidth());
const UChar ch = '0';
- return style()->font().width(TextRun(&ch, 1, false, 0, 0, TextRun::AllowTrailingExpansion));
+ return style()->font().width(constructTextRunAllowTrailingExpansion(String(&ch, 1), style()));
}
float RenderTextControl::scaleEmToUnits(int x) const