Diff
Modified: trunk/LayoutTests/ChangeLog (139350 => 139351)
--- trunk/LayoutTests/ChangeLog 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/LayoutTests/ChangeLog 2013-01-10 20:32:24 UTC (rev 139351)
@@ -1,3 +1,14 @@
+2013-01-10 Ojan Vafai <o...@chromium.org>
+
+ Flexboxes incorrectly add the scrollbar width to the intrinsic width of fixed-width items
+ https://bugs.webkit.org/show_bug.cgi?id=106591
+
+ Reviewed by Levi Weintraub.
+
+ * fast/css/fixed-width-intrinsic-width-excludes-scrollbars-expected.txt: Added.
+ * fast/css/fixed-width-intrinsic-width-excludes-scrollbars.html: Added.
+ * fast/css/positioned-overflow-scroll.html:
+
2013-01-10 Zan Dobersek <zandober...@gmail.com>
Unreviewed GTK gardening.
Added: trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars-expected.txt (0 => 139351)
--- trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars-expected.txt 2013-01-10 20:32:24 UTC (rev 139351)
@@ -0,0 +1 @@
+PASS
Added: trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars.html (0 => 139351)
--- trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars.html (rev 0)
+++ trunk/LayoutTests/fast/css/fixed-width-intrinsic-width-excludes-scrollbars.html 2013-01-10 20:32:24 UTC (rev 139351)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<style>
+.container {
+ display: -webkit-flex;
+ display: -moz-flex;
+ display: -ie-flex;
+ display: -o-flex;
+ display: flex;
+}
+.container > div {
+ overflow: scroll;
+ width: 50px;
+ height: 50px;
+}
+</style>
+
+<div class="container" style="display: -webkit-flex">
+ <div></div>
+ <div style="display:-webkit-flex;"></div>
+ <div style="display:-webkit-box;"></div>
+</div>
+
+<script src=""
+<script>
+Array.prototype.forEach.call(document.querySelectorAll('.container > div'), function(item) {
+ item.setAttribute('data-expected-width', 50);
+ item.setAttribute('data-expected-height', 50);
+});
+checkLayout('.container');
+</script>
\ No newline at end of file
Modified: trunk/LayoutTests/fast/css/positioned-overflow-scroll.html (139350 => 139351)
--- trunk/LayoutTests/fast/css/positioned-overflow-scroll.html 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/LayoutTests/fast/css/positioned-overflow-scroll.html 2013-01-10 20:32:24 UTC (rev 139351)
@@ -14,8 +14,10 @@
<body>
Test that scrollbar width is added to the intrinsic width of different display types.
-<div style="top: 100px" data-expected-width=100 data-expected-height=100><span class="box"></span></div>
-<div style="display: -webkit-box; top:100px; left: 150px;" data-expected-width=100 data-expected-height=100><span class="box"></span></div>
+<div style="top: 100px"><span class="box"></span></div>
+<div style="top: 100px; left: 150px; display: -webkit-box;"><span class="box"></span></div>
+<div style="top: 100px; left: 300px; -webkit-writing-mode: vertical-rl; overflow-x: hidden" data-no-horizontal-scrollbar><span class="box"></span></div>
+<div style="top: 100px; left: 450px; overflow-y: hidden" data-no-vertical-scrollbar><span class="box"></span></div>
<script src=""
<script>
@@ -26,8 +28,14 @@
document.body.removeChild(dummy);
Array.prototype.forEach.call(document.querySelectorAll('div'), function(node) {
- node.setAttribute('data-expected-width', 100 + scrollbarWidth);
- node.setAttribute('data-expected-height', 100 + scrollbarWidth);
+ var width = 100;
+ if (!node.hasAttribute('data-no-vertical-scrollbar'))
+ width += scrollbarWidth;
+ node.setAttribute('data-expected-width', width);
+ var height = 100;
+ if (!node.hasAttribute('data-no-horizontal-scrollbar'))
+ height += scrollbarWidth;
+ node.setAttribute('data-expected-height', height);
});
checkLayout('body');
</script>
Modified: trunk/Source/WebCore/ChangeLog (139350 => 139351)
--- trunk/Source/WebCore/ChangeLog 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/ChangeLog 2013-01-10 20:32:24 UTC (rev 139351)
@@ -1,3 +1,39 @@
+2013-01-10 Ojan Vafai <o...@chromium.org>
+
+ Flexboxes incorrectly add the scrollbar width to the intrinsic width of fixed-width items
+ https://bugs.webkit.org/show_bug.cgi?id=106591
+
+ Reviewed by Levi Weintraub.
+
+ The scrollbar width should only be added if the width of the flex item
+ is not fixed.
+
+ Test: fast/css/fixed-width-intrinsic-width-excludes-scrollbars.html
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::computePreferredLogicalWidths):
+ Use shared helper method. This also happens to fix the vertical
+ writing-mode case.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::instrinsicScrollbarLogicalWidth):
+ (WebCore):
+ * rendering/RenderBox.h:
+ (RenderBox):
+ Add a method for determining the scrollbar's contribution to the boxes
+ intrinsic width.
+
+ * rendering/RenderDeprecatedFlexibleBox.cpp:
+ (WebCore::RenderDeprecatedFlexibleBox::computePreferredLogicalWidths):
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::computePreferredLogicalWidths):
+ Use shared code for determining the scrollbar width and only add the
+ width when computing the intrinsic widths.
+
+ * rendering/RenderGrid.cpp:
+ (WebCore::RenderGrid::computePreferredLogicalWidths):\
+ Just adding a FIXME to account for scrollbar width.
+
2013-01-10 Nate Chapin <jap...@chromium.org>
Replace unnecessary null-checks with an assert in MainResourceLoader::continueAfterNavigationPolicy.
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-01-10 20:32:24 UTC (rev 139351)
@@ -5604,14 +5604,8 @@
m_minPreferredLogicalWidth = 0;
}
- int scrollbarWidth = 0;
- // FIXME: This should only be done for horizontal writing mode.
- // For vertical writing mode, this should check overflowX and use the horizontalScrollbarHeight.
- if (hasOverflowClip() && styleToUse->overflowY() == OSCROLL) {
- layer()->setHasVerticalScrollbar(true);
- scrollbarWidth = verticalScrollbarWidth();
- m_maxPreferredLogicalWidth += scrollbarWidth;
- }
+ int scrollbarWidth = instrinsicScrollbarLogicalWidth();
+ m_maxPreferredLogicalWidth += scrollbarWidth;
if (isTableCell()) {
Length w = toRenderTableCell(this)->styleOrColLogicalWidth();
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2013-01-10 20:32:24 UTC (rev 139351)
@@ -622,6 +622,24 @@
return includeHorizontalScrollbarSize() ? layer()->horizontalScrollbarHeight() : 0;
}
+int RenderBox::instrinsicScrollbarLogicalWidth() const
+{
+ if (!hasOverflowClip())
+ return 0;
+
+ if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) {
+ ASSERT(layer()->hasVerticalScrollbar());
+ return verticalScrollbarWidth();
+ }
+
+ if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) {
+ ASSERT(layer()->hasHorizontalScrollbar());
+ return horizontalScrollbarHeight();
+ }
+
+ return 0;
+}
+
bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier, Node** stopNode)
{
RenderLayer* l = layer();
Modified: trunk/Source/WebCore/rendering/RenderBox.h (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderBox.h 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2013-01-10 20:32:24 UTC (rev 139351)
@@ -441,6 +441,7 @@
virtual int verticalScrollbarWidth() const;
int horizontalScrollbarHeight() const;
+ int instrinsicScrollbarLogicalWidth() const;
int scrollbarLogicalHeight() const { return style()->isHorizontalWritingMode() ? horizontalScrollbarHeight() : verticalScrollbarWidth(); }
virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
Modified: trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp 2013-01-10 20:32:24 UTC (rev 139351)
@@ -216,11 +216,8 @@
calcHorizontalPrefWidths();
m_maxPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
- }
- if (hasOverflowClip() && style()->overflowY() == OSCROLL) {
- layer()->setHasVerticalScrollbar(true);
- LayoutUnit scrollbarWidth = verticalScrollbarWidth();
+ LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth();
m_maxPreferredLogicalWidth += scrollbarWidth;
m_minPreferredLogicalWidth += scrollbarWidth;
}
Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp 2013-01-10 20:32:24 UTC (rev 139351)
@@ -194,21 +194,12 @@
}
m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
- }
- LayoutUnit scrollbarWidth = 0;
- if (hasOverflowClip()) {
- if (isHorizontalWritingMode() && styleToUse->overflowY() == OSCROLL) {
- ASSERT(layer()->hasVerticalScrollbar());
- scrollbarWidth = verticalScrollbarWidth();
- } else if (!isHorizontalWritingMode() && styleToUse->overflowX() == OSCROLL) {
- ASSERT(layer()->hasHorizontalScrollbar());
- scrollbarWidth = horizontalScrollbarHeight();
- }
+ LayoutUnit scrollbarWidth = instrinsicScrollbarLogicalWidth();
+ m_maxPreferredLogicalWidth += scrollbarWidth;
+ m_minPreferredLogicalWidth += scrollbarWidth;
}
- m_maxPreferredLogicalWidth += scrollbarWidth;
- m_minPreferredLogicalWidth += scrollbarWidth;
// FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for min-width.
if (styleToUse->logicalMinWidth().isFixed() && styleToUse->logicalMinWidth().value() > 0) {
Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (139350 => 139351)
--- trunk/Source/WebCore/rendering/RenderGrid.cpp 2013-01-10 20:21:35 UTC (rev 139350)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp 2013-01-10 20:32:24 UTC (rev 139351)
@@ -136,6 +136,8 @@
m_minPreferredLogicalWidth += minTrackBreadth;
m_maxPreferredLogicalWidth += maxTrackBreadth;
+
+ // FIXME: This should add in the scrollbarWidth (e.g. see RenderFlexibleBox).
}
// FIXME: We should account for min / max logical width.