Title: [156025] trunk/Source/WebCore
Revision
156025
Author
an...@apple.com
Date
2013-09-17 23:30:30 -0700 (Tue, 17 Sep 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156024 => 156025)


--- trunk/Source/WebCore/ChangeLog	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/ChangeLog	2013-09-18 06:30:30 UTC (rev 156025)
@@ -1,3 +1,45 @@
+2013-09-17  Antti Koivisto  <an...@apple.com>
+
+        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.
+
 2013-09-17  Sam Weinig  <s...@webkit.org>
 
         Shrink SVGPathStringBuilder

Modified: trunk/Source/WebCore/rendering/InlineBox.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/InlineBox.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/InlineBox.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -142,7 +142,7 @@
         return virtualLogicalHeight();
     
     if (renderer().isTextOrBR())
-        return m_bitfields.isText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
+        return behavesLikeText() ? renderer().style(isFirstLineStyle())->fontMetrics().height() : 0;
     if (renderer().isBox() && parent())
         return isHorizontal() ? toRenderBox(renderer()).height() : toRenderBox(renderer()).width();
 
@@ -157,14 +157,14 @@
 
 int InlineBox::baselinePosition(FontBaseline baselineType) const
 {
-    if (renderer().isBR() && !isText())
+    if (renderer().isBR() && !behavesLikeText())
         return 0;
     return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
 }
 
 LayoutUnit InlineBox::lineHeight() const
 {
-    if (renderer().isBR() && !isText())
+    if (renderer().isBR() && !behavesLikeText())
         return 0;
     return boxModelObject()->lineHeight(m_bitfields.firstLine(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
 }

Modified: trunk/Source/WebCore/rendering/InlineBox.h (156024 => 156025)


--- trunk/Source/WebCore/rendering/InlineBox.h	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/InlineBox.h	2013-09-18 06:30:30 UTC (rev 156025)
@@ -117,8 +117,8 @@
     virtual const char* boxName() const;
 #endif
 
-    bool isText() const { return m_bitfields.isText(); }
-    void setIsText(bool isText) { m_bitfields.setIsText(isText); }
+    bool behavesLikeText() const { return m_bitfields.behavesLikeText(); }
+    void setBehavesLikeText(bool behavesLikeText) { m_bitfields.setBehavesLikeText(behavesLikeText); }
  
     virtual bool isInlineFlowBox() const { return false; }
     virtual bool isInlineTextBox() const { return false; }
@@ -336,7 +336,7 @@
             , m_knownToHaveNoOverflow(true)  
             , m_hasEllipsisBoxOrHyphen(false)
             , m_dirOverride(false)
-            , m_isText(false)
+            , m_behavesLikeText(false)
             , m_determinedIfNextOnLineExists(false)
             , m_nextOnLineExists(false)
             , m_expansion(0)
@@ -367,7 +367,7 @@
         ADD_BOOLEAN_BITFIELD(hasEllipsisBoxOrHyphen, HasEllipsisBoxOrHyphen);
         // for InlineTextBox
         ADD_BOOLEAN_BITFIELD(dirOverride, DirOverride);
-        ADD_BOOLEAN_BITFIELD(isText, IsText); // Whether or not this object represents text with a non-zero height. Includes non-image list markers, text boxes.
+        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.
 
     private:
         mutable unsigned m_determinedIfNextOnLineExists : 1;

Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -111,7 +111,7 @@
     }
     child->setFirstLineStyleBit(isFirstLineStyle());
     child->setIsHorizontal(isHorizontal());
-    if (child->isText()) {
+    if (child->behavesLikeText()) {
         if (child->renderer().parent() == &renderer())
             m_hasTextChildren = true;
         setHasTextDescendantsOnAncestors(this);
@@ -126,7 +126,7 @@
         bool shouldClearDescendantsHaveSameLineHeightAndBaseline = false;
         if (child->renderer().isReplaced())
             shouldClearDescendantsHaveSameLineHeightAndBaseline = true;
-        else if (child->isText()) {
+        else if (child->behavesLikeText()) {
             if (child->renderer().isBR() || child->renderer().parent() != &renderer()) {
                 if (!parentStyle->font().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle->font().fontMetrics())
                     || parentStyle->lineHeight() != childStyle->lineHeight()
@@ -158,7 +158,7 @@
     }
 
     if (!child->renderer().isOutOfFlowPositioned()) {
-        if (child->isText()) {
+        if (child->behavesLikeText()) {
             RenderStyle* childStyle = child->renderer().style(isFirstLineStyle());
             if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
                 child->clearKnownToHaveNoOverflow();
@@ -659,7 +659,7 @@
         LayoutUnit boxHeight = curr->logicalHeight();
         LayoutUnit boxHeightIncludingMargins = boxHeight;
             
-        if (curr->isText() || curr->isInlineFlowBox()) {
+        if (curr->behavesLikeText() || curr->isInlineFlowBox()) {
             const FontMetrics& fontMetrics = curr->renderer().style(isFirstLineStyle())->fontMetrics();
             newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
             if (curr->isInlineFlowBox()) {

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -98,7 +98,7 @@
 
 int InlineTextBox::baselinePosition(FontBaseline baselineType) const
 {
-    if (!isText() || !parent())
+    if (!behavesLikeText() || !parent())
         return 0;
     if (&parent()->renderer() == renderer().parent())
         return parent()->baselinePosition(baselineType);
@@ -107,7 +107,7 @@
 
 LayoutUnit InlineTextBox::lineHeight() const
 {
-    if (!isText() || !renderer().parent())
+    if (!behavesLikeText() || !renderer().parent())
         return 0;
     if (&parent()->renderer() == renderer().parent())
         return parent()->lineHeight();

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -274,7 +274,7 @@
         InlineBox* inlineBox = toRenderBR(obj)->createInlineBox();
         // We only treat a box as text for a <br> if we are on a line by ourself or in strict mode
         // (Note the use of strict mode. In "almost strict" mode, we don't treat the box for <br> as text.)
-        inlineBox->setIsText(isOnlyRun || obj->document().inNoQuirksMode());
+        inlineBox->setBehavesLikeText(isOnlyRun || obj->document().inNoQuirksMode());
         return inlineBox;
     }
 
@@ -656,14 +656,14 @@
 
     run->m_box->setLogicalWidth(measuredWidth + hyphenWidth);
     if (!fallbackFonts.isEmpty()) {
-        ASSERT(run->m_box->isText());
+        ASSERT(run->m_box->behavesLikeText());
         GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         ASSERT(it->value.first.isEmpty());
         copyToVector(fallbackFonts, it->value.first);
         run->m_box->parent()->clearDescendantsHaveSameLineHeightAndBaseline();
     }
     if ((glyphOverflow.top || glyphOverflow.bottom || glyphOverflow.left || glyphOverflow.right)) {
-        ASSERT(run->m_box->isText());
+        ASSERT(run->m_box->behavesLikeText());
         GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.add(toInlineTextBox(run->m_box), make_pair(Vector<const SimpleFontData*>(), GlyphOverflow())).iterator;
         it->value.second = glyphOverflow;
         run->m_box->clearKnownToHaveNoOverflow();

Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/RenderListMarker.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -1164,7 +1164,7 @@
 InlineBox* RenderListMarker::createInlineBox()
 {
     InlineBox* result = RenderBox::createInlineBox();
-    result->setIsText(isText());
+    result->setBehavesLikeText(isText());
     return result;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -1438,7 +1438,7 @@
         textBox->setPreviousTextBox(m_lastTextBox);
         m_lastTextBox = textBox;
     }
-    textBox->setIsText(true);
+    textBox->setBehavesLikeText(true);
     return textBox;
 }
 

Modified: trunk/Source/WebCore/rendering/RootInlineBox.cpp (156024 => 156025)


--- trunk/Source/WebCore/rendering/RootInlineBox.cpp	2013-09-18 06:05:09 UTC (rev 156024)
+++ trunk/Source/WebCore/rendering/RootInlineBox.cpp	2013-09-18 06:30:30 UTC (rev 156025)
@@ -1001,7 +1001,7 @@
 
 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const
 {
-    if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
+    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
         return false;
 
     LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
@@ -1010,10 +1010,10 @@
 
 bool RootInlineBox::includeFontForBox(InlineBox* box) const
 {
-    if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
+    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
         return false;
     
-    if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
+    if (!box->behavesLikeText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
         return false;
 
     // For now map "glyphs" to "font" in vertical text mode until the bounds returned by glyphs aren't garbage.
@@ -1023,10 +1023,10 @@
 
 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const
 {
-    if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
+    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
         return false;
     
-    if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
+    if (!box->behavesLikeText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren())
         return false;
 
     // FIXME: We can't fit to glyphs yet for vertical text, since the bounds returned are garbage.
@@ -1036,7 +1036,7 @@
 
 bool RootInlineBox::includeMarginForBox(InlineBox* box) const
 {
-    if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isText()))
+    if (box->renderer().isReplaced() || (box->renderer().isTextOrBR() && !box->behavesLikeText()))
         return false;
 
     LineBoxContain lineBoxContain = renderer().style()->lineBoxContain();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to