Changeset 112566 in webkit


Ignore:
Timestamp:
Mar 29, 2012 1:20:13 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

Add a compile assert for the size of RenderBlock
https://bugs.webkit.org/show_bug.cgi?id=82586

Reviewed by Tony Chang.

Add compile asserts for the size of RenderBlock and RenderBlock::MarginValues.
We can't add asserts for FloatingObject and MarginInfo because they're private to RenderBlock.

  • rendering/RenderBlock.cpp:

(SameSizeAsRenderBlock):
(WebCore):
(WebCore::RenderBlock::addOverflowFromFloats):
(WebCore::RenderBlock::repaintOverhangingFloats):
(WebCore::RenderBlock::paintFloats):
(WebCore::RenderBlock::insertFloatingObject):
(WebCore::RenderBlock::clearFloats):
(WebCore::RenderBlock::addOverhangingFloats):
(WebCore::RenderBlock::addIntrudingFloats):
(WebCore::RenderBlock::hitTestFloats):
(WebCore::RenderBlock::adjustForBorderFit):

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::FloatingObject::shouldPaint):
(WebCore::RenderBlock::FloatingObject::setShouldPaint):
(WebCore::RenderBlock::FloatingObject::isDescendant):
(WebCore::RenderBlock::FloatingObject::setIsDescendant):
(FloatingObject):
(RenderBlock):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112564 r112566  
     12012-03-29  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Add a compile assert for the size of RenderBlock
     4        https://bugs.webkit.org/show_bug.cgi?id=82586
     5
     6        Reviewed by Tony Chang.
     7       
     8        Add compile asserts for the size of RenderBlock and RenderBlock::MarginValues.
     9        We can't add asserts for FloatingObject and MarginInfo because they're private to RenderBlock.
     10
     11        * rendering/RenderBlock.cpp:
     12        (SameSizeAsRenderBlock):
     13        (WebCore):
     14        (WebCore::RenderBlock::addOverflowFromFloats):
     15        (WebCore::RenderBlock::repaintOverhangingFloats):
     16        (WebCore::RenderBlock::paintFloats):
     17        (WebCore::RenderBlock::insertFloatingObject):
     18        (WebCore::RenderBlock::clearFloats):
     19        (WebCore::RenderBlock::addOverhangingFloats):
     20        (WebCore::RenderBlock::addIntrudingFloats):
     21        (WebCore::RenderBlock::hitTestFloats):
     22        (WebCore::RenderBlock::adjustForBorderFit):
     23        * rendering/RenderBlock.h:
     24        (WebCore::RenderBlock::FloatingObject::shouldPaint):
     25        (WebCore::RenderBlock::FloatingObject::setShouldPaint):
     26        (WebCore::RenderBlock::FloatingObject::isDescendant):
     27        (WebCore::RenderBlock::FloatingObject::setIsDescendant):
     28        (FloatingObject):
     29        (RenderBlock):
     30
    1312012-03-29  Gavin Barraclough  <barraclough@apple.com>
    232
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r112555 r112566  
    7070using namespace HTMLNames;
    7171
     72struct SameSizeAsRenderBlock : public RenderBox {
     73    void* pointers[3];
     74    RenderObjectChildList children;
     75    RenderLineBoxList lineBoxes;
     76    uint32_t bitfields;
     77};
     78
     79COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock_should_stay_small);
     80
     81struct SameSizeAsFloatingObject {
     82    void* pointers[2];
     83    LayoutRect rect;
     84    int paginationStrut;
     85    uint32_t bitfields : 8;
     86};
     87
     88COMPILE_ASSERT(sizeof(RenderBlock::MarginValues) == sizeof(LayoutUnit[4]), MarginValues_should_stay_small);
     89
     90struct SameSizeAsMarginInfo {
     91    uint32_t bitfields : 16;
     92    LayoutUnit margins[2];
     93};
     94
    7295typedef WTF::HashMap<const RenderBox*, ColumnInfo*> ColumnInfoMap;
    7396static ColumnInfoMap* gColumnInfoMap = 0;
     
    182205{
    183206    setChildrenInline(true);
     207    COMPILE_ASSERT(sizeof(RenderBlock::FloatingObject) == sizeof(SameSizeAsFloatingObject), FloatingObject_should_stay_small);
     208    COMPILE_ASSERT(sizeof(RenderBlock::MarginInfo) == sizeof(SameSizeAsMarginInfo), MarginInfo_should_stay_small);
    184209}
    185210
     
    17221747    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    17231748        FloatingObject* r = *it;
    1724         if (r->m_isDescendant && !r->m_renderer->isPositioned())
     1749        if (r->isDescendant() && !r->m_renderer->isPositioned())
    17251750            addOverflowFromChild(r->m_renderer, IntSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
    17261751    }
     
    26292654        // is our responsibility to paint (m_shouldPaint is set). When paintAllDescendants is true, the latter
    26302655        // condition is replaced with being a descendant of us.
    2631         if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->m_renderer->isDescendantOf(this)) || r->m_shouldPaint) && !r->m_renderer->hasSelfPaintingLayer()) {
     2656        if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->m_renderer->isDescendantOf(this)) || r->shouldPaint()) && !r->m_renderer->hasSelfPaintingLayer()) {
    26322657            r->m_renderer->repaint();
    26332658            r->m_renderer->repaintOverhangingFloats();
     
    29883013        FloatingObject* r = *it;
    29893014        // Only paint the object if our m_shouldPaint flag is set.
    2990         if (r->m_shouldPaint && !r->m_renderer->hasSelfPaintingLayer()) {
     3015        if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) {
    29913016            PaintInfo currentPaintInfo(paintInfo);
    29923017            currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
     
    35823607    setLogicalWidthForFloat(newObj, logicalWidthForChild(o) + marginStartForChild(o) + marginEndForChild(o));
    35833608
    3584     newObj->m_shouldPaint = !o->hasSelfPaintingLayer(); // If a layer exists, the float will paint itself. Otherwise someone else will.
    3585     newObj->m_isDescendant = true;
     3609    newObj->setShouldPaint(!o->hasSelfPaintingLayer()); // If a layer exists, the float will paint itself. Otherwise someone else will.
     3610    newObj->setIsDescendant(true);
    35863611    newObj->m_renderer = o;
    35873612
     
    42394264        for (RendererToFloatInfoMap::iterator it = floatMap.begin(); it != end; ++it) {
    42404265            FloatingObject* floatingObject = (*it).second;
    4241             if (!floatingObject->m_isDescendant) {
     4266            if (!floatingObject->isDescendant()) {
    42424267                changeLogicalTop = 0;
    42434268                changeLogicalBottom = max(changeLogicalBottom, logicalBottomForFloat(floatingObject));
     
    42824307                // if we hit a self-painting layer boundary.
    42834308                if (r->m_renderer->enclosingFloatPaintingLayer() == enclosingFloatPaintingLayer())
    4284                     r->m_shouldPaint = false;
     4309                    r->setShouldPaint(false);
    42854310                else
    4286                     floatingObj->m_shouldPaint = false;
    4287                
    4288                 floatingObj->m_isDescendant = true;
     4311                    floatingObj->setShouldPaint(false);
     4312
     4313                floatingObj->setIsDescendant(true);
    42894314
    42904315                // We create the floating object list lazily.
     
    42954320            }
    42964321        } else {
    4297             if (makeChildPaintOtherFloats && !r->m_shouldPaint && !r->m_renderer->hasSelfPaintingLayer() &&
    4298                 r->m_renderer->isDescendantOf(child) && r->m_renderer->enclosingFloatPaintingLayer() == child->enclosingFloatPaintingLayer()) {
     4322            if (makeChildPaintOtherFloats && !r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()
     4323                && r->m_renderer->isDescendantOf(child) && r->m_renderer->enclosingFloatPaintingLayer() == child->enclosingFloatPaintingLayer()) {
    42994324                // The float is not overhanging from this block, so if it is a descendant of the child, the child should
    43004325                // paint it (the other case is that it is intruding into the child), unless it has its own layer or enclosing
     
    43024327                // If makeChildPaintOtherFloats is false, it means that the child must already know about all the floats
    43034328                // it should paint.
    4304                 r->m_shouldPaint = true;
     4329                r->setShouldPaint(true);
    43054330            }
    43064331           
    43074332            // Since the float doesn't overhang, it didn't get put into our list.  We need to go ahead and add its overflow in to the
    43084333            // child now.
    4309             if (r->m_isDescendant)
     4334            if (r->isDescendant())
    43104335                child->addOverflowFromChild(r->m_renderer, LayoutSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
    43114336        }
     
    43584383                }
    43594384               
    4360                 floatingObj->m_shouldPaint = false; // We are not in the direct inheritance chain for this float. We will never paint it.
     4385                floatingObj->setShouldPaint(false); // We are not in the direct inheritance chain for this float. We will never paint it.
    43614386                floatingObj->m_renderer = r->m_renderer;
    43624387               
     
    45764601        --it;
    45774602        FloatingObject* floatingObject = *it;
    4578         if (floatingObject->m_shouldPaint && !floatingObject->m_renderer->hasSelfPaintingLayer()) {
     4603        if (floatingObject->shouldPaint() && !floatingObject->m_renderer->hasSelfPaintingLayer()) {
    45794604            LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->x();
    45804605            LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->y();
     
    63076332                FloatingObject* r = *it;
    63086333                // Only examine the object if our m_shouldPaint flag is set.
    6309                 if (r->m_shouldPaint) {
     6334                if (r->shouldPaint()) {
    63106335                    LayoutUnit floatLeft = xPositionForFloatIncludingMargin(r) - r->m_renderer->x();
    63116336                    LayoutUnit floatRight = floatLeft + r->m_renderer->width();
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r111217 r112566  
    621621#endif
    622622
     623        bool shouldPaint() const { return m_shouldPaint; }
     624        void setShouldPaint(bool shouldPaint) { m_shouldPaint = shouldPaint; }
     625        bool isDescendant() const { return m_isDescendant; }
     626        void setIsDescendant(bool isDescendant) { m_isDescendant = isDescendant; }
     627
    623628        RenderBox* m_renderer;
    624629        RootInlineBox* m_originatingLine;
    625630        LayoutRect m_frameRect;
    626631        int m_paginationStrut;
     632
     633    private:
    627634        unsigned m_type : 3; // Type (left/right aligned or positioned)
    628         bool m_shouldPaint : 1;
    629         bool m_isDescendant : 1;
    630         bool m_isPlaced : 1;
     635        unsigned m_shouldPaint : 1;
     636        unsigned m_isDescendant : 1;
     637        unsigned m_isPlaced : 1;
    631638#ifndef NDEBUG
    632         bool m_isInPlacedTree : 1;
     639        unsigned m_isInPlacedTree : 1;
    633640#endif
    634641    };
     
    11281135
    11291136    mutable signed m_lineHeight : 29;
    1130     bool m_beingDestroyed : 1;
    1131     bool m_hasPositionedFloats : 1;
    1132     bool m_hasMarkupTruncation : 1;
     1137    unsigned m_beingDestroyed : 1;
     1138    unsigned m_hasPositionedFloats : 1;
     1139    unsigned m_hasMarkupTruncation : 1;
    11331140
    11341141    // RenderRubyBase objects need to be able to split and merge, moving their children around
Note: See TracChangeset for help on using the changeset viewer.