- Revision
- 129975
- Author
- kenn...@webkit.org
- Date
- 2012-09-29 03:22:22 -0700 (Sat, 29 Sep 2012)
Log Message
Scroll offset of flex items lost during relayout
https://bugs.webkit.org/show_bug.cgi?id=97706
Reviewed by Tony Chang.
Source/WebCore:
Test: fast/flexbox/overflow-keep-scrollpos.html
Flex box does a second pass layout of the flex children.
We layout the child without scrollbars (to get the size
used for flexing), then we relayout the child at its final size.
We must not apply the scroll position during the first pass,
as it will be clamped to 0 (no scrolling possible).
* rendering/RenderBlock.h:
(RenderBlock):
Make updateScrollInfoAfterLayout public
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock):
Delay applying scroll info until we clamp the size of the child
and get scrollbars back again. For this to work we use
RenderBlock::updateScrollInfoAfterLayout instead of the non-guarded
RenderLayer::updateScrollInfoAfterLayout.
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::updateScrollInfoAfterLayout):
Add workaround for now to keep passing css3/flexbox/child-overflow.html
Basically do not postpone applying scroll changes for RenderBlocks
with opposite writing mode, as they need to have their content
overflow in the right direction.
LayoutTests:
Add a new test for testing that flex items scroll offsets are
not lost during relayout.
* css3/flexbox/overflow-keep-scrollpos-expected.txt: Added.
* css3/flexbox/overflow-keep-scrollpos.html: Added.
* css3/flexbox/child-overflow.html: Fix minor errors.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (129974 => 129975)
--- trunk/LayoutTests/ChangeLog 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/LayoutTests/ChangeLog 2012-09-29 10:22:22 UTC (rev 129975)
@@ -1,3 +1,17 @@
+2012-09-29 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ Scroll offset of flex items lost during relayout
+ https://bugs.webkit.org/show_bug.cgi?id=97706
+
+ Reviewed by Tony Chang.
+
+ Add a new test for testing that flex items scroll offsets are
+ not lost during relayout.
+
+ * css3/flexbox/overflow-keep-scrollpos-expected.txt: Added.
+ * css3/flexbox/overflow-keep-scrollpos.html: Added.
+ * css3/flexbox/child-overflow.html: Fix minor errors.
+
2012-09-28 Emil A Eklund <e...@chromium.org>
Improve saturation arithmetic support in FractionalLayoutUnit
Modified: trunk/LayoutTests/css3/flexbox/child-overflow.html (129974 => 129975)
--- trunk/LayoutTests/css3/flexbox/child-overflow.html 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/LayoutTests/css3/flexbox/child-overflow.html 2012-09-29 10:22:22 UTC (rev 129975)
@@ -77,13 +77,11 @@
document.body.innerHTML +=
"<div class='" + containerClass + "'>" +
"<div class='" + flexboxClass + "'>" +
- "<div style='-webkit-flex: 0 1 auto; -webkit-flex: 0 1 auto'><div></div></div>" +
+ "<div style='-webkit-flex: 0 1 auto'><div></div></div>" +
"</div>" +
"</div> ";
});
document.body.innerHTML += "<br>";
});
-
</script>
-</body>
</html>
Added: trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos-expected.txt (0 => 129975)
--- trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos-expected.txt (rev 0)
+++ trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos-expected.txt 2012-09-29 10:22:22 UTC (rev 129975)
@@ -0,0 +1,2 @@
+PASS document.querySelector('.overflow-auto').scrollTop is 50
+
Added: trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos.html (0 => 129975)
--- trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos.html (rev 0)
+++ trunk/LayoutTests/css3/flexbox/overflow-keep-scrollpos.html 2012-09-29 10:22:22 UTC (rev 129975)
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style>
+div.flexbox {
+ display: -webkit-flex;
+}
+div.overflow-auto {
+ overflow: auto;
+}
+div.flex {
+ -webkit-flex: 1;
+}
+.container {
+ width: 100px;
+ height: 100px;
+}
+</style>
+<script>
+ function runTest() {
+ document.querySelector('.overflow-auto').scrollTop = 50;
+ document.querySelector('#sidebar').innerHTML = '';
+ shouldBe("document.querySelector('.overflow-auto').scrollTop", "50");
+ }
+</script>
+
+</head>
+<body _onload_="runTest()">
+<div class="container flexbox">
+ <div class="flex overflow-auto flexbox">
+ <div style="height: 400px"></div>
+ </div>
+ <div id="sidebar">foo</div>
+</div>
+<div id="console"></div>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (129974 => 129975)
--- trunk/Source/WebCore/ChangeLog 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/Source/WebCore/ChangeLog 2012-09-29 10:22:22 UTC (rev 129975)
@@ -1,3 +1,42 @@
+2012-09-29 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ Scroll offset of flex items lost during relayout
+ https://bugs.webkit.org/show_bug.cgi?id=97706
+
+ Reviewed by Tony Chang.
+
+ Test: fast/flexbox/overflow-keep-scrollpos.html
+
+ Flex box does a second pass layout of the flex children.
+
+ We layout the child without scrollbars (to get the size
+ used for flexing), then we relayout the child at its final size.
+
+ We must not apply the scroll position during the first pass,
+ as it will be clamped to 0 (no scrolling possible).
+
+ * rendering/RenderBlock.h:
+ (RenderBlock):
+
+ Make updateScrollInfoAfterLayout public
+
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::layoutBlock):
+
+ Delay applying scroll info until we clamp the size of the child
+ and get scrollbars back again. For this to work we use
+ RenderBlock::updateScrollInfoAfterLayout instead of the non-guarded
+ RenderLayer::updateScrollInfoAfterLayout.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::updateScrollInfoAfterLayout):
+
+ Add workaround for now to keep passing css3/flexbox/child-overflow.html
+
+ Basically do not postpone applying scroll changes for RenderBlocks
+ with opposite writing mode, as they need to have their content
+ overflow in the right direction.
+
2012-09-29 Dimitri Glazkov <dglaz...@chromium.org>
Slightly improve clarity of the patch in bug 78595.
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (129974 => 129975)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-09-29 10:22:22 UTC (rev 129975)
@@ -1355,6 +1355,15 @@
void RenderBlock::updateScrollInfoAfterLayout()
{
if (hasOverflowClip()) {
+ if (style()->isFlippedBlocksWritingMode()) {
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937
+ // Workaround for now. We cannot delay the scroll info for overflow
+ // for items with opposite writing directions, as the contents needs
+ // to overflow in that direction
+ layer()->updateScrollInfoAfterLayout();
+ return;
+ }
+
if (gDelayUpdateScrollInfo)
gDelayedUpdateScrollInfoSet->add(this);
else
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (129974 => 129975)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2012-09-29 10:22:22 UTC (rev 129975)
@@ -460,6 +460,8 @@
static void startDelayUpdateScrollInfo();
static void finishDelayUpdateScrollInfo();
+ void updateScrollInfoAfterLayout();
+
virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
@@ -858,8 +860,6 @@
bool expandsToEncloseOverhangingFloats() const;
- void updateScrollInfoAfterLayout();
-
void splitBlocks(RenderBlock* fromBlock, RenderBlock* toBlock, RenderBlock* middleBlock,
RenderObject* beforeChild, RenderBoxModelObject* oldCont);
void splitFlow(RenderObject* beforeChild, RenderBlock* newBlockBox,
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (129974 => 129975)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-09-29 09:21:11 UTC (rev 129974)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2012-09-29 10:22:22 UTC (rev 129975)
@@ -258,6 +258,8 @@
m_overflow.clear();
+ RenderBlock::startDelayUpdateScrollInfo();
+
WTF::Vector<LineContext> lineContexts;
OrderHashSet orderValues;
computeMainAxisPreferredSizes(relayoutChildren, orderValues);
@@ -268,6 +270,8 @@
updateLogicalHeight();
repositionLogicalHeightDependentFlexItems(*m_orderIterator, lineContexts, oldClientAfterEdge);
+ RenderBlock::finishDelayUpdateScrollInfo();
+
if (size() != previousSize)
relayoutChildren = true;
@@ -283,8 +287,7 @@
// Update our scroll information if we're overflow:auto/scroll/hidden now that we know if
// we overflow or not.
- if (hasOverflowClip())
- layer()->updateScrollInfoAfterLayout();
+ updateScrollInfoAfterLayout();
repainter.repaintAfterLayout();