Ignore:
Timestamp:
Sep 28, 2013, 11:30:16 AM (12 years ago)
Author:
Antti Koivisto
Message:

Clean up code for getting first line style
https://bugs.webkit.org/show_bug.cgi?id=122037

Reviewed by Andreas Kling.

We have confusing RenderObject::style(bool firstLine). Get rid of it in favour of
just using RenderObject::firstLineStyle() where appropriate.

Also switch to RenderStyle references in many places and move first line style caching
code down to RenderElement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/rendering/RenderRubyRun.cpp

    r156151 r156608  
    277277}
    278278
     279static bool shouldOverhang(bool firstLine, const RenderObject* renderer, const RenderRubyBase& rubyBase)
     280{
     281    if (!renderer || !renderer->isText())
     282        return false;
     283    const RenderStyle& rubyBaseStyle = firstLine ? *rubyBase.firstLineStyle() : *rubyBase.style();
     284    const RenderStyle& style = firstLine ? *renderer->firstLineStyle() : *renderer->style();
     285    return style.fontSize() <= rubyBaseStyle.fontSize();
     286}
     287
    279288void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, int& startOverhang, int& endOverhang) const
    280289{
     
    304313    endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : logicalLeftOverhang;
    305314
    306     if (!startRenderer || !startRenderer->isText() || startRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
     315    if (!shouldOverhang(firstLine, startRenderer, *rubyBase))
    307316        startOverhang = 0;
    308 
    309     if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)->fontSize() > rubyBase->style(firstLine)->fontSize())
     317    if (!shouldOverhang(firstLine, endRenderer, *rubyBase))
    310318        endOverhang = 0;
    311319
     
    313321    // We can overhang the ruby by no more than half the width of the neighboring text
    314322    // and no more than half the font size.
    315     int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2;
     323    const RenderStyle& rubyTextStyle = firstLine ? *rubyText->firstLineStyle() : *rubyText->style();
     324    int halfWidthOfFontSize = rubyTextStyle.fontSize() / 2;
    316325    if (startOverhang)
    317326        startOverhang = min<int>(startOverhang, min<int>(toRenderText(startRenderer)->minLogicalWidth(), halfWidthOfFontSize));
Note: See TracChangeset for help on using the changeset viewer.