[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 13:55:44 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 0e31dc2182adde1d3cc734537eff74e9fab0c1e8
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 29 21:45:36 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=46838
    
    Reviewed by Simon Fraser.
    
    Get rid of the marginXXXUsing/setMarginXXXUsing methods on RenderBox.  I'm inverting the way these are called
    and putting the methods on RenderBlock instead.  The methods can be named better this way and the getters
    can operate on RenderBoxModelObjects instead of just RenderBoxes.
    
    * rendering/RenderBlock.cpp:
    (WebCore::RenderBlock::layoutBlockChild):
    (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/RenderBlock.h:
    (WebCore::RenderBlock::logicalHeightForChild):
    (WebCore::RenderBlock::logicalTopForChild):
    * 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):
    (WebCore::RenderBox::computeLogicalWidth):
    (WebCore::RenderBox::computeInlineDirectionMargins):
    (WebCore::RenderBox::computeBlockDirectionMargins):
    * rendering/RenderBox.h:
    (WebCore::RenderBox::setMarginTop):
    (WebCore::RenderBox::setMarginBottom):
    (WebCore::RenderBox::setMarginLeft):
    (WebCore::RenderBox::setMarginRight):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68687 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 621e779..f15dad8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,44 @@
+2010-09-29  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Simon Fraser.
+
+        https://bugs.webkit.org/show_bug.cgi?id=46838
+        
+        Get rid of the marginXXXUsing/setMarginXXXUsing methods on RenderBox.  I'm inverting the way these are called
+        and putting the methods on RenderBlock instead.  The methods can be named better this way and the getters
+        can operate on RenderBoxModelObjects instead of just RenderBoxes.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::layoutBlockChild):
+        (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/RenderBlock.h:
+        (WebCore::RenderBlock::logicalHeightForChild):
+        (WebCore::RenderBlock::logicalTopForChild):
+        * 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):
+        (WebCore::RenderBox::computeLogicalWidth):
+        (WebCore::RenderBox::computeInlineDirectionMargins):
+        (WebCore::RenderBox::computeBlockDirectionMargins):
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::setMarginTop):
+        (WebCore::RenderBox::setMarginBottom):
+        (WebCore::RenderBox::setMarginLeft):
+        (WebCore::RenderBox::setMarginRight):
+
 2010-09-29  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index ee28015..c9f1805 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -1949,7 +1949,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
     // Update our height now that the child has been placed in the correct position.
     setLogicalHeight(logicalHeight() + logicalHeightForChild(child));
     if (child->style()->marginAfterCollapse() == MSEPARATE) {
-        setLogicalHeight(logicalHeight() + child->marginAfterUsing(style()));
+        setLogicalHeight(logicalHeight() + marginAfterForChild(child));
         marginInfo.clearMargin();
     }
     // If the child has overhanging floats that intrude into following siblings (or possibly out
@@ -6019,7 +6019,119 @@ void RenderBlock::adjustLinePositionForPagination(RootInlineBox* lineBox, int& d
         }
     }  
 }
- 
+
+int RenderBlock::marginBeforeForChild(RenderBoxModelObject* child) const
+{
+    switch (style()->blockFlow()) {
+    case TopToBottomBlockFlow:
+        return child->marginTop();
+    case BottomToTopBlockFlow:
+        return child->marginBottom();
+    case LeftToRightBlockFlow:
+        return child->marginLeft();
+    case RightToLeftBlockFlow:
+        return child->marginRight();
+    }
+    ASSERT_NOT_REACHED();
+    return child->marginTop();
+}
+
+int RenderBlock::marginAfterForChild(RenderBoxModelObject* child) const
+{
+    switch (style()->blockFlow()) {
+    case TopToBottomBlockFlow:
+        return child->marginBottom();
+    case BottomToTopBlockFlow:
+        return child->marginTop();
+    case LeftToRightBlockFlow:
+        return child->marginRight();
+    case RightToLeftBlockFlow:
+        return child->marginLeft();
+    }
+    ASSERT_NOT_REACHED();
+    return child->marginBottom();
+}
+    
+int RenderBlock::marginStartForChild(RenderBoxModelObject* child) const
+{
+    if (style()->isVerticalBlockFlow())
+        return style()->direction() == LTR ? child->marginLeft() : child->marginRight();
+    return style()->direction() == LTR ? child->marginTop() : child->marginBottom();
+}
+
+int RenderBlock::marginEndForChild(RenderBoxModelObject* child) const
+{
+    if (style()->isVerticalBlockFlow())
+        return style()->direction() == LTR ? child->marginRight() : child->marginLeft();
+    return style()->direction() == LTR ? child->marginBottom() : child->marginTop();
+}
+
+void RenderBlock::setMarginStartForChild(RenderBox* child, int margin)
+{
+    if (style()->isVerticalBlockFlow()) {
+        if (style()->direction() == LTR)
+            child->setMarginLeft(margin);
+        else
+            child->setMarginRight(margin);
+    } else {
+        if (style()->direction() == LTR)
+            child->setMarginTop(margin);
+        else
+            child->setMarginBottom(margin);
+    }
+}
+
+void RenderBlock::setMarginEndForChild(RenderBox* child, int margin)
+{
+    if (style()->isVerticalBlockFlow()) {
+        if (style()->direction() == LTR)
+            child->setMarginRight(margin);
+        else
+            child->setMarginLeft(margin);
+    } else {
+        if (style()->direction() == LTR)
+            child->setMarginBottom(margin);
+        else
+            child->setMarginTop(margin);
+    }
+}
+
+void RenderBlock::setMarginBeforeForChild(RenderBox* child, int margin)
+{
+    switch (style()->blockFlow()) {
+    case TopToBottomBlockFlow:
+        child->setMarginTop(margin);
+        break;
+    case BottomToTopBlockFlow:
+        child->setMarginBottom(margin);
+        break;
+    case LeftToRightBlockFlow:
+        child->setMarginLeft(margin);
+        break;
+    case RightToLeftBlockFlow:
+        child->setMarginRight(margin);
+        break;
+    }
+}
+
+void RenderBlock::setMarginAfterForChild(RenderBox* child, int margin)
+{
+    switch (style()->blockFlow()) {
+    case TopToBottomBlockFlow:
+        child->setMarginBottom(margin);
+        break;
+    case BottomToTopBlockFlow:
+        child->setMarginTop(margin);
+        break;
+    case LeftToRightBlockFlow:
+        child->setMarginRight(margin);
+        break;
+    case RightToLeftBlockFlow:
+        child->setMarginLeft(margin);
+        break;
+    }
+}
+
 const char* RenderBlock::renderName() const
 {
     if (isBody())
diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h
index dde49dc..107ce88 100644
--- a/WebCore/rendering/RenderBlock.h
+++ b/WebCore/rendering/RenderBlock.h
@@ -169,6 +169,18 @@ public:
     void setPaginationStrut(int strut);
     void setPageY(int y);
 
+    // Accessors for logical width/height and margins in the containing block's block-flow direction.
+    int logicalHeightForChild(RenderBox* child) { return style()->isVerticalBlockFlow() ? child->height() : child->width(); }
+    int logicalTopForChild(RenderBox* child) { return style()->isVerticalBlockFlow() ? child->y() : child->x(); }
+    int marginBeforeForChild(RenderBoxModelObject* child) const;
+    int marginAfterForChild(RenderBoxModelObject* child) const;
+    int marginStartForChild(RenderBoxModelObject* child) const;
+    int marginEndForChild(RenderBoxModelObject* child) const;
+    void setMarginStartForChild(RenderBox* child, int);
+    void setMarginEndForChild(RenderBox* child, int);
+    void setMarginBeforeForChild(RenderBox* child, int);
+    void setMarginAfterForChild(RenderBox* child, int);
+
 protected:
     // These functions are only used internally to manipulate the render tree structure via remove/insert/appendChildNode.
     // Since they are typically called only to move objects around within anonymous blocks (which only have layers in
@@ -571,8 +583,6 @@ private:
     void handleAfterSideOfBlock(int top, int bottom, MarginInfo&);
     void setCollapsedBottomMargin(const MarginInfo&);
     void setLogicalTopForChild(RenderBox* child, int logicalTop);
-    int logicalHeightForChild(RenderBox* child) { return style()->isVerticalBlockFlow() ? child->height() : child->width(); }
-    int logicalTopForChild(RenderBox* child) { return style()->isVerticalBlockFlow() ? child->y() : child->x(); }
     // End helper functions and structs used by layoutBlockChildren.
 
     // Pagination routines.
diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp
index 1d8377f..cba86f4 100644
--- a/WebCore/rendering/RenderBox.cpp
+++ b/WebCore/rendering/RenderBox.cpp
@@ -85,12 +85,7 @@ RenderBox::~RenderBox()
 
 int RenderBox::marginBefore() const
 {
-    return marginBeforeUsing(style());
-}
-
-int RenderBox::marginBeforeUsing(const RenderStyle* s) const
-{
-    switch (s->blockFlow()) {
+    switch (style()->blockFlow()) {
     case TopToBottomBlockFlow:
         return m_marginTop;
     case BottomToTopBlockFlow:
@@ -106,12 +101,7 @@ int RenderBox::marginBeforeUsing(const RenderStyle* s) const
 
 int RenderBox::marginAfter() const
 {
-    return marginAfterUsing(style());
-}
-
-int RenderBox::marginAfterUsing(const RenderStyle* s) const
-{
-    switch (s->blockFlow()) {
+    switch (style()->blockFlow()) {
     case TopToBottomBlockFlow:
         return m_marginBottom;
     case BottomToTopBlockFlow:
@@ -127,62 +117,42 @@ int RenderBox::marginAfterUsing(const RenderStyle* s) const
 
 int RenderBox::marginStart() const
 {
-    return marginStartUsing(style());
-}
-
-int RenderBox::marginStartUsing(const RenderStyle* s) const
-{
-    if (s->isVerticalBlockFlow())
-        return s->direction() == LTR ? m_marginLeft : m_marginRight;
-    return s->direction() == LTR ? m_marginTop : m_marginBottom;
+    if (style()->isVerticalBlockFlow())
+        return style()->direction() == LTR ? m_marginLeft : m_marginRight;
+    return style()->direction() == LTR ? m_marginTop : m_marginBottom;
 }
 
 int RenderBox::marginEnd() const
 {
-    return marginEndUsing(style());
-}
-
-int RenderBox::marginEndUsing(const RenderStyle* s) const
-{
-    if (s->isVerticalBlockFlow())
-        return s->direction() == LTR ? m_marginRight : m_marginLeft;
-    return s->direction() == LTR ? m_marginBottom : m_marginTop;
+    if (style()->isVerticalBlockFlow())
+        return style()->direction() == LTR ? m_marginRight : m_marginLeft;
+    return style()->direction() == LTR ? m_marginBottom : m_marginTop;
 }
 
 void RenderBox::setMarginStart(int margin)
 {
-    setMarginStartUsing(style(), margin);
-}
-
-void RenderBox::setMarginEnd(int margin)
-{
-    setMarginEndUsing(style(), margin);
-}
-
-void RenderBox::setMarginStartUsing(const RenderStyle* s, int margin)
-{
-    if (s->isVerticalBlockFlow()) {
-        if (s->direction() == LTR)
+    if (style()->isVerticalBlockFlow()) {
+        if (style()->direction() == LTR)
             m_marginLeft = margin;
         else
             m_marginRight = margin;
     } else {
-        if (s->direction() == LTR)
+        if (style()->direction() == LTR)
             m_marginTop = margin;
         else
             m_marginBottom = margin;
     }
 }
 
-void RenderBox::setMarginEndUsing(const RenderStyle* s, int margin)
+void RenderBox::setMarginEnd(int margin)
 {
-    if (s->isVerticalBlockFlow()) {
-        if (s->direction() == LTR)
+    if (style()->isVerticalBlockFlow()) {
+        if (style()->direction() == LTR)
             m_marginRight = margin;
         else
             m_marginLeft = margin;
     } else {
-        if (s->direction() == LTR)
+        if (style()->direction() == LTR)
             m_marginBottom = margin;
         else
             m_marginTop = margin;
@@ -191,17 +161,7 @@ void RenderBox::setMarginEndUsing(const RenderStyle* s, int margin)
 
 void RenderBox::setMarginBefore(int margin)
 {
-    setMarginBeforeUsing(style(), margin);
-}
-
-void RenderBox::setMarginAfter(int margin)
-{
-    setMarginAfterUsing(style(), margin);
-}
-
-void RenderBox::setMarginBeforeUsing(const RenderStyle* s, int margin)
-{
-    switch (s->blockFlow()) {
+    switch (style()->blockFlow()) {
     case TopToBottomBlockFlow:
         m_marginTop = margin;
         break;
@@ -217,9 +177,9 @@ void RenderBox::setMarginBeforeUsing(const RenderStyle* s, int margin)
     }
 }
 
-void RenderBox::setMarginAfterUsing(const RenderStyle* s, int margin)
+void RenderBox::setMarginAfter(int margin)
 {
-    switch (s->blockFlow()) {
+    switch (style()->blockFlow()) {
     case TopToBottomBlockFlow:
         m_marginBottom = margin;
         break;
@@ -1531,7 +1491,7 @@ void RenderBox::computeLogicalWidth()
 
     if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (logicalWidth() + marginStart() + marginEnd())
             && !isFloating() && !isInline() && !cb->isFlexibleBox())
-        setMarginEndUsing(cb->style(), containerLogicalWidth - logicalWidth() - marginStartUsing(cb->style()));
+        cb->setMarginEndForChild(this, containerLogicalWidth - logicalWidth() - cb->marginStartForChild(this));
 }
 
 int RenderBox::computeLogicalWidthUsing(LogicalWidthType widthType, int availableLogicalWidth)
@@ -1613,15 +1573,15 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, int
     // Case One: The object is being centered in the containing block's available logical width.
     if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth)
         || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containingBlock->style()->textAlign() == WEBKIT_CENTER)) {
-        setMarginStartUsing(containingBlockStyle, max(0, (containerWidth - childWidth) / 2));
-        setMarginEndUsing(containingBlockStyle, containerWidth - childWidth - marginStartUsing(containingBlockStyle));
+        containingBlock->setMarginStartForChild(this, max(0, (containerWidth - childWidth) / 2));
+        containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this));
         return;
     } 
     
     // Case Two: The object is being pushed to the start of the containing block's available logical width.
     if (marginEndLength.isAuto() && childWidth < containerWidth) {
-        setMarginStartUsing(containingBlockStyle, marginStartLength.calcValue(containerWidth));
-        setMarginEndUsing(containingBlockStyle, containerWidth - childWidth - marginStartUsing(containingBlockStyle));
+        containingBlock->setMarginStartForChild(this, marginStartLength.calcValue(containerWidth));
+        containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this));
         return;
     } 
     
@@ -1629,15 +1589,15 @@ void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, int
     bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((containingBlockStyle->direction() == RTL && containingBlockStyle->textAlign() == WEBKIT_LEFT)
         || (containingBlockStyle->direction() == LTR && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
     if ((marginStartLength.isAuto() && childWidth < containerWidth) || pushToEndFromTextAlign) {
-        setMarginEndUsing(containingBlockStyle, marginEndLength.calcValue(containerWidth));
-        setMarginStartUsing(containingBlockStyle, containerWidth - childWidth - marginEndUsing(containingBlockStyle));
+        containingBlock->setMarginEndForChild(this, marginEndLength.calcValue(containerWidth));
+        containingBlock->setMarginStartForChild(this, containerWidth - childWidth - containingBlock->marginEndForChild(this));
         return;
     } 
     
     // Case Four: Either no auto margins, or our width is >= the container width (css2.1, 10.3.3).  In that case
     // auto margins will just turn into 0.
-    setMarginStartUsing(containingBlockStyle, marginStartLength.calcMinValue(containerWidth));
-    setMarginEndUsing(containingBlockStyle, marginEndLength.calcMinValue(containerWidth));
+    containingBlock->setMarginStartForChild(this, marginStartLength.calcMinValue(containerWidth));
+    containingBlock->setMarginEndForChild(this, marginEndLength.calcMinValue(containerWidth));
 }
 
 void RenderBox::computeLogicalHeight()
@@ -1975,8 +1935,8 @@ void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock)
     int cw = containingBlockLogicalWidthForContent();
 
     RenderStyle* containingBlockStyle = containingBlock->style();
-    setMarginBeforeUsing(containingBlockStyle, style()->marginBeforeUsing(containingBlockStyle).calcMinValue(cw));
-    setMarginAfterUsing(containingBlockStyle, style()->marginAfterUsing(containingBlockStyle).calcMinValue(cw));
+    containingBlock->setMarginBeforeForChild(this, style()->marginBeforeUsing(containingBlockStyle).calcMinValue(cw));
+    containingBlock->setMarginAfterForChild(this, style()->marginAfterUsing(containingBlockStyle).calcMinValue(cw));
 }
 
 int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const
diff --git a/WebCore/rendering/RenderBox.h b/WebCore/rendering/RenderBox.h
index 7cb20b9..9a69741 100644
--- a/WebCore/rendering/RenderBox.h
+++ b/WebCore/rendering/RenderBox.h
@@ -181,6 +181,10 @@ public:
     virtual int marginBottom() const { return m_marginBottom; }
     virtual int marginLeft() const { return m_marginLeft; }
     virtual int marginRight() const { return m_marginRight; }
+    void setMarginTop(int margin) { m_marginTop = margin; }
+    void setMarginBottom(int margin) { m_marginBottom = margin; }
+    void setMarginLeft(int margin) { m_marginLeft = margin; }
+    void setMarginRight(int margin) { m_marginRight = margin; }
     virtual int marginBefore() const;
     virtual int marginAfter() const;
     virtual int marginStart() const;
@@ -190,11 +194,6 @@ public:
     void setMarginBefore(int);
     void setMarginAfter(int);
 
-    int marginStartUsing(const RenderStyle*) const;
-    int marginEndUsing(const RenderStyle*) const;
-    int marginBeforeUsing(const RenderStyle*) const;
-    int marginAfterUsing(const RenderStyle*) const;
-
     // The following five functions are used to implement collapsing margins.
     // All objects know their maximal positive and negative margins.  The
     // formula for computing a collapsed margin is |maxPosMargin| - |maxNegmargin|.
@@ -428,11 +427,6 @@ private:
     // These include tables, positioned objects, floats and flexible boxes.
     virtual void computePreferredLogicalWidths() { setPreferredLogicalWidthsDirty(false); }
 
-    void setMarginStartUsing(const RenderStyle*, int);
-    void setMarginEndUsing(const RenderStyle*, int);
-    void setMarginBeforeUsing(const RenderStyle*, int);
-    void setMarginAfterUsing(const RenderStyle*, int);
-
 private:
     // The width/height of the contents + borders + padding.  The x/y location is relative to our container (which is not always our parent).
     IntRect m_frameRect;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list