[css-grid] Don't create renderers for whitespace nodes
authorobrufau@igalia.com <obrufau@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2020 22:59:01 +0000 (22:59 +0000)
committerobrufau@igalia.com <obrufau@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2020 22:59:01 +0000 (22:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212220

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

Import WPT test.

* web-platform-tests/css/css-grid/grid-items/w3c-import.log:
* web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html: Added.
* web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html: Added.

Source/WebCore:

Even with 'white-space: pre' we shouldn't create RenderTexts
for whitespace-only nodes in grid layout, according to
https://drafts.csswg.org/css-grid/#grid-items

This patch is based on https://codereview.chromium.org/16888008

Tests: fast/text/simple-line-layout-with-zero-sized-font.html
       imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html

* rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::textRendererIsNeeded):

LayoutTests:

Update test expectation.

* fast/text/simple-line-layout-with-zero-sized-font-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/simple-line-layout-with-zero-sized-font-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/updating/RenderTreeUpdater.cpp

index f35ef23..dc5d3ed 100644 (file)
@@ -1,3 +1,14 @@
+2020-05-21  Oriol Brufau  <obrufau@igalia.com>
+
+        [css-grid] Don't create renderers for whitespace nodes
+        https://bugs.webkit.org/show_bug.cgi?id=212220
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Update test expectation.
+
+        * fast/text/simple-line-layout-with-zero-sized-font-expected.txt:
+
 2020-05-21  Diego Pino Garcia  <dpino@igalia.com>
 
         [GTK] Gardening, update expectations after r262016
index 354b864..cb5efcf 100644 (file)
@@ -1,3 +1,16 @@
+2020-05-21  Oriol Brufau  <obrufau@igalia.com>
+
+        [css-grid] Don't create renderers for whitespace nodes
+        https://bugs.webkit.org/show_bug.cgi?id=212220
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Import WPT test.
+
+        * web-platform-tests/css/css-grid/grid-items/w3c-import.log:
+        * web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html: Added.
+        * web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html: Added.
+
 2020-05-20  Oriol Brufau  <obrufau@igalia.com>
 
         Computed min-width/height for auto depends on box
index 4a6a7ca..6a1edaa 100644 (file)
@@ -259,3 +259,5 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/ref-filled-green-100px-square-image.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/table-with-infinite-max-intrinsic-width-expected.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/table-with-infinite-max-intrinsic-width.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001-expected.html
new file mode 100644 (file)
index 0000000..1531d98
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<link href="/css/support/grid.css" rel="stylesheet">
+<style>
+  .item {
+    height: 100%;
+    width: 30px;
+    background: salmon;
+  }
+</style>
+<body>
+  <p>This test passes if it has the same output than the reference. As spec states that child text runs containing only white space should not rendered (just as if its text nodes were display:none).</p>
+  <div class="grid">
+    <div class="item"></div>
+  </div>
+</body>
+</html>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html
new file mode 100644 (file)
index 0000000..f79baab
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<title>CSS Grid : Whitespace in grid item</title>
+<link rel="author" title="Christian Biesinger" href="mailto:cbiesinger@chromium.org">
+<link rel="help" href="https://drafts.csswg.org/css-grid/#grid-items">
+<link rel="match" href="whitespace-in-grid-item-001-ref.html">
+<link rel="help" href="https://codereview.chromium.org/16888008">
+<meta name="assert" content="Grid items shouldn't be created for white spaces."/>
+<link href="/css/support/grid.css" rel="stylesheet">
+<style>
+  .grid {
+    white-space: pre;
+  }
+  .item {
+    height: 100%;
+    width: 30px;
+    background: salmon;
+  }
+</style>
+<body>
+  <p>This test passes if it has the same output than the reference. As spec states that child text runs containing only white space should not rendered (just as if its text nodes were display:none).</p>
+  <div class="grid">
+
+    <div class="item"></div> &#9;
+  </div>
+</body>
+</html>
index 72b26bc..1603b0b 100644 (file)
@@ -1,3 +1,22 @@
+2020-05-21  Oriol Brufau  <obrufau@igalia.com>
+
+        [css-grid] Don't create renderers for whitespace nodes
+        https://bugs.webkit.org/show_bug.cgi?id=212220
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        Even with 'white-space: pre' we shouldn't create RenderTexts
+        for whitespace-only nodes in grid layout, according to
+        https://drafts.csswg.org/css-grid/#grid-items
+
+        This patch is based on https://codereview.chromium.org/16888008
+
+        Tests: fast/text/simple-line-layout-with-zero-sized-font.html
+               imported/w3c/web-platform-tests/css/css-grid/grid-items/whitespace-in-grid-item-001.html
+
+        * rendering/updating/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::textRendererIsNeeded):
+
 2020-05-21  Simon Fraser  <simon.fraser@apple.com>
 
         Fix rare crash in TileGrid::platformCALayerShowRepaintCounter()
index dd64fde..1e6e1f0 100644 (file)
@@ -427,9 +427,7 @@ bool RenderTreeUpdater::textRendererIsNeeded(const Text& textNode)
     if (is<RenderText>(renderingParent.previousChildRenderer))
         return true;
     // This text node has nothing but white space. We may still need a renderer in some cases.
-    if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet())
-        return false;
-    if (parentRenderer.isFlexibleBox() && !parentRenderer.isRenderButton())
+    if (parentRenderer.isTable() || parentRenderer.isTableRow() || parentRenderer.isTableSection() || parentRenderer.isRenderTableCol() || parentRenderer.isFrameSet() || parentRenderer.isRenderGrid() || (parentRenderer.isFlexibleBox() && !parentRenderer.isRenderButton()))
         return false;
     if (parentRenderer.style().preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
         return true;