Title: [98568] trunk
Revision
98568
Author
commit-qu...@webkit.org
Date
2011-10-27 07:26:04 -0700 (Thu, 27 Oct 2011)

Log Message

StyleSheet.parentStyleSheet does not work.
https://bugs.webkit.org/show_bug.cgi?id=70956

Patch by Andreas Kling <kl...@webkit.org> on 2011-10-27
Reviewed by Antti Koivisto.

Source/WebCore:

Since StyleSheet is only ever parented by a CSSRule, we need
to go through that rule when resolving the StyleSheet's parent.

Test: fast/css/stylesheet-parentStyleSheet.html

* css/StyleSheet.cpp:
(WebCore::StyleSheet::parentStyleSheet):

LayoutTests:

* fast/css/stylesheet-parentStyleSheet-expected.txt: Added.
* fast/css/stylesheet-parentStyleSheet.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98567 => 98568)


--- trunk/LayoutTests/ChangeLog	2011-10-27 14:23:49 UTC (rev 98567)
+++ trunk/LayoutTests/ChangeLog	2011-10-27 14:26:04 UTC (rev 98568)
@@ -1,3 +1,13 @@
+2011-10-27  Andreas Kling  <kl...@webkit.org>
+
+        StyleSheet.parentStyleSheet does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=70956
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css/stylesheet-parentStyleSheet-expected.txt: Added.
+        * fast/css/stylesheet-parentStyleSheet.html: Added.
+
 2011-10-27  Yury Semikhatsky  <yu...@chromium.org>
 
         Unreviewed, gardening.

Added: trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet-expected.txt (0 => 98568)


--- trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet-expected.txt	2011-10-27 14:26:04 UTC (rev 98568)
@@ -0,0 +1,2 @@
+Test that StyleSheet.parentStyleSheet works properly. You should see "PASS" below.
+PASS

Added: trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet.html (0 => 98568)


--- trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/stylesheet-parentStyleSheet.html	2011-10-27 14:26:04 UTC (rev 98568)
@@ -0,0 +1,16 @@
+<head>
+<style>
+@import url("data:text/css,#test{}");
+</style>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function test() {
+    if (document.styleSheets[0].cssRules[0].styleSheet.parentStyleSheet == document.styleSheets[0])
+        document.getElementById('test').innerHTML = 'PASS';
+}
+</script>
+<body _onload_='test()'>
+Test that StyleSheet.parentStyleSheet works properly. You should see "PASS" below.
+<div id="test">FAIL</div>

Modified: trunk/Source/WebCore/ChangeLog (98567 => 98568)


--- trunk/Source/WebCore/ChangeLog	2011-10-27 14:23:49 UTC (rev 98567)
+++ trunk/Source/WebCore/ChangeLog	2011-10-27 14:26:04 UTC (rev 98568)
@@ -1,3 +1,18 @@
+2011-10-27  Andreas Kling  <kl...@webkit.org>
+
+        StyleSheet.parentStyleSheet does not work.
+        https://bugs.webkit.org/show_bug.cgi?id=70956
+
+        Reviewed by Antti Koivisto.
+
+        Since StyleSheet is only ever parented by a CSSRule, we need
+        to go through that rule when resolving the StyleSheet's parent.
+
+        Test: fast/css/stylesheet-parentStyleSheet.html
+
+        * css/StyleSheet.cpp:
+        (WebCore::StyleSheet::parentStyleSheet):
+
 2011-10-27  Antoine Labour  <pi...@chromium.org>
 
         Disable blending when drawing opaque layers

Modified: trunk/Source/WebCore/css/StyleSheet.cpp (98567 => 98568)


--- trunk/Source/WebCore/css/StyleSheet.cpp	2011-10-27 14:23:49 UTC (rev 98567)
+++ trunk/Source/WebCore/css/StyleSheet.cpp	2011-10-27 14:26:04 UTC (rev 98568)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "StyleSheet.h"
 
+#include "CSSRule.h"
 #include "CSSStyleSheet.h"
 #include "MediaList.h"
 #include "Node.h"
@@ -52,7 +53,10 @@
 
 StyleSheet* StyleSheet::parentStyleSheet() const
 {
-    return (parent() && parent()->isStyleSheet()) ? static_cast<StyleSheet*>(parent()) : 0;
+    if (!parent())
+        return 0;
+    ASSERT(parent()->isRule());
+    return static_cast<CSSRule*>(parent())->parentStyleSheet();
 }
 
 void StyleSheet::setMedia(PassRefPtr<MediaList> media)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to