Bug 8845. Define a TextRun (similar to the old WebCoreTextRun) and
make it the new API for Font and GraphicsContext when drawing/measuring
text.
Reviewed by andersca
* platform/Font.cpp:
(WebCore::m_finalRoundingWidth):
(WebCore::WidthIterator::advance):
(WebCore::WidthIterator::normalizeVoicingMarks):
(WebCore::Font::width):
(WebCore::Font::canUseGlyphCache):
(WebCore::Font::drawSimpleText):
(WebCore::Font::drawText):
(WebCore::Font::floatWidth):
(WebCore::Font::floatWidthForSimpleText):
* platform/Font.h:
(WebCore::TextRun::m_to):
(WebCore::TextRun::operator[]):
(WebCore::TextRun::data):
(WebCore::TextRun::adjustFrom):
(WebCore::TextRun::adjustTo):
(WebCore::TextRun::characters):
(WebCore::TextRun::length):
(WebCore::TextRun::from):
(WebCore::TextRun::to):
* platform/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawText):
(WebCore::GraphicsContext::drawHighlightForText):
* platform/GraphicsContext.h:
* platform/mac/FontMac.mm:
(WebCore::addDirectionalOverride):
(WebCore::overrideLayoutOperation):
(WebCore::ATSULayoutParameters::initialize):
(WebCore::Font::selectionRectForText):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawHighlightForText):
(WebCore::Font::floatWidthForComplexText):
(WebCore::Font::checkSelectionPoint):
* platform/win/FontWin.cpp:
(WebCore::hackishExtentForString):
(WebCore::Font::floatWidth):
(WebCore::Font::drawText):
(WebCore::Font::drawHighlightForText):
(WebCore::Font::selectionRectForText):
(WebCore::Font::checkSelectionPoint):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::selectionRect):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintMarkedTextBackground):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::offsetForPosition):
(WebCore::InlineTextBox::positionForOffset):
* rendering/RenderBlock.cpp:
(WebCore::stripTrailingSpace):
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutVerticalBox):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::imageChanged):
(WebCore::RenderImage::paint):
* rendering/RenderText.cpp:
(WebCore::RenderText::cacheWidths):
(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::trimmedMinMaxWidth):
(WebCore::RenderText::calcMinMaxWidth):
(WebCore::RenderText::width):
* rendering/RenderTextField.cpp:
(WebCore::RenderTextField::calcMinMaxWidth):
* rendering/bidi.cpp:
(WebCore::RenderBlock::tabWidth):
(WebCore::RenderBlock::checkLinesForTextOverflow):
* rendering/render_line.cpp:
(WebCore::EllipsisBox::paint):
* rendering/render_list.cpp:
(WebCore::RenderListMarker::paint):
(WebCore::RenderListMarker::calcMinMaxWidth):
(WebCore::RenderListMarker::getRelativeMarkerRect):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14297 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 3810f97..ab13aca 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -846,7 +846,7 @@
if (!m_tabWidth) {
const UChar spaceChar = ' ';
const Font& font = style()->font();
- int spaceWidth = font.width(&spaceChar, 1);
+ int spaceWidth = font.width(TextRun(&spaceChar, 1));
m_tabWidth = spaceWidth * 8;
assert(m_tabWidth != 0);
}
@@ -2559,11 +2559,12 @@
{
// Determine the width of the ellipsis using the current font.
const UChar ellipsis = 0x2026; // FIXME: CSS3 says this is configurable, also need to use 0x002E (FULL STOP) if 0x2026 not renderable
+ TextRun ellipsisRun(&ellipsis, 1);
static AtomicString ellipsisStr(&ellipsis, 1);
const Font& firstLineFont = firstLineStyle()->font();
const Font& font = style()->font();
- int firstLineEllipsisWidth = firstLineFont.width(&ellipsis, 1);
- int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(&ellipsis, 1);
+ int firstLineEllipsisWidth = firstLineFont.width(ellipsisRun);
+ int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(ellipsisRun);
// For LTR text truncation, we want to get the right edge of our padding box, and then we want to see
// if the right edge of a line box exceeds that. For RTL, we use the left edge of the padding box and