Show
Ignore:
Timestamp:
04/02/07 18:01:09 (22 months ago)
Author:
antti
Message:

Reviewed by Hyatt.

Render tree memory savings, part 3


These changes shrink all RenderBlocks by additional 28 bytes. Together with parts 1 and 2
RenderBlock goes from 172 bytes to 128 bytes, a saving of 26%.


  • Pack bitfields together in RenderFlow
  • Move top/bottom min/max margin values to a struct that is only allocated in case these variables have non default values. Usually this is <5% of all blocks.
  • Move rarely used column variables to hash
  • rendering/RenderBlock.cpp: (WebCore::ColumnInfo::ColumnInfo): (WebCore::RenderBlock::RenderBlock): (WebCore::RenderBlock::~RenderBlock): (WebCore::RenderBlock::layoutBlock): (WebCore::RenderBlock::collapseMargins): (WebCore::RenderBlock::clearFloatsIfNeeded): (WebCore::RenderBlock::setCollapsedBottomMargin): (WebCore::RenderBlock::layoutBlockChildren): (WebCore::RenderBlock::paintColumns): (WebCore::RenderBlock::paintObject): (WebCore::RenderBlock::fillSelectionGaps): (WebCore::RenderBlock::lowestPosition): (WebCore::RenderBlock::rightmostPosition): (WebCore::RenderBlock::leftmostPosition): (WebCore::RenderBlock::nodeAtPoint): (WebCore::RenderBlock::hitTestColumns): (WebCore::RenderBlock::positionForCoordinates): (WebCore::RenderBlock::availableWidth): (WebCore::RenderBlock::calcColumnWidth): (WebCore::RenderBlock::setDesiredColumnCountAndWidth): (WebCore::RenderBlock::desiredColumnWidth): (WebCore::RenderBlock::desiredColumnCount): (WebCore::RenderBlock::columnRects): (WebCore::RenderBlock::layoutColumns): (WebCore::RenderBlock::adjustPointToColumnContents): (WebCore::RenderBlock::adjustRectForColumns): (WebCore::RenderBlock::setMaxTopMargins): (WebCore::RenderBlock::setMaxBottomMargins):
  • rendering/RenderBlock.h: (WebCore::RenderBlock::maxTopMargin): (WebCore::RenderBlock::maxBottomMargin): (WebCore::RenderBlock::maxTopPosMargin): (WebCore::RenderBlock::maxTopNegMargin): (WebCore::RenderBlock::maxBottomPosMargin): (WebCore::RenderBlock::maxBottomNegMargin): (WebCore::RenderBlock::initMaxMarginValues): (WebCore::RenderBlock::MaxMargin::MaxMargin): (WebCore::RenderBlock::MaxMargin::topPosDefault): (WebCore::RenderBlock::MaxMargin::topNegDefault): (WebCore::RenderBlock::MaxMargin::bottomPosDefault): (WebCore::RenderBlock::MaxMargin::bottomNegDefault):
  • rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutBlock):
  • rendering/RenderFlow.h: (WebCore::RenderFlow::RenderFlow): (WebCore::RenderFlow::hasColumns):
  • rendering/RenderInline.cpp: (WebCore::RenderInline::RenderInline):
  • rendering/RenderInline.h:
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/rendering/RenderBlock.h

    r20636 r20673  
    7777    virtual bool isBottomMarginQuirk() const { return m_bottomMarginQuirk; } 
    7878 
    79     virtual int maxTopMargin(bool positive) const { return positive ? m_maxTopPosMargin : m_maxTopNegMargin; } 
    80     virtual int maxBottomMargin(bool positive) const { return positive ? m_maxBottomPosMargin : m_maxBottomNegMargin; } 
    81  
     79    virtual int maxTopMargin(bool positive) const { return positive ? maxTopPosMargin() : maxTopNegMargin(); } 
     80    virtual int maxBottomMargin(bool positive) const { return positive ? maxBottomPosMargin() : maxBottomNegMargin(); } 
     81 
     82    int maxTopPosMargin() const { return m_maxMargin ? m_maxMargin->m_topPos : MaxMargin::topPosDefault(this); } 
     83    int maxTopNegMargin() const { return m_maxMargin ? m_maxMargin->m_topNeg : MaxMargin::topNegDefault(this); } 
     84    int maxBottomPosMargin() const { return m_maxMargin ? m_maxMargin->m_bottomPos : MaxMargin::bottomPosDefault(this); } 
     85    int maxBottomNegMargin() const { return m_maxMargin ? m_maxMargin->m_bottomNeg : MaxMargin::bottomNegDefault(this); } 
     86    void setMaxTopMargins(int pos, int neg); 
     87    void setMaxBottomMargins(int pos, int neg); 
     88     
    8289    void initMaxMarginValues() 
    8390    { 
    84         int margTop = marginTop(); 
    85         if (margTop >= 0) { 
    86             m_maxTopPosMargin = margTop; 
    87             m_maxTopNegMargin = 0; 
    88         } else { 
    89             m_maxTopNegMargin = -margTop; 
    90             m_maxTopPosMargin = 0; 
    91         } 
    92         int margBottom = marginBottom(); 
    93         if (margBottom >= 0) { 
    94             m_maxBottomPosMargin = margBottom; 
    95             m_maxBottomNegMargin = 0; 
    96         } else { 
    97             m_maxBottomNegMargin = -margBottom; 
    98             m_maxBottomPosMargin = 0; 
     91        if (m_maxMargin) { 
     92            m_maxMargin->m_topPos = MaxMargin::topPosDefault(this); 
     93            m_maxMargin->m_topNeg = MaxMargin::topNegDefault(this); 
     94            m_maxMargin->m_bottomPos = MaxMargin::bottomPosDefault(this); 
     95            m_maxMargin->m_bottomNeg = MaxMargin::bottomNegDefault(this); 
    9996        } 
    10097    } 
     
    286283    void clearTruncation(); 
    287284 
    288     virtual bool hasColumns() const { return m_desiredColumnCount > 1; } 
     285    int desiredColumnWidth() const; 
     286    unsigned desiredColumnCount() const; 
     287    Vector<IntRect>* columnRects() const; 
     288    void setDesiredColumnCountAndWidth(int count, int width); 
     289     
    289290    void adjustRectForColumns(IntRect&) const; 
    290291private: 
     
    437438    DeprecatedPtrList<FloatingObject>* m_floatingObjects; 
    438439    DeprecatedPtrList<RenderObject>* m_positionedObjects; 
    439  
    440     bool m_childrenInline : 1; 
    441     bool m_firstLine : 1; 
    442     unsigned m_clearStatus  : 2; // EClear 
    443     bool m_topMarginQuirk : 1; 
    444     bool m_bottomMarginQuirk : 1; 
    445     bool m_hasMarkupTruncation : 1; 
    446     unsigned m_selectionState : 3; // SelectionState 
     440          
     441     // Allocated only when some of these fields have non-default values 
     442     struct MaxMargin { 
     443         MaxMargin(const RenderBlock* o)  
     444             : m_topPos(topPosDefault(o)) 
     445             , m_topNeg(topNegDefault(o)) 
     446             , m_bottomPos(bottomPosDefault(o)) 
     447             , m_bottomNeg(bottomNegDefault(o)) 
     448             {  
     449             } 
     450         static int topPosDefault(const RenderBlock* o) { return o->marginTop() > 0 ? o->marginTop() : 0; } 
     451         static int topNegDefault(const RenderBlock* o) { return o->marginTop() < 0 ? -o->marginTop() : 0; } 
     452         static int bottomPosDefault(const RenderBlock* o) { return o->marginBottom() > 0 ? o->marginBottom() : 0; } 
     453         static int bottomNegDefault(const RenderBlock* o) { return o->marginBottom() < 0 ? -o->marginBottom() : 0; } 
     454          
     455         int m_topPos; 
     456         int m_topNeg; 
     457         int m_bottomPos; 
     458         int m_bottomNeg; 
     459     }; 
     460 
     461    MaxMargin* m_maxMargin; 
    447462 
    448463protected: 
    449     int m_maxTopPosMargin; 
    450     int m_maxTopNegMargin; 
    451     int m_maxBottomPosMargin; 
    452     int m_maxBottomNegMargin; 
    453  
    454464    // How much content overflows out of our block vertically or horizontally. 
    455465    int m_overflowHeight; 
     
    457467    int m_overflowLeft; 
    458468    int m_overflowTop; 
    459  
    460 private: 
    461  
    462     // Column information. 
    463     int m_desiredColumnWidth; 
    464     unsigned m_desiredColumnCount; 
    465     Vector<IntRect>* m_columnRects; 
    466469}; 
    467470