<rdar://problem/9313186> Make the fix for <rdar://problem/9190108> more robust.
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 May 2011 02:20:02 +0000 (02:20 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 May 2011 02:20:02 +0000 (02:20 +0000)
Reviewed by Darin Adler.

Added a pointer from FloatingObject to its originating line, if there is one, and made sure to
dirty the line when the float is removed, instead of relying on the float always intersecting
its originating line.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::removeFloatingObject):
(WebCore::RenderBlock::removeFloatingObjectsBelow):
(WebCore::RenderBlock::clearFloats):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatingObject::FloatingObject):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::appendFloatingObjectToLastLine):
(WebCore::RenderBlock::layoutRunsAndFloats):
(WebCore::RenderBlock::determineStartPosition):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index 9ba2c382784ea19be364b3fc3ce4d76e437348cb..9c681ded4e7efbff8247baa6c65e459eb69b0255 100644 (file)
@@ -1,3 +1,24 @@
+2011-05-03  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/9313186> Make the fix for <rdar://problem/9190108> more robust.
+
+        Added a pointer from FloatingObject to its originating line, if there is one, and made sure to
+        dirty the line when the float is removed, instead of relying on the float always intersecting
+        its originating line.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::removeFloatingObject):
+        (WebCore::RenderBlock::removeFloatingObjectsBelow):
+        (WebCore::RenderBlock::clearFloats):
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::FloatingObject::FloatingObject):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlock::appendFloatingObjectToLastLine):
+        (WebCore::RenderBlock::layoutRunsAndFloats):
+        (WebCore::RenderBlock::determineStartPosition):
+
 2011-05-02  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Adam Roben.
index 118235a0f465950b10a27033e84678108471945e..965036b36d7cb3aea4c7e6386b72ae69b27d2a5c 100644 (file)
@@ -3163,10 +3163,18 @@ void RenderBlock::removeFloatingObject(RenderBox* o)
                     // accomplished by pretending they have a height of 1.
                     logicalBottom = max(logicalBottom, logicalTop + 1);
                 }
+                if (r->m_originatingLine) {
+                    ASSERT(r->m_originatingLine->renderer() == this);
+                    r->m_originatingLine->markDirty();
+#if !ASSERT_DISABLED
+                    r->m_originatingLine = 0;
+#endif
+                }
                 markLinesDirtyInBlockRange(0, logicalBottom);
             }
             m_floatingObjects->decreaseObjectsCount(r->type());
             floatingObjectSet.remove(it);
+            ASSERT(!r->m_originatingLine);
             delete r;
         }
     }
@@ -3182,6 +3190,7 @@ void RenderBlock::removeFloatingObjectsBelow(FloatingObject* lastFloat, int logi
     while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) >= logicalOffset)) {
         m_floatingObjects->decreaseObjectsCount(curr->type());
         floatingObjectSet.removeLast();
+        ASSERT(!curr->m_originatingLine);
         delete curr;
         curr = floatingObjectSet.last();
     }
@@ -3619,6 +3628,10 @@ void RenderBlock::clearFloats()
                     }
 
                     floatMap.remove(f->m_renderer);
+                    if (oldFloatingObject->m_originatingLine) {
+                        ASSERT(oldFloatingObject->m_originatingLine->renderer() == this);
+                        oldFloatingObject->m_originatingLine->markDirty();
+                    }
                     delete oldFloatingObject;
                 } else {
                     changeLogicalTop = 0;
index 940cff6f1b59be6993ef3c6b89a17e76e93cd858..fdfbe81b5f97385c718ed9d6b5eff7e0d9f0faa6 100644 (file)
@@ -389,6 +389,7 @@ private:
 
         FloatingObject(Type type)
             : m_renderer(0)
+            , m_originatingLine(0)
             , m_paginationStrut(0)
             , m_type(type)
             , m_shouldPaint(true)
@@ -399,6 +400,7 @@ private:
 
         FloatingObject(Type type, const IntRect& frameRect)
             : m_renderer(0)
+            , m_originatingLine(0)
             , m_frameRect(frameRect)
             , m_paginationStrut(0)
             , m_type(type)
@@ -430,6 +432,7 @@ private:
         void setFrameRect(const IntRect& frameRect) { m_frameRect = frameRect; }
 
         RenderBox* m_renderer;
+        RootInlineBox* m_originatingLine;
         IntRect m_frameRect;
         int m_paginationStrut;
         unsigned m_type : 2; // Type (left or right aligned)
index 9e8de3481206d4ad64dfb57dace00f77f61dca35..b8d6edbd2a5d03b794115fecbc9eb6bbe60cde23 100644 (file)
@@ -757,12 +757,8 @@ inline BidiRun* RenderBlock::handleTrailingSpaces(BidiRunList<BidiRun>& bidiRuns
 
 void RenderBlock::appendFloatingObjectToLastLine(FloatingObject* floatingObject)
 {
-    // Ensure that the float touches the line.
-    if (RootInlineBox* previousLine = lastRootBox()->prevRootBox()) {
-        if (logicalBottomForFloat(floatingObject) < previousLine->blockLogicalHeight())
-            setLogicalHeightForFloat(floatingObject, previousLine->blockLogicalHeight() - logicalTopForFloat(floatingObject));
-    }
-
+    ASSERT(!floatingObject->m_originatingLine);
+    floatingObject->m_originatingLine = lastRootBox();
     lastRootBox()->appendFloat(floatingObject->renderer());
 }
 
@@ -1024,7 +1020,9 @@ void RenderBlock::layoutRunsAndFloats(bool fullLayout, bool hasInlineChild, Vect
                 if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) {
                     Vector<RenderBox*>::iterator end = cleanLineFloats->end();
                     for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
-                        insertFloatingObject(*f);
+                        FloatingObject* floatingObject = insertFloatingObject(*f);
+                        ASSERT(!floatingObject->m_originatingLine);
+                        floatingObject->m_originatingLine = line;
                         setLogicalHeight(logicalTopForChild(*f) - marginBeforeForChild(*f) + delta);
                         positionNewFloats();
                     }
@@ -1291,7 +1289,9 @@ RootInlineBox* RenderBlock::determineStartPosition(LineInfo& lineInfo, bool& ful
             if (Vector<RenderBox*>* cleanLineFloats = line->floatsPtr()) {
                 Vector<RenderBox*>::iterator end = cleanLineFloats->end();
                 for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
-                    insertFloatingObject(*f);
+                    FloatingObject* floatingObject = insertFloatingObject(*f);
+                    ASSERT(!floatingObject->m_originatingLine);
+                    floatingObject->m_originatingLine = line;
                     setLogicalHeight(logicalTopForChild(*f) - marginBeforeForChild(*f));
                     positionNewFloats();
                     ASSERT(floats[numCleanFloats].object == *f);