WebCore:
authorantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2007 20:42:14 +0000 (20:42 +0000)
committerantti <antti@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Sep 2007 20:42:14 +0000 (20:42 +0000)
        Reviewed by Darin.

        Fix <rdar://problem/5480050>
        Leopard9A551 with Dashcode 112: Dashcode crash when dragging image into canvas.

        If @import stylesheet was modified through CSS DOM style selector would not get updated. This
        could lead to crashes.

        Test: fast/css/import-style-update.html

        * css/CSSStyleSheet.cpp:
        (WebCore::CSSStyleSheet::styleSheetChanged):

LayoutTests:

        Reviewed by Darin.

        Test for <rdar://problem/5480050>
        Leopard9A551 with Dashcode 112: Dashcode crash when dragging image into canvas.

        Non-crashing test case, but it demonstrates the same problem that would crash
        under some circumstances.

        * fast/css/import-style-update-expected.txt: Added.
        * fast/css/import-style-update.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/import-style-update-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/import-style-update.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSheet.cpp

index 25bc39f7b9c2d97d0add37e559098255fc303600..175970a37c22cf63278a834e167a1665bb6fa786 100644 (file)
@@ -1,3 +1,16 @@
+2007-09-17  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        Test for <rdar://problem/5480050>
+        Leopard9A551 with Dashcode 112: Dashcode crash when dragging image into canvas.
+        
+        Non-crashing test case, but it demonstrates the same problem that would crash
+        under some circumstances.
+
+        * fast/css/import-style-update-expected.txt: Added.
+        * fast/css/import-style-update.html: Added.
+
 2007-09-16  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/fast/css/import-style-update-expected.txt b/LayoutTests/fast/css/import-style-update-expected.txt
new file mode 100644 (file)
index 0000000..f112c32
--- /dev/null
@@ -0,0 +1,3 @@
+Test that modifying @import stylesheet through DOM updates style properly. You should see PASS below:
+PASS
+
diff --git a/LayoutTests/fast/css/import-style-update.html b/LayoutTests/fast/css/import-style-update.html
new file mode 100644 (file)
index 0000000..6ee449e
--- /dev/null
@@ -0,0 +1,15 @@
+<head>
+<style>
+@import url("data:text/css,#test{display:none;}");
+</style>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+function test() {
+var s = document.styleSheets;
+s[0].cssRules[0].styleSheet.deleteRule(0);
+}
+</script>
+<body onload='test()'>
+Test that modifying @import stylesheet through DOM updates style properly. You should see PASS below:
+<div id=test>PASS</div>
index 35ce7654e4ae222bc1ea0dca76abc02f8280f166..8136a7d6ec2ab6b08c23f000ab10d3f37e863696 100644 (file)
@@ -1,3 +1,18 @@
+2007-09-17  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+        
+        Fix <rdar://problem/5480050>
+        Leopard9A551 with Dashcode 112: Dashcode crash when dragging image into canvas.
+        
+        If @import stylesheet was modified through CSS DOM style selector would not get updated. This
+        could lead to crashes.
+
+        Test: fast/css/import-style-update.html
+
+        * css/CSSStyleSheet.cpp:
+        (WebCore::CSSStyleSheet::styleSheetChanged):
+
 2007-09-17  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Adam.
index 63fd21b8c075f85f170d2a9d5ea96a1635caf4b3..2685185901fb176239d394417fb11aa5863dcfb6 100644 (file)
@@ -190,12 +190,17 @@ DocLoader *CSSStyleSheet::docLoader()
 
 void CSSStyleSheet::styleSheetChanged()
 {
+    StyleBase* root = this;
+    while (StyleBase* parent = root->parent())
+        root = parent;
+    Document* documentToUpdate = (root && root->isCSSStyleSheet()) ? static_cast<CSSStyleSheet*>(root)->doc() : 0;
+    
     /* FIXME: We don't need to do everything updateStyleSelector does,
      * basically we just need to recreate the document's selector with the
      * already existing style sheets.
      */
-    if (m_doc)
-        m_doc->updateStyleSelector();
+    if (documentToUpdate)
+        documentToUpdate->updateStyleSelector();
 }
 
 }