2010-11-09 Yuzo Fujishima <yuzo@google.com>
authoryuzo@google.com <yuzo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Nov 2010 12:21:21 +0000 (12:21 +0000)
committeryuzo@google.com <yuzo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Nov 2010 12:21:21 +0000 (12:21 +0000)
        Reviewed by Shinichiro Hamaji.

        Fix for Bug 48984 - [Chromium] @media print crash due to paged media support
        https://bugs.webkit.org/show_bug.cgi?id=48984

        * printing/page-format-data-display-none-expected.txt: Added.
        * printing/page-format-data-display-none.html: Added.
2010-11-09  Yuzo Fujishima  <yuzo@google.com>

        Reviewed by Shinichiro Hamaji.

        Fix for Bug 48984 - [Chromium] @media print crash due to paged media support
        Page context has been inheriting from document element style that becomes null if display property is none.
        It should inherit from document style instead to properly handle direction property (and to avoid the null reference).
        https://bugs.webkit.org/show_bug.cgi?id=48984

        Test: printing/page-format-data-display-none.html

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::styleForPage): Page context inherits from
        document style.

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

LayoutTests/ChangeLog
LayoutTests/printing/page-format-data-display-none-expected.txt [new file with mode: 0644]
LayoutTests/printing/page-format-data-display-none.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp

index 92bafd8..b846fb1 100644 (file)
@@ -1,3 +1,13 @@
+2010-11-09  Yuzo Fujishima  <yuzo@google.com>
+
+        Reviewed by Shinichiro Hamaji.
+
+        Fix for Bug 48984 - [Chromium] @media print crash due to paged media support
+        https://bugs.webkit.org/show_bug.cgi?id=48984
+
+        * printing/page-format-data-display-none-expected.txt: Added.
+        * printing/page-format-data-display-none.html: Added.
+
 2010-11-09  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Unreviewed.
diff --git a/LayoutTests/printing/page-format-data-display-none-expected.txt b/LayoutTests/printing/page-format-data-display-none-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/printing/page-format-data-display-none.html b/LayoutTests/printing/page-format-data-display-none.html
new file mode 100644 (file)
index 0000000..2c99e0f
--- /dev/null
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+<head>
+<title>Test for Bug 48984 - [Chromium] @media print crash due to paged media support</title>
+<style>
+* { display: none; }
+</style>
+</head>
+<body>
+<div id="output">
+Test has not run yet.
+Click the print button and see if Chromium crashes.
+<input type="button" value="print" onclick="testManually()"/>
+</div>
+<script>
+function testManually() {
+    document.documentElement.style.display = "none";
+    window.print();
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+
+    // The test passes if the following line doesn't cause a crash.
+    layoutTestController.pageSizeAndMarginsInPixels(0, 100, 200, 1, 2, 3, 4);
+
+    document.getElementById("output").innerHTML = "PASS";
+}
+// Remove the display: none; rule. Otherwise, DumpRenderTree dumps weird stuff.
+document.styleSheets[0].removeRule(0);
+</script>
+</body>
+</html>
index ab8287a..3667bbc 100644 (file)
@@ -1,3 +1,18 @@
+2010-11-09  Yuzo Fujishima  <yuzo@google.com>
+
+        Reviewed by Shinichiro Hamaji.
+
+        Fix for Bug 48984 - [Chromium] @media print crash due to paged media support
+        Page context has been inheriting from document element style that becomes null if display property is none.
+        It should inherit from document style instead to properly handle direction property (and to avoid the null reference).
+        https://bugs.webkit.org/show_bug.cgi?id=48984
+
+        Test: printing/page-format-data-display-none.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::styleForPage): Page context inherits from
+        document style.
+
 2010-11-09  Chris Rogers  <crogers@google.com>
 
         Reviewed by Kenneth Russell.
index 24f0ee1..fc8493e 100644 (file)
@@ -1609,7 +1609,7 @@ PassRefPtr<RenderStyle> CSSStyleSelector::pseudoStyleForElement(PseudoId pseudo,
 
 PassRefPtr<RenderStyle> CSSStyleSelector::styleForPage(int pageIndex)
 {
-    initForStyleResolve(m_checker.m_document->body());
+    initForStyleResolve(m_checker.m_document->documentElement()); // m_rootElementStyle will be set to the document style.
 
     m_style = RenderStyle::create();
     m_style->inheritFrom(m_rootElementStyle);