Title: [127000] trunk
Revision
127000
Author
[email protected]
Date
2012-08-29 07:48:31 -0700 (Wed, 29 Aug 2012)

Log Message

Web Inspector: Page with @import and :last-child in an edited stylesheet will crash
https://bugs.webkit.org/show_bug.cgi?id=95324

Reviewed by Antti Koivisto.

Source/WebCore:

Ensure the destroyed StyleRules removal from StyleResolver by creating a separate RuleMutationScope for clearing the StyleSheetContents.

Test: inspector/styles/import-pseudoclass-crash.html

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyleSheet::reparseStyleSheet):

LayoutTests:

* inspector/styles/import-pseudoclass-crash-expected.txt: Added.
* inspector/styles/import-pseudoclass-crash.html: Added.
* inspector/styles/resources/import-pseudoclass-crash-empty.css: Added.
* inspector/styles/resources/import-pseudoclass-crash.css: Added.
(:last-child):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126999 => 127000)


--- trunk/LayoutTests/ChangeLog	2012-08-29 13:52:48 UTC (rev 126999)
+++ trunk/LayoutTests/ChangeLog	2012-08-29 14:48:31 UTC (rev 127000)
@@ -1,3 +1,16 @@
+2012-08-29  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Page with @import and :last-child in an edited stylesheet will crash
+        https://bugs.webkit.org/show_bug.cgi?id=95324
+
+        Reviewed by Antti Koivisto.
+
+        * inspector/styles/import-pseudoclass-crash-expected.txt: Added.
+        * inspector/styles/import-pseudoclass-crash.html: Added.
+        * inspector/styles/resources/import-pseudoclass-crash-empty.css: Added.
+        * inspector/styles/resources/import-pseudoclass-crash.css: Added.
+        (:last-child):
+
 2012-08-29  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Turn workspace into a container of UiSourceCodes put in different projects.

Added: trunk/LayoutTests/inspector/styles/import-pseudoclass-crash-expected.txt (0 => 127000)


--- trunk/LayoutTests/inspector/styles/import-pseudoclass-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/import-pseudoclass-crash-expected.txt	2012-08-29 14:48:31 UTC (rev 127000)
@@ -0,0 +1,3 @@
+Tests that modifying stylesheet text with @import and :last-child selector does not crash (Bug 95324).
+
+:last-child
Property changes on: trunk/LayoutTests/inspector/styles/import-pseudoclass-crash-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/styles/import-pseudoclass-crash.html (0 => 127000)


--- trunk/LayoutTests/inspector/styles/import-pseudoclass-crash.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/import-pseudoclass-crash.html	2012-08-29 14:48:31 UTC (rev 127000)
@@ -0,0 +1,50 @@
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    WebInspector.showPanel("elements");
+    InspectorTest.nodeWithId("lastchild", nodeFound);
+
+    function nodeFound(node)
+    {
+        WebInspector.cssModel.getMatchedStylesAsync(node.id, true, false, matchedStylesCallback);
+    }
+
+    var styleSheetId;
+
+    function matchedStylesCallback(styles)
+    {
+        styleSheetId = styles.matchedCSSRules[1].id.styleSheetId;
+        CSSAgent.setStyleSheetText(styleSheetId,
+            "@import url(\"import-pseudoclass-crash-empty.css\");\n\n:last-child { color: #000001; }\n", modifiedCallback);
+    }
+
+    function modifiedCallback()
+    {
+        CSSAgent.setStyleSheetText(styleSheetId, "@import url(\"import-pseudoclass-crash-empty.css\");\n\n:last-child { color: #002001; }\n", modifiedCallback2);
+    }
+
+    function modifiedCallback2()
+    {
+        InspectorTest.completeTest();
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests that modifying stylesheet text with @import and :last-child selector does not crash (<a href="" 95324</a>).
+</p>
+
+<div>
+    <p id="lastchild">:last-child</p>
+</div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/styles/import-pseudoclass-crash.html
___________________________________________________________________

Added: svn:eol-style

Property changes: trunk/LayoutTests/inspector/styles/resources/import-pseudoclass-crash-empty.css


Added: svn:eol-style

Added: trunk/LayoutTests/inspector/styles/resources/import-pseudoclass-crash.css (0 => 127000)


--- trunk/LayoutTests/inspector/styles/resources/import-pseudoclass-crash.css	                        (rev 0)
+++ trunk/LayoutTests/inspector/styles/resources/import-pseudoclass-crash.css	2012-08-29 14:48:31 UTC (rev 127000)
@@ -0,0 +1,5 @@
+@import url("import-pseudoclass-crash-empty.css");
+
+:last-child {
+  color: #000;
+}
Property changes on: trunk/LayoutTests/inspector/styles/resources/import-pseudoclass-crash.css
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (126999 => 127000)


--- trunk/Source/WebCore/ChangeLog	2012-08-29 13:52:48 UTC (rev 126999)
+++ trunk/Source/WebCore/ChangeLog	2012-08-29 14:48:31 UTC (rev 127000)
@@ -1,3 +1,17 @@
+2012-08-29  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: Page with @import and :last-child in an edited stylesheet will crash
+        https://bugs.webkit.org/show_bug.cgi?id=95324
+
+        Reviewed by Antti Koivisto.
+
+        Ensure the destroyed StyleRules removal from StyleResolver by creating a separate RuleMutationScope for clearing the StyleSheetContents.
+
+        Test: inspector/styles/import-pseudoclass-crash.html
+
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyleSheet::reparseStyleSheet):
+
 2012-08-29  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Turn workspace into a container of UiSourceCodes put in different projects.

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (126999 => 127000)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2012-08-29 13:52:48 UTC (rev 126999)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2012-08-29 14:48:31 UTC (rev 127000)
@@ -737,12 +737,18 @@
 
 void InspectorStyleSheet::reparseStyleSheet(const String& text)
 {
-    CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
-    m_pageStyleSheet->contents()->clearRules();
-    m_pageStyleSheet->contents()->parseString(text);
-    m_pageStyleSheet->clearChildRuleCSSOMWrappers();
-    m_inspectorStyles.clear();
-    fireStyleSheetChanged();
+    {
+        // Have a separate scope for clearRules() (bug 95324).
+        CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
+        m_pageStyleSheet->contents()->clearRules();
+    }
+    {
+        CSSStyleSheet::RuleMutationScope mutationScope(m_pageStyleSheet.get());
+        m_pageStyleSheet->contents()->parseString(text);
+        m_pageStyleSheet->clearChildRuleCSSOMWrappers();
+        m_inspectorStyles.clear();
+        fireStyleSheetChanged();
+    }
 }
 
 bool InspectorStyleSheet::setText(const String& text)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to