Changeset 97062 in webkit


Ignore:
Timestamp:
Oct 10, 2011 7:51:44 AM (13 years ago)
Author:
andreas.kling@nokia.com
Message:

Shrink RenderLayer and ScrollableArea.
https://bugs.webkit.org/show_bug.cgi?id=69759

Reviewed by Antti Koivisto.

Rearrange the members of RenderLayer and its base class ScrollableArea
to maximize struct packing, shrinking RenderLayer by one CPU word on
32-bit (and two on 64-bit.)

This reduces memory consumption by 134 kB (on 64-bit) when loading the
full HTML5 spec.

  • platform/ScrollableArea.h:

(WebCore::ScrollableArea::verticalScrollElasticity):
(WebCore::ScrollableArea::horizontalScrollElasticity):
(WebCore::ScrollableArea::scrollbarOverlayStyle):

Cast the now-bitfield members to the appropriate enum types.

  • rendering/RenderLayer.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::RenderLayer):

Move shouldBeNormalFlowOnly() call out of initializer list since it
depends on m_renderer being initialized.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r97058 r97062  
     12011-10-10  Andreas Kling  <kling@webkit.org>
     2
     3        Shrink RenderLayer and ScrollableArea.
     4        https://bugs.webkit.org/show_bug.cgi?id=69759
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Rearrange the members of RenderLayer and its base class ScrollableArea
     9        to maximize struct packing, shrinking RenderLayer by one CPU word on
     10        32-bit (and two on 64-bit.)
     11
     12        This reduces memory consumption by 134 kB (on 64-bit) when loading the
     13        full HTML5 spec.
     14
     15        * platform/ScrollableArea.h:
     16        (WebCore::ScrollableArea::verticalScrollElasticity):
     17        (WebCore::ScrollableArea::horizontalScrollElasticity):
     18        (WebCore::ScrollableArea::scrollbarOverlayStyle):
     19
     20            Cast the now-bitfield members to the appropriate enum types.
     21
     22        * rendering/RenderLayer.h:
     23        * rendering/RenderLayer.cpp:
     24        (WebCore::RenderLayer::RenderLayer):
     25
     26            Move shouldBeNormalFlowOnly() call out of initializer list since it
     27            depends on m_renderer being initialized.
     28
    1292011-10-10  Cary Clark  <caryclark@google.com>
    230
  • trunk/Source/WebCore/platform/ScrollableArea.h

    r97034 r97062  
    6767
    6868    void setVerticalScrollElasticity(ScrollElasticity scrollElasticity) { m_verticalScrollElasticity = scrollElasticity; }
    69     ScrollElasticity verticalScrollElasticity() const { return m_verticalScrollElasticity; }
     69    ScrollElasticity verticalScrollElasticity() const { return static_cast<ScrollElasticity>(m_verticalScrollElasticity); }
    7070
    7171    void setHorizontalScrollElasticity(ScrollElasticity scrollElasticity) { m_horizontalScrollElasticity = scrollElasticity; }
    72     ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
     72    ScrollElasticity horizontalScrollElasticity() const { return static_cast<ScrollElasticity>(m_horizontalScrollElasticity); }
    7373
    7474    bool inLiveResize() const { return m_inLiveResize; }
     
    8383    bool hasOverlayScrollbars() const;
    8484    virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
    85     ScrollbarOverlayStyle scrollbarOverlayStyle() const { return m_scrollbarOverlayStyle; }
     85    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<ScrollbarOverlayStyle>(m_scrollbarOverlayStyle); }
    8686
    8787    ScrollAnimator* scrollAnimator() const;
     
    165165    // NOTE: Only called from Internals for testing.
    166166    void setScrollOffsetFromInternals(const IntPoint&);
    167 
    168 private:
    169     // NOTE: Only called from the ScrollAnimator.
    170     friend class ScrollAnimator;
    171     void setScrollOffsetFromAnimation(const IntPoint&);
    172 
    173     mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
    174     bool m_constrainsScrollingToContentEdge;
    175 
    176     bool m_inLiveResize;
    177 
    178     ScrollElasticity m_verticalScrollElasticity;
    179     ScrollElasticity m_horizontalScrollElasticity;
    180 
    181     ScrollbarOverlayStyle m_scrollbarOverlayStyle;
    182167
    183168protected:
     
    209194    // vertical-rl / rtl            YES                     YES
    210195    IntPoint m_scrollOrigin;
     196
     197private:
     198    // NOTE: Only called from the ScrollAnimator.
     199    friend class ScrollAnimator;
     200    void setScrollOffsetFromAnimation(const IntPoint&);
     201
     202    mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
     203    bool m_constrainsScrollingToContentEdge : 1;
     204
     205    bool m_inLiveResize : 1;
     206
     207    unsigned m_verticalScrollElasticity : 2; // ScrollElasticity
     208    unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity
     209
     210    unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
    211211};
    212212
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r96786 r97062  
    130130
    131131RenderLayer::RenderLayer(RenderBoxModelObject* renderer)
    132     : m_renderer(renderer)
    133     , m_parent(0)
    134     , m_previous(0)
    135     , m_next(0)
    136     , m_first(0)
    137     , m_last(0)
    138     , m_posZOrderList(0)
    139     , m_negZOrderList(0)
    140     , m_normalFlowList(0)
    141     , m_clipRects(0)
    142 #ifndef NDEBUG   
    143     , m_clipRectsRoot(0)
    144 #endif
    145     , m_inResizeMode(false)
     132    : m_inResizeMode(false)
    146133    , m_scrollDimensionsDirty(true)
    147134    , m_zOrderListsDirty(true)
    148135    , m_normalFlowListDirty(true)
    149     , m_isNormalFlowOnly(shouldBeNormalFlowOnly())
    150136    , m_usedTransparency(false)
    151137    , m_paintingInsideReflection(false)
     
    165151#endif
    166152    , m_containsDirtyOverlayScrollbars(false)
     153    , m_renderer(renderer)
     154    , m_parent(0)
     155    , m_previous(0)
     156    , m_next(0)
     157    , m_first(0)
     158    , m_last(0)
     159    , m_posZOrderList(0)
     160    , m_negZOrderList(0)
     161    , m_normalFlowList(0)
     162    , m_clipRects(0)
     163#ifndef NDEBUG
     164    , m_clipRectsRoot(0)
     165#endif
    167166    , m_marquee(0)
    168167    , m_staticInlinePosition(0)
     
    173172    , m_scrollableAreaPage(0)
    174173{
     174    m_isNormalFlowOnly = shouldBeNormalFlowOnly();
     175
    175176    ScrollableArea::setConstrainsScrollingToContentEdge(false);
    176177
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r96620 r97062  
    698698
    699699protected:
    700     RenderBoxModelObject* m_renderer;
    701 
    702     RenderLayer* m_parent;
    703     RenderLayer* m_previous;
    704     RenderLayer* m_next;
    705     RenderLayer* m_first;
    706     RenderLayer* m_last;
    707 
    708     LayoutRect m_repaintRect; // Cached repaint rects. Used by layout.
    709     LayoutRect m_outlineBox;
    710 
    711     // Our current relative position offset.
    712     LayoutSize m_relativeOffset;
    713 
    714     // Our (x,y) coordinates are in our parent layer's coordinate space.
    715     LayoutPoint m_topLeft;
    716 
    717     // The layer's width/height
    718     LayoutSize m_layerSize;
    719 
    720     // Our scroll offsets if the view is scrolled.
    721     LayoutSize m_scrollOffset;
    722 
    723     LayoutSize m_scrollOverflow;
    724    
    725     // The width/height of our scrolled area.
    726     LayoutSize m_scrollSize;
    727 
    728     // For layers with overflow, we have a pair of scrollbars.
    729     RefPtr<Scrollbar> m_hBar;
    730     RefPtr<Scrollbar> m_vBar;
    731 
    732     // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
    733     // descendant layers within the stacking context that have z-indices of 0 or greater
    734     // (auto will count as 0).  m_negZOrderList holds descendants within our stacking context with negative
    735     // z-indices.
    736     Vector<RenderLayer*>* m_posZOrderList;
    737     Vector<RenderLayer*>* m_negZOrderList;
    738 
    739     // This list contains child layers that cannot create stacking contexts.  For now it is just
    740     // overflow layers, but that may change in the future.
    741     Vector<RenderLayer*>* m_normalFlowList;
    742 
    743     ClipRects* m_clipRects;      // Cached clip rects used when painting and hit testing.
    744 #ifndef NDEBUG
    745     const RenderLayer* m_clipRectsRoot;   // Root layer used to compute clip rects.
    746 #endif
     700    // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
    747701
    748702    // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
     
    781735    bool m_containsDirtyOverlayScrollbars : 1;
    782736
     737    RenderBoxModelObject* m_renderer;
     738
     739    RenderLayer* m_parent;
     740    RenderLayer* m_previous;
     741    RenderLayer* m_next;
     742    RenderLayer* m_first;
     743    RenderLayer* m_last;
     744
     745    LayoutRect m_repaintRect; // Cached repaint rects. Used by layout.
     746    LayoutRect m_outlineBox;
     747
     748    // Our current relative position offset.
     749    LayoutSize m_relativeOffset;
     750
     751    // Our (x,y) coordinates are in our parent layer's coordinate space.
     752    LayoutPoint m_topLeft;
     753
     754    // The layer's width/height
     755    LayoutSize m_layerSize;
     756
     757    // Our scroll offsets if the view is scrolled.
     758    LayoutSize m_scrollOffset;
     759
     760    LayoutSize m_scrollOverflow;
     761   
     762    // The width/height of our scrolled area.
     763    LayoutSize m_scrollSize;
     764
     765    // For layers with overflow, we have a pair of scrollbars.
     766    RefPtr<Scrollbar> m_hBar;
     767    RefPtr<Scrollbar> m_vBar;
     768
     769    // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
     770    // descendant layers within the stacking context that have z-indices of 0 or greater
     771    // (auto will count as 0).  m_negZOrderList holds descendants within our stacking context with negative
     772    // z-indices.
     773    Vector<RenderLayer*>* m_posZOrderList;
     774    Vector<RenderLayer*>* m_negZOrderList;
     775
     776    // This list contains child layers that cannot create stacking contexts.  For now it is just
     777    // overflow layers, but that may change in the future.
     778    Vector<RenderLayer*>* m_normalFlowList;
     779
     780    ClipRects* m_clipRects;      // Cached clip rects used when painting and hit testing.
     781#ifndef NDEBUG
     782    const RenderLayer* m_clipRectsRoot;   // Root layer used to compute clip rects.
     783#endif
     784
    783785    LayoutPoint m_cachedOverlayScrollbarOffset;
    784786
Note: See TracChangeset for help on using the changeset viewer.