Changeset 116723 in webkit


Ignore:
Timestamp:
May 10, 2012 8:28:46 PM (12 years ago)
Author:
morrita@google.com
Message:

WebKit should support tab-size.
https://bugs.webkit.org/show_bug.cgi?id=52994

Source/WebCore:

  • Added boilerplate for "tab-size" CSS property.
  • Added RenderStye::tabSize() as a RareInheritedData.
  • Replaced TextRun::m_allowTabs into TextRun::m_tabSize.

Reviewed by Simon Fraser.

Tests: fast/css/tab-size-expected.html

fast/css/tab-size.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty):

  • css/CSSPropertyNames.in:
  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::drawTextInternal):

  • platform/chromium/PopupListBox.cpp:

(WebCore::PopupListBox::paintRow):

  • platform/graphics/Font.h:

(WebCore::Font::tabWidth):

  • platform/graphics/TextRun.h:

(WebCore::TextRun::TextRun):
(WebCore::TextRun::allowTabs):
(WebCore::TextRun::tabSize):
(WebCore::TextRun::setTabSize):

  • platform/graphics/WidthIterator.cpp:

(WebCore::WidthIterator::advance):

  • platform/graphics/mac/ComplexTextController.cpp:

(WebCore::ComplexTextController::adjustGlyphsAndAdvances):

  • platform/win/PopupMenuWin.cpp:

(WebCore::PopupMenuWin::paint):

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::constructTextRun):

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::constructTextRun):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::textWidth):
(WebCore::tryHyphenating):

  • rendering/RenderText.cpp:

(WebCore::RenderText::widthFromCache):
(WebCore::RenderText::computePreferredLogicalWidths):
(WebCore::RenderText::width):

  • rendering/RenderText.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::diff):

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyleBitfields::tabSize):
(WebCore::RenderStyleBitfields::collapsedTabSize):
(WebCore::RenderStyleBitfields::setTabSize):
(WebCore::RenderStyleBitfields::initialTabSize):

  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):

  • rendering/style/StyleRareInheritedData.h:
  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::constructTextRun):

  • rendering/svg/SVGTextMetrics.cpp:

(WebCore::constructTextRun):

Source/WebKit/chromium:

Reviewed by Simon Fraser.

  • src/WebTextRun.cpp:

(WebKit::WebTextRun::operator WebCore::TextRun):

LayoutTests:

Reviewed by Simon Fraser.

  • fast/css/tab-size-expected.html: Added.
  • fast/css/tab-size.html: Added.
  • platform/chromium-linux/svg/css/getComputedStyle-basic-expected.txt:
  • platform/chromium-win/fast/css/getComputedStyle/computed-style-expected.txt:
  • platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
Location:
trunk
Files:
2 added
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116698 r116723  
     12012-05-10  MORITA Hajime  <morrita@google.com>
     2
     3        WebKit should support tab-size.
     4        https://bugs.webkit.org/show_bug.cgi?id=52994
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/css/tab-size-expected.html: Added.
     9        * fast/css/tab-size.html: Added.
     10        * platform/chromium-linux/svg/css/getComputedStyle-basic-expected.txt:
     11        * platform/chromium-win/fast/css/getComputedStyle/computed-style-expected.txt:
     12        * platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     13
    1142012-05-10  Abhishek Arya  <inferno@chromium.org>
    215
  • trunk/LayoutTests/platform/chromium-linux/svg/css/getComputedStyle-basic-expected.txt

    r114777 r116723  
    165165rect: style.getPropertyValue(table-layout) : auto
    166166rect: style.getPropertyCSSValue(table-layout) : [object CSSPrimitiveValue]
     167rect: style.getPropertyValue(tab-size) : 8
     168rect: style.getPropertyCSSValue(tab-size) : [object CSSPrimitiveValue]
    167169rect: style.getPropertyValue(text-align) : -webkit-auto
    168170rect: style.getPropertyCSSValue(text-align) : [object CSSPrimitiveValue]
     
    693695g: style.getPropertyValue(table-layout) : auto
    694696g: style.getPropertyCSSValue(table-layout) : [object CSSPrimitiveValue]
     697g: style.getPropertyValue(tab-size) : 8
     698g: style.getPropertyCSSValue(tab-size) : [object CSSPrimitiveValue]
    695699g: style.getPropertyValue(text-align) : -webkit-auto
    696700g: style.getPropertyCSSValue(text-align) : [object CSSPrimitiveValue]
  • trunk/LayoutTests/platform/chromium-win/fast/css/getComputedStyle/computed-style-expected.txt

    r114766 r116723  
    8484speak: normal;
    8585table-layout: auto;
     86tab-size: 8;
    8687text-align: -webkit-auto;
    8788text-decoration: none;
  • trunk/LayoutTests/platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r114766 r116723  
    8383    speak: normal
    8484    table-layout: auto
     85    tab-size: 8
    8586    text-align: -webkit-auto
    8687    text-decoration: none
  • trunk/Source/WebCore/ChangeLog

    r116722 r116723  
     12012-05-10  Hajime Morrita  <morrita@google.com>
     2
     3        WebKit should support tab-size.
     4        https://bugs.webkit.org/show_bug.cgi?id=52994
     5
     6        - Added boilerplate for "tab-size" CSS property.
     7        - Added RenderStye::tabSize() as a RareInheritedData.
     8        - Replaced TextRun::m_allowTabs into TextRun::m_tabSize.
     9
     10        Reviewed by Simon Fraser.
     11
     12        Tests: fast/css/tab-size-expected.html
     13               fast/css/tab-size.html
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     17        * css/CSSParser.cpp:
     18        (WebCore::CSSParser::parseValue):
     19        * css/CSSProperty.cpp:
     20        (WebCore::CSSProperty::isInheritedProperty):
     21        * css/CSSPropertyNames.in:
     22        * css/CSSStyleSelector.cpp:
     23        (WebCore::CSSStyleSelector::applyProperty):
     24        * html/canvas/CanvasRenderingContext2D.cpp:
     25        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     26        * platform/chromium/PopupListBox.cpp:
     27        (WebCore::PopupListBox::paintRow):
     28        * platform/graphics/Font.h:
     29        (WebCore::Font::tabWidth):
     30        * platform/graphics/TextRun.h:
     31        (WebCore::TextRun::TextRun):
     32        (WebCore::TextRun::allowTabs):
     33        (WebCore::TextRun::tabSize):
     34        (WebCore::TextRun::setTabSize):
     35        * platform/graphics/WidthIterator.cpp:
     36        (WebCore::WidthIterator::advance):
     37        * platform/graphics/mac/ComplexTextController.cpp:
     38        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
     39        * platform/win/PopupMenuWin.cpp:
     40        (WebCore::PopupMenuWin::paint):
     41        * rendering/InlineTextBox.cpp:
     42        (WebCore::InlineTextBox::constructTextRun):
     43        * rendering/RenderBlock.cpp:
     44        (WebCore::RenderBlock::constructTextRun):
     45        * rendering/RenderBlockLineLayout.cpp:
     46        (WebCore::textWidth):
     47        (WebCore::tryHyphenating):
     48        * rendering/RenderText.cpp:
     49        (WebCore::RenderText::widthFromCache):
     50        (WebCore::RenderText::computePreferredLogicalWidths):
     51        (WebCore::RenderText::width):
     52        * rendering/RenderText.h:
     53        * rendering/style/RenderStyle.cpp:
     54        (WebCore::RenderStyle::diff):
     55        * rendering/style/RenderStyle.h:
     56        (WebCore::RenderStyleBitfields::tabSize):
     57        (WebCore::RenderStyleBitfields::collapsedTabSize):
     58        (WebCore::RenderStyleBitfields::setTabSize):
     59        (WebCore::RenderStyleBitfields::initialTabSize):
     60        * rendering/style/StyleRareInheritedData.cpp:
     61        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     62        (WebCore::StyleRareInheritedData::operator==):
     63        * rendering/style/StyleRareInheritedData.h:
     64        * rendering/svg/SVGInlineTextBox.cpp:
     65        (WebCore::SVGInlineTextBox::constructTextRun):
     66        * rendering/svg/SVGTextMetrics.cpp:
     67        (WebCore::constructTextRun):
     68
    1692012-05-10  Antoine Labour  <piman@chromium.org>
    270
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r116645 r116723  
    158158    CSSPropertySpeak,
    159159    CSSPropertyTableLayout,
     160    CSSPropertyTabSize,
    160161    CSSPropertyTextAlign,
    161162    CSSPropertyTextDecoration,
     
    15921593                return cssValuePool().createIdentifierValue(CSSValueAuto);
    15931594            return zoomAdjustedPixelValue(style->columnWidth(), style.get());
     1595        case CSSPropertyTabSize:
     1596            return cssValuePool().createValue(style->tabSize(), CSSPrimitiveValue::CSS_NUMBER);
    15941597        case CSSPropertyWebkitRegionBreakAfter:
    15951598            return cssValuePool().createValue(style->regionBreakAfter());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r116645 r116723  
    19741974        return true;
    19751975    }
     1976    case CSSPropertyTabSize:
     1977        validPrimitive = validUnit(value, FInteger | FNonNeg);
     1978        break;
    19761979    case CSSPropertyWebkitAspectRatio:
    19771980        return parseAspectRatio(important);
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r113031 r116723  
    280280    case CSSPropertyResize:
    281281    case CSSPropertySpeak:
     282    case CSSPropertyTabSize:
    282283    case CSSPropertyTextAlign:
    283284    case CSSPropertyTextDecoration:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r112968 r116723  
    151151speak
    152152table-layout
     153tab-size
    153154text-align
    154155text-decoration
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r115953 r116723  
    18801880    setPropertyHandler(CSSPropertySpeak, ApplyPropertyDefault<ESpeak, &RenderStyle::speak, ESpeak, &RenderStyle::setSpeak, ESpeak, &RenderStyle::initialSpeak>::createHandler());
    18811881    setPropertyHandler(CSSPropertyTableLayout, ApplyPropertyDefault<ETableLayout, &RenderStyle::tableLayout, ETableLayout, &RenderStyle::setTableLayout, ETableLayout, &RenderStyle::initialTableLayout>::createHandler());
     1882    setPropertyHandler(CSSPropertyTabSize, ApplyPropertyDefault<unsigned, &RenderStyle::tabSize, unsigned, &RenderStyle::setTabSize, unsigned, &RenderStyle::initialTabSize>::createHandler());
    18821883    setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler());
    18831884    setPropertyHandler(CSSPropertyTextDecoration, ApplyPropertyTextDecoration::createHandler());
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r115215 r116723  
    20542054    bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
    20552055
    2056     unsigned length = text.length();
    2057     const UChar* string = text.characters();
    2058     TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
    2059 
     2056    TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override, true, TextRun::NoRounding);
    20602057    // Draw the item text at the correct point.
    20612058    FloatPoint location(x, y);
     
    20782075    }
    20792076
    2080     float fontWidth = font.width(TextRun(text, false, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
     2077    float fontWidth = font.width(TextRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, override));
    20812078
    20822079    useMaxWidth = (useMaxWidth && maxWidth < fontWidth);
  • trunk/Source/WebCore/platform/chromium/PopupListBox.cpp

    r114568 r116723  
    480480
    481481    // Prepare the directionality to draw text.
    482     TextRun textRun(itemText.characters(), itemText.length(), false, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
     482    TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
    483483    // If the text is right-to-left, make it right-aligned by adjusting its
    484484    // beginning position.
     
    518518    }
    519519
    520     TextRun labelTextRun(itemLabel.characters(), itemLabel.length(), false, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
     520    TextRun labelTextRun(itemLabel, 0, 0, TextRun::AllowTrailingExpansion, style.textDirection(), style.hasTextDirectionOverride());
    521521    if (rightAligned)
    522522        textX = max<int>(0, m_popupClient->clientPaddingLeft() - m_popupClient->clientInsetLeft());
  • trunk/Source/WebCore/platform/graphics/Font.h

    r114032 r116723  
    161161    const FontMetrics& fontMetrics() const { return primaryFont()->fontMetrics(); }
    162162    float spaceWidth() const { return primaryFont()->spaceWidth() + m_letterSpacing; }
    163     float tabWidth(const SimpleFontData& fontData) const { return 8 * fontData.spaceWidth() + letterSpacing(); }
     163    float tabWidth(const SimpleFontData&, unsigned tabSize, float position) const;
     164    float tabWidth(unsigned tabSize, float position) const { return tabWidth(*primaryFont(), tabSize, position); }
     165
    164166    int emphasisMarkAscent(const AtomicString&) const;
    165167    int emphasisMarkDescent(const AtomicString&) const;
     
    304306}
    305307
    306 }
    307 
    308 #endif
     308inline float Font::tabWidth(const SimpleFontData& fontData, unsigned tabSize, float position) const
     309{
     310    if (!tabSize)
     311        return letterSpacing();
     312    float tabWidth = tabSize * fontData.spaceWidth() + letterSpacing();
     313    return tabWidth - fmodf(position, tabWidth);
     314}
     315
     316}
     317
     318#endif
  • trunk/Source/WebCore/platform/graphics/TextRun.cpp

    r116262 r116723  
    3838    float float3;
    3939    uint32_t bitfields : 9;
     40    unsigned anUnsigned;
    4041    RefPtr<TextRun::RenderingContext> renderingContext;
    4142};
  • trunk/Source/WebCore/platform/graphics/TextRun.h

    r116260 r116723  
    5959    typedef unsigned RoundingHacks;
    6060
    61     TextRun(const UChar* c, int len, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
     61    TextRun(const UChar* c, int len, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
    6262        : m_characters(c)
    6363        , m_charactersLength(len)
     
    6969        , m_expansion(expansion)
    7070        , m_expansionBehavior(expansionBehavior)
    71         , m_allowTabs(allowTabs)
     71        , m_allowTabs(false)
    7272        , m_direction(direction)
    7373        , m_directionalOverride(directionalOverride)
     
    7676        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
    7777        , m_disableSpacing(false)
     78        , m_tabSize(0)
    7879    {
    7980    }
    8081
    81     TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
     82    TextRun(const String& s, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
    8283        : m_characters(s.characters())
    8384        , m_charactersLength(s.length())
     
    8990        , m_expansion(expansion)
    9091        , m_expansionBehavior(expansionBehavior)
    91         , m_allowTabs(allowTabs)
     92        , m_allowTabs(false)
    9293        , m_direction(direction)
    9394        , m_directionalOverride(directionalOverride)
     
    9697        , m_applyWordRounding((roundingHacks & WordRounding) && s_allowsRoundingHacks)
    9798        , m_disableSpacing(false)
     99        , m_tabSize(0)
    98100    {
    99101    }
     
    115117
    116118    bool allowTabs() const { return m_allowTabs; }
    117     void setAllowTabs(bool allowTabs) { m_allowTabs = allowTabs; }
     119    unsigned tabSize() const { return m_tabSize; }
     120    void setTabSize(bool, unsigned);
     121
    118122    float xPos() const { return m_xpos; }
    119123    void setXPos(float xPos) { m_xpos = xPos; }
     
    167171    float m_horizontalGlyphStretch;
    168172#endif
     173
    169174    float m_expansion;
    170175    ExpansionBehavior m_expansionBehavior : 2;
     
    176181    unsigned m_applyWordRounding : 1;
    177182    unsigned m_disableSpacing : 1;
     183    unsigned m_tabSize;
    178184    RefPtr<RenderingContext> m_renderingContext;
    179185};
     186
     187inline void TextRun::setTabSize(bool allow, unsigned size)
     188{
     189    m_allowTabs = allow;
     190    m_tabSize = size;
     191}
    180192
    181193}
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r104545 r116723  
    118118        // Now that we have a glyph and font data, get its width.
    119119        float width;
    120         if (character == '\t' && m_run.allowTabs()) {
    121             float tabWidth = m_font->tabWidth(*fontData);
    122             width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding, tabWidth);
    123         } else {
     120        if (character == '\t' && m_run.allowTabs())
     121            width = m_font->tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding);
     122        else {
    124123            width = fontData->widthForGlyph(glyph);
    125124
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r111589 r116723  
    517517            CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];
    518518
    519             if (ch == '\t' && m_run.allowTabs()) {
    520                 float tabWidth = m_font.tabWidth(*fontData);
    521                 advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastCommit, tabWidth);
    522             } else if (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
     519            if (ch == '\t' && m_run.allowTabs())
     520                advance.width = m_font.tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_totalWidth + widthSinceLastCommit);
     521            else if (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
    523522                advance.width = 0;
    524523                glyph = fontData->spaceGlyph();
  • trunk/Source/WebCore/platform/win/PopupMenuWin.cpp

    r115672 r116723  
    637637        String itemText = client()->itemText(index);
    638638           
    639         unsigned length = itemText.length();
    640         const UChar* string = itemText.characters();
    641639        TextDirection direction = (itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft) ? RTL : LTR;
    642         TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, direction);
     640        TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, direction);
    643641
    644642        context.setFillColor(optionTextColor, ColorSpaceDeviceRGB);
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r116373 r116723  
    13321332    ASSERT(maximumLength >= length);
    13331333
    1334     TextRun run(characters, length, textRenderer->allowTabs(), textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style->rtlOrdering() == VisualOrder, !textRenderer->canUseSimpleFontCodePath());
     1334    TextRun run(characters, length, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style->rtlOrdering() == VisualOrder, !textRenderer->canUseSimpleFontCodePath());
     1335    run.setTabSize(!style->collapseWhiteSpace(), style->tabSize());
    13351336    if (textRunNeedsRenderingContext(font))
    13361337        run.setRenderingContext(SVGTextRunRenderingContext::create(textRenderer));
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r116438 r116723  
    72757275    }
    72767276
    7277     TextRun run(characters, length, false, 0, 0, expansion, textDirection, directionalOverride);
     7277    TextRun run(characters, length, 0, 0, expansion, textDirection, directionalOverride);
    72787278    if (textRunNeedsRenderingContext(font))
    72797279        run.setRenderingContext(SVGTextRunRenderingContext::create(context));
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r115691 r116723  
    19491949
    19501950    run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath());
    1951     run.setAllowTabs(!collapseWhiteSpace);
     1951    run.setTabSize(!collapseWhiteSpace, text->style()->tabSize());
    19521952    run.setXPos(xPos);
    19531953    return font.width(run);
     
    19811981    ASSERT(run.charactersLength() >= run.length());
    19821982
    1983     run.setAllowTabs(!collapseWhiteSpace);
     1983    run.setTabSize(!collapseWhiteSpace, text->style()->tabSize());
    19841984    run.setXPos(xPos + lastSpaceWordSpacing);
    19851985
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r116476 r116723  
    408408    paintInfo.context->setFillColor(textColor, colorSpace);
    409409
    410     unsigned length = itemText.length();
    411     const UChar* string = itemText.characters();
    412     TextRun textRun(string, length, false, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding);
     410    TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, itemStyle->direction(), isOverride(itemStyle->unicodeBidi()), true, TextRun::NoRounding);
    413411    Font itemFont = style()->font();
    414412    LayoutRect r = itemBoundingBoxRect(paintOffset, listIndex);
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r115177 r116723  
    730730    if (f.isFixedPitch() && !f.isSmallCaps() && m_isAllASCII && (!glyphOverflow || !glyphOverflow->computeBounds)) {
    731731        float monospaceCharacterWidth = f.spaceWidth();
    732         float tabWidth = allowTabs() ? monospaceCharacterWidth * 8 : 0;
    733732        float w = 0;
    734733        bool isSpace;
     
    743742                    isSpace = true;
    744743                } else if (c == '\t') {
    745                     w += tabWidth ? tabWidth - fmodf(xPos + w, tabWidth) : monospaceCharacterWidth;
     744                    w += style()->collapseWhiteSpace() ? monospaceCharacterWidth : f.tabWidth(style()->tabSize(), xPos + w);
    746745                    isSpace = true;
    747746                } else
     
    763762
    764763    run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
    765     run.setAllowTabs(allowTabs());
     764    run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
    766765    run.setXPos(xPos);
    767766    return f.width(run, fallbackFonts, glyphOverflow);
     
    10621061                run.setCharactersLength(len - i);
    10631062                ASSERT(run.charactersLength() >= run.length());
    1064 
    1065                 run.setAllowTabs(allowTabs());
     1063                run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
    10661064                run.setXPos(leadWidth + currMaxWidth);
    10671065
     
    14781476
    14791477        run.setCharacterScanForCodePath(!canUseSimpleFontCodePath());
    1480         run.setAllowTabs(allowTabs());
     1478        run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize());
    14811479        run.setXPos(xPos);
    14821480        w = f.width(run, fallbackFonts, glyphOverflow);
  • trunk/Source/WebCore/rendering/RenderText.h

    r115177 r116723  
    123123
    124124    InlineTextBox* findNextInlineTextBox(int offset, int& pos) const;
    125 
    126     bool allowTabs() const { return !style()->collapseWhiteSpace(); }
    127125
    128126    void checkConsistency() const;
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r116174 r116723  
    463463            || rareInheritedData->textEmphasisPosition != other->rareInheritedData->textEmphasisPosition
    464464            || rareInheritedData->textEmphasisCustomMark != other->rareInheritedData->textEmphasisCustomMark
     465            || rareInheritedData->m_tabSize != other->rareInheritedData->m_tabSize
    465466            || rareInheritedData->m_lineBoxContain != other->rareInheritedData->m_lineBoxContain
    466467            || rareInheritedData->m_lineGrid != other->rareInheritedData->m_lineGrid
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r116174 r116723  
    910910    TextCombine textCombine() const { return static_cast<TextCombine>(rareNonInheritedData->m_textCombine); }
    911911    bool hasTextCombine() const { return textCombine() != TextCombineNone; }
     912
     913    unsigned tabSize() const { return rareInheritedData->m_tabSize; }
     914
    912915    // End CSS3 Getters
    913916
     
    13251328    void setFilter(const FilterOperations& ops) { SET_VAR(rareNonInheritedData.access()->m_filter, m_operations, ops); }
    13261329#endif
     1330
     1331    void setTabSize(unsigned size) { SET_VAR(rareInheritedData, m_tabSize, size); }
    13271332
    13281333    // End CSS3 Setters
     
    16651670#endif
    16661671
     1672    static unsigned initialTabSize() { return 8; }
     1673
    16671674    static const AtomicString& initialLineGrid() { return nullAtom; }
    16681675    static LineSnap initialLineSnap() { return LineSnapNone; }
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r108133 r116723  
    6363    , hyphenationLimitLines(-1)
    6464    , m_lineGrid(RenderStyle::initialLineGrid())
     65    , m_tabSize(RenderStyle::initialTabSize())
    6566#if ENABLE(TOUCH_EVENTS)
    6667    , tapHighlightColor(RenderStyle::initialTapHighlightColor())
     
    114115    , textEmphasisCustomMark(o.textEmphasisCustomMark)
    115116    , m_lineGrid(o.m_lineGrid)
     117    , m_tabSize(o.m_tabSize)
    116118#if ENABLE(TOUCH_EVENTS)
    117119    , tapHighlightColor(o.tapHighlightColor)
     
    178180        && textEmphasisCustomMark == o.textEmphasisCustomMark
    179181        && QuotesData::equal(quotes.get(), o.quotes.get())
     182        && m_tabSize == o.m_tabSize
    180183        && m_lineGrid == o.m_lineGrid
    181184        && m_imageRendering == o.m_imageRendering
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r108133 r116723  
    107107    AtomicString textEmphasisCustomMark;
    108108    RefPtr<QuotesData> quotes;
    109    
     109
    110110    AtomicString m_lineGrid;
     111    unsigned m_tabSize;
    111112
    112113#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r116343 r116723  
    432432    TextRun run(text->characters() + fragment.characterOffset
    433433                , fragment.length
    434                 , false /* allowTabs */
    435434                , 0 /* xPos, only relevant with allowTabs=true */
    436435                , 0 /* padding, only relevant for justified text, not relevant for SVG */
  • trunk/Source/WebCore/rendering/svg/SVGTextMetrics.cpp

    r109806 r116723  
    7171    TextRun run(characters + position
    7272                , length
    73                 , false /* allowTabs */
    7473                , 0 /* xPos, only relevant with allowTabs=true */
    7574                , 0 /* padding, only relevant for justified text, not relevant for SVG */
  • trunk/Source/WebKit/chromium/ChangeLog

    r116714 r116723  
     12012-05-10  Hajime Morrita  <morrita@google.com>
     2
     3        WebKit should support tab-size.
     4        https://bugs.webkit.org/show_bug.cgi?id=52994
     5
     6        Reviewed by Simon Fraser.
     7
     8        * src/WebTextRun.cpp:
     9        (WebKit::WebTextRun::operator WebCore::TextRun):
     10
    1112012-05-10  Kent Tamura  <tkent@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebTextRun.cpp

    r95901 r116723  
    4040WebTextRun::operator WebCore::TextRun() const
    4141{
    42     return TextRun(text, false, 0, 0, TextRun::AllowTrailingExpansion, rtl ? RTL : LTR, directionalOverride);
     42    return TextRun(text, 0, 0, TextRun::AllowTrailingExpansion, rtl ? RTL : LTR, directionalOverride);
    4343}
    4444
Note: See TracChangeset for help on using the changeset viewer.