[CSSOM] Extraneous whitespace in CSSImportRule.cssText

https://bugs.webkit.org/show_bug.cgi?id=100657

Patch by Glenn Adams <glenn@skynav.com> 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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132834 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 371825cd
2012-10-29 Glenn Adams <glenn@skynav.com>
[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 <zandobersek@gmail.com>
Unreviewed GTK gardening.
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;'
<!DOCTYPE html>
<html>
<head>
<title>CSSOM - CSSImportRule - Media</title>
<link rel="author" title="Glenn Adams" href="mailto:glenn@skynav.com"/>
<link rel="help" href="http://www.w3.org/TR/cssom/#the-cssimportrule-interface"/>
<meta name="flags" content="dom"/>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<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>
......@@ -188,7 +188,7 @@ Test 12
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; }
......
......@@ -188,7 +188,7 @@ Test 12
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; }
......
2012-10-29 Glenn Adams <glenn@skynav.com>
[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 <a.renevier@sisa.samsung.com>
webview not redrawn as needed when accelerated compositing is enabled.
......@@ -69,8 +69,11 @@ String CSSImportRule::cssText() const
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(';');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment