Title: [181939] releases/WebKitGTK/webkit-2.8
Revision
181939
Author
[email protected]
Date
2015-03-25 02:50:23 -0700 (Wed, 25 Mar 2015)

Log Message

Merge r181691 - Flex and grid items should be painted as inline-blocks
https://bugs.webkit.org/show_bug.cgi?id=142266

Reviewed by Darin Adler.

Source/WebCore:

Based on Blink r157004 by <[email protected]>.
https://src.chromium.org/viewvc/blink?revision=157004&view=revision

Both flexbox and grid specs define that the painting order of flex/grid
items is the same as inline blocks. See
http://dev.w3.org/csswg/css-flexbox/#painting and
http://dev.w3.org/csswg/css-grid/#z-order.

Extracted inline blocks painting code from InlineElementBox and moved to
a helper method that will be reused for flexboxes and grids.

Tests: css3/flexbox/flex-item-text-background-not-interleaved.html
       fast/css-grid-layout/grid-item-text-background-not-interleaved.html

* rendering/InlineElementBox.cpp:
(WebCore::InlineElementBox::paint): Move code to
RenderElement::paintAsInlineBlock().
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintChild): Add new argument to paint children
as inline blocks.
* rendering/RenderBlock.h: Define PaintType enmu and modify paintChild()
signature to add the new argument.
* rendering/RenderElement.cpp:
(WebCore::paintPhase): Paint element in a phase.
(WebCore::RenderElement::paintAsInlineBlock): Code extracted from
InlineElementBox::paint().
* rendering/RenderElement.h: Add new method signature.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::paintChildren): Call
RenderBlock::paintChild() with the new argument.
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::paintChildren): Ditto.

LayoutTests:

* css3/flexbox/flex-item-text-background-not-interleaved-expected.html: Added.
* css3/flexbox/flex-item-text-background-not-interleaved.html: Added.
* fast/css-grid-layout/float-not-protruding-into-next-grid-item-expected.html:
Add some vertical space to avoid issues with backgrounds.
* fast/css-grid-layout/float-not-protruding-into-next-grid-item.html:
Ditto.
* fast/css-grid-layout/grid-item-text-background-not-interleaved-expected.html: Added.
* fast/css-grid-layout/grid-item-text-background-not-interleaved.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/ChangeLog	2015-03-25 09:50:23 UTC (rev 181939)
@@ -1,3 +1,19 @@
+2015-03-18  Manuel Rego Casasnovas  <[email protected]>
+
+        Flex and grid items should be painted as inline-blocks
+        https://bugs.webkit.org/show_bug.cgi?id=142266
+
+        Reviewed by Darin Adler.
+
+        * css3/flexbox/flex-item-text-background-not-interleaved-expected.html: Added.
+        * css3/flexbox/flex-item-text-background-not-interleaved.html: Added.
+        * fast/css-grid-layout/float-not-protruding-into-next-grid-item-expected.html:
+        Add some vertical space to avoid issues with backgrounds.
+        * fast/css-grid-layout/float-not-protruding-into-next-grid-item.html:
+        Ditto.
+        * fast/css-grid-layout/grid-item-text-background-not-interleaved-expected.html: Added.
+        * fast/css-grid-layout/grid-item-text-background-not-interleaved.html: Added.
+
 2015-03-16  Joanmarie Diggs  <[email protected]>
 
         AX: Crash viewing http://www.last.fm/

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved-expected.html (0 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved-expected.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<style>
+.first {
+    display: inline-block;
+    width: 50px;
+    background: lime;
+}
+
+.second {
+    display: inline-block;
+    width: 50px;
+    background: cyan;
+}
+</style>
+
+<p>This test checks that flex items text and background are not interleaved.</p>
+<p>The test passes if you see "Item2" on top of "VeryLongItem1".</p>
+<div>
+    <div class="first">VeryLongItem1</div><div class="second">Item2</div>
+</div>

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved.html (0 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/css3/flexbox/flex-item-text-background-not-interleaved.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<style>
+.first {
+    width: 50px;
+    background: lime;
+}
+
+.second {
+    width: 50px;
+    background: cyan;
+}
+</style>
+
+<p>This test checks that flex items text and background are not interleaved.</p>
+<p>The test passes if you see "Item2" on top of "VeryLongItem1".</p>
+<div class="flexbox">
+    <div class="first">VeryLongItem1</div>
+    <div class="second">Item2</div>
+</div>

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item-expected.html (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item-expected.html	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item-expected.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -25,7 +25,7 @@
 
 <body>
 
-<div>This test checks that grid item sets a new formatting context for its content, preventing any 'float' protruding content on the adjoining grid item ('Float' text shouldn't overflow the first row).</div>
+<p>This test checks that grid item sets a new formatting context for its content, preventing any 'float' protruding content on the adjoining grid item ('Float' text shouldn't overflow the first row).</p>
 
 <div>
   <div class="cell floatLeft firstRowFirstColumn">

Modified: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item.html (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item.html	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/float-not-protruding-into-next-grid-item.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -23,7 +23,7 @@
 
 <body>
 
-<div>This test checks that grid item sets a new formatting context for its content, preventing any 'float' protruding content on the adjoining grid item ('Float' text shouldn't overflow the first row).</div>
+<p>This test checks that grid item sets a new formatting context for its content, preventing any 'float' protruding content on the adjoining grid item ('Float' text shouldn't overflow the first row).</p>
 
 <div class="grid">
   <div class="cell firstRowFirstColumn">

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved-expected.html (0 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved-expected.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<style>
+.container {
+    background-color: grey;
+}
+.element {
+    background: lime;
+    width: 100px;
+}
+</style>
+
+<p>This test checks that grid items text and background are not interleaved.</p>
+<p>The test passes if you see only "PASS" text and not "FAIL".</p>
+<div class="container">
+    <div class="element">PASS</div>
+</div>

Added: releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved.html (0 => 181939)


--- releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.8/LayoutTests/fast/css-grid-layout/grid-item-text-background-not-interleaved.html	2015-03-25 09:50:23 UTC (rev 181939)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<style>
+.grid {
+    -webkit-grid-template-columns: 50px 50px;
+}
+.firstRowFirstColumnSpanning2 {
+    background: lime;
+    -webkit-grid-column: 1 / span 2;
+    -webkit-grid-row: 1;
+}
+</style>
+
+<p>This test checks that grid items text and background are not interleaved.</p>
+<p>The test passes if you see only "PASS" text and not "FAIL".</p>
+<div class="grid">
+    <div class="firstRowSecondColumn">FAIL</div>
+    <div class="firstRowFirstColumnSpanning2">PASS</div>
+</div>

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/ChangeLog	2015-03-25 09:50:23 UTC (rev 181939)
@@ -1,3 +1,43 @@
+2015-03-18  Manuel Rego Casasnovas  <[email protected]>
+
+        Flex and grid items should be painted as inline-blocks
+        https://bugs.webkit.org/show_bug.cgi?id=142266
+
+        Reviewed by Darin Adler.
+
+        Based on Blink r157004 by <[email protected]>.
+        https://src.chromium.org/viewvc/blink?revision=157004&view=revision
+
+        Both flexbox and grid specs define that the painting order of flex/grid
+        items is the same as inline blocks. See
+        http://dev.w3.org/csswg/css-flexbox/#painting and
+        http://dev.w3.org/csswg/css-grid/#z-order.
+
+        Extracted inline blocks painting code from InlineElementBox and moved to
+        a helper method that will be reused for flexboxes and grids.
+
+        Tests: css3/flexbox/flex-item-text-background-not-interleaved.html
+               fast/css-grid-layout/grid-item-text-background-not-interleaved.html
+
+        * rendering/InlineElementBox.cpp:
+        (WebCore::InlineElementBox::paint): Move code to
+        RenderElement::paintAsInlineBlock().
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintChild): Add new argument to paint children
+        as inline blocks.
+        * rendering/RenderBlock.h: Define PaintType enmu and modify paintChild()
+        signature to add the new argument.
+        * rendering/RenderElement.cpp:
+        (WebCore::paintPhase): Paint element in a phase.
+        (WebCore::RenderElement::paintAsInlineBlock): Code extracted from
+        InlineElementBox::paint().
+        * rendering/RenderElement.h: Add new method signature.
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::paintChildren): Call
+        RenderBlock::paintChild() with the new argument.
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::paintChildren): Ditto.
+
 2015-03-20  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Crash due to empty drag image during drag-and-drop

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/InlineElementBox.cpp (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/InlineElementBox.cpp	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/InlineElementBox.cpp	2015-03-25 09:50:23 UTC (rev 181939)
@@ -72,23 +72,7 @@
     if (is<RenderBox>(renderer()) && parent()->renderer().style().isFlippedBlocksWritingMode()) // Faster than calling containingBlock().
         childPoint = renderer().containingBlock()->flipForWritingModeForChild(&downcast<RenderBox>(renderer()), childPoint);
 
-    // Paint all phases of replaced elements atomically, as though the replaced element established its
-    // own stacking context.  (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
-    // specification.)
-    bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip;
-    PaintInfo info(paintInfo);
-    info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
-    renderer().paint(info, childPoint);
-    if (!preservePhase) {
-        info.phase = PaintPhaseChildBlockBackgrounds;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseFloat;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseForeground;
-        renderer().paint(info, childPoint);
-        info.phase = PaintPhaseOutline;
-        renderer().paint(info, childPoint);
-    }
+    renderer().paintAsInlineBlock(paintInfo, childPoint);
 }
 
 bool InlineElementBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.cpp (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.cpp	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.cpp	2015-03-25 09:50:23 UTC (rev 181939)
@@ -1452,7 +1452,7 @@
     }
 }
 
-bool RenderBlock::paintChild(RenderBox& child, PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
+bool RenderBlock::paintChild(RenderBox& child, PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect, PaintBlockType paintType)
 {
     // Check for page-break-before: always, and if it's set, break and bail.
     bool checkBeforeAlways = !childrenInline() && (usePrintRect && child.style().pageBreakBefore() == PBALWAYS);
@@ -1476,8 +1476,12 @@
     }
 
     LayoutPoint childPoint = flipForWritingModeForChild(&child, paintOffset);
-    if (!child.hasSelfPaintingLayer() && !child.isFloating())
-        child.paint(paintInfoForChild, childPoint);
+    if (!child.hasSelfPaintingLayer() && !child.isFloating()) {
+        if (paintType == PaintAsInlineBlock)
+            child.paintAsInlineBlock(paintInfoForChild, childPoint);
+        else
+            child.paint(paintInfoForChild, childPoint);
+    }
 
     // Check for page-break-after: always, and if it's set, break and bail.
     bool checkAfterAlways = !childrenInline() && (usePrintRect && child.style().pageBreakAfter() == PBALWAYS);
@@ -1491,7 +1495,6 @@
     return true;
 }
 
-
 void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffset, CaretType type)
 {
     // Paint the caret if the FrameSelection says so or if caret browsing is enabled

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.h (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.h	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderBlock.h	2015-03-25 09:50:23 UTC (rev 181939)
@@ -325,7 +325,8 @@
     virtual void paint(PaintInfo&, const LayoutPoint&) override;
     virtual void paintObject(PaintInfo&, const LayoutPoint&) override;
     virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
-    bool paintChild(RenderBox&, PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect);
+    enum PaintBlockType { PaintAsBlock, PaintAsInlineBlock };
+    bool paintChild(RenderBox&, PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect, PaintBlockType paintType = PaintAsBlock);
    
     LayoutUnit logicalRightOffsetForLine(LayoutUnit logicalTop, LayoutUnit fixedOffset, bool applyTextIndent, LayoutUnit logicalHeight = 0) const
     {

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.cpp (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.cpp	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.cpp	2015-03-25 09:50:23 UTC (rev 181939)
@@ -1157,6 +1157,31 @@
     return hoverAncestor;
 }
 
+static inline void paintPhase(RenderElement& element, PaintPhase phase, PaintInfo& paintInfo, const LayoutPoint& childPoint)
+{
+    paintInfo.phase = phase;
+    element.paint(paintInfo, childPoint);
+}
+
+void RenderElement::paintAsInlineBlock(PaintInfo& paintInfo, const LayoutPoint& childPoint)
+{
+    // Paint all phases atomically, as though the element established its own stacking context.
+    // (See Appendix E.2, section 6.4 on inline block/table/replaced elements in the CSS2.1 specification.)
+    // This is also used by other elements (e.g. flex items and grid items).
+    if (paintInfo.phase == PaintPhaseSelection) {
+        paint(paintInfo, childPoint);
+    } else if (paintInfo.phase == PaintPhaseForeground) {
+        paintPhase(*this, PaintPhaseBlockBackground, paintInfo, childPoint);
+        paintPhase(*this, PaintPhaseChildBlockBackgrounds, paintInfo, childPoint);
+        paintPhase(*this, PaintPhaseFloat, paintInfo, childPoint);
+        paintPhase(*this, PaintPhaseForeground, paintInfo, childPoint);
+        paintPhase(*this, PaintPhaseOutline, paintInfo, childPoint);
+
+        // Reset |paintInfo| to the original phase.
+        paintInfo.phase = PaintPhaseForeground;
+    }
+}
+
 void RenderElement::layout()
 {
     StackStats::LayoutCheckPoint layoutCheckPoint;

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.h (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.h	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderElement.h	2015-03-25 09:50:23 UTC (rev 181939)
@@ -112,6 +112,11 @@
 
     virtual void paint(PaintInfo&, const LayoutPoint&) = 0;
 
+    // inline-block elements paint all phases atomically. This function ensures that. Certain other elements
+    // (grid items, flex items) require this behavior as well, and this function exists as a helper for them.
+    // It is expected that the caller will call this function independent of the value of paintInfo.phase.
+    void paintAsInlineBlock(PaintInfo&, const LayoutPoint&);
+
     // Recursive function that computes the size and position of this object and all its descendants.
     virtual void layout();
 

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderFlexibleBox.cpp (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderFlexibleBox.cpp	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderFlexibleBox.cpp	2015-03-25 09:50:23 UTC (rev 181939)
@@ -336,7 +336,7 @@
 void RenderFlexibleBox::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
 {
     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {
-        if (!paintChild(*child, paintInfo, paintOffset, paintInfoForChild, usePrintRect))
+        if (!paintChild(*child, paintInfo, paintOffset, paintInfoForChild, usePrintRect, PaintAsInlineBlock))
             return;
     }
 }

Modified: releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderGrid.cpp (181938 => 181939)


--- releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderGrid.cpp	2015-03-25 09:38:11 UTC (rev 181938)
+++ releases/WebKitGTK/webkit-2.8/Source/WebCore/rendering/RenderGrid.cpp	2015-03-25 09:50:23 UTC (rev 181939)
@@ -1074,7 +1074,7 @@
 void RenderGrid::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect)
 {
     for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next())
-        paintChild(*child, paintInfo, paintOffset, forChild, usePrintRect);
+        paintChild(*child, paintInfo, paintOffset, forChild, usePrintRect, PaintAsInlineBlock);
 }
 
 const char* RenderGrid::renderName() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to