Changeset 117946 in webkit


Ignore:
Timestamp:
May 22, 2012 4:16:16 AM (12 years ago)
Author:
eae@chromium.org
Message:

Change RenderBlock to user RenderBox/RenderInline writing mode logic
https://bugs.webkit.org/show_bug.cgi?id=87040

Reviewed by Eric Seidel.

Remove unnecessary writing mode logic in RenderBlock and use the
implementation in RenderBox and RenderInline instead.

No new tests, no change in functionality.

  • rendering/RenderBlock.cpp:

(WebCore):

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::marginBeforeForChild):
(WebCore::RenderBlock::marginAfterForChild):
(WebCore::RenderBlock::marginStartForChild):
(WebCore::RenderBlock::marginEndForChild):
(WebCore::RenderBlock::setMarginStartForChild):
(WebCore::RenderBlock::setMarginEndForChild):
(WebCore::RenderBlock::setMarginBeforeForChild):
(WebCore::RenderBlock::setMarginAfterForChild):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::marginBefore):
(WebCore::RenderBox::marginAfter):
(WebCore::RenderBox::marginStart):
(WebCore::RenderBox::marginEnd):
(WebCore::RenderBox::setMarginStart):
(WebCore::RenderBox::setMarginEnd):
(WebCore::RenderBox::setMarginBefore):
(WebCore::RenderBox::setMarginAfter):

  • rendering/RenderBox.h:

(RenderBox):

  • rendering/RenderBoxModelObject.h:

(RenderBoxModelObject):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::marginStart):
(WebCore::RenderInline::marginEnd):
(WebCore::RenderInline::marginBefore):
(WebCore::RenderInline::marginAfter):

  • rendering/RenderInline.h:

(RenderInline):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117944 r117946  
     12012-05-22  Emil A Eklund  <eae@chromium.org>
     2
     3        Change RenderBlock to user RenderBox/RenderInline writing mode logic
     4        https://bugs.webkit.org/show_bug.cgi?id=87040
     5
     6        Reviewed by Eric Seidel.
     7
     8        Remove unnecessary writing mode logic in RenderBlock and use the
     9        implementation in RenderBox and RenderInline instead.
     10
     11        No new tests, no change in functionality.
     12
     13        * rendering/RenderBlock.cpp:
     14        (WebCore):
     15        * rendering/RenderBlock.h:
     16        (WebCore::RenderBlock::marginBeforeForChild):
     17        (WebCore::RenderBlock::marginAfterForChild):
     18        (WebCore::RenderBlock::marginStartForChild):
     19        (WebCore::RenderBlock::marginEndForChild):
     20        (WebCore::RenderBlock::setMarginStartForChild):
     21        (WebCore::RenderBlock::setMarginEndForChild):
     22        (WebCore::RenderBlock::setMarginBeforeForChild):
     23        (WebCore::RenderBlock::setMarginAfterForChild):
     24        * rendering/RenderBox.cpp:
     25        (WebCore::RenderBox::marginBefore):
     26        (WebCore::RenderBox::marginAfter):
     27        (WebCore::RenderBox::marginStart):
     28        (WebCore::RenderBox::marginEnd):
     29        (WebCore::RenderBox::setMarginStart):
     30        (WebCore::RenderBox::setMarginEnd):
     31        (WebCore::RenderBox::setMarginBefore):
     32        (WebCore::RenderBox::setMarginAfter):
     33        * rendering/RenderBox.h:
     34        (RenderBox):
     35        * rendering/RenderBoxModelObject.h:
     36        (RenderBoxModelObject):
     37        * rendering/RenderInline.cpp:
     38        (WebCore::RenderInline::marginStart):
     39        (WebCore::RenderInline::marginEnd):
     40        (WebCore::RenderInline::marginBefore):
     41        (WebCore::RenderInline::marginAfter):
     42        * rendering/RenderInline.h:
     43        (RenderInline):
     44
    1452012-05-22  Li Yin  <li.yin@intel.com>
    246
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r117865 r117946  
    70397039}
    70407040
    7041 LayoutUnit RenderBlock::marginBeforeForChild(const RenderBoxModelObject* child) const
    7042 {
    7043     switch (style()->writingMode()) {
    7044     case TopToBottomWritingMode:
    7045         return child->marginTop();
    7046     case BottomToTopWritingMode:
    7047         return child->marginBottom();
    7048     case LeftToRightWritingMode:
    7049         return child->marginLeft();
    7050     case RightToLeftWritingMode:
    7051         return child->marginRight();
    7052     }
    7053     ASSERT_NOT_REACHED();
    7054     return child->marginTop();
    7055 }
    7056 
    7057 LayoutUnit RenderBlock::marginAfterForChild(const RenderBoxModelObject* child) const
    7058 {
    7059     switch (style()->writingMode()) {
    7060     case TopToBottomWritingMode:
    7061         return child->marginBottom();
    7062     case BottomToTopWritingMode:
    7063         return child->marginTop();
    7064     case LeftToRightWritingMode:
    7065         return child->marginRight();
    7066     case RightToLeftWritingMode:
    7067         return child->marginLeft();
    7068     }
    7069     ASSERT_NOT_REACHED();
    7070     return child->marginBottom();
    7071 }
    7072 
    7073 LayoutUnit RenderBlock::marginStartForChild(const RenderBoxModelObject* child) const
    7074 {
    7075     if (isHorizontalWritingMode())
    7076         return style()->isLeftToRightDirection() ? child->marginLeft() : child->marginRight();
    7077     return style()->isLeftToRightDirection() ? child->marginTop() : child->marginBottom();
    7078 }
    7079 
    7080 LayoutUnit RenderBlock::marginEndForChild(const RenderBoxModelObject* child) const
    7081 {
    7082     if (isHorizontalWritingMode())
    7083         return style()->isLeftToRightDirection() ? child->marginRight() : child->marginLeft();
    7084     return style()->isLeftToRightDirection() ? child->marginBottom() : child->marginTop();
    7085 }
    7086 
    7087 void RenderBlock::setMarginStartForChild(RenderBox* child, LayoutUnit margin)
    7088 {
    7089     if (isHorizontalWritingMode()) {
    7090         if (style()->isLeftToRightDirection())
    7091             child->setMarginLeft(margin);
    7092         else
    7093             child->setMarginRight(margin);
    7094     } else {
    7095         if (style()->isLeftToRightDirection())
    7096             child->setMarginTop(margin);
    7097         else
    7098             child->setMarginBottom(margin);
    7099     }
    7100 }
    7101 
    7102 void RenderBlock::setMarginEndForChild(RenderBox* child, LayoutUnit margin)
    7103 {
    7104     if (isHorizontalWritingMode()) {
    7105         if (style()->isLeftToRightDirection())
    7106             child->setMarginRight(margin);
    7107         else
    7108             child->setMarginLeft(margin);
    7109     } else {
    7110         if (style()->isLeftToRightDirection())
    7111             child->setMarginBottom(margin);
    7112         else
    7113             child->setMarginTop(margin);
    7114     }
    7115 }
    7116 
    7117 void RenderBlock::setMarginBeforeForChild(RenderBox* child, LayoutUnit margin)
    7118 {
    7119     switch (style()->writingMode()) {
    7120     case TopToBottomWritingMode:
    7121         child->setMarginTop(margin);
    7122         break;
    7123     case BottomToTopWritingMode:
    7124         child->setMarginBottom(margin);
    7125         break;
    7126     case LeftToRightWritingMode:
    7127         child->setMarginLeft(margin);
    7128         break;
    7129     case RightToLeftWritingMode:
    7130         child->setMarginRight(margin);
    7131         break;
    7132     }
    7133 }
    7134 
    7135 void RenderBlock::setMarginAfterForChild(RenderBox* child, LayoutUnit margin)
    7136 {
    7137     switch (style()->writingMode()) {
    7138     case TopToBottomWritingMode:
    7139         child->setMarginBottom(margin);
    7140         break;
    7141     case BottomToTopWritingMode:
    7142         child->setMarginTop(margin);
    7143         break;
    7144     case LeftToRightWritingMode:
    7145         child->setMarginRight(margin);
    7146         break;
    7147     case RightToLeftWritingMode:
    7148         child->setMarginLeft(margin);
    7149         break;
    7150     }
    7151 }
    7152 
    71537041RenderBlock::MarginValues RenderBlock::marginValuesForChild(RenderBox* child)
    71547042{
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r117865 r117946  
    285285    void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
    286286    void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
    287     LayoutUnit marginBeforeForChild(const RenderBoxModelObject* child) const;
    288     LayoutUnit marginAfterForChild(const RenderBoxModelObject* child) const;
    289     LayoutUnit marginStartForChild(const RenderBoxModelObject* child) const;
    290     LayoutUnit marginEndForChild(const RenderBoxModelObject* child) const;
    291     void setMarginStartForChild(RenderBox* child, LayoutUnit);
    292     void setMarginEndForChild(RenderBox* child, LayoutUnit);
    293     void setMarginBeforeForChild(RenderBox* child, LayoutUnit);
    294     void setMarginAfterForChild(RenderBox* child, LayoutUnit);
     287    LayoutUnit marginBeforeForChild(const RenderBoxModelObject* child) const { return child->marginBefore(style()); }
     288    LayoutUnit marginAfterForChild(const RenderBoxModelObject* child) const { return child->marginAfter(style()); }
     289    LayoutUnit marginStartForChild(const RenderBoxModelObject* child) const { return child->marginStart(style()); }
     290    LayoutUnit marginEndForChild(const RenderBoxModelObject* child) const { return child->marginEnd(style()); }
     291    void setMarginStartForChild(RenderBox* child, LayoutUnit value) { child->setMarginStart(value, style()); }
     292    void setMarginEndForChild(RenderBox* child, LayoutUnit value) { child->setMarginEnd(value, style()); }
     293    void setMarginBeforeForChild(RenderBox* child, LayoutUnit value) { child->setMarginBefore(value, style()); }
     294    void setMarginAfterForChild(RenderBox* child, LayoutUnit value) { child->setMarginAfter(value, style()); }
    295295    LayoutUnit collapsedMarginBeforeForChild(const RenderBox* child) const;
    296296    LayoutUnit collapsedMarginAfterForChild(const RenderBox* child) const;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r117697 r117946  
    8787}
    8888
    89 LayoutUnit RenderBox::marginBefore() const
    90 {
    91     switch (style()->writingMode()) {
     89LayoutUnit RenderBox::marginBefore(const RenderStyle* overrideStyle) const
     90{
     91    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
    9292    case TopToBottomWritingMode:
    9393        return m_marginTop;
     
    103103}
    104104
    105 LayoutUnit RenderBox::marginAfter() const
    106 {
    107     switch (style()->writingMode()) {
     105LayoutUnit RenderBox::marginAfter(const RenderStyle* overrideStyle) const
     106{
     107    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
    108108    case TopToBottomWritingMode:
    109109        return m_marginBottom;
     
    119119}
    120120
    121 LayoutUnit RenderBox::marginStart() const
    122 {
    123     if (isHorizontalWritingMode())
    124         return style()->isLeftToRightDirection() ? m_marginLeft : m_marginRight;
    125     return style()->isLeftToRightDirection() ? m_marginTop : m_marginBottom;
    126 }
    127 
    128 LayoutUnit RenderBox::marginEnd() const
    129 {
    130     if (isHorizontalWritingMode())
    131         return style()->isLeftToRightDirection() ? m_marginRight : m_marginLeft;
    132     return style()->isLeftToRightDirection() ? m_marginBottom : m_marginTop;
    133 }
    134 
    135 void RenderBox::setMarginStart(LayoutUnit margin)
    136 {
    137     if (isHorizontalWritingMode()) {
    138         if (style()->isLeftToRightDirection())
     121LayoutUnit RenderBox::marginStart(const RenderStyle* overrideStyle) const
     122{
     123    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
     124    if (styleToUse->isHorizontalWritingMode())
     125        return styleToUse->isLeftToRightDirection() ? m_marginLeft : m_marginRight;
     126    return styleToUse->isLeftToRightDirection() ? m_marginTop : m_marginBottom;
     127}
     128
     129LayoutUnit RenderBox::marginEnd(const RenderStyle* overrideStyle) const
     130{
     131    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
     132    if (styleToUse->isHorizontalWritingMode())
     133        return styleToUse->isLeftToRightDirection() ? m_marginRight : m_marginLeft;
     134    return styleToUse->isLeftToRightDirection() ? m_marginBottom : m_marginTop;
     135}
     136
     137void RenderBox::setMarginStart(LayoutUnit margin, const RenderStyle* overrideStyle)
     138{
     139    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
     140    if (styleToUse->isHorizontalWritingMode()) {
     141        if (styleToUse->isLeftToRightDirection())
    139142            m_marginLeft = margin;
    140143        else
    141144            m_marginRight = margin;
    142145    } else {
    143         if (style()->isLeftToRightDirection())
     146        if (styleToUse->isLeftToRightDirection())
    144147            m_marginTop = margin;
    145148        else
     
    148151}
    149152
    150 void RenderBox::setMarginEnd(LayoutUnit margin)
    151 {
    152     if (isHorizontalWritingMode()) {
    153         if (style()->isLeftToRightDirection())
     153void RenderBox::setMarginEnd(LayoutUnit margin, const RenderStyle* overrideStyle)
     154{
     155    const RenderStyle* styleToUse = overrideStyle ? overrideStyle : style();
     156    if (styleToUse->isHorizontalWritingMode()) {
     157        if (styleToUse->isLeftToRightDirection())
    154158            m_marginRight = margin;
    155159        else
    156160            m_marginLeft = margin;
    157161    } else {
    158         if (style()->isLeftToRightDirection())
     162        if (styleToUse->isLeftToRightDirection())
    159163            m_marginBottom = margin;
    160164        else
     
    163167}
    164168
    165 void RenderBox::setMarginBefore(LayoutUnit margin)
    166 {
    167     switch (style()->writingMode()) {
     169void RenderBox::setMarginBefore(LayoutUnit margin, const RenderStyle* overrideStyle)
     170{
     171    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
    168172    case TopToBottomWritingMode:
    169173        m_marginTop = margin;
     
    181185}
    182186
    183 void RenderBox::setMarginAfter(LayoutUnit margin)
    184 {
    185     switch (style()->writingMode()) {
     187void RenderBox::setMarginAfter(LayoutUnit margin, const RenderStyle* overrideStyle)
     188{
     189    switch (overrideStyle ? overrideStyle->writingMode() : style()->writingMode()) {
    186190    case TopToBottomWritingMode:
    187191        m_marginBottom = margin;
  • trunk/Source/WebCore/rendering/RenderBox.h

    r117697 r117946  
    230230    void setMarginLeft(LayoutUnit margin) { m_marginLeft = margin; }
    231231    void setMarginRight(LayoutUnit margin) { m_marginRight = margin; }
    232     virtual LayoutUnit marginBefore() const;
    233     virtual LayoutUnit marginAfter() const;
    234     virtual LayoutUnit marginStart() const;
    235     virtual LayoutUnit marginEnd() const;
    236     void setMarginStart(LayoutUnit);
    237     void setMarginEnd(LayoutUnit);
    238     void setMarginBefore(LayoutUnit);
    239     void setMarginAfter(LayoutUnit);
     232    virtual LayoutUnit marginBefore(const RenderStyle* overrideStyle = 0) const;
     233    virtual LayoutUnit marginAfter(const RenderStyle* overrideStyle = 0) const;
     234    virtual LayoutUnit marginStart(const RenderStyle* overrideStyle = 0) const;
     235    virtual LayoutUnit marginEnd(const RenderStyle* overrideStyle = 0) const;
     236    void setMarginStart(LayoutUnit, const RenderStyle* overrideStyle = 0);
     237    void setMarginEnd(LayoutUnit, const RenderStyle* overrideStyle = 0);
     238    void setMarginBefore(LayoutUnit, const RenderStyle* overrideStyle = 0);
     239    void setMarginAfter(LayoutUnit, const RenderStyle* overrideStyle = 0);
    240240
    241241    // The following five functions are used to implement collapsing margins.
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.h

    r117482 r117946  
    131131    virtual LayoutUnit marginLeft() const = 0;
    132132    virtual LayoutUnit marginRight() const = 0;
    133     virtual LayoutUnit marginBefore() const = 0;
    134     virtual LayoutUnit marginAfter() const = 0;
    135     virtual LayoutUnit marginStart() const = 0;
    136     virtual LayoutUnit marginEnd() const = 0;
     133    virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const = 0;
     134    virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const = 0;
     135    virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const = 0;
     136    virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const = 0;
    137137    LayoutUnit marginHeight() const { return marginTop() + marginBottom(); }
    138138    LayoutUnit marginWidth() const { return marginLeft() + marginRight(); }
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r117865 r117946  
    695695}
    696696
    697 LayoutUnit RenderInline::marginStart() const
    698 {
    699     return computeMargin(this, style()->marginStart());
    700 }
    701 
    702 LayoutUnit RenderInline::marginEnd() const
    703 {
    704     return computeMargin(this, style()->marginEnd());
    705 }
    706 
    707 LayoutUnit RenderInline::marginBefore() const
    708 {
    709     return computeMargin(this, style()->marginBefore());
    710 }
    711 
    712 LayoutUnit RenderInline::marginAfter() const
    713 {
    714     return computeMargin(this, style()->marginAfter());
     697LayoutUnit RenderInline::marginStart(const RenderStyle* otherStyle) const
     698{
     699    return computeMargin(this, style()->marginStartUsing(otherStyle ? otherStyle : style()));
     700}
     701
     702LayoutUnit RenderInline::marginEnd(const RenderStyle* otherStyle) const
     703{
     704    return computeMargin(this, style()->marginEndUsing(otherStyle ? otherStyle : style()));
     705}
     706
     707LayoutUnit RenderInline::marginBefore(const RenderStyle* otherStyle) const
     708{
     709    return computeMargin(this, style()->marginBeforeUsing(otherStyle ? otherStyle : style()));
     710}
     711
     712LayoutUnit RenderInline::marginAfter(const RenderStyle* otherStyle) const
     713{
     714    return computeMargin(this, style()->marginAfterUsing(otherStyle ? otherStyle : style()));
    715715}
    716716
  • trunk/Source/WebCore/rendering/RenderInline.h

    r117865 r117946  
    4242    virtual LayoutUnit marginTop() const;
    4343    virtual LayoutUnit marginBottom() const;
    44     virtual LayoutUnit marginBefore() const;
    45     virtual LayoutUnit marginAfter() const;
    46     virtual LayoutUnit marginStart() const;
    47     virtual LayoutUnit marginEnd() const;
     44    virtual LayoutUnit marginBefore(const RenderStyle* otherStyle = 0) const;
     45    virtual LayoutUnit marginAfter(const RenderStyle* otherStyle = 0) const;
     46    virtual LayoutUnit marginStart(const RenderStyle* otherStyle = 0) const;
     47    virtual LayoutUnit marginEnd(const RenderStyle* otherStyle = 0) const;
    4848
    4949    virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
Note: See TracChangeset for help on using the changeset viewer.