2009-02-10 David Hyatt <hyatt@apple.com>
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Feb 2009 19:50:00 +0000 (19:50 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Feb 2009 19:50:00 +0000 (19:50 +0000)
        Shrink the size of all replaced elements (images, form controls, plugins) by 4 bytes by packing the
        overflow boolean into the RenderObject base class.

        Reviewed by Sam Weinig

        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::RenderObject):
        * rendering/RenderObject.h:
        (WebCore::RenderObject::replacedHasOverflow):
        (WebCore::RenderObject::setReplacedHasOverflow):
        * rendering/RenderReplaced.cpp:
        (WebCore::RenderReplaced::RenderReplaced):
        (WebCore::RenderReplaced::~RenderReplaced):
        (WebCore::RenderReplaced::adjustOverflowForBoxShadow):
        (WebCore::RenderReplaced::overflowHeight):
        (WebCore::RenderReplaced::overflowWidth):
        (WebCore::RenderReplaced::overflowLeft):
        (WebCore::RenderReplaced::overflowTop):
        (WebCore::RenderReplaced::overflowRect):
        * rendering/RenderReplaced.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40829 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderObject.h
WebCore/rendering/RenderReplaced.cpp
WebCore/rendering/RenderReplaced.h

index 17080b8..3e91c4b 100644 (file)
@@ -1,3 +1,26 @@
+2009-02-10  David Hyatt  <hyatt@apple.com>
+
+        Shrink the size of all replaced elements (images, form controls, plugins) by 4 bytes by packing the
+        overflow boolean into the RenderObject base class.
+
+        Reviewed by Sam Weinig
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::RenderObject):
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::replacedHasOverflow):
+        (WebCore::RenderObject::setReplacedHasOverflow):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::RenderReplaced):
+        (WebCore::RenderReplaced::~RenderReplaced):
+        (WebCore::RenderReplaced::adjustOverflowForBoxShadow):
+        (WebCore::RenderReplaced::overflowHeight):
+        (WebCore::RenderReplaced::overflowWidth):
+        (WebCore::RenderReplaced::overflowLeft):
+        (WebCore::RenderReplaced::overflowTop):
+        (WebCore::RenderReplaced::overflowRect):
+        * rendering/RenderReplaced.h:
+
 2009-02-10  Eric Carlson  <eric.carlson@apple.com>
 
         Reviewed by Simon Fraser.
index 6cadc9d..de2018b 100644 (file)
@@ -191,6 +191,7 @@ RenderObject::RenderObject(Node* node)
     , m_selectionState(SelectionNone)
     , m_hasColumns(false)
     , m_cellWidthChanged(false)
+    , m_replacedHasOverflow(false)
 {
 #ifndef NDEBUG
     renderObjectCounter.increment();
index 7b16da5..1f9e7df 100644 (file)
@@ -759,6 +759,9 @@ public:
         return outlineBoundsForRepaint(0);
     }
 
+    bool replacedHasOverflow() const { return m_replacedHasOverflow; }
+    void setReplacedHasOverflow(bool b = true) { m_replacedHasOverflow = b; }
+    
 protected:
     // Overrides should call the superclass at the end
     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
@@ -827,8 +830,7 @@ private:
 #endif
     mutable int m_verticalPosition;
 
-    // 31 bits have been used here.  Count the bits before you add any and update the comment
-    // with the new total.
+    // 32 bits have been used here. THERE ARE NO FREE BITS AVAILABLE.
     bool m_needsLayout               : 1;
     bool m_needsPositionedMovementLayout :1;
     bool m_normalChildNeedsLayout    : 1;
@@ -872,6 +874,9 @@ private:
     // from RenderTableCell
     bool m_cellWidthChanged : 1;
 
+    // from RenderReplaced
+    bool m_replacedHasOverflow : 1;
+
 private:
     // Store state between styleWillChange and styleDidChange
     static bool s_affectsParentBlock;
index 486f701..d7a725d 100644 (file)
@@ -42,7 +42,6 @@ const int cDefaultHeight = 150;
 RenderReplaced::RenderReplaced(Node* node)
     : RenderBox(node)
     , m_intrinsicSize(cDefaultWidth, cDefaultHeight)
-    , m_hasOverflow(false)
 {
     setReplaced(true);
 }
@@ -50,14 +49,13 @@ RenderReplaced::RenderReplaced(Node* node)
 RenderReplaced::RenderReplaced(Node* node, const IntSize& intrinsicSize)
     : RenderBox(node)
     , m_intrinsicSize(intrinsicSize)
-    , m_hasOverflow(false)
 {
     setReplaced(true);
 }
 
 RenderReplaced::~RenderReplaced()
 {
-    if (m_hasOverflow)
+    if (replacedHasOverflow())
         gOverflowRectMap->remove(this);
 }
 
@@ -327,16 +325,16 @@ void RenderReplaced::adjustOverflowForBoxShadow()
             gOverflowRectMap = new OverflowRectMap();
         overflow.unite(borderBoxRect());
         gOverflowRectMap->set(this, overflow);
-        m_hasOverflow = true;
-    } else if (m_hasOverflow) {
+        setReplacedHasOverflow(true);
+    } else if (replacedHasOverflow()) {
         gOverflowRectMap->remove(this);
-        m_hasOverflow = false;
+        setReplacedHasOverflow(false);
     }
 }
 
 int RenderReplaced::overflowHeight(bool) const
 {
-    if (m_hasOverflow) {
+    if (replacedHasOverflow()) {
         IntRect *r = &gOverflowRectMap->find(this)->second;
         return r->height() + r->y();
     }
@@ -346,7 +344,7 @@ int RenderReplaced::overflowHeight(bool) const
 
 int RenderReplaced::overflowWidth(bool) const
 {
-    if (m_hasOverflow) {
+    if (replacedHasOverflow()) {
         IntRect *r = &gOverflowRectMap->find(this)->second;
         return r->width() + r->x();
     }
@@ -356,7 +354,7 @@ int RenderReplaced::overflowWidth(bool) const
 
 int RenderReplaced::overflowLeft(bool) const
 {
-    if (m_hasOverflow)
+    if (replacedHasOverflow())
         return gOverflowRectMap->get(this).x();
 
     return 0;
@@ -364,7 +362,7 @@ int RenderReplaced::overflowLeft(bool) const
 
 int RenderReplaced::overflowTop(bool) const
 {
-    if (m_hasOverflow)
+    if (replacedHasOverflow())
         return gOverflowRectMap->get(this).y();
 
     return 0;
@@ -372,7 +370,7 @@ int RenderReplaced::overflowTop(bool) const
 
 IntRect RenderReplaced::overflowRect(bool) const
 {
-    if (m_hasOverflow)
+    if (replacedHasOverflow())
         return gOverflowRectMap->find(this)->second;
 
     return borderBoxRect();
index 334784d..f3cfd13 100644 (file)
@@ -78,7 +78,6 @@ protected:
 
 private:
     IntSize m_intrinsicSize;
-    bool m_hasOverflow;
 };
 
 }