mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove dead position:relative code.
There are some cases in this patch where it's not obvious that the code only applies to position:relative, but the code asserts that it does. In those cases, I trusted the asserts and deleted the code. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/938193004
This commit is contained in:
parent
c78cea7e54
commit
a42e249b69
@ -49,14 +49,6 @@ LayoutState::LayoutState(RenderBox& renderer, const LayoutSize& offset, bool con
|
||||
{
|
||||
renderer.view()->pushLayoutState(*this);
|
||||
m_layoutOffset = m_next->m_layoutOffset + offset;
|
||||
|
||||
if (renderer.isOutOfFlowPositioned()) {
|
||||
if (RenderObject* container = renderer.container()) {
|
||||
if (container->style()->hasInFlowPosition() && container->isRenderInline())
|
||||
m_layoutOffset += toRenderInline(container)->offsetForInFlowPositionedInline(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
|
||||
}
|
||||
|
||||
|
||||
@ -640,14 +640,6 @@ GapRects RenderBlock::blockSelectionGaps(RenderBlock* rootBlock, const LayoutPoi
|
||||
if (curr->isFloatingOrOutOfFlowPositioned())
|
||||
continue; // We must be a normal flow object in order to even be considered.
|
||||
|
||||
if (curr->isRelPositioned() && curr->hasLayer()) {
|
||||
// If the relposition offset is anything other than 0, then treat this just like an absolute positioned element.
|
||||
// Just disregard it completely.
|
||||
LayoutSize relOffset = curr->layer()->offsetForInFlowPosition();
|
||||
if (relOffset.width() || relOffset.height())
|
||||
continue;
|
||||
}
|
||||
|
||||
bool paintsOwnSelection = curr->shouldPaintSelectionGaps();
|
||||
bool fillBlockGaps = paintsOwnSelection || (curr->canBeSelectionLeaf() && childState != SelectionNone);
|
||||
if (fillBlockGaps) {
|
||||
@ -1117,8 +1109,6 @@ static inline bool isEditingBoundary(RenderObject* ancestor, RenderObject* child
|
||||
static PositionWithAffinity positionForPointRespectingEditingBoundaries(RenderBlock* parent, RenderBox* child, const LayoutPoint& pointInParentCoordinates)
|
||||
{
|
||||
LayoutPoint childLocation = child->location();
|
||||
if (child->isRelPositioned())
|
||||
childLocation += child->offsetForInFlowPosition();
|
||||
|
||||
// FIXME: This is wrong if the child's writing-mode is different from the parent's.
|
||||
LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates - childLocation));
|
||||
@ -1631,8 +1621,6 @@ const char* RenderBlock::renderName() const
|
||||
return "RenderBlock (anonymous)";
|
||||
if (isAnonymous())
|
||||
return "RenderBlock (generated)";
|
||||
if (isRelPositioned())
|
||||
return "RenderBlock (relative positioned)";
|
||||
return "RenderBlock";
|
||||
}
|
||||
|
||||
|
||||
@ -1115,18 +1115,9 @@ void RenderBox::mapLocalToContainer(const RenderLayerModelObject* paintInvalidat
|
||||
LayoutSize RenderBox::offsetFromContainer(const RenderObject* o, const LayoutPoint& point, bool* offsetDependsOnPoint) const
|
||||
{
|
||||
ASSERT(o == container());
|
||||
|
||||
LayoutSize offset;
|
||||
if (isRelPositioned())
|
||||
offset += offsetForInFlowPosition();
|
||||
|
||||
if (!isInline() || isReplaced())
|
||||
offset += locationOffset();
|
||||
|
||||
if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->isRenderInline())
|
||||
offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this);
|
||||
|
||||
return offset;
|
||||
return locationOffset();
|
||||
return LayoutSize();
|
||||
}
|
||||
|
||||
InlineBox* RenderBox::createInlineBox()
|
||||
@ -1170,9 +1161,6 @@ void RenderBox::positionLineBox(InlineBox* box)
|
||||
setChildNeedsLayout(MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
|
||||
}
|
||||
|
||||
if (container()->isRenderInline())
|
||||
moveWithEdgeOfInlineContainerIfNecessary();
|
||||
|
||||
// Nuke the box.
|
||||
box->remove(DontMarkLineBoxes);
|
||||
box->destroy();
|
||||
@ -1182,17 +1170,6 @@ void RenderBox::positionLineBox(InlineBox* box)
|
||||
}
|
||||
}
|
||||
|
||||
void RenderBox::moveWithEdgeOfInlineContainerIfNecessary()
|
||||
{
|
||||
ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container()->isRelPositioned());
|
||||
// If this object is inside a relative positioned inline and its inline position is an explicit offset from the edge of its container
|
||||
// then it will need to move if its inline container has changed width. We do not track if the width has changed
|
||||
// but if we are here then we are laying out lines inside it, so it probably has - mark our object for layout so that it can
|
||||
// move to the new offset created by the new width.
|
||||
if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition())
|
||||
setChildNeedsLayout(MarkOnlyThis);
|
||||
}
|
||||
|
||||
void RenderBox::deleteLineBoxWrapper()
|
||||
{
|
||||
if (inlineBoxWrapper()) {
|
||||
@ -1807,54 +1784,16 @@ void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
|
||||
|
||||
LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock) const
|
||||
{
|
||||
if (containingBlock->isBox())
|
||||
return toRenderBox(containingBlock)->clientLogicalWidth();
|
||||
|
||||
ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned());
|
||||
|
||||
const RenderInline* flow = toRenderInline(containingBlock);
|
||||
InlineFlowBox* first = flow->firstLineBox();
|
||||
InlineFlowBox* last = flow->lastLineBox();
|
||||
|
||||
// If the containing block is empty, return a width of 0.
|
||||
if (!first || !last)
|
||||
return 0;
|
||||
|
||||
LayoutUnit fromLeft;
|
||||
LayoutUnit fromRight;
|
||||
if (containingBlock->style()->isLeftToRightDirection()) {
|
||||
fromLeft = first->logicalLeft() + first->borderLogicalLeft();
|
||||
fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLogicalRight();
|
||||
} else {
|
||||
fromRight = first->logicalLeft() + first->logicalWidth() - first->borderLogicalRight();
|
||||
fromLeft = last->logicalLeft() + last->borderLogicalLeft();
|
||||
}
|
||||
|
||||
return std::max<LayoutUnit>(0, fromRight - fromLeft);
|
||||
ASSERT(containingBlock->isBox());
|
||||
return toRenderBox(containingBlock)->clientLogicalWidth();
|
||||
}
|
||||
|
||||
LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock) const
|
||||
{
|
||||
if (containingBlock->isBox()) {
|
||||
const RenderBlock* cb = containingBlock->isRenderBlock() ?
|
||||
toRenderBlock(containingBlock) : containingBlock->containingBlock();
|
||||
return cb->clientLogicalHeight();
|
||||
}
|
||||
|
||||
ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned());
|
||||
|
||||
const RenderInline* flow = toRenderInline(containingBlock);
|
||||
InlineFlowBox* first = flow->firstLineBox();
|
||||
InlineFlowBox* last = flow->lastLineBox();
|
||||
|
||||
// If the containing block is empty, return a height of 0.
|
||||
if (!first || !last)
|
||||
return 0;
|
||||
|
||||
LayoutRect boundingBox = flow->linesBoundingBox();
|
||||
LayoutUnit heightResult = boundingBox.height();
|
||||
heightResult -= (containingBlock->borderBefore() + containingBlock->borderAfter());
|
||||
return heightResult;
|
||||
ASSERT(containingBlock->isBox());
|
||||
const RenderBlock* cb = containingBlock->isRenderBlock() ?
|
||||
toRenderBlock(containingBlock) : containingBlock->containingBlock();
|
||||
return cb->clientLogicalHeight();
|
||||
}
|
||||
|
||||
static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRight, const RenderBox* child, const RenderBoxModelObject* containerBlock, LayoutUnit containerLogicalWidth)
|
||||
@ -1866,18 +1805,8 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
|
||||
if (child->parent()->style()->direction() == LTR) {
|
||||
LayoutUnit staticPosition = child->layer()->staticInlinePosition() - containerBlock->borderLogicalLeft();
|
||||
for (RenderObject* curr = child->parent(); curr && curr != containerBlock; curr = curr->container()) {
|
||||
if (curr->isBox()) {
|
||||
if (curr->isBox())
|
||||
staticPosition += toRenderBox(curr)->logicalLeft();
|
||||
if (toRenderBox(curr)->isRelPositioned())
|
||||
staticPosition += toRenderBox(curr)->relativePositionOffset().width();
|
||||
} else if (curr->isInline()) {
|
||||
if (curr->isRelPositioned()) {
|
||||
if (!curr->style()->logicalLeft().isAuto())
|
||||
staticPosition += curr->style()->logicalLeft().value();
|
||||
else
|
||||
staticPosition -= curr->style()->logicalRight().value();
|
||||
}
|
||||
}
|
||||
}
|
||||
logicalLeft.setValue(Fixed, staticPosition);
|
||||
} else {
|
||||
@ -1885,20 +1814,10 @@ static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
|
||||
LayoutUnit staticPosition = child->layer()->staticInlinePosition() + containerLogicalWidth + containerBlock->borderLogicalLeft();
|
||||
for (RenderObject* curr = child->parent(); curr; curr = curr->container()) {
|
||||
if (curr->isBox()) {
|
||||
if (curr != containerBlock) {
|
||||
if (curr != containerBlock)
|
||||
staticPosition -= toRenderBox(curr)->logicalLeft();
|
||||
if (toRenderBox(curr)->isRelPositioned())
|
||||
staticPosition -= toRenderBox(curr)->relativePositionOffset().width();
|
||||
}
|
||||
if (curr == enclosingBox)
|
||||
staticPosition -= enclosingBox->logicalWidth();
|
||||
} else if (curr->isInline()) {
|
||||
if (curr->isRelPositioned()) {
|
||||
if (!curr->style()->logicalLeft().isAuto())
|
||||
staticPosition -= curr->style()->logicalLeft().value();
|
||||
else
|
||||
staticPosition += curr->style()->logicalRight().value();
|
||||
}
|
||||
}
|
||||
if (curr == containerBlock)
|
||||
break;
|
||||
@ -3092,14 +3011,8 @@ LayoutRect RenderBox::layoutOverflowRectForPropagation() const
|
||||
if (!hasOverflowClip())
|
||||
rect.unite(layoutOverflowRect());
|
||||
|
||||
bool hasTransform = hasLayer() && layer()->transform();
|
||||
if (isRelPositioned() || hasTransform) {
|
||||
if (hasTransform)
|
||||
rect = layer()->currentTransform().mapRect(rect);
|
||||
|
||||
if (isRelPositioned())
|
||||
rect.move(offsetForInFlowPosition());
|
||||
}
|
||||
if (hasLayer() && layer()->transform())
|
||||
rect = layer()->currentTransform().mapRect(rect);
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
@ -327,7 +327,6 @@ public:
|
||||
void computeAndSetBlockDirectionMargins(const RenderBlock* containingBlock);
|
||||
|
||||
void positionLineBox(InlineBox*);
|
||||
void moveWithEdgeOfInlineContainerIfNecessary();
|
||||
|
||||
virtual InlineBox* createInlineBox();
|
||||
void dirtyLineBoxes(bool fullLayout);
|
||||
|
||||
@ -175,9 +175,6 @@ LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
|
||||
if (offsetParent->isBox())
|
||||
referencePoint.move(-toRenderBox(offsetParent)->borderLeft(), -toRenderBox(offsetParent)->borderTop());
|
||||
if (!isOutOfFlowPositioned()) {
|
||||
if (isRelPositioned())
|
||||
referencePoint.move(relativePositionOffset());
|
||||
|
||||
RenderObject* current;
|
||||
for (current = parent(); current != offsetParent && current->parent(); current = current->parent()) {
|
||||
// FIXME: What are we supposed to do inside SVG content?
|
||||
@ -192,11 +189,6 @@ LayoutPoint RenderBoxModelObject::adjustedPositionRelativeToOffsetParent(const L
|
||||
return referencePoint;
|
||||
}
|
||||
|
||||
LayoutSize RenderBoxModelObject::offsetForInFlowPosition() const
|
||||
{
|
||||
return isRelPositioned() ? relativePositionOffset() : LayoutSize();
|
||||
}
|
||||
|
||||
LayoutUnit RenderBoxModelObject::offsetLeft() const
|
||||
{
|
||||
// Note that RenderInline and RenderBox override this to pass a different
|
||||
|
||||
@ -59,8 +59,6 @@ public:
|
||||
LayoutSize relativePositionOffset() const;
|
||||
LayoutSize relativePositionLogicalOffset() const { return relativePositionOffset(); }
|
||||
|
||||
LayoutSize offsetForInFlowPosition() const;
|
||||
|
||||
// IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
|
||||
// to return the remaining width on a given line (and the height of a single line).
|
||||
virtual LayoutUnit offsetLeft() const;
|
||||
|
||||
@ -351,10 +351,6 @@ LayoutUnit RenderInline::marginAfter(const RenderStyle* otherStyle) const
|
||||
|
||||
const char* RenderInline::renderName() const
|
||||
{
|
||||
if (isRelPositioned())
|
||||
return "RenderInline (relative positioned)";
|
||||
if (isAnonymous())
|
||||
return "RenderInline (generated)";
|
||||
return "RenderInline";
|
||||
}
|
||||
|
||||
@ -584,21 +580,6 @@ LayoutRect RenderInline::linesVisualOverflowBoundingBox() const
|
||||
return rect;
|
||||
}
|
||||
|
||||
LayoutSize RenderInline::offsetFromContainer(const RenderObject* container, const LayoutPoint& point, bool* offsetDependsOnPoint) const
|
||||
{
|
||||
ASSERT(container == this->container());
|
||||
|
||||
LayoutSize offset;
|
||||
if (isRelPositioned())
|
||||
offset += offsetForInFlowPosition();
|
||||
|
||||
// FIXME(sky): Remove now that it's always false?
|
||||
if (offsetDependsOnPoint)
|
||||
*offsetDependsOnPoint = false;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
void RenderInline::mapLocalToContainer(const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags mode) const
|
||||
{
|
||||
if (paintInvalidationContainer == this)
|
||||
@ -711,44 +692,6 @@ int RenderInline::baselinePosition(FontBaseline baselineType, bool firstLine, Li
|
||||
return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction, linePositionMode) - fontMetrics.height()) / 2;
|
||||
}
|
||||
|
||||
LayoutSize RenderInline::offsetForInFlowPositionedInline(const RenderBox& child) const
|
||||
{
|
||||
// FIXME: This function isn't right with mixed writing modes.
|
||||
|
||||
ASSERT(isRelPositioned());
|
||||
if (!isRelPositioned())
|
||||
return LayoutSize();
|
||||
|
||||
// When we have an enclosing relpositioned inline, we need to add in the offset of the first line
|
||||
// box from the rest of the content, but only in the cases where we know we're positioned
|
||||
// relative to the inline itself.
|
||||
|
||||
LayoutSize logicalOffset;
|
||||
LayoutUnit inlinePosition;
|
||||
LayoutUnit blockPosition;
|
||||
if (firstLineBox()) {
|
||||
inlinePosition = LayoutUnit::fromFloatRound(firstLineBox()->logicalLeft());
|
||||
blockPosition = firstLineBox()->logicalTop();
|
||||
} else {
|
||||
inlinePosition = layer()->staticInlinePosition();
|
||||
blockPosition = layer()->staticBlockPosition();
|
||||
}
|
||||
|
||||
// Per http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width an absolute positioned box
|
||||
// with a static position should locate itself as though it is a normal flow box in relation to
|
||||
// its containing block. If this relative-positioned inline has a negative offset we need to
|
||||
// compensate for it so that we align the positioned object with the edge of its containing block.
|
||||
if (child.style()->hasStaticInlinePosition())
|
||||
logicalOffset.setWidth(std::max(LayoutUnit(), -offsetForInFlowPosition().width()));
|
||||
else
|
||||
logicalOffset.setWidth(inlinePosition);
|
||||
|
||||
if (!child.style()->hasStaticBlockPosition())
|
||||
logicalOffset.setHeight(blockPosition);
|
||||
|
||||
return logicalOffset;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class AbsoluteRectsIgnoringEmptyRectsGeneratorContext : public AbsoluteRectsGeneratorContext {
|
||||
|
||||
@ -58,8 +58,6 @@ public:
|
||||
|
||||
virtual void absoluteQuads(Vector<FloatQuad>&) const override;
|
||||
|
||||
virtual LayoutSize offsetFromContainer(const RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const override final;
|
||||
|
||||
IntRect linesBoundingBox() const;
|
||||
LayoutRect linesVisualOverflowBoundingBox() const;
|
||||
|
||||
@ -76,8 +74,6 @@ public:
|
||||
InlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
|
||||
InlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
|
||||
|
||||
LayoutSize offsetForInFlowPositionedInline(const RenderBox& child) const;
|
||||
|
||||
virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) const override final;
|
||||
|
||||
bool alwaysCreateLineBoxes() const { return alwaysCreateLineBoxesForRenderInline(); }
|
||||
@ -118,7 +114,7 @@ private:
|
||||
|
||||
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) override final;
|
||||
|
||||
virtual LayerType layerTypeRequired() const override { return isRelPositioned() || createsGroup() || hasClipPath() ? NormalLayer : NoLayer; }
|
||||
virtual LayerType layerTypeRequired() const override { return createsGroup() || hasClipPath() ? NormalLayer : NoLayer; }
|
||||
|
||||
virtual LayoutUnit offsetLeft() const override final;
|
||||
virtual LayoutUnit offsetTop() const override final;
|
||||
|
||||
@ -347,29 +347,12 @@ LayoutPoint RenderLayer::location() const
|
||||
}
|
||||
}
|
||||
|
||||
// Subtract our parent's scroll offset.
|
||||
if (renderer()->isOutOfFlowPositioned() && enclosingPositionedAncestor()) {
|
||||
RenderLayer* positionedParent = enclosingPositionedAncestor();
|
||||
|
||||
if (positionedParent->renderer()->isRelPositioned() && positionedParent->renderer()->isRenderInline()) {
|
||||
LayoutSize offset = toRenderInline(positionedParent->renderer())->offsetForInFlowPositionedInline(*toRenderBox(renderer()));
|
||||
localPoint += offset;
|
||||
}
|
||||
}
|
||||
|
||||
localPoint.move(offsetForInFlowPosition());
|
||||
|
||||
// FIXME: We'd really like to just get rid of the concept of a layer rectangle and rely on the renderers.
|
||||
localPoint -= inlineBoundingBoxOffset;
|
||||
|
||||
return localPoint;
|
||||
}
|
||||
|
||||
const LayoutSize RenderLayer::offsetForInFlowPosition() const
|
||||
{
|
||||
return renderer()->isRelPositioned() ? toRenderBoxModelObject(renderer())->offsetForInFlowPosition() : LayoutSize();
|
||||
}
|
||||
|
||||
TransformationMatrix RenderLayer::perspectiveTransform() const
|
||||
{
|
||||
if (!renderer()->hasTransform())
|
||||
|
||||
@ -120,9 +120,6 @@ public:
|
||||
void updateTransformationMatrix();
|
||||
RenderLayer* renderingContextRoot();
|
||||
|
||||
// Our current relative position offset.
|
||||
const LayoutSize offsetForInFlowPosition() const;
|
||||
|
||||
RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); }
|
||||
const RenderLayerStackingNode* stackingNode() const { return m_stackingNode.get(); }
|
||||
|
||||
|
||||
@ -308,7 +308,6 @@ public:
|
||||
}
|
||||
|
||||
bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositioned(); } // absolute or fixed positioning
|
||||
bool isRelPositioned() const { return m_bitfields.isRelPositioned(); } // relative positioning
|
||||
bool isPositioned() const { return m_bitfields.isPositioned(); }
|
||||
|
||||
bool isText() const { return m_bitfields.isText(); }
|
||||
@ -780,8 +779,6 @@ private:
|
||||
|
||||
public:
|
||||
bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOfFlowPositioned; }
|
||||
// FIXME(sky): Remove
|
||||
bool isRelPositioned() const { return false; }
|
||||
bool isPositioned() const { return m_positionedState != IsStaticallyPositioned; }
|
||||
|
||||
void setPositionedState(int positionState)
|
||||
|
||||
@ -198,10 +198,6 @@ inline void setStaticPositions(RenderBlockFlow* block, RenderBox* child)
|
||||
// inline so that we can obtain the value later.
|
||||
toRenderInline(containerBlock)->layer()->setStaticInlinePosition(block->startAlignedOffsetForLine(false));
|
||||
toRenderInline(containerBlock)->layer()->setStaticBlockPosition(blockHeight);
|
||||
|
||||
// If |child| is a leading or trailing positioned object this is its only opportunity to ensure it moves with an inline
|
||||
// container changing width.
|
||||
child->moveWithEdgeOfInlineContainerIfNecessary();
|
||||
}
|
||||
block->updateStaticInlinePositionForChild(child);
|
||||
child->layer()->setStaticBlockPosition(blockHeight);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user