summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/rendering/RenderBox.cpp')
-rw-r--r--Source/WebCore/rendering/RenderBox.cpp98
1 files changed, 63 insertions, 35 deletions
diff --git a/Source/WebCore/rendering/RenderBox.cpp b/Source/WebCore/rendering/RenderBox.cpp
index a1a3c9922..c56d7a9ea 100644
--- a/Source/WebCore/rendering/RenderBox.cpp
+++ b/Source/WebCore/rendering/RenderBox.cpp
@@ -201,7 +201,7 @@ void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl
void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
- // Horizontal writing mode definition is updated in RenderBoxModelObject::updateBoxModelInfoFromStyle,
+ // Horizontal writing mode definition is updated in RenderBoxModelObject::updateFromStyle,
// (as part of the RenderBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal
// writing mode value before style change here.
bool oldHorizontalWritingMode = isHorizontalWritingMode();
@@ -269,9 +269,9 @@ void RenderBox::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle
}
}
-void RenderBox::updateBoxModelInfoFromStyle()
+void RenderBox::updateFromStyle()
{
- RenderBoxModelObject::updateBoxModelInfoFromStyle();
+ RenderBoxModelObject::updateFromStyle();
RenderStyle* styleToUse = style();
bool isRootObject = isRoot();
@@ -403,7 +403,7 @@ void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul
void RenderBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
{
- quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height()), false, wasFixed));
+ quads.append(localToAbsoluteQuad(FloatRect(0, 0, width(), height()), 0 /* mode */, wasFixed));
}
void RenderBox::updateLayerTransform()
@@ -436,7 +436,7 @@ IntRect RenderBox::absoluteContentBox() const
{
// This is wrong with transforms and flipped writing modes.
IntRect rect = pixelSnappedIntRect(contentBoxRect());
- FloatPoint absPos = localToAbsolute(FloatPoint());
+ FloatPoint absPos = localToAbsolute();
rect.move(absPos.x(), absPos.y());
return rect;
}
@@ -447,7 +447,7 @@ FloatQuad RenderBox::absoluteContentQuad() const
return localToAbsoluteQuad(FloatRect(rect));
}
-LayoutRect RenderBox::outlineBoundsForRepaint(RenderBoxModelObject* repaintContainer, LayoutPoint* cachedOffsetToRepaintContainer) const
+LayoutRect RenderBox::outlineBoundsForRepaint(RenderLayerModelObject* repaintContainer, LayoutPoint* cachedOffsetToRepaintContainer) const
{
LayoutRect box = borderBoundingBox();
adjustRectForOutlineAndShadow(box);
@@ -698,24 +698,34 @@ void RenderBox::setOverrideLogicalContentWidth(LayoutUnit width)
gOverrideWidthMap->set(this, width);
}
-void RenderBox::clearOverrideSize()
+void RenderBox::clearOverrideLogicalContentHeight()
{
if (gOverrideHeightMap)
gOverrideHeightMap->remove(this);
+}
+
+void RenderBox::clearOverrideLogicalContentWidth()
+{
if (gOverrideWidthMap)
gOverrideWidthMap->remove(this);
}
+void RenderBox::clearOverrideSize()
+{
+ clearOverrideLogicalContentHeight();
+ clearOverrideLogicalContentWidth();
+}
+
LayoutUnit RenderBox::overrideLogicalContentWidth() const
{
- // FIXME: This should probably be returning contentLogicalWidth instead of contentWidth.
- return hasOverrideWidth() ? gOverrideWidthMap->get(this) : contentWidth();
+ ASSERT(hasOverrideWidth());
+ return gOverrideWidthMap->get(this);
}
LayoutUnit RenderBox::overrideLogicalContentHeight() const
{
- // FIXME: This should probably be returning contentLogicalHeight instead of contentHeight.
- return hasOverrideHeight() ? gOverrideHeightMap->get(this) : contentHeight();
+ ASSERT(hasOverrideHeight());
+ return gOverrideHeightMap->get(this);
}
LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const
@@ -1258,7 +1268,7 @@ LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const
return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.value());
}
-void RenderBox::mapLocalToContainer(RenderBoxModelObject* repaintContainer, TransformState& transformState, MapLocalToContainerFlags mode, bool* wasFixed) const
+void RenderBox::mapLocalToContainer(RenderLayerModelObject* repaintContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed) const
{
if (repaintContainer == this)
return;
@@ -1323,7 +1333,7 @@ void RenderBox::mapLocalToContainer(RenderBoxModelObject* repaintContainer, Tran
o->mapLocalToContainer(repaintContainer, transformState, mode, wasFixed);
}
-const RenderObject* RenderBox::pushMappingToContainer(const RenderBoxModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
+const RenderObject* RenderBox::pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap& geometryMap) const
{
ASSERT(ancestorToStopAt != this);
@@ -1363,18 +1373,18 @@ const RenderObject* RenderBox::pushMappingToContainer(const RenderBoxModelObject
return ancestorSkipped ? ancestorToStopAt : container;
}
-void RenderBox::mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState& transformState) const
+void RenderBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const
{
bool isFixedPos = style()->position() == FixedPosition;
bool hasTransform = hasLayer() && layer()->transform();
- if (hasTransform) {
+ if (hasTransform && !isFixedPos) {
// If this box has a transform, it acts as a fixed position container for fixed descendants,
// and may itself also be fixed position. So propagate 'fixed' up only if this box is fixed position.
- fixed &= isFixedPos;
- } else
- fixed |= isFixedPos;
+ mode &= ~IsFixed;
+ } else if (isFixedPos)
+ mode |= IsFixed;
- RenderBoxModelObject::mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
+ RenderBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState);
}
LayoutSize RenderBox::offsetFromContainer(RenderObject* o, const LayoutPoint& point, bool* offsetDependsOnPoint) const
@@ -1473,7 +1483,7 @@ void RenderBox::deleteLineBoxWrapper()
}
}
-LayoutRect RenderBox::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const
+LayoutRect RenderBox::clippedOverflowRectForRepaint(RenderLayerModelObject* repaintContainer) const
{
if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
return LayoutRect();
@@ -1500,7 +1510,7 @@ LayoutRect RenderBox::clippedOverflowRectForRepaint(RenderBoxModelObject* repain
return r;
}
-void RenderBox::computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect& rect, bool fixed) const
+void RenderBox::computeRectForRepaint(RenderLayerModelObject* repaintContainer, LayoutRect& rect, bool fixed) const
{
// The rect we compute at each step is shifted by our x/y offset in the parent container's coordinate space.
// Only when we cross a writing mode boundary will we have to possibly flipForWritingMode (to convert into a more appropriate
@@ -1762,6 +1772,24 @@ LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Layou
return logicalWidthResult;
}
+static bool flexItemHasStretchAlignment(const RenderObject* flexitem)
+{
+ RenderObject* parent = flexitem->parent();
+ return flexitem->style()->alignSelf() == AlignStretch || (flexitem->style()->alignSelf() == AlignAuto && parent->style()->alignItems() == AlignStretch);
+}
+
+static bool isStretchingColumnFlexItem(const RenderObject* flexitem)
+{
+ RenderObject* parent = flexitem->parent();
+ if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VERTICAL && parent->style()->boxAlign() == BSTRETCH)
+ return true;
+
+ // We don't stretch multiline flexboxes because they need to apply line spacing (align-content) first.
+ if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexWrapNone && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem))
+ return true;
+ return false;
+}
+
bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const
{
// Marquees in WinIE are like a mixture of blocks and inline-blocks. They size as though they're blocks,
@@ -1790,11 +1818,10 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const
// In the case of columns that have a stretch alignment, we go ahead and layout at the
// stretched size to avoid an extra layout when applying alignment.
if (parent()->isFlexibleBox()) {
- // For multiline columns, we need to apply the flex-line-pack first, so we can't stretch now.
+ // For multiline columns, we need to apply align-content first, so we can't stretch now.
if (!parent()->style()->isColumnFlexDirection() || parent()->style()->flexWrap() != FlexWrapNone)
return true;
- EAlignItems itemAlign = style()->alignSelf();
- if (itemAlign != AlignStretch && (itemAlign != AlignAuto || parent()->style()->alignItems() != AlignStretch))
+ if (!flexItemHasStretchAlignment(this))
return true;
}
@@ -1802,16 +1829,14 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const
// that don't stretch their kids lay out their children at their intrinsic widths.
// FIXME: Think about block-flow here.
// https://bugs.webkit.org/show_bug.cgi?id=46473
- if (parent()->isDeprecatedFlexibleBox()
- && (parent()->style()->boxOrient() == HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))
+ if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() == HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))
return true;
- // Button, input, select, textarea, and legend treat
- // width value of 'auto' as 'intrinsic' unless it's in a
- // stretching vertical flexbox.
+ // Button, input, select, textarea, and legend treat width value of 'auto' as 'intrinsic' unless it's in a
+ // stretching column flexbox.
// FIXME: Think about block-flow here.
// https://bugs.webkit.org/show_bug.cgi?id=46473
- if (logicalWidth.type() == Auto && !(parent()->isDeprecatedFlexibleBox() && parent()->style()->boxOrient() == VERTICAL && parent()->style()->boxAlign() == BSTRETCH) && node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)))
+ if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)))
return true;
if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode())
@@ -2341,8 +2366,11 @@ LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h) const
// We need to stop here, since we don't want to increase the height of the table
// artificially. We're going to rely on this cell getting expanded to some new
// height, and then when we lay out again we'll use the calculation below.
- if (isTableCell() && (h.isAuto() || h.isPercent()))
- return overrideLogicalContentHeight();
+ if (isTableCell() && (h.isAuto() || h.isPercent())) {
+ if (hasOverrideHeight())
+ return overrideLogicalContentHeight();
+ return logicalHeight() - borderAndPaddingLogicalHeight();
+ }
if (h.isPercent() && isOutOfFlowPositioned()) {
// FIXME: This is wrong if the containingBlock has a perpendicular writing mode.
@@ -3315,7 +3343,7 @@ void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
LayoutUnit logicalLeftPos = logicalLeftValue + marginLogicalLeftAlias;
computeLogicalLeftPositionedOffset(logicalLeftPos, this, computedValues.m_extent, containerBlock, containerLogicalWidth);
- computedValues.m_position = logicalLeftPos.round();
+ computedValues.m_position = logicalLeftPos;
}
void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValues& computedValues) const
@@ -3444,7 +3472,7 @@ void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu
// Use computed values to calculate the vertical position.
LayoutUnit logicalTopPos = logicalTopValue + marginBeforeAlias;
computeLogicalTopPositionedOffset(logicalTopPos, this, computedValues.m_extent, containerBlock, containerLogicalHeight);
- computedValues.m_position = logicalTopPos.round();
+ computedValues.m_position = logicalTopPos;
}
LayoutRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit* extraWidthToEndOfLine)
@@ -3820,7 +3848,7 @@ RenderLayer* RenderBox::enclosingFloatPaintingLayer() const
{
const RenderObject* curr = this;
while (curr) {
- RenderLayer* layer = curr->hasLayer() && curr->isBox() ? toRenderBoxModelObject(curr)->layer() : 0;
+ RenderLayer* layer = curr->hasLayer() && curr->isBox() ? toRenderBox(curr)->layer() : 0;
if (layer && layer->isSelfPaintingLayer())
return layer;
curr = curr->parent();