Changeset 156025 in webkit


Ignore:
Timestamp:
Sep 17, 2013, 11:30:30 PM (11 years ago)
Author:
Antti Koivisto
Message:

Rename InlineBox::isText()
<https://webkit.org/b/121525>

Reviewed by Andreas Kling.

The flag sounds like RenderObject::isText() yet it can be set for some inline boxes generated
for non-text renderers too (br, list markers). This is pretty confusing.

Rename to InlineBox::behavesLikeText().

  • rendering/InlineBox.cpp:

(WebCore::InlineBox::logicalHeight):
(WebCore::InlineBox::baselinePosition):
(WebCore::InlineBox::lineHeight):

  • rendering/InlineBox.h:

(WebCore::InlineBox::behavesLikeText):
(WebCore::InlineBox::setBehavesLikeText):
(WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields):

  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::addToLine):
(WebCore::InlineFlowBox::placeBoxesInBlockDirection):

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::baselinePosition):
(WebCore::InlineTextBox::lineHeight):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::createInlineBoxForRenderer):
(WebCore::setLogicalWidthForTextRun):

  • rendering/RenderListMarker.cpp:

(WebCore::RenderListMarker::createInlineBox):

  • rendering/RenderText.cpp:

(WebCore::RenderText::createInlineTextBox):

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::includeLeadingForBox):
(WebCore::RootInlineBox::includeFontForBox):
(WebCore::RootInlineBox::includeGlyphsForBox):
(WebCore::RootInlineBox::includeMarginForBox):

Switch tests from isText() to isTextOrBR(). This matches the behavior before r155957.
I don't know if there is a case where this actually makes any difference in behavior.

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r156024 r156025  
     12013-09-17  Antti Koivisto  <antti@apple.com>
     2
     3        Rename InlineBox::isText()
     4        <https://webkit.org/b/121525>
     5
     6        Reviewed by Andreas Kling.
     7
     8        The flag sounds like RenderObject::isText() yet it can be set for some inline boxes generated
     9        for non-text renderers too (br, list markers). This is pretty confusing.
     10       
     11        Rename to InlineBox::behavesLikeText().
     12
     13        * rendering/InlineBox.cpp:
     14        (WebCore::InlineBox::logicalHeight):
     15        (WebCore::InlineBox::baselinePosition):
     16        (WebCore::InlineBox::lineHeight):
     17        * rendering/InlineBox.h:
     18        (WebCore::InlineBox::behavesLikeText):
     19        (WebCore::InlineBox::setBehavesLikeText):
     20        (WebCore::InlineBox::InlineBoxBitfields::InlineBoxBitfields):
     21        * rendering/InlineFlowBox.cpp:
     22        (WebCore::InlineFlowBox::addToLine):
     23        (WebCore::InlineFlowBox::placeBoxesInBlockDirection):
     24        * rendering/InlineTextBox.cpp:
     25        (WebCore::InlineTextBox::baselinePosition):
     26        (WebCore::InlineTextBox::lineHeight):
     27        * rendering/RenderBlockLineLayout.cpp:
     28        (WebCore::createInlineBoxForRenderer):
     29        (WebCore::setLogicalWidthForTextRun):
     30        * rendering/RenderListMarker.cpp:
     31        (WebCore::RenderListMarker::createInlineBox):
     32        * rendering/RenderText.cpp:
     33        (WebCore::RenderText::createInlineTextBox):
     34        * rendering/RootInlineBox.cpp:
     35        (WebCore::RootInlineBox::includeLeadingForBox):
     36        (WebCore::RootInlineBox::includeFontForBox):
     37        (WebCore::RootInlineBox::includeGlyphsForBox):
     38        (WebCore::RootInlineBox::includeMarginForBox):
     39       
     40            Switch tests from isText() to isTextOrBR(). This matches the behavior before r155957.
     41            I don't know if there is a case where this actually makes any difference in behavior.
     42
    1432013-09-17  Sam Weinig  <sam@webkit.org>
    244
  • trunk/Source/WebCore/rendering/InlineBox.cpp

    r155975 r156025  
    143143   
    144144    if (renderer().isTextOrBR())
    145         return m_bitfields.isText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
     145        return behavesLikeText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
    146146    if (renderer().isBox() && parent())
    147147        return isHorizontal() ? toRenderBox(renderer()).height() : toRenderBox(renderer()).width();
     
    158158int InlineBox::baselinePosition(FontBaseline baselineType) const
    159159{
    160     if (renderer().isBR() && !isText())
     160    if (renderer().isBR() && !behavesLikeText())
    161161        return 0;
    162162    return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
     
    165165LayoutUnit InlineBox::lineHeight() const
    166166{
    167     if (renderer().isBR() && !isText())
     167    if (renderer().isBR() && !behavesLikeText())
    168168        return 0;
    169169    return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
  • trunk/Source/WebCore/rendering/InlineBox.h

    r155957 r156025  
    118118#endif
    119119
    120     bool isText() const { return m_bitfields.isText(); }
    121     void setIsText(bool isText) { m_bitfields.setIsText(isText); }
     120    bool behavesLikeText() const { return m_bitfields.behavesLikeText(); }
     121    void setBehavesLikeText(bool behavesLikeText) { m_bitfields.setBehavesLikeText(behavesLikeText); }
    122122 
    123123    virtual bool isInlineFlowBox() const { return false; }
     
    337337            , m_hasEllipsisBoxOrHyphen(false)
    338338            , m_dirOverride(false)
    339             , m_isText(false)
     339            , m_behavesLikeText(false)
    340340            , m_determinedIfNextOnLineExists(false)
    341341            , m_nextOnLineExists(false)
     
    368368        // for InlineTextBox
    369369        ADD_BOOLEAN_BITFIELD(dirOverride, DirOverride);
    370         ADD_BOOLEAN_BITFIELD(isText, IsText); // Whether or not this object represents text with a non-zero height. Includes non-image list markers, text boxes.
     370        ADD_BOOLEAN_BITFIELD(behavesLikeText, BehavesLikeText); // Whether or not this object represents text with a non-zero height. Includes non-image list markers, text boxes, br.
    371371
    372372    private:
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r155957 r156025  
    112112    child->setFirstLineStyleBit(isFirstLineStyle());
    113113    child->setIsHorizontal(isHorizontal());
    114     if (child->isText()) {
     114    if (child->behavesLikeText()) {
    115115        if (child->renderer().parent() == &renderer())
    116116            m_hasTextChildren = true;
     
    127127        if (child->renderer().isReplaced())
    128128            shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
    129         else if (child->isText()) {
     129        else if (child->behavesLikeText()) {
    130130            if (child->renderer().isBR() || child->renderer().parent() != &renderer()) {
    131131                if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle->font().fontMetrics())
     
    159159
    160160    if (!child->renderer().isOutOfFlowPositioned()) {
    161         if (child->isText()) {
     161        if (child->behavesLikeText()) {
    162162            RenderStyle* childStyle = child->renderer().style(isFirstLineStyle());
    163163            if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
     
    660660        LayoutUnit boxHeightIncludingMargins = boxHeight;
    661661           
    662         if (curr->isText() || curr->isInlineFlowBox()) {
     662        if (curr->behavesLikeText() || curr->isInlineFlowBox()) {
    663663            const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineStyle())->fontMetrics();
    664664            newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r155957 r156025  
    9999int InlineTextBox::baselinePosition(FontBaseline baselineType) const
    100100{
    101     if (!isText() || !parent())
     101    if (!behavesLikeText() || !parent())
    102102        return 0;
    103103    if (&parent()->renderer() == renderer().parent())
     
    108108LayoutUnit InlineTextBox::lineHeight() const
    109109{
    110     if (!isText() || !renderer().parent())
     110    if (!behavesLikeText() || !renderer().parent())
    111111        return 0;
    112112    if (&parent()->renderer() == renderer().parent())
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r156022 r156025  
    275275        // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
    276276        // (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.)
    277         inlineBox->setIsText(isOnlyRun || obj->document().inNoQuirksMode());
     277        inlineBox->setBehavesLikeText(isOnlyRun || obj->document().inNoQuirksMode());
    278278        return inlineBox;
    279279    }
     
    657657    run->m_box->setLogicalWidth(measuredWidth + hyphenWidth);
    658658    if (!fallbackFonts.isEmpty()) {
    659         ASSERT(run->m_box->isText());
     659        ASSERT(run->m_box->behavesLikeText());
    660660        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
    661661        ASSERT(it->value.first.isEmpty());
     
    664664    }
    665665    if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
    666         ASSERT(run->m_box->isText());
     666        ASSERT(run->m_box->behavesLikeText());
    667667        GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
    668668        it->value.second = glyphOverflow;
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r155908 r156025  
    11651165{
    11661166    InlineBox* result = RenderBox::createInlineBox();
    1167     result->setIsText(isText());
     1167    result->setBehavesLikeText(isText());
    11681168    return result;
    11691169}
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r155957 r156025  
    14391439        m_lastTextBox = textBox;
    14401440    }
    1441     textBox->setIsText(true);
     1441    textBox->setBehavesLikeText(true);
    14421442    return textBox;
    14431443}
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r155975 r156025  
    10021002bool RootInlineBox::includeLeadingForBox(InlineBox* box) const
    10031003{
    1004     if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
     1004    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
    10051005        return false;
    10061006
     
    10111011bool RootInlineBox::includeFontForBox(InlineBox* box) const
    10121012{
    1013     if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
     1013    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
    10141014        return false;
    10151015   
    1016     if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
     1016    if (!box->behavesLikeText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
    10171017        return false;
    10181018
     
    10241024bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const
    10251025{
    1026     if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
     1026    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
    10271027        return false;
    10281028   
    1029     if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
     1029    if (!box->behavesLikeText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
    10301030        return false;
    10311031
     
    10371037bool RootInlineBox::includeMarginForBox(InlineBox* box) const
    10381038{
    1039     if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
     1039    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
    10401040        return false;
    10411041
Note: See TracChangeset for help on using the changeset viewer.