2010-06-10 Yuzo Fujishima <yuzo@google.com>
authoryuzo@google.com <yuzo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jun 2010 05:51:38 +0000 (05:51 +0000)
committeryuzo@google.com <yuzo@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jun 2010 05:51:38 +0000 (05:51 +0000)
        Reviewed by Shinichiro Hamaji.

        Fix Bug 40452: REGRESSION: printing is broken if stylesheet has @page
        https://bugs.webkit.org/show_bug.cgi?id=40452

        * platform/chromium/test_expectations.txt:
        * platform/mac/printing/page-rule-in-media-query-expected.checksum: Added.
        * platform/mac/printing/page-rule-in-media-query-expected.png: Added.
        * platform/mac/printing/page-rule-in-media-query-expected.txt: Added.
        * printing/page-rule-in-media-query.html: Added.
2010-06-10  Yuzo Fujishima  <yuzo@google.com>

        Reviewed by Shinichiro Hamaji.

        Fix Bug 40452: REGRESSION: printing is broken if stylesheet has @page
        https://bugs.webkit.org/show_bug.cgi?id=40452

        Test: printing/page-rule-in-media-query.html

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSRuleSet::addRulesFromSheet):
        (WebCore::CSSRuleSet::addStyleRule):

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.txt [new file with mode: 0644]
LayoutTests/printing/page-rule-in-media-query.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp

index 4a2b337..19508f1 100644 (file)
@@ -1,3 +1,16 @@
+2010-06-10  Yuzo Fujishima  <yuzo@google.com>
+
+        Reviewed by Shinichiro Hamaji.
+
+        Fix Bug 40452: REGRESSION: printing is broken if stylesheet has @page
+        https://bugs.webkit.org/show_bug.cgi?id=40452
+
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/printing/page-rule-in-media-query-expected.checksum: Added.
+        * platform/mac/printing/page-rule-in-media-query-expected.png: Added.
+        * platform/mac/printing/page-rule-in-media-query-expected.txt: Added.
+        * printing/page-rule-in-media-query.html: Added.
+
 2010-06-10  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 6d96acc..5869493 100644 (file)
@@ -310,8 +310,9 @@ WONTFIX LINUX WIN : fast/replaced/pdf-as-image.html = FAIL
 
 // These tests try to print a PDF file as the expected result.  I don't think
 // we plan on supporting this anytime soon.
-WONTFIX SKIP : printing/media-queries-print.html = PASS
 WONTFIX SKIP : printing/compositing-layer-printing.html = PASS
+WONTFIX SKIP : printing/media-queries-print.html = PASS
+WONTFIX SKIP : printing/page-rule-in-media-query.html = PASS
 
 // Chrome doesn't call the willCacheResponse callback (a method
 // of ResourceHandleClient).  That function is Mac-specific.
diff --git a/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.checksum b/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.checksum
new file mode 100644 (file)
index 0000000..787eee3
--- /dev/null
@@ -0,0 +1 @@
+95053ecbd1212c92d50e2a03e151b8be
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.png b/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.png
new file mode 100644 (file)
index 0000000..9fdb6d5
Binary files /dev/null and b/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.png differ
diff --git a/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.txt b/LayoutTests/platform/mac/printing/page-rule-in-media-query-expected.txt
new file mode 100644 (file)
index 0000000..86e774f
--- /dev/null
@@ -0,0 +1,16 @@
+layer at (0,0) size 1000x68
+  RenderView at (0,0) size 1000x68
+layer at (1,1) size 998x66
+  RenderBlock {HTML} at (1,1) size 998x66
+    RenderBody {BODY} at (1,1) size 996x64
+      RenderBlock {DIV} at (1,0) size 994x64 [border: (1px solid #000000)]
+        RenderBlock (anonymous) at (1,1) size 992x18
+          RenderText {#text} at (0,0) size 41x18
+            text run at (0,0) width 41: "DIV 1"
+        RenderBlock {DIV} at (2,20) size 990x42 [border: (1px solid #000000)]
+          RenderBlock (anonymous) at (1,1) size 988x18
+            RenderText {#text} at (0,0) size 41x18
+              text run at (0,0) width 41: "DIV 2"
+          RenderBlock {DIV} at (2,20) size 986x20 [border: (1px solid #000000)]
+            RenderText {#text} at (1,1) size 330x18
+              text run at (1,1) width 330: "The margins of divs should remain 1px in printing."
diff --git a/LayoutTests/printing/page-rule-in-media-query.html b/LayoutTests/printing/page-rule-in-media-query.html
new file mode 100644 (file)
index 0000000..a632980
--- /dev/null
@@ -0,0 +1,33 @@
+<!doctype html>
+<html>
+<head>
+<title>Test for Bug 40452 - REGRESSION: printing is broken if stylesheet has @page</title>
+<style>
+* {
+    margin: 1px;
+}
+div {
+    border: 1px solid black;
+}
+@media print {
+    @page {
+        margin: 0.5in;
+    }
+}
+</style>
+<script>
+if (window.layoutTestController)
+    layoutTestController.setPrinting();
+</script>
+</head>
+<body>
+    <div>DIV 1
+        <div>
+            DIV 2
+            <div>
+                The margins of divs should remain 1px in printing.
+            </div>
+        </div>
+    </div>
+</body>
+</html>
index 4dba699..d7e8f18 100644 (file)
@@ -1,3 +1,16 @@
+2010-06-10  Yuzo Fujishima  <yuzo@google.com>
+
+        Reviewed by Shinichiro Hamaji.
+
+        Fix Bug 40452: REGRESSION: printing is broken if stylesheet has @page
+        https://bugs.webkit.org/show_bug.cgi?id=40452
+
+        Test: printing/page-rule-in-media-query.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSRuleSet::addRulesFromSheet):
+        (WebCore::CSSRuleSet::addStyleRule):
+
 2010-06-10  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r60989.
index 3b86f0f..fc1a75b 100644 (file)
@@ -357,7 +357,8 @@ public:
     typedef HashMap<AtomicStringImpl*, CSSRuleDataList*> AtomRuleMap;
     
     void addRulesFromSheet(CSSStyleSheet*, const MediaQueryEvaluator&, CSSStyleSelector* = 0);
-    
+
+    void addStyleRule(StyleBase* item);
     void addRule(CSSStyleRule* rule, CSSSelector* sel);
     void addPageRule(CSSStyleRule* rule, CSSSelector* sel);
     void addToRuleSet(AtomicStringImpl* key, AtomRuleMap& map,
@@ -2768,14 +2769,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
     for (int i = 0; i < len; i++) {
         StyleBase* item = sheet->item(i);
         if (item->isStyleRule()) {
-            if (item->isPageRule()) {
-                CSSPageRule* pageRule = static_cast<CSSPageRule*>(item);
-                addPageRule(pageRule, pageRule->selectorList().first());
-            } else {
-                CSSStyleRule* rule = static_cast<CSSStyleRule*>(item);
-                for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s))
-                    addRule(rule, s);
-            }
+            addStyleRule(item);
         }
         else if (item->isImportRule()) {
             CSSImportRule* import = static_cast<CSSImportRule*>(item);
@@ -2792,9 +2786,7 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
                     CSSRule *childItem = rules->item(j);
                     if (childItem->isStyleRule()) {
                         // It is a StyleRule, so append it to our list
-                        CSSStyleRule* rule = static_cast<CSSStyleRule*>(childItem);
-                        for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s))
-                            addRule(rule, s);
+                        addStyleRule(childItem);
                     } else if (childItem->isFontFaceRule() && styleSelector) {
                         // Add this font face to our set.
                         const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(childItem);
@@ -2819,6 +2811,18 @@ void CSSRuleSet::addRulesFromSheet(CSSStyleSheet* sheet, const MediaQueryEvaluat
     }
 }
 
+void CSSRuleSet::addStyleRule(StyleBase* item)
+{
+    if (item->isPageRule()) {
+        CSSPageRule* pageRule = static_cast<CSSPageRule*>(item);
+        addPageRule(pageRule, pageRule->selectorList().first());
+    } else {
+        CSSStyleRule* rule = static_cast<CSSStyleRule*>(item);
+        for (CSSSelector* s = rule->selectorList().first(); s; s = CSSSelectorList::next(s))
+            addRule(rule, s);
+    }
+}
+
 // -------------------------------------------------------------------------------------
 // this is mostly boring stuff on how to apply a certain rule to the renderstyle...