Crash in WebCore::RenderStyle::overflowX with display:contents
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 14:46:17 +0000 (14:46 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Nov 2017 14:46:17 +0000 (14:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178857
<rdar://problem/35201120>

Reviewed by Zalan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-display-3/display-contents-computed-style-expected.txt:

Source/WebCore:

Crash test by Renata Hodovan.

Tests: fast/css/display-contents-all.html
       fast/css/display-contents-document-element.html

* css/StyleResolver.cpp:
(WebCore::adjustDisplayContentsStyle):

For document element 'display:contents' should adjust to 'display:block' like it does for other display types.

LayoutTests:

* fast/css/display-contents-all-expected.html: Added.
* fast/css/display-contents-all.html: Added.
* fast/css/display-contents-document-element-expected.txt: Added.
* fast/css/display-contents-document-element.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/display-contents-all-expected.html [new file with mode: 0644]
LayoutTests/fast/css/display-contents-all.html [new file with mode: 0644]
LayoutTests/fast/css/display-contents-document-element-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/display-contents-document-element.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-display-3/display-contents-computed-style-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp

index e06381a..f16b6ea 100644 (file)
@@ -1,3 +1,16 @@
+2017-11-03  Antti Koivisto  <antti@apple.com>
+
+        Crash in WebCore::RenderStyle::overflowX with display:contents
+        https://bugs.webkit.org/show_bug.cgi?id=178857
+        <rdar://problem/35201120>
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/css/display-contents-all-expected.html: Added.
+        * fast/css/display-contents-all.html: Added.
+        * fast/css/display-contents-document-element-expected.txt: Added.
+        * fast/css/display-contents-document-element.html: Added.
+
 2017-11-03  Ms2ger  <Ms2ger@igalia.com>
 
         [WPE] Enable the dom/ directory of web-platform-tests.
diff --git a/LayoutTests/fast/css/display-contents-all-expected.html b/LayoutTests/fast/css/display-contents-all-expected.html
new file mode 100644 (file)
index 0000000..1f41f8d
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<style>
+body { margin: 0px }
+</style>
+* { display:contents; } This should render.
diff --git a/LayoutTests/fast/css/display-contents-all.html b/LayoutTests/fast/css/display-contents-all.html
new file mode 100644 (file)
index 0000000..fe469f4
--- /dev/null
@@ -0,0 +1,5 @@
+<html>
+<style>
+* { display:contents; }
+</style>
+This should render.
diff --git a/LayoutTests/fast/css/display-contents-document-element-expected.txt b/LayoutTests/fast/css/display-contents-document-element-expected.txt
new file mode 100644 (file)
index 0000000..d0ce763
--- /dev/null
@@ -0,0 +1 @@
+This shouldn't crash.
diff --git a/LayoutTests/fast/css/display-contents-document-element.html b/LayoutTests/fast/css/display-contents-document-element.html
new file mode 100644 (file)
index 0000000..8ad1239
--- /dev/null
@@ -0,0 +1,13 @@
+<html>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+<style>
+html {
+    display:contents;
+    overflow-x:auto;
+    direction: rtl;
+}
+</style>
+This shouldn't crash.
index e3afa59..83c6edf 100644 (file)
@@ -1,3 +1,13 @@
+2017-11-03  Antti Koivisto  <antti@apple.com>
+
+        Crash in WebCore::RenderStyle::overflowX with display:contents
+        https://bugs.webkit.org/show_bug.cgi?id=178857
+        <rdar://problem/35201120>
+
+        Reviewed by Zalan Bujtas.
+
+        * web-platform-tests/css/css-display-3/display-contents-computed-style-expected.txt:
+
 2017-11-02  Youenn Fablet  <youenn@apple.com>
 
         Fix WPT service worker tests using www1 URLs
index ed1155d..43d299e 100644 (file)
@@ -1,67 +1,7 @@
 
-CSS Display: Computed style for display:contents
-
-
-
-
-
-
-
-    html, .contents { display: contents }
-
-    #t2 .contents { background-color: green }
-    #t2 span { background-color: inherit }
-
-    #t3 .contents { color: green }
-
-    #t4 {
-        width: auto;
-        height: 50%;
-        margin-left: 25%;
-        padding-top: 10%;
-    }
-
-
-
-    
-        
-    
-
-
-    
-        
-    
-
-
-
-    test(function(){
-        assert_equals(getComputedStyle(document.querySelector("#t1")).display, "contents");
-    }, "Serialization of computed style value for display:contents");
-
-    test(function(){
-        assert_equals(getComputedStyle(document.querySelector("#t2 span")).backgroundColor, "rgb(0, 128, 0)");
-    }, "display:contents element as inherit parent - explicit inheritance");
-
-    test(function(){
-        assert_equals(getComputedStyle(document.querySelector("#t3 span")).color, "rgb(0, 128, 0)");
-    }, "display:contents element as inherit parent - implicit inheritance");
-
-    test(function(){
-        var computed = getComputedStyle(document.querySelector("#t4"));
-        assert_equals(computed.width, "auto");
-        assert_equals(computed.height, "50%");
-        assert_equals(computed.marginLeft, "25%");
-        assert_equals(computed.paddingTop, "10%");
-    }, "Resolved value should be computed value, not used value, for display:contents");
-
-    test(function(){
-        assert_equals(getComputedStyle(document.documentElement).display, "block");
-    }, "display:contents is blockified for root elements");
-
-
 PASS Serialization of computed style value for display:contents 
 PASS display:contents element as inherit parent - explicit inheritance 
 PASS display:contents element as inherit parent - implicit inheritance 
 PASS Resolved value should be computed value, not used value, for display:contents 
-FAIL display:contents is blockified for root elements assert_equals: expected "block" but got "contents"
+PASS display:contents is blockified for root elements 
 
index 1f650e4..780b998 100644 (file)
@@ -1,3 +1,21 @@
+2017-11-03  Antti Koivisto  <antti@apple.com>
+
+        Crash in WebCore::RenderStyle::overflowX with display:contents
+        https://bugs.webkit.org/show_bug.cgi?id=178857
+        <rdar://problem/35201120>
+
+        Reviewed by Zalan Bujtas.
+
+        Crash test by Renata Hodovan.
+
+        Tests: fast/css/display-contents-all.html
+               fast/css/display-contents-document-element.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::adjustDisplayContentsStyle):
+
+        For document element 'display:contents' should adjust to 'display:block' like it does for other display types.
+
 2017-11-03  Jiewen Tan  <jiewen_tan@apple.com>
 
         Replace some auto* with RefPtr within WebCore/html
index 6de802c..476493a 100644 (file)
@@ -801,6 +801,10 @@ static void adjustDisplayContentsStyle(RenderStyle& style, const Element* elemen
             style.setDisplay(NONE);
         return;
     }
+    if (element->document().documentElement() == element) {
+        style.setDisplay(BLOCK);
+        return;
+    }
     if (hasEffectiveDisplayNoneForDisplayContents(*element))
         style.setDisplay(NONE);
 }