Diff
Modified: trunk/LayoutTests/ChangeLog (138036 => 138037)
--- trunk/LayoutTests/ChangeLog 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/LayoutTests/ChangeLog 2012-12-18 18:23:15 UTC (rev 138037)
@@ -1,3 +1,15 @@
+2012-12-18 Tony Chang <t...@chromium.org>
+
+ REGRESSION(r136324): flex items with percent heights not resizing
+ https://bugs.webkit.org/show_bug.cgi?id=105213
+
+ Reviewed by Ojan Vafai.
+
+ Add a test that changes the height of a flexbox with a percentage height child.
+
+ * css3/flexbox/flexitem-percent-height-change-expected.txt: Added.
+ * css3/flexbox/flexitem-percent-height-change.html: Added.
+
2012-12-17 Simon Fraser <simon.fra...@apple.com>
Fix position:-webkit-sticky behavior when zoomed
Added: trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change-expected.txt (0 => 138037)
--- trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change-expected.txt 2012-12-18 18:23:15 UTC (rev 138037)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change.html (0 => 138037)
--- trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change.html (rev 0)
+++ trunk/LayoutTests/css3/flexbox/flexitem-percent-height-change.html 2012-12-18 18:23:15 UTC (rev 138037)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script>
+window._onload_ = function()
+{
+ var outer = document.getElementById("outer");
+ outer.style.height = "300px";
+ outer.offsetLeft;
+ outer.style.height = "100px";
+ checkLayout('#outer');
+};
+</script>
+</head>
+<body>
+<div id="outer" data-expected-height="100">
+ <div class="flexbox" data-expected-height="100" style="height: 100%">
+ <div class="flex-one" data-expected-height="100" style="overflow-y: auto; height: 100%">
+ <div data-expected-height="100" style="height: 100%">
+ <div data-expected-height="100" style="width: 100px; height: 100px; background-color: green"></div>
+ </div>
+ </div>
+ </div>
+</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (138036 => 138037)
--- trunk/Source/WebCore/ChangeLog 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/Source/WebCore/ChangeLog 2012-12-18 18:23:15 UTC (rev 138037)
@@ -1,3 +1,30 @@
+2012-12-18 Tony Chang <t...@chromium.org>
+
+ REGRESSION(r136324): flex items with percent heights not resizing
+ https://bugs.webkit.org/show_bug.cgi?id=105213
+
+ Reviewed by Ojan Vafai.
+
+ We were missing some of the logic for when to relayout a flex child. Refactor
+ the code in RenderBlock::layoutBlockChildren so we can use it in RenderFlexibleBox.
+
+ Test: css3/flexbox/flexitem-percent-height-change.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::updateNeedsLayoutAndPreferredLogicalWidthsDirtyBeforeBlockChildLayout):
+ Pull out logic needed by RenderFlexibleBox.
+ (WebCore::RenderBlock::layoutBlockChildren): Use helper method.
+ * rendering/RenderBlock.h:
+ (RenderBlock): Add updateNeedsLayoutAndPreferredLogicalWidthsDirtyBeforeBlockChildLayout.
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::layoutBlock): Pass through relayoutChildren bool.
+ (WebCore::RenderFlexibleBox::layoutFlexItems): Pass through relayoutChildren and mark the child as needing
+ layout if it has a percent height.
+ (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): We need to always layout here since we're
+ trying to get the preferred size.
+ (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+ * rendering/RenderFlexibleBox.h:
+
2012-12-17 Simon Fraser <simon.fra...@apple.com>
Fix position:-webkit-sticky behavior when zoomed
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (138036 => 138037)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-12-18 18:23:15 UTC (rev 138037)
@@ -2317,6 +2317,18 @@
}
}
+void RenderBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox* child)
+{
+ // FIXME: Technically percentage height objects only need a relayout if their percentage isn't going to be turned into
+ // an auto value. Add a method to determine this, so that we can avoid the relayout.
+ if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView()))
+ child->setChildNeedsLayout(true, MarkOnlyThis);
+
+ // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
+ if (relayoutChildren && child->needsPreferredWidthsRecalculation())
+ child->setPreferredLogicalWidthsDirty(true, MarkOnlyThis);
+}
+
void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalBottom)
{
if (gPercentHeightDescendantsMap) {
@@ -2366,16 +2378,8 @@
if (childToExclude == child)
continue; // Skip this child, since it will be positioned by the specialized subclass (fieldsets and ruby runs).
- // Make sure we layout children if they need it.
- // FIXME: Technically percentage height objects only need a relayout if their percentage isn't going to be turned into
- // an auto value. Add a method to determine this, so that we can avoid the relayout.
- if (relayoutChildren || (child->hasRelativeLogicalHeight() && !isRenderView()))
- child->setChildNeedsLayout(true, MarkOnlyThis);
+ updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
- // If relayoutChildren is set and the child has percentage padding or an embedded content box, we also need to invalidate the childs pref widths.
- if (relayoutChildren && child->needsPreferredWidthsRecalculation())
- child->setPreferredLogicalWidthsDirty(true, MarkOnlyThis);
-
// Handle the four types of special elements first. These include positioned content, floating content, compacts and
// run-ins. When we encounter these four types of objects, we don't actually lay them out as normal flow blocks.
if (handleSpecialChild(child, marginInfo))
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (138036 => 138037)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2012-12-18 18:23:15 UTC (rev 138037)
@@ -528,6 +528,8 @@
void updateRegionsAndExclusionsLogicalSize();
void computeRegionRangeForBlock();
+ void updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, RenderBox*);
+
virtual void checkForPaginationLogicalHeightChange(LayoutUnit& pageLogicalHeight, bool& pageLogicalHeightChanged, bool& hasSpecifiedPageLogicalHeight);
private:
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (138036 => 138037)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-12-18 18:23:15 UTC (rev 138037)
@@ -330,12 +330,12 @@
Vector<LineContext> lineContexts;
OrderHashSet orderValues;
- computeMainAxisPreferredSizes(relayoutChildren, orderValues);
+ computeMainAxisPreferredSizes(orderValues);
m_orderIterator = adoptPtr(new OrderIterator(this, orderValues));
ChildFrameRects oldChildRects;
appendChildFrameRects(oldChildRects);
- layoutFlexItems(lineContexts);
+ layoutFlexItems(relayoutChildren, lineContexts);
LayoutUnit oldClientAfterEdge = clientLogicalBottom();
updateLogicalHeight();
@@ -723,7 +723,7 @@
return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis));
}
-void RenderFlexibleBox::layoutFlexItems(Vector<LineContext>& lineContexts)
+void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren, Vector<LineContext>& lineContexts)
{
ASSERT(m_orderIterator);
@@ -745,7 +745,7 @@
ASSERT(inflexibleItems.size() > 0);
}
- layoutAndPlaceChildren(crossAxisOffset, orderedChildren, childSizes, availableFreeSpace, lineContexts);
+ layoutAndPlaceChildren(crossAxisOffset, orderedChildren, childSizes, availableFreeSpace, relayoutChildren, lineContexts);
}
}
@@ -864,7 +864,7 @@
return minimumValueForLength(margin, availableSize, view);
}
-void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet& orderValues)
+void RenderFlexibleBox::computeMainAxisPreferredSizes(OrderHashSet& orderValues)
{
RenderView* renderView = view();
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
@@ -876,8 +876,7 @@
// Only need to layout here if we will need to get the logicalHeight of the child in computeNextFlexLine.
Length childMainAxisMin = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
if (hasOrthogonalFlow(child) && (flexBasisForChild(child).isAuto() || childMainAxisMin.isAuto())) {
- if (!relayoutChildren)
- child->setChildNeedsLayout(true, MarkOnlyThis);
+ child->setChildNeedsLayout(true, MarkOnlyThis);
child->layoutIfNeeded();
}
@@ -1109,7 +1108,7 @@
child->updateLogicalHeight();
}
-void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList& children, const Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, Vector<LineContext>& lineContexts)
+void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList& children, const Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>& lineContexts)
{
ASSERT(childSizes.size() == children.size());
@@ -1131,6 +1130,7 @@
prepareChildForPositionedLayout(child, mainAxisOffset, crossAxisOffset, FlipForRowReverse);
continue;
}
+
LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPaddingExtentForChild(child);
setLogicalOverrideSize(child, childPreferredSize);
// FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905.
@@ -1140,6 +1140,7 @@
// To avoid double applying margin changes in updateAutoMarginsInCrossAxis, we reset the margins here.
resetAutoMarginsAndLogicalTopInCrossAxis(child);
}
+ updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
child->layoutIfNeeded();
updateAutoMarginsInMainAxis(child, autoMarginOffset);
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (138036 => 138037)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2012-12-18 18:07:56 UTC (rev 138036)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h 2012-12-18 18:23:15 UTC (rev 138037)
@@ -118,7 +118,7 @@
LayoutUnit mainAxisScrollbarExtentForChild(RenderBox* child) const;
LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child);
- void layoutFlexItems(Vector<LineContext>&);
+ void layoutFlexItems(bool relayoutChildren, Vector<LineContext>&);
LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace);
void updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit autoMarginOffset);
bool hasAutoMarginsInCrossAxis(RenderBox* child) const;
@@ -132,7 +132,7 @@
LayoutUnit marginBoxAscentForChild(RenderBox*);
LayoutUnit computeChildMarginValue(Length margin, RenderView*);
- void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&);
+ void computeMainAxisPreferredSizes(OrderHashSet&);
LayoutUnit adjustChildSizeForMinAndMax(RenderBox*, LayoutUnit childSize);
bool computeNextFlexLine(OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent);
@@ -144,7 +144,7 @@
void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode);
size_t numberOfInFlowPositionedChildren(const OrderedFlexItemList&) const;
- void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, Vector<LineContext>&);
+ void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, bool relayoutChildren, Vector<LineContext>&);
void layoutColumnReverse(const OrderedFlexItemList&, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace);
void alignFlexLines(Vector<LineContext>&);
void alignChildren(const Vector<LineContext>&);