Title: [97062] trunk/Source/WebCore
Revision
97062
Author
[email protected]
Date
2011-10-10 07:51:44 -0700 (Mon, 10 Oct 2011)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97061 => 97062)


--- trunk/Source/WebCore/ChangeLog	2011-10-10 14:47:07 UTC (rev 97061)
+++ trunk/Source/WebCore/ChangeLog	2011-10-10 14:51:44 UTC (rev 97062)
@@ -1,3 +1,31 @@
+2011-10-10  Andreas Kling  <[email protected]>
+
+        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.
+
 2011-10-10  Cary Clark  <[email protected]>
 
         [Skia on Chromium Mac] Set canExpandAroundIdeographsInComplexText to true

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (97061 => 97062)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2011-10-10 14:47:07 UTC (rev 97061)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2011-10-10 14:51:44 UTC (rev 97062)
@@ -66,10 +66,10 @@
     void setConstrainsScrollingToContentEdge(bool constrainsScrollingToContentEdge) { m_constrainsScrollingToContentEdge = constrainsScrollingToContentEdge; }
 
     void setVerticalScrollElasticity(ScrollElasticity scrollElasticity) { m_verticalScrollElasticity = scrollElasticity; }
-    ScrollElasticity verticalScrollElasticity() const { return m_verticalScrollElasticity; }
+    ScrollElasticity verticalScrollElasticity() const { return static_cast<ScrollElasticity>(m_verticalScrollElasticity); }
 
     void setHorizontalScrollElasticity(ScrollElasticity scrollElasticity) { m_horizontalScrollElasticity = scrollElasticity; }
-    ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
+    ScrollElasticity horizontalScrollElasticity() const { return static_cast<ScrollElasticity>(m_horizontalScrollElasticity); }
 
     bool inLiveResize() const { return m_inLiveResize; }
     void willStartLiveResize();
@@ -82,7 +82,7 @@
 
     bool hasOverlayScrollbars() const;
     virtual void setScrollbarOverlayStyle(ScrollbarOverlayStyle);
-    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return m_scrollbarOverlayStyle; }
+    ScrollbarOverlayStyle scrollbarOverlayStyle() const { return static_cast<ScrollbarOverlayStyle>(m_scrollbarOverlayStyle); }
 
     ScrollAnimator* scrollAnimator() const;
     const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
@@ -165,21 +165,6 @@
     // NOTE: Only called from Internals for testing.
     void setScrollOffsetFromInternals(const IntPoint&);
 
-private:
-    // NOTE: Only called from the ScrollAnimator.
-    friend class ScrollAnimator;
-    void setScrollOffsetFromAnimation(const IntPoint&);
-
-    mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
-    bool m_constrainsScrollingToContentEdge;
-
-    bool m_inLiveResize;
-
-    ScrollElasticity m_verticalScrollElasticity;
-    ScrollElasticity m_horizontalScrollElasticity;
-
-    ScrollbarOverlayStyle m_scrollbarOverlayStyle;
-
 protected:
     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
     virtual void invalidateScrollCornerRect(const IntRect&) = 0;
@@ -208,6 +193,21 @@
     // vertical-rl / ltr            YES                     NO
     // vertical-rl / rtl            YES                     YES
     IntPoint m_scrollOrigin;
+
+private:
+    // NOTE: Only called from the ScrollAnimator.
+    friend class ScrollAnimator;
+    void setScrollOffsetFromAnimation(const IntPoint&);
+
+    mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
+    bool m_constrainsScrollingToContentEdge : 1;
+
+    bool m_inLiveResize : 1;
+
+    unsigned m_verticalScrollElasticity : 2; // ScrollElasticity
+    unsigned m_horizontalScrollElasticity : 2; // ScrollElasticity
+
+    unsigned m_scrollbarOverlayStyle : 2; // ScrollbarOverlayStyle
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (97061 => 97062)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-10-10 14:47:07 UTC (rev 97061)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-10-10 14:51:44 UTC (rev 97062)
@@ -129,24 +129,10 @@
 }
 
 RenderLayer::RenderLayer(RenderBoxModelObject* renderer)
-    : m_renderer(renderer)
-    , m_parent(0)
-    , m_previous(0)
-    , m_next(0)
-    , m_first(0)
-    , m_last(0)
-    , m_posZOrderList(0)
-    , m_negZOrderList(0)
-    , m_normalFlowList(0)
-    , m_clipRects(0) 
-#ifndef NDEBUG    
-    , m_clipRectsRoot(0)
-#endif
-    , m_inResizeMode(false)
+    : m_inResizeMode(false)
     , m_scrollDimensionsDirty(true)
     , m_zOrderListsDirty(true)
     , m_normalFlowListDirty(true)
-    , m_isNormalFlowOnly(shouldBeNormalFlowOnly())
     , m_usedTransparency(false)
     , m_paintingInsideReflection(false)
     , m_inOverflowRelayout(false)
@@ -164,6 +150,19 @@
     , m_mustOverlapCompositedLayers(false)
 #endif
     , m_containsDirtyOverlayScrollbars(false)
+    , m_renderer(renderer)
+    , m_parent(0)
+    , m_previous(0)
+    , m_next(0)
+    , m_first(0)
+    , m_last(0)
+    , m_posZOrderList(0)
+    , m_negZOrderList(0)
+    , m_normalFlowList(0)
+    , m_clipRects(0)
+#ifndef NDEBUG
+    , m_clipRectsRoot(0)
+#endif
     , m_marquee(0)
     , m_staticInlinePosition(0)
     , m_staticBlockPosition(0)
@@ -172,6 +171,8 @@
     , m_resizer(0)
     , m_scrollableAreaPage(0)
 {
+    m_isNormalFlowOnly = shouldBeNormalFlowOnly();
+
     ScrollableArea::setConstrainsScrollingToContentEdge(false);
 
     if (!renderer->firstChild() && renderer->style()) {

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (97061 => 97062)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2011-10-10 14:47:07 UTC (rev 97061)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2011-10-10 14:51:44 UTC (rev 97062)
@@ -697,6 +697,43 @@
     }
 
 protected:
+    // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
+
+    // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
+    bool m_inResizeMode : 1;
+
+    bool m_scrollDimensionsDirty : 1;
+    bool m_zOrderListsDirty : 1;
+    bool m_normalFlowListDirty: 1;
+    bool m_isNormalFlowOnly : 1;
+
+    bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
+                                 // we ended up painting this layer or any descendants (and therefore need to
+                                 // blend).
+    bool m_paintingInsideReflection : 1;  // A state bit tracking if we are painting inside a replica.
+    bool m_inOverflowRelayout : 1;
+    bool m_needsFullRepaint : 1;
+
+    bool m_overflowStatusDirty : 1;
+    bool m_horizontalOverflow : 1;
+    bool m_verticalOverflow : 1;
+    bool m_visibleContentStatusDirty : 1;
+    bool m_hasVisibleContent : 1;
+    bool m_visibleDescendantStatusDirty : 1;
+    bool m_hasVisibleDescendant : 1;
+
+    bool m_isPaginated : 1; // If we think this layer is split by a multi-column ancestor, then this bit will be set.
+
+    bool m_3DTransformedDescendantStatusDirty : 1;
+    bool m_has3DTransformedDescendant : 1;  // Set on a stacking context layer that has 3D descendants anywhere
+                                            // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
+#if USE(ACCELERATED_COMPOSITING)
+    bool m_hasCompositingDescendant : 1; // In the z-order tree.
+    bool m_mustOverlapCompositedLayers : 1;
+#endif
+
+    bool m_containsDirtyOverlayScrollbars : 1;
+
     RenderBoxModelObject* m_renderer;
 
     RenderLayer* m_parent;
@@ -745,41 +782,6 @@
     const RenderLayer* m_clipRectsRoot;   // Root layer used to compute clip rects.
 #endif
 
-    // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
-    bool m_inResizeMode : 1;
-
-    bool m_scrollDimensionsDirty : 1;
-    bool m_zOrderListsDirty : 1;
-    bool m_normalFlowListDirty: 1;
-    bool m_isNormalFlowOnly : 1;
-
-    bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
-                                 // we ended up painting this layer or any descendants (and therefore need to
-                                 // blend).
-    bool m_paintingInsideReflection : 1;  // A state bit tracking if we are painting inside a replica.
-    bool m_inOverflowRelayout : 1;
-    bool m_needsFullRepaint : 1;
-
-    bool m_overflowStatusDirty : 1;
-    bool m_horizontalOverflow : 1;
-    bool m_verticalOverflow : 1;
-    bool m_visibleContentStatusDirty : 1;
-    bool m_hasVisibleContent : 1;
-    bool m_visibleDescendantStatusDirty : 1;
-    bool m_hasVisibleDescendant : 1;
-
-    bool m_isPaginated : 1; // If we think this layer is split by a multi-column ancestor, then this bit will be set.
-
-    bool m_3DTransformedDescendantStatusDirty : 1;
-    bool m_has3DTransformedDescendant : 1;  // Set on a stacking context layer that has 3D descendants anywhere
-                                            // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
-#if USE(ACCELERATED_COMPOSITING)
-    bool m_hasCompositingDescendant : 1; // In the z-order tree.
-    bool m_mustOverlapCompositedLayers : 1;
-#endif
-
-    bool m_containsDirtyOverlayScrollbars : 1;
-
     LayoutPoint m_cachedOverlayScrollbarOffset;
 
     RenderMarquee* m_marquee; // Used by layers with overflow:marquee
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to