2009-01-23 David Hyatt <hyatt@apple.com>
[WebKit-https.git] / WebCore / rendering / RenderBlock.cpp
index 14d41b1..77489c7 100644 (file)
@@ -152,6 +152,29 @@ RenderBlock::~RenderBlock()
 void RenderBlock::styleWillChange(RenderStyle::Diff diff, const RenderStyle* newStyle)
 {
     setReplaced(newStyle->isDisplayReplacedType());
+    
+    if (style() && parent() && diff == RenderStyle::Layout && style()->position() != newStyle->position()) {
+        if (newStyle->position() == StaticPosition)
+            // Clear our positioned objects list. Our absolutely positioned descendants will be
+            // inserted into our containing block's positioned objects list during layout.
+            removePositionedObjects(0);
+        else if (style()->position() == StaticPosition) {
+            // Remove our absolutely positioned descendants from their current containing block.
+            // They will be inserted into our positioned objects list during layout.
+            RenderObject* cb = parent();
+            while (cb && (cb->style()->position() == StaticPosition || (cb->isInline() && !cb->isReplaced())) && !cb->isRenderView()) {
+                if (cb->style()->position() == RelativePosition && cb->isInline() && !cb->isReplaced()) {
+                    cb = cb->containingBlock();
+                    break;
+                }
+                cb = cb->parent();
+            }
+            
+            if (cb->isRenderBlock())
+                static_cast<RenderBlock*>(cb)->removePositionedObjects(this);
+        }
+    }
+
     RenderFlow::styleWillChange(diff, newStyle);
 }