提交 aadd9d43 编写于 作者: O Ojan Vafai

Remove some more assorted code from RenderBox.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/691223003
上级 da617058
......@@ -844,7 +844,7 @@ inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
// transforms or relative positioning (since those objects always have self-painting layers), but it does need to be adjusted
// for writing-mode differences.
if (!box.hasSelfPaintingLayer()) {
LayoutRect childLogicalVisualOverflow = box.logicalVisualOverflowRectForPropagation(renderer().style());
LayoutRect childLogicalVisualOverflow = box.visualOverflowRect();
childLogicalVisualOverflow.move(inlineBox->logicalLeft(), inlineBox->logicalTop());
logicalVisualOverflow.unite(childLogicalVisualOverflow);
}
......@@ -852,7 +852,7 @@ inline void InlineFlowBox::addReplacedChildOverflow(const InlineBox* inlineBox,
// Layout overflow internal to the child box only propagates if the child box doesn't have overflow clip set.
// Otherwise the child border box propagates as layout overflow. This rectangle must include transforms and relative positioning
// and be adjusted for writing-mode differences.
LayoutRect childLogicalLayoutOverflow = box.logicalLayoutOverflowRectForPropagation(renderer().style());
LayoutRect childLogicalLayoutOverflow = box.layoutOverflowRectForPropagation();
childLogicalLayoutOverflow.move(inlineBox->logicalLeft(), inlineBox->logicalTop());
logicalLayoutOverflow.unite(childLogicalLayoutOverflow);
}
......
......@@ -966,7 +966,7 @@ void RenderBlock::computeOverflow(LayoutUnit oldClientAfterEdge, bool)
// When we have overflow clip, propagate the original spillout since it will include collapsed bottom margins
// and bottom padding. Set the axis we don't care about to be 1, since we want this overflow to always
// be considered reachable.
LayoutRect clientRect(noOverflowRect());
LayoutRect clientRect(paddingBoxRect());
LayoutRect rectToApply;
rectToApply = LayoutRect(clientRect.x(), clientRect.y(), 1, std::max<LayoutUnit>(0, oldClientAfterEdge - clientRect.y()));
addLayoutOverflow(rectToApply);
......@@ -1001,7 +1001,7 @@ void RenderBlock::addOverflowFromPositionedObjects()
bool RenderBlock::createsBlockFormattingContext() const
{
return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() || isDocumentElement();
return isInlineBlock() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItem() || isDocumentElement();
}
void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox* child)
......@@ -1454,7 +1454,7 @@ bool RenderBlock::isSelectionRoot() const
|| isPositioned()
|| isInlineBlock()
|| hasTransform() || hasMask()
|| isFlexItemIncludingDeprecated())
|| isFlexItem())
return true;
if (view() && view()->selectionStart()) {
......
......@@ -1219,43 +1219,11 @@ LayoutRect RenderBox::clipRect(const LayoutPoint& location)
return clipRect;
}
static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, LayoutUnit contentSide, LayoutUnit offset)
{
if (childMargin <= 0)
return 0;
LayoutUnit contentSideWithMargin = contentSide + childMargin;
if (offset > contentSideWithMargin)
return childMargin;
return offset - contentSide;
}
LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const
{
LayoutUnit width = cb->availableLogicalWidthForLine(false) - std::max<LayoutUnit>(0, childMarginStart) - std::max<LayoutUnit>(0, childMarginEnd);
// We need to see if margins on either the start side or the end side can contain the floats in question. If they can,
// then just using the line width is inaccurate. In the case where a float completely fits, we don't need to use the line
// offset at all, but can instead push all the way to the content edge of the containing block. In the case where the float
// doesn't fit, we can use the line offset, but we need to grow it by the margin to reflect the fact that the margin was
// "consumed" by the float. Negative margins aren't consumed by the float, and so we ignore them.
width += portionOfMarginNotConsumedByFloat(childMarginStart, cb->startOffsetForContent(), cb->startOffsetForLine(false));
width += portionOfMarginNotConsumedByFloat(childMarginEnd, cb->endOffsetForContent(), cb->endOffsetForLine(false));
return width;
}
LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHeightType heightType) const
{
return containingBlock()->availableLogicalHeight(heightType);
}
LayoutUnit RenderBox::containingBlockAvailableLineWidth() const
{
RenderBlock* cb = containingBlock();
if (cb->isRenderBlockFlow())
return toRenderBlockFlow(cb)->availableLogicalWidthForLine(false);
return 0;
}
void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags mode, const PaintInvalidationState* paintInvalidationState) const
{
if (paintInvalidationContainer == this)
......@@ -1306,7 +1274,7 @@ LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoi
offset += offsetForInFlowPosition();
if (!isInline() || isReplaced())
offset += topLeftLocationOffset();
offset += locationOffset();
if (o->hasOverflowClip())
offset -= toRenderBox(o)->scrolledContentOffset();
......@@ -3304,7 +3272,7 @@ void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
// Only propagate layout overflow from the child if the child isn't clipping its overflow. If it is, then
// its overflow is internal to it, and we don't care about it. layoutOverflowRectForPropagation takes care of this
// and just propagates the border box rect instead.
LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation(style());
LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation();
childLayoutOverflowRect.move(delta);
addLayoutOverflow(childLayoutOverflowRect);
......@@ -3313,14 +3281,14 @@ void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta)
// overflow if we are clipping our own overflow.
if (child->hasSelfPaintingLayer())
return;
LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation(style());
LayoutRect childVisualOverflowRect = child->visualOverflowRect();
childVisualOverflowRect.move(delta);
addContentsVisualOverflow(childVisualOverflowRect);
}
void RenderBox::addLayoutOverflow(const LayoutRect& rect)
{
LayoutRect clientBox = noOverflowRect();
LayoutRect clientBox = paddingBoxRect();
if (clientBox.contains(rect) || rect.isEmpty())
return;
......@@ -3368,7 +3336,7 @@ void RenderBox::addVisualOverflow(const LayoutRect& rect)
return;
if (!m_overflow)
m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox));
m_overflow = adoptPtr(new RenderOverflow(paddingBoxRect(), borderBox));
m_overflow->addVisualOverflow(rect);
}
......@@ -3381,7 +3349,7 @@ void RenderBox::addContentsVisualOverflow(const LayoutRect& rect)
}
if (!m_overflow)
m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBoxRect()));
m_overflow = adoptPtr(new RenderOverflow(paddingBoxRect(), borderBoxRect()));
m_overflow->addContentsVisualOverflow(rect);
}
......@@ -3395,7 +3363,7 @@ void RenderBox::clearLayoutOverflow()
return;
}
m_overflow->setLayoutOverflow(noOverflowRect());
m_overflow->setLayoutOverflow(paddingBoxRect());
}
bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool isOutOfFlowPositioned)
......@@ -3467,25 +3435,7 @@ RenderLayer* RenderBox::enclosingFloatPaintingLayer() const
return 0;
}
LayoutRect RenderBox::logicalVisualOverflowRectForPropagation(RenderStyle* parentStyle) const
{
// FIXME(sky): Remove
return visualOverflowRectForPropagation(parentStyle);
}
LayoutRect RenderBox::visualOverflowRectForPropagation(RenderStyle* parentStyle) const
{
// FIXME(sky): Remove
return visualOverflowRect();
}
LayoutRect RenderBox::logicalLayoutOverflowRectForPropagation(RenderStyle* parentStyle) const
{
// FIXME(sky): Remove
return layoutOverflowRectForPropagation(parentStyle);
}
LayoutRect RenderBox::layoutOverflowRectForPropagation(RenderStyle* parentStyle) const
LayoutRect RenderBox::layoutOverflowRectForPropagation() const
{
// Only propagate interior layout overflow if we don't clip it.
LayoutRect rect = borderBoxRect();
......@@ -3506,37 +3456,14 @@ LayoutRect RenderBox::layoutOverflowRectForPropagation(RenderStyle* parentStyle)
return rect;
}
LayoutRect RenderBox::noOverflowRect() const
{
// FIXME(sky): Replace with borderBoxRect?
LayoutUnit left = borderLeft();
LayoutUnit top = borderTop();
LayoutUnit right = borderRight();
LayoutUnit bottom = borderBottom();
LayoutRect rect(left, top, width() - left - right, height() - top - bottom);
return rect;
}
LayoutUnit RenderBox::offsetLeft() const
{
return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x();
return adjustedPositionRelativeToOffsetParent(location()).x();
}
LayoutUnit RenderBox::offsetTop() const
{
return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y();
}
LayoutPoint RenderBox::topLeftLocation() const
{
// FIXME(sky): Remove this.
return location();
}
LayoutSize RenderBox::topLeftLocationOffset() const
{
// FIXME(sky): Remove this.
return locationOffset();
return adjustedPositionRelativeToOffsetParent(location()).y();
}
bool RenderBox::hasRelativeLogicalHeight() const
......
......@@ -100,8 +100,8 @@ public:
// These represent your location relative to your container as a physical offset.
// In layout related methods you almost always want the logical location (e.g. x() and y()).
LayoutUnit top() const { return topLeftLocation().y(); }
LayoutUnit left() const { return topLeftLocation().x(); }
LayoutUnit top() const { return location().y(); }
LayoutUnit left() const { return location().x(); }
void setX(LayoutUnit x) { m_frameRect.setX(x); }
void setY(LayoutUnit y) { m_frameRect.setY(y); }
......@@ -188,8 +188,7 @@ public:
// For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
// respectively are flipped when compared to their physical counterparts. For example minX is on the left in vertical-lr,
// but it is on the right in vertical-rl.
LayoutRect noOverflowRect() const;
LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : noOverflowRect(); }
LayoutRect layoutOverflowRect() const { return m_overflow ? m_overflow->layoutOverflowRect() : paddingBoxRect(); }
IntRect pixelSnappedLayoutOverflowRect() const { return pixelSnappedIntRect(layoutOverflowRect()); }
LayoutSize maxLayoutOverflow() const { return LayoutSize(layoutOverflowRect().maxX(), layoutOverflowRect().maxY()); }
LayoutUnit logicalLeftLayoutOverflow() const { return layoutOverflowRect().x(); }
......@@ -369,9 +368,6 @@ public:
LayoutUnit containingBlockLogicalHeightForContent(AvailableLogicalHeightType) const;
LayoutUnit containingBlockAvailableLineWidth() const;
LayoutUnit perpendicularContainingBlockLogicalHeight() const;
virtual void updateLogicalWidth();
virtual void updateLogicalHeight();
virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
......@@ -387,8 +383,6 @@ public:
// of a containing block). HTML4 buttons, <select>s, <input>s, legends, and floating/compact elements do this.
bool sizesLogicalWidthToFitContent(const Length& logicalWidth) const;
LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const;
LayoutUnit computeLogicalWidthUsing(SizeType, const Length& logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock) const;
LayoutUnit computeLogicalHeightUsing(const Length& height, LayoutUnit intrinsicContentHeight) const;
LayoutUnit computeContentLogicalHeight(const Length& height, LayoutUnit intrinsicContentHeight) const;
......@@ -470,7 +464,7 @@ public:
virtual int firstLineBoxBaseline() const { return -1; }
virtual int inlineBlockBaseline(LineDirectionMode) const { return -1; } // Returns -1 if we should skip this box when computing the baseline of an inline-block.
bool isFlexItemIncludingDeprecated() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isFlexibleBox(); }
bool isFlexItem() const { return !isInline() && !isFloatingOrOutOfFlowPositioned() && parent() && parent()->isFlexibleBox(); }
virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
......@@ -478,15 +472,7 @@ public:
virtual LayoutUnit offsetLeft() const override;
virtual LayoutUnit offsetTop() const override;
// These represent your location relative to your container as a physical offset.
// In layout related methods you almost always want the logical location (e.g. x() and y()).
LayoutPoint topLeftLocation() const;
LayoutSize topLeftLocationOffset() const;
LayoutRect logicalVisualOverflowRectForPropagation(RenderStyle*) const;
LayoutRect visualOverflowRectForPropagation(RenderStyle*) const;
LayoutRect logicalLayoutOverflowRectForPropagation(RenderStyle*) const;
LayoutRect layoutOverflowRectForPropagation(RenderStyle*) const;
LayoutRect layoutOverflowRectForPropagation() const;
bool hasRenderOverflow() const { return m_overflow; }
bool hasVisualOverflow() const { return m_overflow && !borderBoxRect().contains(m_overflow->visualOverflowRect()); }
......
......@@ -281,7 +281,7 @@ LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
// FIXME: What are we supposed to do inside SVG content?
if (!isOutOfFlowPositioned()) {
if (current->isBox())
referencePoint.moveBy(toRenderBox(current)->topLeftLocation());
referencePoint.moveBy(toRenderBox(current)->location());
}
}
}
......
......@@ -927,7 +927,7 @@ LayoutRect RenderInline::culledInlineVisualOverflowBoundingBox() const
if (curr->isBox()) {
RenderBox* currBox = toRenderBox(curr);
if (!currBox->hasSelfPaintingLayer() && currBox->inlineBoxWrapper()) {
LayoutRect logicalRect = currBox->logicalVisualOverflowRectForPropagation(style());
LayoutRect logicalRect = currBox->visualOverflowRect();
logicalRect.moveBy(currBox->location());
result.uniteIfNonZero(logicalRect);
}
......
......@@ -486,7 +486,7 @@ LayoutPoint RenderLayer::location() const
inlineBoundingBoxOffset = toSize(lineBox.location());
localPoint += inlineBoundingBoxOffset;
} else if (RenderBox* box = renderBox()) {
localPoint += box->topLeftLocationOffset();
localPoint += box->locationOffset();
}
if (!renderer()->isOutOfFlowPositioned() && renderer()->parent()) {
......@@ -497,7 +497,7 @@ LayoutPoint RenderLayer::location() const
if (curr->isBox()) {
// Rows and cells share the same coordinate space (that of the section).
// Omit them when computing our xpos/ypos.
localPoint += toRenderBox(curr)->topLeftLocationOffset();
localPoint += toRenderBox(curr)->locationOffset();
}
curr = curr->parent();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册