Changeset 28298 in webkit


Ignore:
Timestamp:
Dec 1, 2007 8:28:57 AM (16 years ago)
Author:
mitz@apple.com
Message:

Reviewed by Darin Adler.

  • fold FontStyle into TextRun
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/Font.cpp: (WebCore::WidthIterator::WidthIterator): (WebCore::WidthIterator::advance): (WebCore::Font::width): (WebCore::Font::drawSimpleText): (WebCore::Font::drawGlyphBuffer): (WebCore::Font::drawText): (WebCore::Font::floatWidth): (WebCore::Font::floatWidthForSimpleText): (WebCore::Font::selectionRectForText): (WebCore::Font::selectionRectForSimpleText): (WebCore::Font::offsetForPosition): (WebCore::Font::offsetForPositionForSimpleText):
  • platform/graphics/Font.h: (WebCore::TextRun::TextRun): (WebCore::TextRun::setText): (WebCore::TextRun::allowTabs): (WebCore::TextRun::xPos): (WebCore::TextRun::padding): (WebCore::TextRun::rtl): (WebCore::TextRun::ltr): (WebCore::TextRun::directionalOverride): (WebCore::TextRun::applyRunRounding): (WebCore::TextRun::applyWordRounding): (WebCore::TextRun::spacingDisabled): (WebCore::TextRun::disableSpacing): (WebCore::TextRun::disableRoundingHacks): (WebCore::TextRun::setRTL): (WebCore::TextRun::setDirectionalOverride):
  • platform/graphics/FontStyle.h: Removed.
  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::drawText): (WebCore::GraphicsContext::drawBidiText): (WebCore::GraphicsContext::drawHighlightForText):
  • platform/graphics/GraphicsContext.h:
  • platform/graphics/StringTruncator.cpp: (WebCore::stringWidth):
  • platform/graphics/gtk/FontGtk.cpp: (WebCore::Font::drawComplexText): (WebCore::Font::floatWidthForComplexText): (WebCore::Font::offsetForPositionForComplexText): (WebCore::Font::selectionRectForComplexText):
  • platform/graphics/mac/FontMac.mm: (WebCore::ATSULayoutParameters::ATSULayoutParameters): (WebCore::addDirectionalOverride): (WebCore::overrideLayoutOperation): (WebCore::ATSULayoutParameters::initialize): (WebCore::Font::selectionRectForComplexText): (WebCore::Font::drawComplexText): (WebCore::Font::floatWidthForComplexText): (WebCore::Font::offsetForPositionForComplexText):
  • platform/graphics/qt/FontQt.cpp: (WebCore::generateComponents): (WebCore::Font::drawText): (WebCore::Font::width): (WebCore::Font::offsetForPosition): (WebCore::cursorToX): (WebCore::Font::selectionRectForText):
  • platform/graphics/win/FontWin.cpp: (WebCore::Font::selectionRectForComplexText): (WebCore::Font::drawComplexText): (WebCore::Font::floatWidthForComplexText): (WebCore::Font::offsetForPositionForComplexText):
  • platform/graphics/wx/FontWx.cpp: (WebCore::Font::selectionRectForComplexText): (WebCore::Font::drawComplexText): (WebCore::Font::floatWidthForComplexText): (WebCore::Font::offsetForPositionForComplexText):
  • platform/mac/WebCoreTextRenderer.mm: (WebCoreDrawTextAtPoint): (WebCoreTextFloatWidth):
  • platform/win/PopupMenuWin.cpp: (WebCore::PopupMenu::paint):
  • platform/win/UniscribeController.cpp: (WebCore::UniscribeController::UniscribeController): (WebCore::UniscribeController::offsetForPosition): (WebCore::UniscribeController::advance): (WebCore::UniscribeController::itemizeShapeAndPlace): (WebCore::UniscribeController::resetControlAndState): (WebCore::UniscribeController::shapeAndPlaceItem):
  • platform/win/UniscribeController.h:
  • platform/win/WebCoreTextRenderer.cpp: (WebCore::doDrawTextAtPoint):
  • rendering/EllipsisBox.cpp: (WebCore::EllipsisBox::paint):
  • rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::selectionRect): (WebCore::InlineTextBox::paint): (WebCore::InlineTextBox::paintSelection): (WebCore::InlineTextBox::paintCompositionBackground): (WebCore::InlineTextBox::paintSpellingOrGrammarMarker): (WebCore::InlineTextBox::paintTextMatchMarker): (WebCore::InlineTextBox::offsetForPosition): (WebCore::InlineTextBox::positionForOffset):
  • rendering/RenderFileUploadControl.cpp: (WebCore::RenderFileUploadControl::paintObject): (WebCore::RenderFileUploadControl::calcPrefWidths):
  • rendering/RenderImage.cpp:
  • rendering/RenderListBox.cpp: (WebCore::RenderListBox::updateFromElement): (WebCore::RenderListBox::paintItemForeground):
  • rendering/RenderMenuList.cpp: (WebCore::RenderMenuList::updateOptionsWidth):
  • rendering/RenderText.cpp: (WebCore::RenderText::widthFromCache): (WebCore::RenderText::calcPrefWidths): (WebCore::RenderText::width):
  • rendering/RenderText.h: (WebCore::RenderText::allowTabs):
  • rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::calcPrefWidths):
  • rendering/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::calculateGlyphWidth): (WebCore::SVGInlineTextBox::paintCharacters): (WebCore::SVGInlineTextBox::paintSelection):
  • rendering/SVGRootInlineBox.cpp: (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback): (WebCore::cummulatedWidthOfInlineBoxCharacterRange): (WebCore::svgTextRunForInlineTextBox):
  • rendering/SVGRootInlineBox.h:
Location:
trunk/WebCore
Files:
1 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r28275 r28298  
     12007-12-01  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - fold FontStyle into TextRun
     6
     7        * WebCore.xcodeproj/project.pbxproj:
     8        * platform/graphics/Font.cpp:
     9        (WebCore::WidthIterator::WidthIterator):
     10        (WebCore::WidthIterator::advance):
     11        (WebCore::Font::width):
     12        (WebCore::Font::drawSimpleText):
     13        (WebCore::Font::drawGlyphBuffer):
     14        (WebCore::Font::drawText):
     15        (WebCore::Font::floatWidth):
     16        (WebCore::Font::floatWidthForSimpleText):
     17        (WebCore::Font::selectionRectForText):
     18        (WebCore::Font::selectionRectForSimpleText):
     19        (WebCore::Font::offsetForPosition):
     20        (WebCore::Font::offsetForPositionForSimpleText):
     21        * platform/graphics/Font.h:
     22        (WebCore::TextRun::TextRun):
     23        (WebCore::TextRun::setText):
     24        (WebCore::TextRun::allowTabs):
     25        (WebCore::TextRun::xPos):
     26        (WebCore::TextRun::padding):
     27        (WebCore::TextRun::rtl):
     28        (WebCore::TextRun::ltr):
     29        (WebCore::TextRun::directionalOverride):
     30        (WebCore::TextRun::applyRunRounding):
     31        (WebCore::TextRun::applyWordRounding):
     32        (WebCore::TextRun::spacingDisabled):
     33        (WebCore::TextRun::disableSpacing):
     34        (WebCore::TextRun::disableRoundingHacks):
     35        (WebCore::TextRun::setRTL):
     36        (WebCore::TextRun::setDirectionalOverride):
     37        * platform/graphics/FontStyle.h: Removed.
     38        * platform/graphics/GraphicsContext.cpp:
     39        (WebCore::GraphicsContext::drawText):
     40        (WebCore::GraphicsContext::drawBidiText):
     41        (WebCore::GraphicsContext::drawHighlightForText):
     42        * platform/graphics/GraphicsContext.h:
     43        * platform/graphics/StringTruncator.cpp:
     44        (WebCore::stringWidth):
     45        * platform/graphics/gtk/FontGtk.cpp:
     46        (WebCore::Font::drawComplexText):
     47        (WebCore::Font::floatWidthForComplexText):
     48        (WebCore::Font::offsetForPositionForComplexText):
     49        (WebCore::Font::selectionRectForComplexText):
     50        * platform/graphics/mac/FontMac.mm:
     51        (WebCore::ATSULayoutParameters::ATSULayoutParameters):
     52        (WebCore::addDirectionalOverride):
     53        (WebCore::overrideLayoutOperation):
     54        (WebCore::ATSULayoutParameters::initialize):
     55        (WebCore::Font::selectionRectForComplexText):
     56        (WebCore::Font::drawComplexText):
     57        (WebCore::Font::floatWidthForComplexText):
     58        (WebCore::Font::offsetForPositionForComplexText):
     59        * platform/graphics/qt/FontQt.cpp:
     60        (WebCore::generateComponents):
     61        (WebCore::Font::drawText):
     62        (WebCore::Font::width):
     63        (WebCore::Font::offsetForPosition):
     64        (WebCore::cursorToX):
     65        (WebCore::Font::selectionRectForText):
     66        * platform/graphics/win/FontWin.cpp:
     67        (WebCore::Font::selectionRectForComplexText):
     68        (WebCore::Font::drawComplexText):
     69        (WebCore::Font::floatWidthForComplexText):
     70        (WebCore::Font::offsetForPositionForComplexText):
     71        * platform/graphics/wx/FontWx.cpp:
     72        (WebCore::Font::selectionRectForComplexText):
     73        (WebCore::Font::drawComplexText):
     74        (WebCore::Font::floatWidthForComplexText):
     75        (WebCore::Font::offsetForPositionForComplexText):
     76        * platform/mac/WebCoreTextRenderer.mm:
     77        (WebCoreDrawTextAtPoint):
     78        (WebCoreTextFloatWidth):
     79        * platform/win/PopupMenuWin.cpp:
     80        (WebCore::PopupMenu::paint):
     81        * platform/win/UniscribeController.cpp:
     82        (WebCore::UniscribeController::UniscribeController):
     83        (WebCore::UniscribeController::offsetForPosition):
     84        (WebCore::UniscribeController::advance):
     85        (WebCore::UniscribeController::itemizeShapeAndPlace):
     86        (WebCore::UniscribeController::resetControlAndState):
     87        (WebCore::UniscribeController::shapeAndPlaceItem):
     88        * platform/win/UniscribeController.h:
     89        * platform/win/WebCoreTextRenderer.cpp:
     90        (WebCore::doDrawTextAtPoint):
     91        * rendering/EllipsisBox.cpp:
     92        (WebCore::EllipsisBox::paint):
     93        * rendering/InlineTextBox.cpp:
     94        (WebCore::InlineTextBox::selectionRect):
     95        (WebCore::InlineTextBox::paint):
     96        (WebCore::InlineTextBox::paintSelection):
     97        (WebCore::InlineTextBox::paintCompositionBackground):
     98        (WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
     99        (WebCore::InlineTextBox::paintTextMatchMarker):
     100        (WebCore::InlineTextBox::offsetForPosition):
     101        (WebCore::InlineTextBox::positionForOffset):
     102        * rendering/RenderFileUploadControl.cpp:
     103        (WebCore::RenderFileUploadControl::paintObject):
     104        (WebCore::RenderFileUploadControl::calcPrefWidths):
     105        * rendering/RenderImage.cpp:
     106        * rendering/RenderListBox.cpp:
     107        (WebCore::RenderListBox::updateFromElement):
     108        (WebCore::RenderListBox::paintItemForeground):
     109        * rendering/RenderMenuList.cpp:
     110        (WebCore::RenderMenuList::updateOptionsWidth):
     111        * rendering/RenderText.cpp:
     112        (WebCore::RenderText::widthFromCache):
     113        (WebCore::RenderText::calcPrefWidths):
     114        (WebCore::RenderText::width):
     115        * rendering/RenderText.h:
     116        (WebCore::RenderText::allowTabs):
     117        * rendering/RenderTextControl.cpp:
     118        (WebCore::RenderTextControl::calcPrefWidths):
     119        * rendering/SVGInlineTextBox.cpp:
     120        (WebCore::SVGInlineTextBox::calculateGlyphWidth):
     121        (WebCore::SVGInlineTextBox::paintCharacters):
     122        (WebCore::SVGInlineTextBox::paintSelection):
     123        * rendering/SVGRootInlineBox.cpp:
     124        (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback):
     125        (WebCore::cummulatedWidthOfInlineBoxCharacterRange):
     126        (WebCore::svgTextRunForInlineTextBox):
     127        * rendering/SVGRootInlineBox.h:
     128
    11292007-12-01  Adam Treat  <treat@kde.org>
    2130
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r28260 r28298  
    29722972                B24055660B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */; };
    29732973                B25DFAAF0B2E2929000E6510 /* JSSVGMatrixCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B25DFAAE0B2E2929000E6510 /* JSSVGMatrixCustom.cpp */; };
    2974                 B25E96BE0D00975100CFD296 /* FontStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = B25E96BD0D00975100CFD296 /* FontStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
    29752974                B26554EA0B80D74900A50EC3 /* RenderSVGTextPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B26554E80B80D74900A50EC3 /* RenderSVGTextPath.cpp */; };
    29762975                B26554EB0B80D74900A50EC3 /* RenderSVGTextPath.h in Headers */ = {isa = PBXBuildFile; fileRef = B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */; };
     
    69616960                B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceListInternal.h; sourceTree = "<group>"; };
    69626961                B25DFAAE0B2E2929000E6510 /* JSSVGMatrixCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGMatrixCustom.cpp; sourceTree = "<group>"; };
    6963                 B25E96BD0D00975100CFD296 /* FontStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontStyle.h; sourceTree = "<group>"; };
    69646962                B26554E80B80D74900A50EC3 /* RenderSVGTextPath.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTextPath.cpp; sourceTree = "<group>"; };
    69656963                B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGTextPath.h; sourceTree = "<group>"; };
     
    1100811006                        isa = PBXGroup;
    1100911007                        children = (
    11010                                 B25E96BD0D00975100CFD296 /* FontStyle.h */,
    1101111008                                B23540F00D00782E002382FA /* StringTruncator.cpp */,
    1101211009                                B23540F10D00782E002382FA /* StringTruncator.h */,
     
    1392413921                                B2C3DA700D006CD600EF6F26 /* GlyphWidthMap.h in Headers */,
    1392513922                                B23540F30D00782E002382FA /* StringTruncator.h in Headers */,
    13926                                 B25E96BE0D00975100CFD296 /* FontStyle.h in Headers */,
    1392713923                                B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */,
    1392813924                                B2AFFC810D00A5C10030074D /* FontPlatformData.h in Headers */,
  • trunk/WebCore/platform/graphics/Font.cpp

    r28234 r28298  
    3333#include "IntPoint.h"
    3434#include "GlyphBuffer.h"
    35 #include "FontStyle.h"
    3635#include <wtf/unicode/Unicode.h>
    3736#include <wtf/MathExtras.h>
     
    6362
    6463struct WidthIterator {
    65     WidthIterator(const Font* font, const TextRun& run, const FontStyle& style);
     64    WidthIterator(const Font* font, const TextRun& run);
    6665
    6766    void advance(int to, GlyphBuffer* glyphBuffer = 0);
     
    7372    int m_end;
    7473
    75     const FontStyle& m_style;
    76    
    7774    unsigned m_currentCharacter;
    7875    float m_runWidthSoFar;
     
    8582};
    8683
    87 WidthIterator::WidthIterator(const Font* font, const TextRun& run, const FontStyle& style)
     84WidthIterator::WidthIterator(const Font* font, const TextRun& run)
    8885    : m_font(font)
    8986    , m_run(run)
    9087    , m_end(run.length())
    91     , m_style(style)
    9288    , m_currentCharacter(0)
    9389    , m_runWidthSoFar(0)
     
    9692    // If the padding is non-zero, count the number of spaces in the run
    9793    // and divide that by the padding for per space addition.
    98     m_padding = m_style.padding();
     94    m_padding = m_run.padding();
    9995    if (!m_padding)
    10096        m_padPerSpace = 0;
     
    108104            m_padPerSpace = 0;
    109105        else
    110             m_padPerSpace = ceilf(m_style.padding() / numSpaces);
     106            m_padPerSpace = ceilf(m_run.padding() / numSpaces);
    111107    }
    112108}
     
    120116    const UChar* cp = m_run.data(currentCharacter);
    121117
    122     bool rtl = m_style.rtl();
     118    bool rtl = m_run.rtl();
    123119    bool hasExtraSpacing = m_font->letterSpacing() || m_font->wordSpacing() || m_padding;
    124120
     
    164160        // Now that we have a glyph and font data, get its width.
    165161        float width;
    166         if (c == '\t' && m_style.allowTabs()) {
     162        if (c == '\t' && m_run.allowTabs()) {
    167163            float tabWidth = m_font->tabWidth();
    168             width = tabWidth - fmodf(m_style.xPos() + runWidthSoFar, tabWidth);
     164            width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
    169165        } else {
    170166            width = fontData->widthForGlyph(glyph);
     
    173169            // Second, in fixed-pitch fonts we ensure that all characters that
    174170            // match the width of the space character have the same width as the space character.
    175             if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_style.applyWordRounding())
     171            if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_run.applyWordRounding())
    176172                width = fontData->m_adjustedSpaceWidth;
    177173        }
    178174
    179         if (hasExtraSpacing && !m_style.spacingDisabled()) {
     175        if (hasExtraSpacing && !m_run.spacingDisabled()) {
    180176            // Account for letter-spacing.
    181177            if (width && m_font->letterSpacing())
     
    216212        // Force characters that are used to determine word boundaries for the rounding hack
    217213        // to be integer width, so following words will start on an integer boundary.
    218         if (m_style.applyWordRounding() && Font::isRoundingHackCharacter(c))
     214        if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(c))
    219215            width = ceilf(width);
    220216
    221217        // Check to see if the next character is a "rounding hack character", if so, adjust
    222218        // width so that the total run width will be on an integer boundary.
    223         if ((m_style.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
    224                 || (m_style.applyRunRounding() && currentCharacter >= m_end)) {
     219        if ((m_run.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
     220                || (m_run.applyRunRounding() && currentCharacter >= m_end)) {
    225221            float totalWidth = runWidthSoFar + width;
    226222            width += ceilf(totalWidth) - totalWidth;
     
    511507int Font::width(const TextRun& run) const
    512508{
    513     return width(run, FontStyle());
    514 }
    515 
    516 int Font::width(const TextRun& run, const FontStyle& style) const
    517 {
    518     return lroundf(floatWidth(run, style));
     509    return lroundf(floatWidth(run));
    519510}
    520511
     
    619610}
    620611
    621 void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
     612void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
    622613{
    623614    // This glyph buffer holds our glyphs+advances+font data for each glyph.
     
    625616
    626617    float startX = point.x();
    627     WidthIterator it(this, run, style);
     618    WidthIterator it(this, run);
    628619    it.advance(from);
    629620    float beforeWidth = it.m_runWidthSoFar;
     
    636627    float afterWidth = it.m_runWidthSoFar;
    637628
    638     if (style.rtl()) {
     629    if (run.rtl()) {
    639630        float finalRoundingWidth = it.m_finalRoundingWidth;
    640631        it.advance(run.length());
     
    644635
    645636    // Swap the order of the glyphs if right-to-left.
    646     if (style.rtl())
     637    if (run.rtl())
    647638        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
    648639            glyphBuffer.swap(i, end);
     
    651642    // all the advances up to the first glyph.
    652643    FloatPoint startPoint(startX, point.y());
    653     drawGlyphBuffer(context, glyphBuffer, run, style, startPoint);
     644    drawGlyphBuffer(context, glyphBuffer, run, startPoint);
    654645}
    655646
    656647void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuffer,
    657                            const TextRun& run, const FontStyle& style, const FloatPoint& point) const
     648                           const TextRun& run, const FloatPoint& point) const
    658649{   
    659650    // Draw each contiguous run of glyphs that use the same font data.
     
    680671}
    681672
    682 void Font::drawText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
     673void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
    683674{
    684675    // Don't draw anything while we are using custom fonts that are in the process of loading.
     
    688679    to = (to == -1 ? run.length() : to);
    689680    if (canUseGlyphCache(run))
    690         drawSimpleText(context, run, style, point, from, to);
     681        drawSimpleText(context, run, point, from, to);
    691682    else
    692         drawComplexText(context, run, style, point, from, to);
    693 }
    694 
    695 float Font::floatWidth(const TextRun& run, const FontStyle& style) const
     683        drawComplexText(context, run, point, from, to);
     684}
     685
     686float Font::floatWidth(const TextRun& run) const
    696687{
    697688    if (canUseGlyphCache(run))
    698         return floatWidthForSimpleText(run, style, 0);
    699     return floatWidthForComplexText(run, style);
    700 }
    701 
    702 float Font::floatWidthForSimpleText(const TextRun& run, const FontStyle& style, GlyphBuffer* glyphBuffer) const
    703 {
    704     WidthIterator it(this, run, style);
     689        return floatWidthForSimpleText(run, 0);
     690    return floatWidthForComplexText(run);
     691}
     692
     693float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer) const
     694{
     695    WidthIterator it(this, run);
    705696    it.advance(run.length(), glyphBuffer);
    706697    return it.m_runWidthSoFar;
    707698}
    708699
    709 FloatRect Font::selectionRectForText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
     700FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
    710701{
    711702    to = (to == -1 ? run.length() : to);
    712703    if (canUseGlyphCache(run))
    713         return selectionRectForSimpleText(run, style, point, h, from, to);
    714     return selectionRectForComplexText(run, style, point, h, from, to);
    715 }
    716 
    717 FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
    718 {
    719     WidthIterator it(this, run, style);
     704        return selectionRectForSimpleText(run, point, h, from, to);
     705    return selectionRectForComplexText(run, point, h, from, to);
     706}
     707
     708FloatRect Font::selectionRectForSimpleText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
     709{
     710    WidthIterator it(this, run);
    720711    it.advance(from);
    721712    float beforeWidth = it.m_runWidthSoFar;
     
    724715
    725716    // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
    726     if (style.rtl()) {
     717    if (run.rtl()) {
    727718        it.advance(run.length());
    728719        float totalWidth = it.m_runWidthSoFar;
     
    733724}
    734725
    735 int Font::offsetForPosition(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
     726int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs) const
    736727{
    737728    if (canUseGlyphCache(run))
    738         return offsetForPositionForSimpleText(run, style, x, includePartialGlyphs);
    739     return offsetForPositionForComplexText(run, style, x, includePartialGlyphs);
    740 }
    741 
    742 int Font::offsetForPositionForSimpleText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
     729        return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
     730    return offsetForPositionForComplexText(run, x, includePartialGlyphs);
     731}
     732
     733int Font::offsetForPositionForSimpleText(const TextRun& run, int x, bool includePartialGlyphs) const
    743734{
    744735    float delta = (float)x;
    745736
    746     WidthIterator it(this, run, style);
     737    WidthIterator it(this, run);
    747738    GlyphBuffer localGlyphBuffer;
    748739    unsigned offset;
    749     if (style.rtl()) {
    750         delta -= floatWidthForSimpleText(run, style, 0);
     740    if (run.rtl()) {
     741        delta -= floatWidthForSimpleText(run, 0);
    751742        while (1) {
    752743            offset = it.m_currentCharacter;
  • trunk/WebCore/platform/graphics/Font.h

    r28234 r28298  
    4747class GraphicsContext;
    4848class IntPoint;
    49 class FontStyle;
    5049
    5150struct GlyphData;
     
    5352class TextRun {
    5453public:
    55     TextRun(const UChar* c, int len)
    56     :m_characters(c), m_len(len)
    57     {}
    58 
    59     TextRun(const String& s)
    60     :m_characters(s.characters()), m_len(s.length())
    61     {}
     54    TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
     55              bool applyRunRounding = true, bool applyWordRounding = true)
     56        : m_characters(c)
     57        , m_len(len)
     58        , m_allowTabs(allowTabs)
     59        , m_xpos(xpos)
     60        , m_padding(padding)
     61        , m_rtl(rtl)
     62        , m_directionalOverride(directionalOverride)
     63        , m_applyRunRounding(applyRunRounding)
     64        , m_applyWordRounding(applyWordRounding)
     65        , m_disableSpacing(false)
     66    {
     67    }
     68
     69    TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
     70              bool applyRunRounding = true, bool applyWordRounding = true)
     71        : m_characters(s.characters())
     72        , m_len(s.length())
     73        , m_allowTabs(allowTabs)
     74        , m_xpos(xpos)
     75        , m_padding(padding)
     76        , m_rtl(rtl)
     77        , m_directionalOverride(directionalOverride)
     78        , m_applyRunRounding(applyRunRounding)
     79        , m_applyWordRounding(applyWordRounding)
     80        , m_disableSpacing(false)
     81    {
     82    }
    6283
    6384    const UChar operator[](int i) const { return m_characters[i]; }
     
    6687    const UChar* characters() const { return m_characters; }
    6788    int length() const { return m_len; }
    68    
     89
     90    void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
     91
     92    bool allowTabs() const { return m_allowTabs; }
     93    int xPos() const { return m_xpos; }
     94    int padding() const { return m_padding; }
     95    bool rtl() const { return m_rtl; }
     96    bool ltr() const { return !m_rtl; }
     97    bool directionalOverride() const { return m_directionalOverride; }
     98    bool applyRunRounding() const { return m_applyRunRounding; }
     99    bool applyWordRounding() const { return m_applyWordRounding; }
     100    bool spacingDisabled() const { return m_disableSpacing; }
     101
     102    void disableSpacing() { m_disableSpacing = true; }
     103    void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
     104    void setRTL(bool b) { m_rtl = b; }
     105    void setDirectionalOverride(bool override) { m_directionalOverride = override; }
     106   
    69107private:
    70108    const UChar* m_characters;
    71109    int m_len;
     110
     111    bool m_allowTabs;
     112    int m_xpos;
     113    int m_padding;
     114    bool m_rtl;
     115    bool m_directionalOverride;
     116    bool m_applyRunRounding;
     117    bool m_applyWordRounding;
     118    bool m_disableSpacing;
    72119};
    73120
     
    96143    void update(PassRefPtr<FontSelector>) const;
    97144
    98     void drawText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from = 0, int to = -1) const;
    99 
    100     int width(const TextRun&, const FontStyle&) const;
     145    void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const;
     146
    101147    int width(const TextRun&) const;
    102     float floatWidth(const TextRun&, const FontStyle&) const;
    103148    float floatWidth(const TextRun&) const;
    104149   
    105     int offsetForPosition(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
    106     FloatRect selectionRectForText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from = 0, int to = -1) const;
     150    int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
     151    FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const;
    107152
    108153    bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
     
    151196private:
    152197    bool canUseGlyphCache(const TextRun&) const;
    153     void drawSimpleText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const;
     198    void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    154199    void drawGlyphs(GraphicsContext*, const FontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
    155     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FontStyle&, const FloatPoint&) const;
    156     void drawComplexText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const;
    157     float floatWidthForSimpleText(const TextRun&, const FontStyle&, GlyphBuffer*) const;
    158     float floatWidthForComplexText(const TextRun&, const FontStyle&) const;
    159     int offsetForPositionForSimpleText(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
    160     int offsetForPositionForComplexText(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
    161     FloatRect selectionRectForSimpleText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from, int to) const;
    162     FloatRect selectionRectForComplexText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from, int to) const;
     200    void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const;
     201    void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
     202    float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const;
     203    float floatWidthForComplexText(const TextRun&) const;
     204    int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const;
     205    int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const;
     206    FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const;
     207    FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const;
    163208#endif
    164209    friend struct WidthIterator;
  • trunk/WebCore/platform/graphics/GraphicsContext.cpp

    r28234 r28298  
    2929#include "BidiResolver.h"
    3030#include "Font.h"
    31 #include "FontStyle.h"
    3231
    3332using namespace std;
     
    244243void GraphicsContext::drawText(const TextRun& run, const IntPoint& point, int from, int to)
    245244{
    246     drawText(run, point, FontStyle(), from, to);
    247 }
    248 
    249 void GraphicsContext::drawText(const TextRun& run, const IntPoint& point, const FontStyle& style, int from, int to)
    250 {
    251     if (paintingDisabled())
    252         return;
    253    
    254     font().drawText(this, run, style, point, from, to);
    255 }
    256 
    257 void GraphicsContext::drawBidiText(const TextRun& run, const IntPoint& point, const FontStyle& style)
     245    if (paintingDisabled())
     246        return;
     247   
     248    font().drawText(this, run, point, from, to);
     249}
     250
     251void GraphicsContext::drawBidiText(const TextRun& run, const IntPoint& point)
    258252{
    259253    if (paintingDisabled())
     
    261255
    262256    BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
    263     WTF::Unicode::Direction paragraphDirection = style.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
    264 
    265     bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(style.ltr() ? 0 : 1, paragraphDirection, style.directionalOverride())));
     257    WTF::Unicode::Direction paragraphDirection = run.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
     258
     259    bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(run.ltr() ? 0 : 1, paragraphDirection, run.directionalOverride())));
    266260
    267261    bidiResolver.createBidiRunsForLine(TextRunIterator(&run, 0), TextRunIterator(&run, run.length()));
     
    273267    BidiCharacterRun* bidiRun = bidiResolver.firstRun();
    274268    while (bidiRun) {
    275         FontStyle subrunStyle(style);
    276         subrunStyle.setRTL(bidiRun->level() % 2);
    277         subrunStyle.setDirectionalOverride(bidiRun->dirOverride(false));
    278 
    279         TextRun subrun(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
    280 
    281         font().drawText(this, subrun, subrunStyle, currPoint);
     269
     270        TextRun subrun = run;
     271        subrun.setText(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
     272        subrun.setRTL(bidiRun->level() % 2);
     273        subrun.setDirectionalOverride(bidiRun->dirOverride(false));
     274
     275        font().drawText(this, subrun, currPoint);
    282276
    283277        bidiRun = bidiRun->next();
    284278        // FIXME: Have Font::drawText return the width of what it drew so that we don't have to re-measure here.
    285279        if (bidiRun)
    286             currPoint.move(font().floatWidth(subrun, subrunStyle), 0.f);
     280            currPoint.move(font().floatWidth(subrun), 0.f);
    287281    }
    288282
     
    290284}
    291285
    292 void GraphicsContext::drawHighlightForText(const TextRun& run, const IntPoint& point, int h, const FontStyle& style, const Color& backgroundColor, int from, int to)
    293 {
    294     if (paintingDisabled())
    295         return;
    296 
    297     fillRect(font().selectionRectForText(run, style, point, h, from, to), backgroundColor);
     286void GraphicsContext::drawHighlightForText(const TextRun& run, const IntPoint& point, int h, const Color& backgroundColor, int from, int to)
     287{
     288    if (paintingDisabled())
     289        return;
     290
     291    fillRect(font().selectionRectForText(run, point, h, from, to), backgroundColor);
    298292}
    299293
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r28234 r28298  
    8787    class Path;
    8888    class TextRun;
    89     class FontStyle;
    9089
    9190    // These bits can be ORed together for a total of 8 possible text drawing modes.
     
    174173
    175174        void drawText(const TextRun&, const IntPoint&, int from = 0, int to = -1);
    176         void drawText(const TextRun&, const IntPoint&, const FontStyle&, int from = 0, int to = -1);
    177         void drawBidiText(const TextRun&, const IntPoint&, const FontStyle&);
    178         void drawHighlightForText(const TextRun&, const IntPoint&, int h, const FontStyle&, const Color& backgroundColor, int from = 0, int to = -1);
     175        void drawBidiText(const TextRun&, const IntPoint&);
     176        void drawHighlightForText(const TextRun&, const IntPoint&, int h, const Color& backgroundColor, int from = 0, int to = -1);
    179177
    180178        FloatRect roundToDevicePixels(const FloatRect&);
  • trunk/WebCore/platform/graphics/StringTruncator.cpp

    r28234 r28298  
    3434#include "FontPlatformData.h"
    3535#include "TextBreakIterator.h"
    36 #include "FontStyle.h"
    3736#include <wtf/Assertions.h>
    3837#include <wtf/Vector.h>
     
    9796{
    9897    TextRun run(characters, length);
    99     FontStyle style;
    10098    if (disableRoundingHacks)
    101         style.disableRoundingHacks();
    102     return renderer.floatWidth(run, style);
     99        run.disableRoundingHacks();
     100    return renderer.floatWidth(run);
    103101}
    104102
  • trunk/WebCore/platform/graphics/gtk/FontGtk.cpp

    r28251 r28298  
    6262}
    6363
    64 void Font::drawComplexText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const
     64void Font::drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const
    6565{
    6666    notImplemented();
    6767}
    6868
    69 float Font::floatWidthForComplexText(const TextRun&, const FontStyle&) const
     69float Font::floatWidthForComplexText(const TextRun&) const
    7070{
    7171    notImplemented();
     
    7373}
    7474
    75 int Font::offsetForPositionForComplexText(const TextRun&, const FontStyle&, int, bool) const
     75int Font::offsetForPositionForComplexText(const TextRun&, int, bool) const
    7676{
    7777    notImplemented();
     
    7979}
    8080
    81 FloatRect Font::selectionRectForComplexText(const TextRun&, const FontStyle&, const IntPoint&, int, int, int) const
     81FloatRect Font::selectionRectForComplexText(const TextRun&, const IntPoint&, int, int, int) const
    8282{
    8383    notImplemented();
  • trunk/WebCore/platform/graphics/mac/FontMac.mm

    r28251 r28298  
    3535#import "IntRect.h"
    3636#import "Logging.h"
    37 #import "FontStyle.h"
    3837#import "WebCoreSystemInterface.h"
    3938#import "WebCoreTextRenderer.h"
     
    5857struct ATSULayoutParameters
    5958{
    60     ATSULayoutParameters(const TextRun& run, const FontStyle& style)
     59    ATSULayoutParameters(const TextRun& run)
    6160        : m_run(run)
    62         , m_style(style)
    6361        , m_font(0)
    6462        , m_fonts(0)
     
    7270
    7371    const TextRun& m_run;
    74     const FontStyle& m_style;
    7572   
    7673    const Font* m_font;
     
    9390    charactersWithOverride[run.length() + 1] = popDirectionalFormatting;
    9491
    95     return TextRun(charactersWithOverride, run.length() + 2);
     92    TextRun result = run;
     93    result.setText(charactersWithOverride, run.length() + 2);
     94    return result;
    9695}
    9796
     
    157156    ATSLayoutRecord *layoutRecords;
    158157
    159     if (params->m_style.applyWordRounding()) {
     158    if (params->m_run.applyWordRounding()) {
    160159        status = ATSUDirectGetLayoutDataArrayPtrFromLineRef(iLineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, true, (void **)&layoutRecords, &count);
    161160        if (status != noErr) {
     
    177176        Fixed syntheticBoldOffset = 0;
    178177        ATSGlyphRef spaceGlyph = 0;
    179         bool hasExtraSpacing = params->m_font->letterSpacing() || params->m_font->wordSpacing() | params->m_style.padding();
    180         float padding = params->m_style.padding();
     178        bool hasExtraSpacing = params->m_font->letterSpacing() || params->m_font->wordSpacing() | params->m_run.padding();
     179        float padding = params->m_run.padding();
    181180        // In the CoreGraphics code path, the rounding hack is applied in logical order.
    182181        // Here it is applied in visual left-to-right order, which may be better.
     
    214213                    width +=params->m_font->letterSpacing();
    215214                if (Font::treatAsSpace(nextCh)) {
    216                     if (params->m_style.padding()) {
     215                    if (params->m_run.padding()) {
    217216                        if (padding < params->m_padPerSpace) {
    218217                            width += padding;
     
    237236                width = ceilf(width);
    238237            lastAdjustedPos = lastAdjustedPos + width;
    239             if (Font::isRoundingHackCharacter(nextCh) && (!isLastChar || params->m_style.applyRunRounding())){
    240                 if (params->m_style.ltr())
     238            if (Font::isRoundingHackCharacter(nextCh) && (!isLastChar || params->m_run.applyRunRounding())){
     239                if (params->m_run.ltr())
    241240                    lastAdjustedPos = ceilf(lastAdjustedPos);
    242241                else {
     
    353352   
    354353    ATSLineLayoutOptions lineLayoutOptions = kATSLineKeepSpacesOutOfMargin | kATSLineHasNoHangers;
    355     Boolean rtl = m_style.rtl();
     354    Boolean rtl = m_run.rtl();
    356355    overrideSpecifier.operationSelector = kATSULayoutOperationPostLayoutAdjustment;
    357356    overrideSpecifier.overrideUPP = overrideLayoutOperation;
     
    360359    ATSUAttributeValuePtr values[] = { &cgContext, &lineLayoutOptions, &rtl, &overrideSpecifier };
    361360   
    362     status = ATSUSetLayoutControls(layout, (m_style.applyWordRounding() ? 4 : 3), tags, sizes, values);
     361    status = ATSUSetLayoutControls(layout, (m_run.applyWordRounding() ? 4 : 3), tags, sizes, values);
    363362    if (status != noErr)
    364363        LOG_ERROR("ATSUSetLayoutControls failed(%d)", status);
     
    417416                shapeArabic(m_run.characters(), m_charBuffer, runLength, i);
    418417            }
    419             if (m_style.rtl() && !r->m_ATSUMirrors) {
     418            if (m_run.rtl() && !r->m_ATSUMirrors) {
    420419                UChar mirroredChar = u_charMirror(m_run[i]);
    421420                if (mirroredChar != m_run[i]) {
     
    456455        substituteOffset += substituteLength;
    457456    }
    458     if (m_style.padding()) {
     457    if (m_run.padding()) {
    459458        float numSpaces = 0;
    460459        unsigned k;
     
    466465            m_padPerSpace = 0;
    467466        else
    468             m_padPerSpace = ceilf(m_style.padding() / numSpaces);
     467            m_padPerSpace = ceilf(m_run.padding() / numSpaces);
    469468    } else
    470469        m_padPerSpace = 0;
     
    478477}
    479478
    480 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
     479FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
    481480{       
    482     TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
    483     if (style.directionalOverride()) {
     481    TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
     482    if (run.directionalOverride()) {
    484483        from++;
    485484        to++;
    486485    }
    487486
    488     ATSULayoutParameters params(adjustedRun, style);
     487    ATSULayoutParameters params(adjustedRun);
    489488    params.initialize(this);
    490489
     
    504503    FloatRect rect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
    505504
    506     if (style.directionalOverride())
     505    if (run.directionalOverride())
    507506        delete []adjustedRun.characters();
    508507
     
    510509}
    511510
    512 void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
     511void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
    513512{
    514513    OSStatus status;
    515514   
    516515    int drawPortionLength = to - from;
    517     TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
    518     if (style.directionalOverride())
     516    TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
     517    if (run.directionalOverride())
    519518        from++;
    520519
    521     ATSULayoutParameters params(TextRun(adjustedRun.characters(), adjustedRun.length()), style);
     520    ATSULayoutParameters params(TextRun(adjustedRun.characters(), adjustedRun.length()));
    522521    params.initialize(this, graphicsContext);
    523522   
     
    541540    disposeATSULayoutParameters(&params);
    542541   
    543     if (style.directionalOverride())
     542    if (run.directionalOverride())
    544543        delete []adjustedRun.characters();
    545544}
    546545
    547 float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
     546float Font::floatWidthForComplexText(const TextRun& run) const
    548547{
    549548    if (run.length() == 0)
    550549        return 0;
    551550
    552     ATSULayoutParameters params(run, style);
     551    ATSULayoutParameters params(run);
    553552    params.initialize(this);
    554553   
     
    569568}
    570569
    571 int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
    572 {
    573     TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
    574    
    575     ATSULayoutParameters params(adjustedRun, style);
     570int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
     571{
     572    TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
     573   
     574    ATSULayoutParameters params(adjustedRun);
    576575    params.initialize(this);
    577576
     
    586585    if (status == noErr) {
    587586        offset = (unsigned)primaryOffset;
    588         if (style.directionalOverride() && offset > 0)
     587        if (run.directionalOverride() && offset > 0)
    589588            offset--;
    590589    } else
     
    594593    disposeATSULayoutParameters(&params);
    595594   
    596     if (style.directionalOverride())
     595    if (run.directionalOverride())
    597596        delete []adjustedRun.characters();
    598597
  • trunk/WebCore/platform/graphics/qt/FontQt.cpp

    r28251 r28298  
    2424#include "FontDescription.h"
    2525#include "FontSelector.h"
    26 #include "FontStyle.h"
    2726
    2827#include "GraphicsContext.h"
     
    158157}
    159158
    160 static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run, const FontStyle &style)
     159static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run)
    161160{
    162161//     qDebug() << "generateComponents" << QString((const QChar *)run.characters(), run.length());
     
    164163    int wordSpacing = font.wordSpacing();
    165164    bool smallCaps = font.fontDescription().smallCaps();
    166     int padding = style.padding();
     165    int padding = run.padding();
    167166    int numSpaces = 0;
    168167    if (padding) {
     
    184183                --numSpaces;
    185184            }
    186             components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
     185            components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
    187186            offset += add + letterSpacing + components->last().width;
    188187            start = 1;
     
    202201                if (i - start > 0) {
    203202                    components->append(TextRunComponent(run.characters() + start, i - start,
    204                                                         style.rtl(),
     203                                                        run.rtl(),
    205204                                                        f, offset, f == &font.scFont()));
    206205                    offset += components->last().width + letterSpacing;
     
    212211                    --numSpaces;
    213212                }
    214                 components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
     213                components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
    215214                offset += wordSpacing + add + components->last().width + letterSpacing;
    216215                start = i + 1;
     
    229228            if (i - start > 0) {
    230229                components->append(TextRunComponent(run.characters() + start, i - start,
    231                                                     style.rtl(),
     230                                                    run.rtl(),
    232231                                                    f, offset, f == &font.scFont()));
    233232                offset += components->last().width + letterSpacing;
     
    240239        if (run.length() - start > 0) {
    241240            components->append(TextRunComponent(run.characters() + start, run.length() - start,
    242                                                 style.rtl(),
     241                                                run.rtl(),
    243242                                                f, offset, f == &font.scFont()));
    244243            offset += components->last().width;
     
    252251                if (i - start > 0) {
    253252                    components->append(TextRunComponent(run.characters() + start, i - start,
    254                                                         style.rtl(),
     253                                                        run.rtl(),
    255254                                                        f, offset));
    256255                    offset += components->last().width;
     
    262261                    --numSpaces;
    263262                }
    264                 components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
     263                components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
    265264                offset += add + components->last().width;
    266265                if (i)
     
    271270        if (run.length() - start > 0) {
    272271            components->append(TextRunComponent(run.characters() + start, run.length() - start,
    273                                                 style.rtl(),
     272                                                run.rtl(),
    274273                                                f, offset));
    275274            offset += components->last().width;
     
    279278}
    280279
    281 void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
     280void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
    282281{
    283282    if (to < 0)
     
    288287
    289288    Vector<TextRunComponent, 1024> components;
    290     int w = generateComponents(&components, *this, run, style);
     289    int w = generateComponents(&components, *this, run);
    291290
    292291    if (from > 0 || to < run.length()) {
    293         FloatRect clip = selectionRectForText(run, style,
     292        FloatRect clip = selectionRectForText(run,
    294293                                              IntPoint(qRound(point.x()), qRound(point.y())),
    295294                                              QFontMetrics(m_font).height(), from, to);
     
    299298    }
    300299
    301     if (style.rtl()) {
     300    if (run.rtl()) {
    302301        for (int i = 0; i < components.size(); ++i) {
    303302            if (!components.at(i).isSpace()) {
     
    320319}
    321320
    322 int Font::width(const TextRun& run, const FontStyle& style) const
     321int Font::width(const TextRun& run) const
    323322{
    324323    Vector<TextRunComponent, 1024> components;
    325     int w = generateComponents(&components, *this, run, style);
     324    int w = generateComponents(&components, *this, run);
    326325
    327326//     qDebug() << "     width=" << w;
     
    329328}
    330329
    331 int Font::width(const TextRun& run) const
    332 {
    333     return width(run, FontStyle());
    334 }
    335 
    336 float Font::floatWidth(const TextRun& run, const FontStyle& style) const
    337 {
    338     return width(run, style);
    339 }
    340 
    341330float Font::floatWidth(const TextRun& run) const
    342331{
     
    344333}
    345334
    346 int Font::offsetForPosition(const TextRun& run, const FontStyle& style, int position, bool includePartialGlyphs) const
     335int Font::offsetForPosition(const TextRun& run, int position, bool includePartialGlyphs) const
    347336{
    348337    Vector<TextRunComponent, 1024> components;
    349     int w = generateComponents(&components, *this, run, style);
     338    int w = generateComponents(&components, *this, run);
    350339
    351340    int offset = 0;
    352     if (style.rtl()) {
     341    if (run.rtl()) {
    353342        for (int i = 0; i < components.size(); ++i) {
    354343            int xe = w - components.at(i).offset;
     
    402391}
    403392
    404 static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width,
    405                      const FontStyle& style, int cursor)
     393static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width, bool rtl, int cursor)
    406394{
    407395    int start = 0;
     
    412400        }
    413401        int xs = components.at(i).offset;
    414         if (style.rtl())
     402        if (rtl)
    415403            xs = width - xs - components.at(i).width;
    416404        QTextLayout layout(components.at(i).string, *components.at(i).font);
     
    428416}
    429417
    430 FloatRect Font::selectionRectForText(const TextRun& run, const FontStyle& style, const IntPoint& pt,
     418FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt,
    431419                                     int h, int from, int to) const
    432420{
    433421    Vector<TextRunComponent, 1024> components;
    434     int w = generateComponents(&components, *this, run, style);
     422    int w = generateComponents(&components, *this, run);
    435423
    436424    if (from == 0 && to == run.length())
    437425        return FloatRect(pt.x(), pt.y(), w, h);
    438426
    439     float x1 = cursorToX(components, w, style, from);
    440     float x2 = cursorToX(components, w, style, to);
     427    float x1 = cursorToX(components, w, run.rtl(), from);
     428    float x2 = cursorToX(components, w, run.rtl(), to);
    441429    if (x2 < x1)
    442430        qSwap(x1, x2);
  • trunk/WebCore/platform/graphics/win/FontWin.cpp

    r28251 r28298  
    3333#include "IntRect.h"
    3434#include "NotImplemented.h"
    35 #include "FontStyle.h"
    3635#include "UniscribeController.h"
    3736#include <ApplicationServices/ApplicationServices.h>
     
    9695}
    9796
    98 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h,
     97FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h,
    9998                                            int from, int to) const
    10099{
    101     UniscribeController it(this, run, style);
     100    UniscribeController it(this, run);
    102101    it.advance(from);
    103102    float beforeWidth = it.runWidthSoFar();
     
    106105
    107106    // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
    108     if (style.rtl()) {
     107    if (run.rtl()) {
    109108        it.advance(run.length());
    110109        float totalWidth = it.runWidthSoFar();
     
    115114}
    116115
    117 void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point,
     116void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
    118117                           int from, int to) const
    119118{
     
    122121
    123122    float startX = point.x();
    124     UniscribeController controller(this, run, style);
     123    UniscribeController controller(this, run);
    125124    controller.advance(from);
    126125    float beforeWidth = controller.runWidthSoFar();
     
    133132    float afterWidth = controller.runWidthSoFar();
    134133
    135     if (style.rtl()) {
     134    if (run.rtl()) {
    136135        controller.advance(run.length());
    137136        startX += controller.runWidthSoFar() - afterWidth;
     
    141140    // Draw the glyph buffer now at the starting point returned in startX.
    142141    FloatPoint startPoint(startX, point.y());
    143     drawGlyphBuffer(context, glyphBuffer, run, style, startPoint);
     142    drawGlyphBuffer(context, glyphBuffer, run, startPoint);
    144143}
    145144
    146 float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
     145float Font::floatWidthForComplexText(const TextRun& run) const
    147146{
    148     UniscribeController controller(this, run, style);
     147    UniscribeController controller(this, run);
    149148    controller.advance(run.length());
    150149    return controller.runWidthSoFar();
    151150}
    152151
    153 int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
     152int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
    154153{
    155     UniscribeController controller(this, run, style);
     154    UniscribeController controller(this, run);
    156155    return controller.offsetForPosition(x, includePartialGlyphs);
    157156}
  • trunk/WebCore/platform/graphics/wx/FontWx.cpp

    r28251 r28298  
    7575}
    7676
    77 FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
     77FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
    7878{
    7979    notImplemented();
     
    8181}
    8282
    83 void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
     83void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
    8484{
    8585    notImplemented();
    8686}
    8787
    88 float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
     88float Font::floatWidthForComplexText(const TextRun& run) const
    8989{
    9090    notImplemented();
     
    9292}
    9393
    94 int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
     94int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
    9595{
    9696    notImplemented();
  • trunk/WebCore/platform/mac/WebCoreTextRenderer.mm

    r28234 r28298  
    3131#import "GraphicsContext.h"
    3232#import "IntPoint.h"
    33 #import "FontStyle.h"
    3433#import "WebFontCache.h"
    3534
     
    4948    Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
    5049    TextRun run(buffer, length);
    51     FontStyle style;
    52     style.disableRoundingHacks();
     50    run.disableRoundingHacks();
    5351    CGFloat red, green, blue, alpha;
    5452    [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
    5553    graphicsContext.setFillColor(makeRGBA((int)(red * 255), (int)(green * 255), (int)(blue * 255), (int)(alpha * 255)));
    56     renderer.drawText(&graphicsContext, run, style, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y))));
     54    renderer.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y))));
    5755    if (!flipped)
    5856        CGContextScaleCTM(cgContext, 1.0f, -1.0f);
     
    6462    Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
    6563    TextRun run(buffer, length);
    66     FontStyle style;
    67     style.disableRoundingHacks();
    68     return renderer.floatWidth(run, style);
     64    run.disableRoundingHacks();
     65    return renderer.floatWidth(run);
    6966}
    7067
  • trunk/WebCore/platform/win/PopupMenuWin.cpp

    r28240 r28298  
    3636#include "RenderTheme.h"
    3737#include "RenderView.h"
    38 #include "FontStyle.h"
    3938#include <tchar.h>
    4039#include <windows.h>
     
    511510        unsigned length = itemText.length();
    512511        const UChar* string = itemText.characters();
    513         FontStyle fontStyle(0, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
    514         TextRun textRun(string, length);
     512        TextRun textRun(string, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
    515513
    516514        context.setFillColor(optionTextColor);
     
    529527            int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
    530528            int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
    531             context.drawBidiText(textRun, IntPoint(textX, textY), fontStyle);
     529            context.drawBidiText(textRun, IntPoint(textX, textY));
    532530        }
    533531    }
  • trunk/WebCore/platform/win/UniscribeController.cpp

    r28234 r28298  
    3131#include "Font.h"
    3232#include "FontData.h"
    33 #include "FontStyle.h"
    3433#include <wtf/MathExtras.h>
    3534
     
    4039// take the GlyphBuffer as an arg so that we don't have to populate the glyph buffer when
    4140// measuring.
    42 UniscribeController::UniscribeController(const Font* font, const TextRun& run, const FontStyle& style)
     41UniscribeController::UniscribeController(const Font* font, const TextRun& run)
    4342: m_font(*font)
    4443, m_run(run)
    45 , m_style(style)
    4644, m_end(run.length())
    4745, m_currentCharacter(0)
     
    5250, m_offsetPosition(0)
    5351{
    54     m_padding = m_style.padding();
     52    m_padding = m_run.padding();
    5553    if (!m_padding)
    5654        m_padPerSpace = 0;
     
    6462            m_padPerSpace = 0;
    6563        else
    66             m_padPerSpace = ceilf(m_style.padding() / numSpaces);
     64            m_padPerSpace = ceilf(m_run.padding() / numSpaces);
    6765    }
    6866
     
    8078    if (m_computingOffsetPosition) {
    8179        // The point is to the left or to the right of the entire run.
    82         if (m_offsetX >= m_runWidthSoFar && m_style.ltr() || m_offsetX < 0 && m_style.rtl())
     80        if (m_offsetX >= m_runWidthSoFar && m_run.ltr() || m_offsetX < 0 && m_run.rtl())
    8381            m_offsetPosition = m_end;
    8482    }
     
    112110        memcpy(smallCapsBuffer.data(), cp, length * sizeof(UChar));
    113111        bool isSmallCaps = false;
    114         unsigned indexOfCaseShift = m_style.rtl() ? length - 1 : 0;
    115         const UChar* curr = m_style.rtl() ? cp + length  - 1: cp;
    116         const UChar* end = m_style.rtl() ? cp - 1: cp + length;
     112        unsigned indexOfCaseShift = m_run.rtl() ? length - 1 : 0;
     113        const UChar* curr = m_run.rtl() ? cp + length  - 1: cp;
     114        const UChar* end = m_run.rtl() ? cp - 1: cp + length;
    117115        while (curr != end) {
    118116            int index = curr - cp;
    119117            UChar c = smallCapsBuffer[index];
    120118            UChar newC;
    121             curr = m_style.rtl() ? curr - 1 : curr + 1;
     119            curr = m_run.rtl() ? curr - 1 : curr + 1;
    122120            if (U_GET_GC_MASK(c) & U_GC_M_MASK)
    123121                continue;
     
    126124                if (!isSmallCaps) {
    127125                    isSmallCaps = true;
    128                     int itemStart = m_style.rtl() ? index : indexOfCaseShift;
    129                     int itemLength = m_style.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
     126                    int itemStart = m_run.rtl() ? index : indexOfCaseShift;
     127                    int itemLength = m_run.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
    130128                    itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, false, glyphBuffer);
    131129                    indexOfCaseShift = index;
     
    133131            } else if (isSmallCaps) {
    134132                isSmallCaps = false;
    135                 int itemStart = m_style.rtl() ? index : indexOfCaseShift;
    136                 int itemLength = m_style.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
     133                int itemStart = m_run.rtl() ? index : indexOfCaseShift;
     134                int itemLength = m_run.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
    137135                itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, true, glyphBuffer);
    138136                indexOfCaseShift = index;
     
    140138        }
    141139       
    142         int itemLength = m_style.rtl() ? indexOfCaseShift + 1 : length - indexOfCaseShift;
     140        int itemLength = m_run.rtl() ? indexOfCaseShift + 1 : length - indexOfCaseShift;
    143141        if (itemLength) {
    144             int itemStart = m_style.rtl() ? 0 : indexOfCaseShift;
     142            int itemStart = m_run.rtl() ? 0 : indexOfCaseShift;
    145143            itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, isSmallCaps, glyphBuffer);
    146144        }
     
    161159    m_items.resize(numItems + 1);
    162160
    163     if (m_style.rtl()) {
     161    if (m_run.rtl()) {
    164162        for (int i = m_items.size() - 2; i >= 0; i--) {
    165163            if (!shapeAndPlaceItem(cp, i, smallCaps, glyphBuffer))
     
    182180
    183181    // Set up the correct direction for the run.
    184     m_state.uBidiLevel = m_style.rtl();
     182    m_state.uBidiLevel = m_run.rtl();
    185183   
    186184    // Lock the correct directional override.
    187     m_state.fOverrideDirection = m_style.directionalOverride();
     185    m_state.fOverrideDirection = m_run.directionalOverride();
    188186}
    189187
     
    321319        // match the width of the space glyph have the same width as the space glyph.
    322320        if (roundedAdvance == roundedSpaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) &&
    323             m_style.applyWordRounding())
     321            m_run.applyWordRounding())
    324322            advance = fontData->m_adjustedSpaceWidth;
    325323
     
    358356        // to be integer width, so the following words will start on an integer boundary.
    359357        int roundingHackIndex = roundingHackCharacters[k];
    360         if (m_style.applyWordRounding() && roundingHackIndex != -1)
     358        if (m_run.applyWordRounding() && roundingHackIndex != -1)
    361359            advance = ceilf(advance);
    362360
     
    364362        // width so that the total run width will be on an integer boundary.
    365363        int position = m_currentCharacter + len;
    366         bool lastGlyph = (k == glyphs.size() - 1) && (m_style.rtl() ? i == 0 : i == m_items.size() - 2) && (position >= m_end);
    367         if ((m_style.applyWordRounding() && roundingHackWordBoundaries[k] != -1) ||
    368             (m_style.applyRunRounding() && lastGlyph)) {
     364        bool lastGlyph = (k == glyphs.size() - 1) && (m_run.rtl() ? i == 0 : i == m_items.size() - 2) && (position >= m_end);
     365        if ((m_run.applyWordRounding() && roundingHackWordBoundaries[k] != -1) ||
     366            (m_run.applyRunRounding() && lastGlyph)) {
    369367            float totalWidth = m_runWidthSoFar + advance;
    370368            advance += ceilf(totalWidth) - totalWidth;
     
    393391        if (trailing && m_includePartialGlyphs && m_offsetPosition < len - 1) {
    394392            m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
    395             m_offsetX += m_style.rtl() ? -trailing : trailing;
     393            m_offsetX += m_run.rtl() ? -trailing : trailing;
    396394        } else {
    397395            m_computingOffsetPosition = false;
  • trunk/WebCore/platform/win/UniscribeController.h

    r28234 r28298  
    3939class UniscribeController {
    4040public:
    41     UniscribeController(const Font*, const TextRun&, const FontStyle&);
     41    UniscribeController(const Font*, const TextRun&);
    4242
    4343    // Advance and measure/place up to the specified character.
     
    6161    const Font& m_font;
    6262    const TextRun& m_run;
    63     const FontStyle& m_style;
    6463
    6564    SCRIPT_CONTROL m_control;
  • trunk/WebCore/platform/win/WebCoreTextRenderer.cpp

    r28234 r28298  
    3030#include "GraphicsContext.h"
    3131#include "StringTruncator.h"
    32 #include "FontStyle.h"
    3332#include <wtf/unicode/Unicode.h>
    3433
     
    4847{
    4948    TextRun run(text.characters(), text.length());
    50     FontStyle style;
    5149
    5250    context.setFillColor(color);
    5351    if (isOneLeftToRightRun(run))
    54         font.drawText(&context, run, style, point);
     52        font.drawText(&context, run, point);
    5553    else {
    5654        context.setFont(font);
    57         context.drawBidiText(run, point, style);
     55        context.drawBidiText(run, point);
    5856    }
    5957
     
    6462        if (underlinedIndex > 0) {
    6563            TextRun beforeRun(text.characters(), underlinedIndex);
    66             beforeWidth = font.width(beforeRun, style);
     64            beforeWidth = font.width(beforeRun);
    6765        } else
    6866            beforeWidth = 0;
    6967
    7068        TextRun underlinedRun(text.characters() + underlinedIndex, 1);
    71         int underlinedWidth = font.width(underlinedRun, style);
     69        int underlinedWidth = font.width(underlinedRun);
    7270
    7371        IntPoint underlinePoint(point);
  • trunk/WebCore/rendering/EllipsisBox.cpp

    r28240 r28298  
    2626#include "GraphicsContext.h"
    2727#include "HitTestResult.h"
    28 #include "FontStyle.h"
    2928
    3029namespace WebCore {
     
    4847
    4948    const String& str = m_str;
    50     FontStyle fontStyle(0, 0, 0, false, style->visuallyOrdered());
    51     context->drawText(TextRun(str.characters(), str.length()), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
     49    context->drawText(TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + m_baseline));
    5250
    5351    if (setShadow)
  • trunk/WebCore/rendering/InlineTextBox.cpp

    r28234 r28298  
    3333#include "RenderTheme.h"
    3434#include "Text.h"
    35 #include "FontStyle.h"
    3635#include "break_lines.h"
    3736#include <wtf/AlwaysInline.h>
     
    9796    const Font& f = textObj->style(m_firstLine)->font();
    9897
    99     IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len),
    100                                                         FontStyle(textObj->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
     98    IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len, textObj->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
    10199                                                        IntPoint(tx + m_x, ty + selTop), selHeight, sPos, ePos));
    102100    if (r.x() > tx + m_x + m_width)
     
    375373    StringImpl* textStr = textObject()->text();
    376374
    377     FontStyle fontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered());
    378 
    379375    if (!paintSelectedTextOnly && !paintSelectedTextSeparately) {
    380376        // paint all the text
     
    384380        if (m_truncation != cNoTruncation)
    385381            endPoint = m_truncation;
    386         paintInfo.context->drawText(TextRun(textStr->characters() + m_start, endPoint), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
     382        paintInfo.context->drawText(TextRun(textStr->characters() + m_start, endPoint, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
     383                                    IntPoint(m_x + tx, m_y + ty + m_baseline));
    387384    } else {
    388385        int sPos, ePos;
     
    391388            // paint only the text that is not selected
    392389            if (sPos >= ePos)
    393                 paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
     390                paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
     391                                            IntPoint(m_x + tx, m_y + ty + m_baseline));
    394392            else {
    395393                if (sPos - 1 >= 0)
    396                     paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle,  0, sPos);
     394                    paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
     395                                                IntPoint(m_x + tx, m_y + ty + m_baseline),  0, sPos);
    397396                if (ePos < m_start + m_len)
    398                     paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle, ePos);
     397                    paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
     398                                                IntPoint(m_x + tx, m_y + ty + m_baseline), ePos);
    399399            }
    400400        }
     
    410410                paintInfo.context->setShadow(IntSize(selectionTextShadow->x, selectionTextShadow->y),
    411411                                             selectionTextShadow->blur, selectionTextShadow->color);
    412             paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle, sPos, ePos);
     412            paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
     413                                        IntPoint(m_x + tx, m_y + ty + m_baseline), sPos, ePos);
    413414            if (selectionTextShadow)
    414415                paintInfo.context->clearShadow();
     
    502503    int h = selectionHeight();
    503504    p->clip(IntRect(m_x + tx, y + ty, m_width, h));
    504     p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len), IntPoint(m_x + tx, y + ty), h,
    505                             FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()), c,
    506                             sPos, ePos);
     505    p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
     506                            IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
    507507    p->restore();
    508508}
     
    525525    int y = selectionTop();
    526526    int h = selectionHeight();
    527     p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len),
    528                             IntPoint(m_x + tx, y + ty), h,
    529                             FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()), c, sPos, ePos);
     527    p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
     528                            IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
    530529    p->restore();
    531530}
     
    614613        int y = selectionTop();
    615614        IntPoint startPoint = IntPoint(m_x + tx, y + ty);
    616         FontStyle fontStyle = FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
    617615        int startPosition = max(marker.startOffset - m_start, (unsigned)0);
    618616        int endPosition = min(marker.endOffset - m_start, (unsigned)m_len);   
    619         TextRun run = TextRun(textObject()->text()->characters() + m_start, m_len);
    620         IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, fontStyle, startPoint, selectionHeight(), startPosition, endPosition));
     617        TextRun run(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
     618        IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, startPoint, selectionHeight(), startPosition, endPosition));
    621619        object()->document()->setRenderedRectForMarker(object()->node(), marker, markerRect);
    622620    }
     
    650648    int sPos = max(marker.startOffset - m_start, (unsigned)0);
    651649    int ePos = min(marker.endOffset - m_start, (unsigned)m_len);   
    652     TextRun run = TextRun(textObject()->text()->characters() + m_start, m_len);
    653     FontStyle renderStyle = FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
     650    TextRun run(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
    654651    IntPoint startPoint = IntPoint(m_x + tx, y + ty);
    655652   
    656653    // Always compute and store the rect associated with this marker
    657     IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, renderStyle, startPoint, h, sPos, ePos));
     654    IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, startPoint, h, sPos, ePos));
    658655    object()->document()->setRenderedRectForMarker(object()->node(), marker, markerRect);
    659656     
     
    664661        updateGraphicsContext(pt, color, color, 0);  // Don't draw text at all!
    665662        pt->clip(IntRect(tx + m_x, ty + y, m_width, h));
    666         pt->drawHighlightForText(run, startPoint, h, renderStyle, color, sPos, ePos);
     663        pt->drawHighlightForText(run, startPoint, h, color, sPos, ePos);
    667664        pt->restore();
    668665    }
     
    802799    RenderStyle *style = text->style(m_firstLine);
    803800    const Font* f = &style->font();
    804     return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len),
    805                                 FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
     801    return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
    806802                                _x - m_x, includePartialGlyphs);
    807803}
     
    817813    int to = m_reversed ? m_len : offset - m_start;
    818814    // FIXME: Do we need to add rightBearing here?
    819     return enclosingIntRect(f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len),
    820                                                    FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
     815    return enclosingIntRect(f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
    821816                                                   IntPoint(m_x, 0), 0, from, to)).right();
    822817}
  • trunk/WebCore/rendering/RenderFileUploadControl.cpp

    r28240 r28298  
    3232#include "RenderTheme.h"
    3333#include "RenderView.h"
    34 #include "FontStyle.h"
    3534#include <math.h>
    3635
     
    177176        unsigned length = displayedFilename.length();
    178177        const UChar* string = displayedFilename.characters();
    179         FontStyle fontStyle(0, 0, 0, style()->direction() == RTL, style()->unicodeBidi() == Override);
    180         TextRun textRun(string, length);
     178        TextRun textRun(string, length, false, 0, 0, style()->direction() == RTL, style()->unicodeBidi() == Override);
    181179       
    182180        // Determine where the filename should be placed
     
    199197       
    200198        // Draw the filename
    201         paintInfo.context->drawBidiText(textRun, IntPoint(textX, textY), fontStyle);
     199        paintInfo.context->drawBidiText(textRun, IntPoint(textX, textY));
    202200       
    203201        if (m_fileChooser->icon()) {
     
    236234        // (using "0" as the nominal character).
    237235        const UChar ch = '0';
    238         float charWidth = style()->font().floatWidth(TextRun(&ch, 1), FontStyle(0, 0, 0, false, false, false));
     236        float charWidth = style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
    239237        m_maxPrefWidth = (int)ceilf(charWidth * defaultWidthNumChars);
    240238    }
  • trunk/WebCore/rendering/RenderImage.cpp

    r28234 r28298  
    3939#include "Page.h"
    4040#include "RenderView.h"
    41 #include "FontStyle.h"
    4241
    4342using namespace std;
  • trunk/WebCore/rendering/RenderListBox.cpp

    r28240 r28298  
    4747#include "RenderTheme.h"
    4848#include "RenderView.h"
    49 #include "FontStyle.h"
    5049#include <math.h>
    5150
     
    102101       
    103102        float width = 0;
    104         FontStyle fontStyle(0, 0, 0, false, false, false, false);
    105103        for (int i = 0; i < size; ++i) {
    106104            HTMLElement* element = listItems[i];
     
    118116               
    119117            if (!text.isEmpty()) {
    120                 float textWidth = itemFont.floatWidth(TextRun(text.impl()), fontStyle);
     118                float textWidth = itemFont.floatWidth(TextRun(text.impl(), 0, 0, 0, false, false, false, false));
    121119                width = max(width, textWidth);
    122120            }
     
    339337    unsigned length = itemText.length();
    340338    const UChar* string = itemText.characters();
    341     FontStyle fontStyle(0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
    342     TextRun textRun(string, length);
     339    TextRun textRun(string, length, 0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
    343340
    344341    // Draw the item text
    345342    if (itemStyle->visibility() != HIDDEN)
    346         paintInfo.context->drawBidiText(textRun, r.location(), fontStyle);
     343        paintInfo.context->drawBidiText(textRun, r.location());
    347344}
    348345
  • trunk/WebCore/rendering/RenderMenuList.cpp

    r28234 r28298  
    3737#include "RenderText.h"
    3838#include "RenderTheme.h"
    39 #include "FontStyle.h"
    4039#include <math.h>
    4140
     
    141140            String text = static_cast<HTMLOptionElement*>(element)->optionText();
    142141            if (!text.isEmpty())
    143                 maxOptionWidth = max(maxOptionWidth, style()->font().floatWidth(text, FontStyle()));
     142                maxOptionWidth = max(maxOptionWidth, style()->font().floatWidth(text));
    144143        }
    145144    }
  • trunk/WebCore/rendering/RenderText.cpp

    r28234 r28298  
    3434#include "Text.h"
    3535#include "TextBreakIterator.h"
    36 #include "FontStyle.h"
    3736#include "break_lines.h"
    3837#include <wtf/AlwaysInline.h>
     
    413412    }
    414413
    415     return f.width(TextRun(text()->characters() + start, len), FontStyle(allowTabs(), xPos));
     414    return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos));
    416415}
    417416
     
    672671                currMaxWidth = 0;
    673672            } else {
    674                 currMaxWidth += f.width(TextRun(txt + i, 1), FontStyle(allowTabs(), leadWidth + currMaxWidth));
     673                currMaxWidth += f.width(TextRun(txt + i, 1, allowTabs(), leadWidth + currMaxWidth));
    675674                needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1;
    676675            }
     
    10261025            w = widthFromCache(f, from, len, xPos);
    10271026    } else
    1028         w = f.width(TextRun(text()->characters() + from, len), FontStyle(allowTabs(), xPos));
     1027        w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos));
    10291028
    10301029    return w;
  • trunk/WebCore/rendering/RenderText.h

    r25754 r28298  
    128128    InlineTextBox* findNextInlineTextBox(int offset, int& pos) const;
    129129
    130     int allowTabs() const { return !style()->collapseWhiteSpace(); }
     130    bool allowTabs() const { return !style()->collapseWhiteSpace(); }
    131131
    132132    void checkConsistency() const;
  • trunk/WebCore/rendering/RenderTextControl.cpp

    r28240 r28298  
    4747#include "Text.h"
    4848#include "TextIterator.h"
    49 #include "FontStyle.h"
    5049#include "htmlediting.h"
    5150#include "visible_units.h"
     
    850849        // (using "0" as the nominal character).
    851850        const UChar ch = '0';
    852         float charWidth = style()->font().floatWidth(TextRun(&ch, 1), FontStyle(0, 0, 0, false, false, false));
     851        float charWidth = style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
    853852        int factor;
    854853        int scrollbarSize = 0;
  • trunk/WebCore/rendering/SVGInlineTextBox.cpp

    r28234 r28298  
    3636#include "SVGRootInlineBox.h"
    3737#include "Text.h"
    38 #include "FontStyle.h"
    3938
    4039#include <float.h>
     
    7574float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset) const
    7675{
    77     return style->font().floatWidth(TextRun(textObject()->text()->characters() + offset, 1), svgFontStyleForInlineTextBox(style, this, 0));
     76    return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0));
    7877}
    7978
     
    380379
    381380    IntPoint origin((int) svgChar.x, (int) svgChar.y);
    382     TextRun run(chars, length);
    383     FontStyle style = svgFontStyleForInlineTextBox(styleToUse, this, svgChar.x);
    384 
    385     paintInfo.context->drawText(run, origin, style);
     381    TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
     382
     383    paintInfo.context->drawText(run, origin);
    386384
    387385    if (paintInfo.phase != PaintPhaseSelection) {
     
    461459
    462460    int adjust = startPos >= boxStartOffset ? boxStartOffset : 0;
    463     p->drawHighlightForText(TextRun(textObject()->text()->characters() + start() + boxStartOffset, length),
    464                             IntPoint((int) svgChar.x, (int) svgChar.y - f->ascent()), f->ascent() + f->descent(),
    465                             svgFontStyleForInlineTextBox(style, this, svgChar.x), color,
    466                             startPos - adjust, endPos - adjust);
     461    p->drawHighlightForText(svgTextRunForInlineTextBox(textObject()->text()->characters() + start() + boxStartOffset, length, style, this, svgChar.x),
     462                            IntPoint((int) svgChar.x, (int) svgChar.y - f->ascent()),
     463                            f->ascent() + f->descent(), color, startPos - adjust, endPos - adjust);
    467464
    468465    p->restore();
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r28240 r28298  
    4141#include "SVGURIReference.h"
    4242#include "Text.h"
    43 #include "FontStyle.h"
    4443#include "UnicodeRange.h"
    4544
     
    520519            // Paint decorations, that have to be drawn before the text gets drawn
    521520            if (textDecorations != TDNONE && m_paintInfo.phase != PaintPhaseSelection) {
    522                 textWidth = styleToUse->font().width(TextRun(stringStart, stringLength), styleToUse);
     521                textWidth = styleToUse->font().width(svgTextRunForInlineTextBox(stringStart, stringLength, styleToUse, textBox, (*it).x));
    523522                decorationOrigin = IntPoint((int) (*it).x, (int) (*it).y - styleToUse->font().ascent());
    524523                info = m_rootBox->retrievePaintServersForTextDecoration(text);
     
    623622    RenderStyle* style = text->style();
    624623
    625     return style->font().floatWidth(TextRun(text->characters() + textBox->start() + range.startOffset, range.endOffset - range.startOffset), svgFontStyleForInlineTextBox(style, textBox, 0));
     624    return style->font().floatWidth(svgTextRunForInlineTextBox(text->characters() + textBox->start() + range.startOffset, range.endOffset - range.startOffset, style, textBox, 0));
    626625}
    627626
     
    639638}
    640639
    641 FontStyle svgFontStyleForInlineTextBox(RenderStyle* style, const InlineTextBox* textBox, float xPos)
     640TextRun svgTextRunForInlineTextBox(const UChar* c, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos)
    642641{
    643642    ASSERT(textBox);
    644643    ASSERT(style);
    645644
    646     FontStyle fontStyle(false, static_cast<int>(xPos), textBox->toAdd(), textBox->m_reversed, textBox->m_dirOverride || style->visuallyOrdered());
     645    TextRun run(c, len, false, static_cast<int>(xPos), textBox->toAdd(), textBox->m_reversed, textBox->m_dirOverride || style->visuallyOrdered());
    647646
    648647    // We handle letter & word spacing ourselves
    649     fontStyle.disableSpacing();
    650     return fontStyle;
     648    run.disableSpacing();
     649    return run;
    651650}
    652651
  • trunk/WebCore/rendering/SVGRootInlineBox.h

    r28234 r28298  
    7676
    7777// Shared with SVGRenderTreeAsText / SVGInlineTextBox
    78 FontStyle svgFontStyleForInlineTextBox(RenderStyle* style, const InlineTextBox* textBox, float xPos);
     78TextRun svgTextRunForInlineTextBox(const UChar*, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos);
    7979FloatPoint topLeftPositionOfCharacterRange(Vector<SVGChar>::iterator start, Vector<SVGChar>::iterator end);
    8080float cummulatedWidthOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
Note: See TracChangeset for help on using the changeset viewer.