WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Dec 2007 23:45:40 +0000 (23:45 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 8 Dec 2007 23:45:40 +0000 (23:45 +0000)
        Reviewed by Adele Peterson.

        - fix two bugs in parsing of stylesheets in <style> elements created by
          the parser:
          1. each such stylesheet is parsed twice, once when the text node is
             added and again when the </style> tag is reached
          2. re-inserting such a <style> element into the document fails to
             re-parse and apply its stylesheet.

        Test for bug #2: fast/dom/HTMLStyleElement/insert-parser-generated.html

        * html/HTMLStyleElement.cpp:
        (WebCore::HTMLStyleElement::finishedParsing):
        * svg/SVGStyleElement.cpp:
        (WebCore::SVGStyleElement::finishedParsing):

LayoutTests:

        Reviewed by Adele Peterson.

        - test that re-inserting a parser-generated <style> element applies its
          sylesheet.

        * fast/dom/HTMLStyleElement: Added.
        * fast/dom/HTMLStyleElement/insert-parser-generated.html: Added.
        * platform/mac/fast/dom/HTMLStyleElement: Added.
        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.checksum: Added.
        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png: Added.
        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLStyleElement/insert-parser-generated.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLStyleElement.cpp
WebCore/svg/SVGStyleElement.cpp

index 1952f3153a60e42c6f7ec5e013554c760054f07e..869f70a2395af8c38cf6e0c0511a2de598f087f7 100644 (file)
@@ -1,3 +1,17 @@
+2007-12-08  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adele Peterson.
+
+        - test that re-inserting a parser-generated <style> element applies its
+          sylesheet.
+
+        * fast/dom/HTMLStyleElement: Added.
+        * fast/dom/HTMLStyleElement/insert-parser-generated.html: Added.
+        * platform/mac/fast/dom/HTMLStyleElement: Added.
+        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.checksum: Added.
+        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png: Added.
+        * platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.txt: Added.
+
 2007-12-08  Rob Buis  <buis@kde.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/dom/HTMLStyleElement/insert-parser-generated.html b/LayoutTests/fast/dom/HTMLStyleElement/insert-parser-generated.html
new file mode 100644 (file)
index 0000000..c923968
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+<head>
+    <style>
+        div { width: 100px; height: 100px; background-color: red; }
+    </style>
+    <style id="style">
+        div#green { background-color: green; }
+    </style>
+</head>
+<body>
+    <!--
+        Tests that re-inserting a <style> element that was created by the
+        parser applies its stylesheet.
+    -->
+    <div id="green"></div>
+    <script>
+        var style = document.getElementById("style");
+        var head = style.parentNode;
+        head.removeChild(style);
+        head.appendChild(style);
+    </script>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.checksum b/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.checksum
new file mode 100644 (file)
index 0000000..ae7a7bd
--- /dev/null
@@ -0,0 +1 @@
+18f1f64eab31dfb69467a497de9442d7
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png b/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png
new file mode 100644 (file)
index 0000000..fc96c0b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.txt b/LayoutTests/platform/mac/fast/dom/HTMLStyleElement/insert-parser-generated-expected.txt
new file mode 100644 (file)
index 0000000..7ce690f
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
index 6d3b3a918e823aa24624271185eba4cc2c8e534d..c6a59eb6ce5d3add96d4f48dd91d9f705a83aa16 100644 (file)
@@ -1,3 +1,21 @@
+2007-12-08  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adele Peterson.
+
+        - fix two bugs in parsing of stylesheets in <style> elements created by
+          the parser:
+          1. each such stylesheet is parsed twice, once when the text node is
+             added and again when the </style> tag is reached
+          2. re-inserting such a <style> element into the document fails to
+             re-parse and apply its stylesheet.
+
+        Test for bug #2: fast/dom/HTMLStyleElement/insert-parser-generated.html
+
+        * html/HTMLStyleElement.cpp:
+        (WebCore::HTMLStyleElement::finishedParsing):
+        * svg/SVGStyleElement.cpp:
+        (WebCore::SVGStyleElement::finishedParsing):
+
 2007-12-07  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Darin.
index d59f338572c17c0a842c5abefd886bfd6ad37e15..6e053111eaa3fea7d7a61b639e6c6a478441dd73 100644 (file)
@@ -52,7 +52,8 @@ void HTMLStyleElement::parseMappedAttribute(MappedAttribute *attr)
 
 void HTMLStyleElement::finishedParsing()
 {
-    StyleElement::process(this);
+    StyleElement::sheet(this);
+    m_createdByParser = false;
     HTMLElement::finishedParsing();
 }
 
index f35e3aadd1d97e8f3a3a783d043614527dbaa5db..77a6ee6853952514dc6ce72f41287f108d5d6443 100644 (file)
@@ -95,7 +95,8 @@ void SVGStyleElement::parseMappedAttribute(MappedAttribute* attr)
 
 void SVGStyleElement::finishedParsing()
 {
-    StyleElement::process(this);
+    StyleElement::sheet(this);
+    m_createdByParser = false;
     SVGElement::finishedParsing();
 }