+2013-08-14 Bem Jones-Bey <bjonesbe@adobe.com>
+
+ Finish making FloatingObject a real class with private members
+ https://bugs.webkit.org/show_bug.cgi?id=119807
+
+ This is a port from Blink of
+ http://src.chromium.org/viewvc/blink?view=revision&revision=155964
+ Original patch by Eric Seidel.
+
+ From his comments on the Blink change:
+
+ Previously FloatingObject was in a half-done state where it had
+ accessors for many members, but also many members were public.
+
+ This CL makes all members private and adds the necessary remaining
+ accessors.
+
+ Reviewed by David Hyatt.
+
+ No new tests, no behavior change.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::deleteLineBoxTree):
+ (WebCore::RenderBlock::addOverflowFromFloats):
+ (WebCore::RenderBlock::repaintOverhangingFloats):
+ (WebCore::RenderBlock::paintFloats):
+ (WebCore::RenderBlock::selectionGaps):
+ (WebCore::RenderBlock::insertFloatingObject):
+ (WebCore::RenderBlock::removeFloatingObject):
+ (WebCore::RenderBlock::removeFloatingObjectsBelow):
+ (WebCore::RenderBlock::positionNewFloats):
+ (WebCore::RenderBlock::clearFloats):
+ (WebCore::RenderBlock::addOverhangingFloats):
+ (WebCore::RenderBlock::addIntrudingFloats):
+ (WebCore::RenderBlock::hitTestFloats):
+ (WebCore::RenderBlock::adjustForBorderFit):
+ * rendering/RenderBlock.h:
+ (WebCore::RenderBlock::FloatingObject::paginationStrut):
+ (WebCore::RenderBlock::FloatingObject::setPaginationStrut):
+ (WebCore::RenderBlock::FloatingObject::setRenderer):
+ (WebCore::RenderBlock::FloatingObject::originatingLine):
+ (WebCore::RenderBlock::FloatingObject::setOriginatingLine):
+ (WebCore::RenderBlock::FloatingObjectHashFunctions::hash):
+ (WebCore::RenderBlock::FloatingObjectHashFunctions::equal):
+ (WebCore::RenderBlock::FloatingObjectHashTranslator::equal):
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlock::appendFloatingObjectToLastLine):
+ (WebCore::RenderBlock::layoutRunsAndFloatsInRange):
+ (WebCore::RenderBlock::linkToEndLineIfNeeded):
+ (WebCore::RenderBlock::determineStartPosition):
+ (WebCore::RenderBlock::positionNewFloatOnLine):
+
2013-08-14 Rob Buis <rwlbuis@webkit.org>
Assertion failure in RenderObject::drawLineForBoxSide
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
- ASSERT(!((*it)->m_originatingLine) || (*it)->m_originatingLine->renderer() == this);
- (*it)->m_originatingLine = 0;
+ ASSERT(!((*it)->originatingLine()) || (*it)->originatingLine()->renderer() == this);
+ (*it)->setOriginatingLine(0);
}
}
m_lineBoxes.deleteLineBoxTree(renderArena());
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* r = *it;
if (r->isDescendant())
- addOverflowFromChild(r->m_renderer, IntSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
+ addOverflowFromChild(r->renderer(), IntSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
}
}
// Only repaint the object if it is overhanging, is not in its own layer, and
// is our responsibility to paint (m_shouldPaint is set). When paintAllDescendants is true, the latter
// condition is replaced with being a descendant of us.
- if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->m_renderer->isDescendantOf(this)) || r->shouldPaint()) && !r->m_renderer->hasSelfPaintingLayer()) {
- r->m_renderer->repaint();
- r->m_renderer->repaintOverhangingFloats(false);
+ if (logicalBottomForFloat(r) > logicalHeight() && ((paintAllDescendants && r->renderer()->isDescendantOf(this)) || r->shouldPaint()) && !r->renderer()->hasSelfPaintingLayer()) {
+ r->renderer()->repaint();
+ r->renderer()->repaintOverhangingFloats(false);
}
}
}
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* r = *it;
// Only paint the object if our m_shouldPaint flag is set.
- if (r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()) {
+ if (r->shouldPaint() && !r->renderer()->hasSelfPaintingLayer()) {
PaintInfo currentPaintInfo(paintInfo);
currentPaintInfo.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
- LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPoint(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->m_renderer->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->m_renderer->y()));
- r->m_renderer->paint(currentPaintInfo, childPoint);
+ // FIXME: LayoutPoint version of xPositionForFloatIncludingMargin would make this much cleaner.
+ LayoutPoint childPoint = flipFloatForWritingModeForChild(r, LayoutPoint(paintOffset.x() + xPositionForFloatIncludingMargin(r) - r->renderer()->x(), paintOffset.y() + yPositionForFloatIncludingMargin(r) - r->renderer()->y()));
+ r->renderer()->paint(currentPaintInfo, childPoint);
if (!preservePhase) {
currentPaintInfo.phase = PaintPhaseChildBlockBackgrounds;
- r->m_renderer->paint(currentPaintInfo, childPoint);
+ r->renderer()->paint(currentPaintInfo, childPoint);
currentPaintInfo.phase = PaintPhaseFloat;
- r->m_renderer->paint(currentPaintInfo, childPoint);
+ r->renderer()->paint(currentPaintInfo, childPoint);
currentPaintInfo.phase = PaintPhaseForeground;
- r->m_renderer->paint(currentPaintInfo, childPoint);
+ r->renderer()->paint(currentPaintInfo, childPoint);
currentPaintInfo.phase = PaintPhaseOutline;
- r->m_renderer->paint(currentPaintInfo, childPoint);
+ r->renderer()->paint(currentPaintInfo, childPoint);
}
}
}
FloatingObject* r = *it;
LayoutRect floatBox(offsetFromRootBlock.width() + xPositionForFloatIncludingMargin(r),
offsetFromRootBlock.height() + yPositionForFloatIncludingMargin(r),
- r->m_renderer->width(), r->m_renderer->height());
+ r->renderer()->width(), r->renderer()->height());
rootBlock->flipForWritingMode(floatBox);
floatBox.move(rootBlockPhysicalPosition.x(), rootBlockPhysicalPosition.y());
paintInfo->context->clipOut(pixelSnappedIntRect(floatBox));
newObj->setShouldPaint(!o->hasSelfPaintingLayer()); // If a layer exists, the float will paint itself. Otherwise someone else will.
newObj->setIsDescendant(true);
- newObj->m_renderer = o;
+ newObj->setRenderer(o);
m_floatingObjects->add(newObj);
// accomplished by pretending they have a height of 1.
logicalBottom = max(logicalBottom, logicalTop + 1);
}
- if (r->m_originatingLine) {
+ if (r->originatingLine()) {
if (!selfNeedsLayout()) {
- ASSERT(r->m_originatingLine->renderer() == this);
- r->m_originatingLine->markDirty();
+ ASSERT(r->originatingLine()->renderer() == this);
+ r->originatingLine()->markDirty();
}
#if !ASSERT_DISABLED
- r->m_originatingLine = 0;
+ r->setOriginatingLine(0);
#endif
}
markLinesDirtyInBlockRange(0, logicalBottom);
}
m_floatingObjects->remove(r);
- ASSERT(!r->m_originatingLine);
+ ASSERT(!r->originatingLine());
delete r;
}
}
FloatingObject* curr = floatingObjectSet.last();
while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) >= logicalOffset)) {
m_floatingObjects->remove(curr);
- ASSERT(!curr->m_originatingLine);
+ ASSERT(!curr->originatingLine());
delete curr;
if (floatingObjectSet.isEmpty())
break;
}
if (newLogicalTop != floatLogicalLocation.y()) {
- floatingObject->m_paginationStrut = newLogicalTop - floatLogicalLocation.y();
+ floatingObject->setPaginationStrut(newLogicalTop - floatLogicalLocation.y());
floatLogicalLocation = computeLogicalLocationForFloat(floatingObject, newLogicalTop);
setLogicalLeftForFloat(floatingObject, floatLogicalLocation.x());
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* floatingObject = *it;
if (!floatingObject->isDescendant())
- oldIntrudingFloatSet.add(floatingObject->m_renderer);
+ oldIntrudingFloatSet.add(floatingObject->renderer());
}
}
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* f = *it;
- floatMap.add(f->m_renderer, f);
+ floatMap.add(f->renderer(), f);
}
} else
deleteAllValues(floatingObjectSet);
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
FloatingObject* f = *it;
- FloatingObject* oldFloatingObject = floatMap.get(f->m_renderer);
+ FloatingObject* oldFloatingObject = floatMap.get(f->renderer());
LayoutUnit logicalBottom = logicalBottomForFloat(f);
if (oldFloatingObject) {
LayoutUnit oldLogicalBottom = logicalBottomForFloat(oldFloatingObject);
}
}
- floatMap.remove(f->m_renderer);
- if (oldFloatingObject->m_originatingLine && !selfNeedsLayout()) {
- ASSERT(oldFloatingObject->m_originatingLine->renderer() == this);
- oldFloatingObject->m_originatingLine->markDirty();
+ floatMap.remove(f->renderer());
+ if (oldFloatingObject->originatingLine() && !selfNeedsLayout()) {
+ ASSERT(oldFloatingObject->originatingLine()->renderer() == this);
+ oldFloatingObject->originatingLine()->markDirty();
}
delete oldFloatingObject;
} else {
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
FloatingObjectSetIterator end = floatingObjectSet.end();
for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end && !oldIntrudingFloatSet.isEmpty(); ++it)
- oldIntrudingFloatSet.remove((*it)->m_renderer);
+ oldIntrudingFloatSet.remove((*it)->renderer());
if (!oldIntrudingFloatSet.isEmpty())
markAllDescendantsWithFloatsForLayout();
}
if (logicalBottom > logicalHeight()) {
// If the object is not in the list, we add it now.
- if (!containsFloat(r->m_renderer)) {
+ if (!containsFloat(r->renderer())) {
LayoutSize offset = isHorizontalWritingMode() ? LayoutSize(-childLogicalLeft, -childLogicalTop) : LayoutSize(-childLogicalTop, -childLogicalLeft);
FloatingObject* floatingObj = new FloatingObject(r->type(), LayoutRect(r->frameRect().location() - offset, r->frameRect().size()));
- floatingObj->m_renderer = r->m_renderer;
+ floatingObj->setRenderer(r->renderer());
// The nearest enclosing layer always paints the float (so that zindex and stacking
// behaves properly). We always want to propagate the desire to paint the float as
// far out as we can, to the outermost block that overlaps the float, stopping only
// if we hit a self-painting layer boundary.
- if (r->m_renderer->enclosingFloatPaintingLayer() == enclosingFloatPaintingLayer())
+ if (r->renderer()->enclosingFloatPaintingLayer() == enclosingFloatPaintingLayer())
r->setShouldPaint(false);
else
floatingObj->setShouldPaint(false);
m_floatingObjects->add(floatingObj);
}
} else {
- if (makeChildPaintOtherFloats && !r->shouldPaint() && !r->m_renderer->hasSelfPaintingLayer()
- && r->m_renderer->isDescendantOf(child) && r->m_renderer->enclosingFloatPaintingLayer() == child->enclosingFloatPaintingLayer()) {
+ if (makeChildPaintOtherFloats && !r->shouldPaint() && !r->renderer()->hasSelfPaintingLayer()
+ && r->renderer()->isDescendantOf(child) && r->renderer()->enclosingFloatPaintingLayer() == child->enclosingFloatPaintingLayer()) {
// The float is not overhanging from this block, so if it is a descendant of the child, the child should
// paint it (the other case is that it is intruding into the child), unless it has its own layer or enclosing
// layer.
// Since the float doesn't overhang, it didn't get put into our list. We need to go ahead and add its overflow in to the
// child now.
if (r->isDescendant())
- child->addOverflowFromChild(r->m_renderer, LayoutSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
+ child->addOverflowFromChild(r->renderer(), LayoutSize(xPositionForFloatIncludingMargin(r), yPositionForFloatIncludingMargin(r)));
}
}
return lowestFloatLogicalBottom;
}
floatingObj->setShouldPaint(false); // We are not in the direct inheritance chain for this float. We will never paint it.
- floatingObj->m_renderer = r->m_renderer;
+ floatingObj->setRenderer(r->renderer());
// We create the floating object list lazily.
if (!m_floatingObjects)
for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) {
--it;
FloatingObject* floatingObject = *it;
- if (floatingObject->shouldPaint() && !floatingObject->m_renderer->hasSelfPaintingLayer()) {
- LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->x();
- LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->m_renderer->y();
+ if (floatingObject->shouldPaint() && !floatingObject->renderer()->hasSelfPaintingLayer()) {
+ LayoutUnit xOffset = xPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->x();
+ LayoutUnit yOffset = yPositionForFloatIncludingMargin(floatingObject) - floatingObject->renderer()->y();
LayoutPoint childPoint = flipFloatForWritingModeForChild(floatingObject, adjustedLocation + LayoutSize(xOffset, yOffset));
- if (floatingObject->m_renderer->hitTest(request, result, locationInContainer, childPoint)) {
+ if (floatingObject->renderer()->hitTest(request, result, locationInContainer, childPoint)) {
updateHitTestResult(result, locationInContainer.point() - toLayoutSize(childPoint));
return true;
}
FloatingObject* r = *it;
// Only examine the object if our m_shouldPaint flag is set.
if (r->shouldPaint()) {
- LayoutUnit floatLeft = xPositionForFloatIncludingMargin(r) - r->m_renderer->x();
- LayoutUnit floatRight = floatLeft + r->m_renderer->width();
+ LayoutUnit floatLeft = xPositionForFloatIncludingMargin(r) - r->renderer()->x();
+ LayoutUnit floatRight = floatLeft + r->renderer()->width();
left = min(left, floatLeft);
right = max(right, floatRight);
}
void RenderBlock::appendFloatingObjectToLastLine(FloatingObject* floatingObject)
{
- ASSERT(!floatingObject->m_originatingLine);
- floatingObject->m_originatingLine = lastRootBox();
+ ASSERT(!floatingObject->originatingLine());
+ floatingObject->setOriginatingLine(lastRootBox());
lastRootBox()->appendFloat(floatingObject->renderer());
}
for (; it != end; ++it) {
FloatingObject* f = *it;
appendFloatingObjectToLastLine(f);
- ASSERT(f->m_renderer == layoutState.floats()[layoutState.floatIndex()].object);
+ ASSERT(f->renderer() == layoutState.floats()[layoutState.floatIndex()].object);
// If a float's geometry has changed, give up on syncing with clean lines.
if (layoutState.floats()[layoutState.floatIndex()].rect != f->frameRect())
checkForEndLineMatch = false;
Vector<RenderBox*>::iterator end = cleanLineFloats->end();
for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
FloatingObject* floatingObject = insertFloatingObject(*f);
- ASSERT(!floatingObject->m_originatingLine);
- floatingObject->m_originatingLine = line;
+ ASSERT(!floatingObject->originatingLine());
+ floatingObject->setOriginatingLine(line);
setLogicalHeight(logicalTopForChild(*f) - marginBeforeForChild(*f) + delta);
positionNewFloats();
}
Vector<RenderBox*>::iterator end = cleanLineFloats->end();
for (Vector<RenderBox*>::iterator f = cleanLineFloats->begin(); f != end; ++f) {
FloatingObject* floatingObject = insertFloatingObject(*f);
- ASSERT(!floatingObject->m_originatingLine);
- floatingObject->m_originatingLine = line;
+ ASSERT(!floatingObject->originatingLine());
+ floatingObject->setOriginatingLine(line);
setLogicalHeight(logicalTopForChild(*f) - marginBeforeForChild(*f));
positionNewFloats();
ASSERT(layoutState.floats()[numCleanFloats].object == *f);
// We only connect floats to lines for pagination purposes if the floats occur at the start of
// the line and the previous line had a hard break (so this line is either the first in the block
// or follows a <br>).
- if (!newFloat->m_paginationStrut || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
+ if (!newFloat->paginationStrut() || !lineInfo.previousLineBrokeCleanly() || !lineInfo.isEmpty())
return true;
const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
ASSERT(floatingObjectSet.last() == newFloat);
LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat);
- int paginationStrut = newFloat->m_paginationStrut;
+ int paginationStrut = newFloat->paginationStrut();
if (floatLogicalTop - paginationStrut != logicalHeight() + lineInfo.floatPaginationStrut())
return true;
if (f == lastFloatFromPreviousLine)
break;
if (logicalTopForFloat(f) == logicalHeight() + lineInfo.floatPaginationStrut()) {
- f->m_paginationStrut += paginationStrut;
- RenderBox* o = f->m_renderer;
+ f->setPaginationStrut(paginationStrut + f->paginationStrut());
+ RenderBox* o = f->renderer();
setLogicalTopForChild(o, logicalTopForChild(o) + marginBeforeForChild(o) + paginationStrut);
if (o->isRenderBlock())
toRenderBlock(o)->setChildNeedsLayout(true, MarkOnlyThis);