From 9618be7119b548f5af8ea1911245e0bbffee5679 Mon Sep 17 00:00:00 2001 From: "ojan@chromium.org" Date: Wed, 8 Feb 2012 19:58:35 +0000 Subject: [PATCH] Floated flexboxes render as regular RenderBlocks https://bugs.webkit.org/show_bug.cgi?id=77909 Reviewed by Eric Seidel. Source/WebCore: Add grid/flexbox cases to adjusting the display of floated/positioned elements. Also, move this logic into a switch statement. This makes the code more readable and gives compile warnings when new display types are added that aren't handled here. Test: css3/flexbox/floated-flexbox.html * css/CSSStyleSelector.cpp: (WebCore::adjustDisplay): (WebCore): (WebCore::CSSStyleSelector::adjustRenderStyle): LayoutTests: * css3/flexbox/floated-flexbox-expected.txt: Added. * css3/flexbox/floated-flexbox.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107112 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 +++ .../css3/flexbox/floated-flexbox-expected.txt | 7 +++ LayoutTests/css3/flexbox/floated-flexbox.html | 30 +++++++++ Source/WebCore/ChangeLog | 19 ++++++ Source/WebCore/css/CSSStyleSelector.cpp | 72 ++++++++++++++++------ 5 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 LayoutTests/css3/flexbox/floated-flexbox-expected.txt create mode 100644 LayoutTests/css3/flexbox/floated-flexbox.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index f214d17..0a76e46 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-02-07 Ojan Vafai + + Floated flexboxes render as regular RenderBlocks + https://bugs.webkit.org/show_bug.cgi?id=77909 + + Reviewed by Eric Seidel. + + * css3/flexbox/floated-flexbox-expected.txt: Added. + * css3/flexbox/floated-flexbox.html: Added. + 2012-02-08 Julien Chaffraix Unreviewed gardening. diff --git a/LayoutTests/css3/flexbox/floated-flexbox-expected.txt b/LayoutTests/css3/flexbox/floated-flexbox-expected.txt new file mode 100644 index 0000000..dd05afa --- /dev/null +++ b/LayoutTests/css3/flexbox/floated-flexbox-expected.txt @@ -0,0 +1,7 @@ +FAIL: +Expected 130 for width, but got 110. + +
+
+
+
diff --git a/LayoutTests/css3/flexbox/floated-flexbox.html b/LayoutTests/css3/flexbox/floated-flexbox.html new file mode 100644 index 0000000..cc17404 --- /dev/null +++ b/LayoutTests/css3/flexbox/floated-flexbox.html @@ -0,0 +1,30 @@ + + + + + + + +
+
+
+
+ + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 6bc0c8d..a3d74ab 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,22 @@ +2012-02-07 Ojan Vafai + + Floated flexboxes render as regular RenderBlocks + https://bugs.webkit.org/show_bug.cgi?id=77909 + + Reviewed by Eric Seidel. + + Add grid/flexbox cases to adjusting the display of floated/positioned + elements. Also, move this logic into a switch statement. This makes + the code more readable and gives compile warnings when new display types + are added that aren't handled here. + + Test: css3/flexbox/floated-flexbox.html + + * css/CSSStyleSelector.cpp: + (WebCore::adjustDisplay): + (WebCore): + (WebCore::CSSStyleSelector::adjustRenderStyle): + 2012-02-08 Dirk Schulze viewBox on nested SVG causes wrong content size for relative values diff --git a/Source/WebCore/css/CSSStyleSelector.cpp b/Source/WebCore/css/CSSStyleSelector.cpp index 86b0ac3..ffd7c4f 100644 --- a/Source/WebCore/css/CSSStyleSelector.cpp +++ b/Source/WebCore/css/CSSStyleSelector.cpp @@ -1727,6 +1727,55 @@ static void addIntrinsicMargins(RenderStyle* style) } } +static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool strictParsing) +{ + switch (display) { + case BLOCK: + case TABLE: + case BOX: + case FLEXBOX: +#if ENABLE(CSS_GRID_LAYOUT) + case GRID: +#endif + return display; + + case LIST_ITEM: + // It is a WinIE bug that floated list items lose their bullets, so we'll emulate the quirk, but only in quirks mode. + if (!strictParsing && isFloating) + return BLOCK; + return display; + case INLINE_TABLE: + return TABLE; + case INLINE_BOX: + return BOX; + case INLINE_FLEXBOX: + return FLEXBOX; +#if ENABLE(CSS_GRID_LAYOUT) + case INLINE_GRID: + return GRID; +#endif + + case INLINE: + case RUN_IN: + case COMPACT: + case INLINE_BLOCK: + case TABLE_ROW_GROUP: + case TABLE_HEADER_GROUP: + case TABLE_FOOTER_GROUP: + case TABLE_ROW: + case TABLE_COLUMN_GROUP: + case TABLE_COLUMN: + case TABLE_CELL: + case TABLE_CAPTION: + return BLOCK; + case NONE: + ASSERT_NOT_REACHED(); + return NONE; + } + ASSERT_NOT_REACHED(); + return BLOCK; +} + void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, RenderStyle* parentStyle, Element *e) { // Cache our original display. @@ -1776,26 +1825,9 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, RenderStyle* parent if (e && e->hasTagName(legendTag)) style->setDisplay(BLOCK); - // Mutate the display to BLOCK or TABLE for certain cases, e.g., if someone attempts to - // position or float an inline, compact, or run-in. Cache the original display, since it - // may be needed for positioned elements that have to compute their static normal flow - // positions. We also force inline-level roots to be block-level. - if (style->display() != BLOCK && style->display() != TABLE && style->display() != BOX && - (style->position() == AbsolutePosition || style->position() == FixedPosition || style->isFloating() || - (e && e->document()->documentElement() == e))) { - if (style->display() == INLINE_TABLE) - style->setDisplay(TABLE); - else if (style->display() == INLINE_BOX) - style->setDisplay(BOX); - else if (style->display() == LIST_ITEM) { - // It is a WinIE bug that floated list items lose their bullets, so we'll emulate the quirk, - // but only in quirks mode. - if (!m_checker.strictParsing() && style->isFloating()) - style->setDisplay(BLOCK); - } - else - style->setDisplay(BLOCK); - } + // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display. + if (style->position() == AbsolutePosition || style->position() == FixedPosition || style->isFloating() || (e && e->document()->documentElement() == e)) + style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloating(), m_checker.strictParsing())); // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely // clear how that should work. -- 1.8.3.1