https://bugs.webkit.org/show_bug.cgi?id=47100
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2010 19:05:25 +0000 (19:05 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2010 19:05:25 +0000 (19:05 +0000)
Reviewed by Dan Bernstein.

Convert clearFloats() to be block-flow-aware.  Helpers that it calls have not been patched though.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::clearFloats):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::logicalTopForFloat):
(WebCore::RenderBlock::logicalLeftForFloat):
(WebCore::RenderBlock::logicalWidthForFloat):

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

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

index 7356289..62c6c92 100644 (file)
@@ -1,3 +1,18 @@
+2010-10-04  David Hyatt  <hyatt@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=47100
+
+        Convert clearFloats() to be block-flow-aware.  Helpers that it calls have not been patched though.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::clearFloats):
+        * rendering/RenderBlock.h:
+        (WebCore::RenderBlock::logicalTopForFloat):
+        (WebCore::RenderBlock::logicalLeftForFloat):
+        (WebCore::RenderBlock::logicalWidthForFloat):
+
 2010-10-04  Diego Gonzalez  <diegohcg@webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
index f49c598..0314e54 100644 (file)
@@ -3634,6 +3634,7 @@ void RenderBlock::clearFloats()
     // out of flow (like floating/positioned elements), and we also skip over any objects that may have shifted
     // to avoid floats.
     bool parentHasFloats = false;
+    RenderBlock* parentBlock = toRenderBlock(parent());
     RenderObject* prev = previousSibling();
     while (prev && (prev->isFloatingOrPositioned() || !prev->isBox() || !prev->isRenderBlock() || toRenderBlock(prev)->avoidsFloats())) {
         if (prev->isFloating())
@@ -3642,18 +3643,16 @@ void RenderBlock::clearFloats()
     }
 
     // First add in floats from the parent.
-    int offset = y();
-    if (parentHasFloats) {
-        RenderBlock* parentBlock = toRenderBlock(parent());
-        addIntrudingFloats(parentBlock, parentBlock->borderLeft() + parentBlock->paddingLeft(), offset);
-    }
+    int logicalTopOffset = logicalTop();
+    if (parentHasFloats)
+        addIntrudingFloats(parentBlock, parentBlock->logicalLeftOffsetForContent(), logicalTopOffset);
     
-    int xoffset = 0;
+    int logicalLeftOffset = 0;
     if (prev)
-        offset -= toRenderBox(prev)->y();
-    else if (parent()->isBox()) {
-        prev = parent();
-        xoffset += toRenderBox(prev)->borderLeft() + toRenderBox(prev)->paddingLeft();
+        logicalTopOffset -= toRenderBox(prev)->logicalTop();
+    else {
+        prev = parentBlock;
+        logicalLeftOffset += parentBlock->logicalLeftOffsetForContent();
     }
 
     // Add overhanging floats from the previous RenderBlock, but only if it has a float that intrudes into our space.
@@ -3661,29 +3660,31 @@ void RenderBlock::clearFloats()
         return;
     
     RenderBlock* block = toRenderBlock(prev);
-    if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > offset)
-        addIntrudingFloats(block, xoffset, offset);
+    if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > logicalTopOffset)
+        addIntrudingFloats(block, logicalLeftOffset, logicalTopOffset);
 
     if (childrenInline()) {
-        int changeTop = numeric_limits<int>::max();
-        int changeBottom = numeric_limits<int>::min();
+        int changeLogicalTop = numeric_limits<int>::max();
+        int changeLogicalBottom = numeric_limits<int>::min();
         if (m_floatingObjects) {
             for (FloatingObject* f = m_floatingObjects->first(); f; f = m_floatingObjects->next()) {
                 FloatingObject* oldFloatingObject = floatMap.get(f->m_renderer);
+                int logicalBottom = logicalBottomForFloat(f);
                 if (oldFloatingObject) {
-                    if (f->width() != oldFloatingObject->width() || f->left() != oldFloatingObject->left()) {
-                        changeTop = 0;
-                        changeBottom = max(changeBottom, max(f->bottom(), oldFloatingObject->bottom()));
-                    } else if (f->bottom() != oldFloatingObject->bottom()) {
-                        changeTop = min(changeTop, min(f->bottom(), oldFloatingObject->bottom()));
-                        changeBottom = max(changeBottom, max(f->bottom(), oldFloatingObject->bottom()));
+                    int oldLogicalBottom = logicalBottomForFloat(oldFloatingObject);
+                    if (logicalWidthForFloat(f) != logicalWidthForFloat(oldFloatingObject) || logicalLeftForFloat(f) != logicalLeftForFloat(oldFloatingObject)) {
+                        changeLogicalTop = 0;
+                        changeLogicalBottom = max(changeLogicalBottom, max(logicalBottom, oldLogicalBottom));
+                    } else if (logicalBottom != oldLogicalBottom) {
+                        changeLogicalTop = min(changeLogicalTop, min(logicalBottom, oldLogicalBottom));
+                        changeLogicalBottom = max(changeLogicalBottom, max(logicalBottom, oldLogicalBottom));
                     }
 
                     floatMap.remove(f->m_renderer);
                     delete oldFloatingObject;
                 } else {
-                    changeTop = 0;
-                    changeBottom = max(changeBottom, f->bottom());
+                    changeLogicalTop = 0;
+                    changeLogicalBottom = max(changeLogicalBottom, logicalBottom);
                 }
             }
         }
@@ -3692,13 +3693,13 @@ void RenderBlock::clearFloats()
         for (RendererToFloatInfoMap::iterator it = floatMap.begin(); it != end; ++it) {
             FloatingObject* floatingObject = (*it).second;
             if (!floatingObject->m_isDescendant) {
-                changeTop = 0;
-                changeBottom = max(changeBottom, floatingObject->bottom());
+                changeLogicalTop = 0;
+                changeLogicalBottom = max(changeLogicalBottom, logicalBottomForFloat(floatingObject));
             }
         }
         deleteAllValues(floatMap);
 
-        markLinesDirtyInVerticalRange(changeTop, changeBottom);
+        markLinesDirtyInVerticalRange(changeLogicalTop, changeLogicalBottom);
     }
 }
 
index 6430218..ab89de3 100644 (file)
@@ -397,7 +397,10 @@ private:
         bool m_isDescendant : 1;
     };
 
+    int logicalTopForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->top() : child->left(); }
     int logicalBottomForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->bottom() : child->right(); }
+    int logicalLeftForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->left() : child->top(); }
+    int logicalWidthForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->width() : child->height(); }
     
     // The following functions' implementations are in RenderBlockLineLayout.cpp.
     RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly,