[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
hyatt at apple.com
hyatt at apple.com
Wed Dec 22 14:10:29 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 611733c18207eff07a6afe841f73489c2fe98053
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 5 06:13:38 2010 +0000
https://bugs.webkit.org/show_bug.cgi?id=47112
Reviewed by Dan Bernstein.
Convert addOverhangingFloats and addIntrudingFloats to be block-flow-aware.
Also clean up how floats are placed to use a bit instead of the magic -1 value on top().
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::layoutBlock):
(WebCore::RenderBlock::layoutBlockChild):
(WebCore::RenderBlock::insertFloatingObject):
(WebCore::RenderBlock::removeFloatingObject):
(WebCore::RenderBlock::removeFloatingObjectsBelow):
(WebCore::RenderBlock::positionNewFloats):
(WebCore::RenderBlock::markLinesDirtyInBlockRange):
(WebCore::RenderBlock::clearFloats):
(WebCore::RenderBlock::addOverhangingFloats):
(WebCore::RenderBlock::addIntrudingFloats):
* rendering/RenderBlock.h:
(WebCore::RenderBlock::FloatingObject::FloatingObject):
(WebCore::RenderBlock::FloatingObject::isPlaced):
(WebCore::RenderBlock::FloatingObject::setIsPlaced):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::determineStartPosition):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 0f057f8..3bec9bb 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-10-04 David Hyatt <hyatt at apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ https://bugs.webkit.org/show_bug.cgi?id=47112
+
+ Convert addOverhangingFloats and addIntrudingFloats to be block-flow-aware.
+
+ Also clean up how floats are placed to use a bit instead of the magic -1 value on top().
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::layoutBlock):
+ (WebCore::RenderBlock::layoutBlockChild):
+ (WebCore::RenderBlock::insertFloatingObject):
+ (WebCore::RenderBlock::removeFloatingObject):
+ (WebCore::RenderBlock::removeFloatingObjectsBelow):
+ (WebCore::RenderBlock::positionNewFloats):
+ (WebCore::RenderBlock::markLinesDirtyInBlockRange):
+ (WebCore::RenderBlock::clearFloats):
+ (WebCore::RenderBlock::addOverhangingFloats):
+ (WebCore::RenderBlock::addIntrudingFloats):
+ * rendering/RenderBlock.h:
+ (WebCore::RenderBlock::FloatingObject::FloatingObject):
+ (WebCore::RenderBlock::FloatingObject::isPlaced):
+ (WebCore::RenderBlock::FloatingObject::setIsPlaced):
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlock::determineStartPosition):
+
2010-10-04 Nico Weber <thakis at chromium.org>
Reviewed by Kenneth Russell.
diff --git a/WebCore/rendering/RenderBlock.cpp b/WebCore/rendering/RenderBlock.cpp
index 0314e54..71b5be7 100644
--- a/WebCore/rendering/RenderBlock.cpp
+++ b/WebCore/rendering/RenderBlock.cpp
@@ -1225,7 +1225,7 @@ void RenderBlock::layoutBlock(bool relayoutChildren, int pageHeight)
if (child->isBlockFlow() && !child->isFloatingOrPositioned()) {
RenderBlock* block = toRenderBlock(child);
if (block->lowestFloatLogicalBottom() + block->logicalTop() > newHeight)
- addOverhangingFloats(block, -block->x(), -block->y(), false);
+ addOverhangingFloats(block, -block->logicalLeft(), -block->logicalTop(), false);
}
}
}
@@ -1950,7 +1950,7 @@ void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int
// If the child has overhanging floats that intrude into following siblings (or possibly out
// of this block), then the parent gets notified of the floats now.
if (childRenderBlock && childRenderBlock->containsFloats())
- maxFloatLogicalBottom = max(maxFloatLogicalBottom, addOverhangingFloats(toRenderBlock(child), -child->x(), -child->y(), !childNeededLayout));
+ maxFloatLogicalBottom = max(maxFloatLogicalBottom, addOverhangingFloats(toRenderBlock(child), -child->logicalLeft(), -child->logicalTop(), !childNeededLayout));
IntSize childOffset(child->x() - oldRect.x(), child->y() - oldRect.y());
if (childOffset.width() || childOffset.height()) {
@@ -2927,8 +2927,6 @@ RenderBlock::FloatingObject* RenderBlock::insertFloatingObject(RenderBox* o)
// Create the special object entry & append it to the list
FloatingObject* newObj = new FloatingObject(o->style()->floating() == FLEFT ? FloatingObject::FloatLeft : FloatingObject::FloatRight);
-
- newObj->setTop(-1);
// Our location is irrelevant if we're unsplittable or no pagination is in effect.
// Just go ahead and lay out the float.
@@ -2957,12 +2955,14 @@ void RenderBlock::removeFloatingObject(RenderBox* o)
while (it.current()) {
if (it.current()->m_renderer == o) {
if (childrenInline()) {
- int bottom = it.current()->bottom();
+ int logicalTop = logicalTopForFloat(it.current());
+ int logicalBottom = logicalBottomForFloat(it.current());
+
// Special-case zero- and less-than-zero-height floats: those don't touch
// the line that they're on, but it still needs to be dirtied. This is
// accomplished by pretending they have a height of 1.
- bottom = max(bottom, it.current()->top() + 1);
- markLinesDirtyInVerticalRange(0, bottom);
+ logicalBottom = max(logicalBottom, logicalTop + 1);
+ markLinesDirtyInBlockRange(0, logicalBottom);
}
m_floatingObjects->removeRef(it.current());
}
@@ -2977,7 +2977,7 @@ void RenderBlock::removeFloatingObjectsBelow(FloatingObject* lastFloat, int y)
return;
FloatingObject* curr = m_floatingObjects->last();
- while (curr != lastFloat && (curr->top() == -1 || curr->top() >= y)) {
+ while (curr != lastFloat && (!curr->isPlaced() || curr->top() >= y)) {
m_floatingObjects->removeLast();
curr = m_floatingObjects->last();
}
@@ -2991,14 +2991,14 @@ bool RenderBlock::positionNewFloats()
FloatingObject* f = m_floatingObjects->last();
// If all floats have already been positioned, then we have no work to do.
- if (!f || f->top() != -1)
+ if (!f || f->isPlaced())
return false;
// Move backwards through our floating object list until we find a float that has
// already been positioned. Then we'll be able to move forward, positioning all of
// the new floats that need it.
FloatingObject* lastFloat = m_floatingObjects->getPrev();
- while (lastFloat && lastFloat->top() == -1) {
+ while (lastFloat && !lastFloat->isPlaced()) {
f = m_floatingObjects->prev();
lastFloat = m_floatingObjects->getPrev();
}
@@ -3088,6 +3088,8 @@ bool RenderBlock::positionNewFloats()
f->setTop(y);
f->setHeight(o->marginTop() + o->height() + o->marginBottom());
+ f->setIsPlaced();
+
// If the child moved, we have to repaint it.
if (o->checkForRepaintDuringLayout())
o->repaintDuringLayoutIfMoved(oldRect);
@@ -3216,11 +3218,12 @@ int RenderBlock::logicalLeftOffsetForLine(int y, int fixedOffset, bool applyText
{
int left = fixedOffset;
if (m_floatingObjects) {
- if ( heightRemaining ) *heightRemaining = 1;
+ if (heightRemaining)
+ *heightRemaining = 1;
FloatingObject* r;
DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
for ( ; (r = it.current()); ++it) {
- if (r->top() <= y && r->bottom() > y
+ if (r->isPlaced() && r->top() <= y && r->bottom() > y
&& r->type() == FloatingObject::FloatLeft
&& r->right() > left) {
left = r->right();
@@ -3245,11 +3248,12 @@ int RenderBlock::logicalRightOffsetForLine(int y, int fixedOffset, bool applyTex
int right = fixedOffset;
if (m_floatingObjects) {
- if (heightRemaining) *heightRemaining = 1;
+ if (heightRemaining)
+ *heightRemaining = 1;
FloatingObject* r;
DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
for ( ; (r = it.current()); ++it) {
- if (r->top() <= y && r->bottom() > y
+ if (r->isPlaced() && r->top() <= y && r->bottom() > y
&& r->type() == FloatingObject::FloatRight
&& r->left() < right) {
right = r->left();
@@ -3301,7 +3305,7 @@ int RenderBlock::lowestFloatLogicalBottom(FloatingObject::Type floatType) const
FloatingObject* r;
DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
for ( ; (r = it.current()); ++it) {
- if (r->type() & floatType)
+ if (r->isPlaced() && r->type() & floatType)
lowestFloatBottom = max(lowestFloatBottom, logicalBottomForFloat(r));
}
return lowestFloatBottom;
@@ -3585,19 +3589,19 @@ int RenderBlock::leftmostPosition(bool includeOverflowInterior, bool includeSelf
return left;
}
-void RenderBlock::markLinesDirtyInVerticalRange(int top, int bottom, RootInlineBox* highest)
+void RenderBlock::markLinesDirtyInBlockRange(int logicalTop, int logicalBottom, RootInlineBox* highest)
{
- if (top >= bottom)
+ if (logicalTop >= logicalBottom)
return;
RootInlineBox* lowestDirtyLine = lastRootBox();
RootInlineBox* afterLowest = lowestDirtyLine;
- while (lowestDirtyLine && lowestDirtyLine->blockHeight() >= bottom) {
+ while (lowestDirtyLine && lowestDirtyLine->blockHeight() >= logicalBottom) {
afterLowest = lowestDirtyLine;
lowestDirtyLine = lowestDirtyLine->prevRootBox();
}
- while (afterLowest && afterLowest != highest && afterLowest->blockHeight() >= top) {
+ while (afterLowest && afterLowest != highest && afterLowest->blockHeight() >= logicalTop) {
afterLowest->markDirty();
afterLowest = afterLowest->prevRootBox();
}
@@ -3699,11 +3703,11 @@ void RenderBlock::clearFloats()
}
deleteAllValues(floatMap);
- markLinesDirtyInVerticalRange(changeLogicalTop, changeLogicalBottom);
+ markLinesDirtyInBlockRange(changeLogicalTop, changeLogicalBottom);
}
}
-int RenderBlock::addOverhangingFloats(RenderBlock* child, int xoff, int yoff, bool makeChildPaintOtherFloats)
+int RenderBlock::addOverhangingFloats(RenderBlock* child, int logicalLeftOffset, int logicalTopOffset, bool makeChildPaintOtherFloats)
{
// Prevent floats from being added to the canvas by the root element, e.g., <html>.
if (child->hasOverflowClip() || !child->containsFloats() || child->isRoot() || child->hasColumns() || child->isBlockFlowRoot())
@@ -3715,13 +3719,15 @@ int RenderBlock::addOverhangingFloats(RenderBlock* child, int xoff, int yoff, bo
// overflow.
DeprecatedPtrListIterator<FloatingObject> it(*child->m_floatingObjects);
for (FloatingObject* r; (r = it.current()); ++it) {
- int bottom = child->y() + r->bottom();
- lowestFloatLogicalBottom = max(lowestFloatLogicalBottom, bottom);
+ int logicalBottom = child->logicalTop() + logicalBottomForFloat(r);
+ lowestFloatLogicalBottom = max(lowestFloatLogicalBottom, logicalBottom);
- if (bottom > height()) {
+ if (logicalBottom > logicalHeight()) {
// If the object is not in the list, we add it now.
if (!containsFloat(r->m_renderer)) {
- FloatingObject* floatingObj = new FloatingObject(r->type(), IntRect(r->left() - xoff, r->top() - yoff, r->width(), r->height()));
+ int leftOffset = style()->isVerticalBlockFlow() ? logicalLeftOffset : logicalTopOffset;
+ int topOffset = style()->isVerticalBlockFlow() ? logicalTopOffset : logicalLeftOffset;
+ FloatingObject* floatingObj = new FloatingObject(r->type(), IntRect(r->left() - leftOffset, r->top() - topOffset, r->width(), r->height()));
floatingObj->m_renderer = r->m_renderer;
// The nearest enclosing layer always paints the float (so that zindex and stacking
@@ -3755,36 +3761,42 @@ int RenderBlock::addOverhangingFloats(RenderBlock* child, int xoff, int yoff, bo
return lowestFloatLogicalBottom;
}
-void RenderBlock::addIntrudingFloats(RenderBlock* prev, int xoff, int yoff)
+void RenderBlock::addIntrudingFloats(RenderBlock* prev, int logicalLeftOffset, int logicalTopOffset)
{
// If the parent or previous sibling doesn't have any floats to add, don't bother.
if (!prev->m_floatingObjects)
return;
+ logicalLeftOffset += (style()->isVerticalBlockFlow() ? marginLeft() : marginTop());
+
DeprecatedPtrListIterator<FloatingObject> it(*prev->m_floatingObjects);
for (FloatingObject *r; (r = it.current()); ++it) {
- if (r->bottom() > yoff) {
+ if (logicalBottomForFloat(r) > logicalTopOffset) {
// The object may already be in our list. Check for it up front to avoid
// creating duplicate entries.
FloatingObject* f = 0;
if (m_floatingObjects) {
DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
while ((f = it.current())) {
- if (f->m_renderer == r->m_renderer) break;
+ if (f->m_renderer == r->m_renderer)
+ break;
++it;
}
}
if (!f) {
- FloatingObject* floatingObj = new FloatingObject(r->type(), IntRect(r->left() - xoff - marginLeft(), r->top() - yoff, r->width(), r->height()));
+ int leftOffset = style()->isVerticalBlockFlow() ? logicalLeftOffset : logicalTopOffset;
+ int topOffset = style()->isVerticalBlockFlow() ? logicalTopOffset : logicalLeftOffset;
+
+ FloatingObject* floatingObj = new FloatingObject(r->type(), IntRect(r->left() - leftOffset, r->top() - topOffset, r->width(), r->height()));
// Applying the child's margin makes no sense in the case where the child was passed in.
- // since his own margin was added already through the subtraction of the |xoff| variable
- // above. |xoff| will equal -flow->marginLeft() in this case, so it's already been taken
- // into account. Only apply this code if |child| is false, since otherwise the left margin
+ // since this margin was added already through the modification of the |logicalLeftOffset| variable
+ // above. |logicalLeftOffset| will equal the margin in this case, so it's already been taken
+ // into account. Only apply this code if prev is the parent, since otherwise the left margin
// will get applied twice.
if (prev != parent())
- floatingObj->setLeft(floatingObj->left() + prev->marginLeft());
-
+ floatingObj->setLeft(floatingObj->left() + (style()->isVerticalBlockFlow() ? prev->marginLeft() : prev->marginTop()));
+
floatingObj->m_shouldPaint = false; // We are not in the direct inheritance chain for this float. We will never paint it.
floatingObj->m_renderer = r->m_renderer;
diff --git a/WebCore/rendering/RenderBlock.h b/WebCore/rendering/RenderBlock.h
index ab89de3..7c414a9 100644
--- a/WebCore/rendering/RenderBlock.h
+++ b/WebCore/rendering/RenderBlock.h
@@ -361,23 +361,37 @@ private:
struct FloatingObject : Noncopyable {
// Note that Type uses bits so you can use FloatBoth as a mask to query for both left and right.
enum Type { FloatLeft = 1, FloatRight = 2, FloatBoth = 3 };
-
- FloatingObject(Type type, const IntRect& frameRect = IntRect())
+
+ FloatingObject(Type type)
+ : m_renderer(0)
+ , m_paginationStrut(0)
+ , m_type(type)
+ , m_shouldPaint(true)
+ , m_isDescendant(false)
+ , m_isPlaced(false)
+ {
+ }
+
+ FloatingObject(Type type, const IntRect& frameRect)
: m_renderer(0)
, m_frameRect(frameRect)
, m_paginationStrut(0)
, m_type(type)
, m_shouldPaint(true)
, m_isDescendant(false)
+ , m_isPlaced(true)
{
}
Type type() { return static_cast<Type>(m_type); }
- int left() const { return m_frameRect.x(); }
- int right() const { return m_frameRect.right(); }
- int top() const { return m_frameRect.y(); }
- int bottom() const { return m_frameRect.bottom(); }
+ bool isPlaced() const { return m_isPlaced; }
+ void setIsPlaced(bool placed = true) { m_isPlaced = placed; }
+
+ int left() const { ASSERT(isPlaced()); return m_frameRect.x(); }
+ int right() const { ASSERT(isPlaced()); return m_frameRect.right(); }
+ int top() const { ASSERT(isPlaced()); return m_frameRect.y(); }
+ int bottom() const { ASSERT(isPlaced()); return m_frameRect.bottom(); }
int width() const { return m_frameRect.width(); }
int height() const { return m_frameRect.height(); }
@@ -386,7 +400,7 @@ private:
void setWidth(int width) { m_frameRect.setWidth(width); }
void setHeight(int height) { m_frameRect.setHeight(height); }
- const IntRect& frameRect() const { return m_frameRect; }
+ const IntRect& frameRect() const { ASSERT(isPlaced()); return m_frameRect; }
void setFrameRect(const IntRect& frameRect) { m_frameRect = frameRect; }
RenderBox* m_renderer;
@@ -395,6 +409,7 @@ private:
unsigned m_type : 2; // Type (left or right aligned)
bool m_shouldPaint : 1;
bool m_isDescendant : 1;
+ bool m_isPlaced : 1;
};
int logicalTopForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->top() : child->left(); }
@@ -514,7 +529,7 @@ private:
void adjustPointToColumnContents(IntPoint&) const;
void adjustForBorderFit(int x, int& left, int& right) const; // Helper function for borderFitAdjust
- void markLinesDirtyInVerticalRange(int top, int bottom, RootInlineBox* highest = 0);
+ void markLinesDirtyInBlockRange(int logicalTop, int logicalTop, RootInlineBox* highest = 0);
void newLine(EClear);
diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp
index e6b5984..9a9d0ba 100644
--- a/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -959,7 +959,7 @@ RootInlineBox* RenderBlock::determineStartPosition(bool& firstLine, bool& fullLa
if (floats[floatIndex].rect.size() != newSize) {
int floatTop = floats[floatIndex].rect.y();
curr->markDirty();
- markLinesDirtyInVerticalRange(curr->blockHeight(), floatTop + max(floats[floatIndex].rect.height(), newSize.height()), curr);
+ markLinesDirtyInBlockRange(curr->blockHeight(), floatTop + max(floats[floatIndex].rect.height(), newSize.height()), curr);
floats[floatIndex].rect.setSize(newSize);
dirtiedByFloat = true;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list