Title: [132834] trunk
Revision
132834
Author
[email protected]
Date
2012-10-29 12:00:41 -0700 (Mon, 29 Oct 2012)

Log Message

[CSSOM] Extraneous whitespace in CSSImportRule.cssText
https://bugs.webkit.org/show_bug.cgi?id=100657

Patch by Glenn Adams <[email protected]> on 2012-10-29
Reviewed by Simon Fraser.

Source/WebCore:

Remove extraneous whitespace when serializing CSSImportRule.cssText when
media list is empty.

Test: cssom/cssimportrule-media.html

* css/CSSImportRule.cpp:
(WebCore::CSSImportRule::cssText):
Don't append extra whitespace if mediaText is empty.

LayoutTests:

Test (from CSS WG) that checks serializion of CSSImportRule.cssText.

* http/tests/css/shared-stylesheet-mutation-expected.txt:
* http/tests/css/shared-stylesheet-mutation-preconstruct-expected.txt:
Fix expected output to match removal of extraneous space.

* cssom/cssimportrule-media-expected.txt: Added.
* cssom/cssimportrule-media.html: Added.
* cssom/resources/import.css: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (132833 => 132834)


--- trunk/LayoutTests/ChangeLog	2012-10-29 18:58:51 UTC (rev 132833)
+++ trunk/LayoutTests/ChangeLog	2012-10-29 19:00:41 UTC (rev 132834)
@@ -1,3 +1,20 @@
+2012-10-29  Glenn Adams  <[email protected]>
+       
+        [CSSOM] Extraneous whitespace in CSSImportRule.cssText
+        https://bugs.webkit.org/show_bug.cgi?id=100657
+
+        Reviewed by Simon Fraser.
+
+        Test (from CSS WG) that checks serializion of CSSImportRule.cssText.
+
+        * http/tests/css/shared-stylesheet-mutation-expected.txt:
+        * http/tests/css/shared-stylesheet-mutation-preconstruct-expected.txt:
+        Fix expected output to match removal of extraneous space.
+
+        * cssom/cssimportrule-media-expected.txt: Added.
+        * cssom/cssimportrule-media.html: Added.
+        * cssom/resources/import.css: Added.
+
 2012-10-29  Zan Dobersek  <[email protected]>
 
         Unreviewed GTK gardening.

Added: trunk/LayoutTests/cssom/cssimportrule-media-expected.txt (0 => 132834)


--- trunk/LayoutTests/cssom/cssimportrule-media-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/cssom/cssimportrule-media-expected.txt	2012-10-29 19:00:41 UTC (rev 132834)
@@ -0,0 +1,6 @@
+
+PASS doc.styleSheets[0].cssRules[0].cssText == '@import url("resources/import.css");' 
+PASS doc.styleSheets[1].cssRules[0].cssText == '@import url("resources/import.css") all;' 
+PASS doc.styleSheets[2].cssRules[0].cssText == '@import url("resources/import.css") not tv;' 
+PASS doc.styleSheets[3].cssRules[0].cssText == '@import url("resources/import.css") screen, tv;' 
+

Added: trunk/LayoutTests/cssom/cssimportrule-media.html (0 => 132834)


--- trunk/LayoutTests/cssom/cssimportrule-media.html	                        (rev 0)
+++ trunk/LayoutTests/cssom/cssimportrule-media.html	2012-10-29 19:00:41 UTC (rev 132834)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>CSSOM - CSSImportRule - Media</title>
+    <link rel="author" title="Glenn Adams" href=""
+    <link rel="help" href=""
+    <meta name="flags" content="dom"/>
+    <script src=""
+    <script src=""
+    <style id="sheet1">
+      @import "resources/import.css";
+    </style>
+    <style id="sheet2">
+      @import "resources/import.css" all;
+    </style>
+    <style id="sheet3">
+      @import "resources/import.css" not tv;
+    </style>
+    <style id="sheet4">
+      @import "resources/import.css" screen, tv;
+    </style>
+  </head>
+  <body>
+    <div id="log"></div>
+    <div id="box"></div>
+    <script>
+
+      var doc = window.document;
+
+      var sheet1 = doc.styleSheets[0];
+
+      test(function(){
+
+        assert_equals(sheet1.cssRules[0].cssText, '@import url(\"resources/import.css\");');
+
+      }, 'doc.styleSheets[0].cssRules[0].cssText == \'@import url(\"resources/import.css\");\'');
+
+      var sheet2 = doc.styleSheets[1];
+
+      test(function(){
+
+        assert_equals(sheet2.cssRules[0].cssText, '@import url(\"resources/import.css\") all;');
+
+      }, 'doc.styleSheets[1].cssRules[0].cssText == \'@import url(\"resources/import.css\") all;\'');
+
+      var sheet3 = doc.styleSheets[2];
+
+      test(function(){
+
+        assert_equals(sheet3.cssRules[0].cssText, '@import url(\"resources/import.css\") not tv;');
+
+      }, 'doc.styleSheets[2].cssRules[0].cssText == \'@import url(\"resources/import.css\") not tv;\'');
+
+      var sheet4 = doc.styleSheets[3];
+
+      test(function(){
+
+        assert_equals(sheet4.cssRules[0].cssText, '@import url(\"resources/import.css\") screen, tv;');
+
+      }, 'doc.styleSheets[3].cssRules[0].cssText == \'@import url(\"resources/import.css\") screen, tv;\'');
+
+    </script>
+  </body>
+</html>

Added: trunk/LayoutTests/cssom/resources/import.css (0 => 132834)


--- trunk/LayoutTests/cssom/resources/import.css	                        (rev 0)
+++ trunk/LayoutTests/cssom/resources/import.css	2012-10-29 19:00:41 UTC (rev 132834)
@@ -0,0 +1 @@
+* { }

Modified: trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-expected.txt (132833 => 132834)


--- trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-expected.txt	2012-10-29 18:58:51 UTC (rev 132833)
+++ trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-expected.txt	2012-10-29 19:00:41 UTC (rev 132834)
@@ -188,7 +188,7 @@
 PASS getComputedStyle(testElement, null).getPropertyValue('background-color') is 'rgb(0, 128, 0)'
 
 @charset "utf-8";
-@import url("data:text/css;charset=utf-8,%23testdiv%7Bbackground-color%3Agreen%20!important%7D") ;
+@import url("data:text/css;charset=utf-8,%23testdiv%7Bbackground-color%3Agreen%20!important%7D");
 #testdiv { background-color: green; }
 @media all { 
   #testdiv { background-color: red; }

Modified: trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-preconstruct-expected.txt (132833 => 132834)


--- trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-preconstruct-expected.txt	2012-10-29 18:58:51 UTC (rev 132833)
+++ trunk/LayoutTests/http/tests/css/shared-stylesheet-mutation-preconstruct-expected.txt	2012-10-29 19:00:41 UTC (rev 132834)
@@ -188,7 +188,7 @@
 PASS getComputedStyle(testElement, null).getPropertyValue('background-color') is 'rgb(0, 128, 0)'
 
 @charset "utf-8";
-@import url("data:text/css;charset=utf-8,%23testdiv%7Bbackground-color%3Agreen%20!important%7D") ;
+@import url("data:text/css;charset=utf-8,%23testdiv%7Bbackground-color%3Agreen%20!important%7D");
 #testdiv { background-color: green; }
 @media all { 
   #testdiv { background-color: red; }

Modified: trunk/Source/WebCore/ChangeLog (132833 => 132834)


--- trunk/Source/WebCore/ChangeLog	2012-10-29 18:58:51 UTC (rev 132833)
+++ trunk/Source/WebCore/ChangeLog	2012-10-29 19:00:41 UTC (rev 132834)
@@ -1,3 +1,19 @@
+2012-10-29  Glenn Adams  <[email protected]>
+
+        [CSSOM] Extraneous whitespace in CSSImportRule.cssText
+        https://bugs.webkit.org/show_bug.cgi?id=100657
+
+        Reviewed by Simon Fraser.
+
+        Remove extraneous whitespace when serializing CSSImportRule.cssText when
+        media list is empty.
+
+        Test: cssom/cssimportrule-media.html
+
+        * css/CSSImportRule.cpp:
+        (WebCore::CSSImportRule::cssText):
+        Don't append extra whitespace if mediaText is empty.
+
 2012-10-29  Arnaud Renevier  <[email protected]>
 
         webview not redrawn as needed when accelerated compositing is enabled.

Modified: trunk/Source/WebCore/css/CSSImportRule.cpp (132833 => 132834)


--- trunk/Source/WebCore/css/CSSImportRule.cpp	2012-10-29 18:58:51 UTC (rev 132833)
+++ trunk/Source/WebCore/css/CSSImportRule.cpp	2012-10-29 19:00:41 UTC (rev 132834)
@@ -69,8 +69,11 @@
     result.append("\")");
 
     if (m_importRule->mediaQueries()) {
-        result.append(' ');
-        result.append(m_importRule->mediaQueries()->mediaText());
+        String mediaText = m_importRule->mediaQueries()->mediaText();
+        if (!mediaText.isEmpty()) {
+            result.append(' ');
+            result.append(mediaText);
+        }
     }
     result.append(';');
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to