Reviewed by David Hyatt.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Feb 2007 20:31:10 +0000 (20:31 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Feb 2007 20:31:10 +0000 (20:31 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=4128
        !important is ignored in inline styling.

        Handle properties with !important flag better in inline
        style declarations.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/inline-properties-important-expected.checksum [new file with mode: 0644]
LayoutTests/fast/css/inline-properties-important-expected.png [new file with mode: 0644]
LayoutTests/fast/css/inline-properties-important-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/inline-properties-important.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSMutableStyleDeclaration.cpp

index 3eb88e9..f72e083 100644 (file)
@@ -1,3 +1,17 @@
+2007-02-27  Rob Buis  <buis@kde.org>
+
+        Reviewed by David Hyatt.
+
+        http://bugs.webkit.org/show_bug.cgi?id=4128
+        !important is ignored in inline styling.
+
+        Add testcase based on the one in the bug report.
+
+        * fast/css/inline-properties-important-expected.checksum: Added.
+        * fast/css/inline-properties-important-expected.png: Added.
+        * fast/css/inline-properties-important-expected.txt: Added.
+        * fast/css/inline-properties-important.html: Added.
+
 2007-02-27  Darin Adler  <darin@apple.com>
 
         - test for MacRoman encoding name alias
diff --git a/LayoutTests/fast/css/inline-properties-important-expected.checksum b/LayoutTests/fast/css/inline-properties-important-expected.checksum
new file mode 100644 (file)
index 0000000..4e33c11
--- /dev/null
@@ -0,0 +1 @@
+cf42444a08df453a3df5b9da6d4a0d56
\ No newline at end of file
diff --git a/LayoutTests/fast/css/inline-properties-important-expected.png b/LayoutTests/fast/css/inline-properties-important-expected.png
new file mode 100644 (file)
index 0000000..9cf4626
Binary files /dev/null and b/LayoutTests/fast/css/inline-properties-important-expected.png differ
diff --git a/LayoutTests/fast/css/inline-properties-important-expected.txt b/LayoutTests/fast/css/inline-properties-important-expected.txt
new file mode 100644 (file)
index 0000000..6c90cb0
--- /dev/null
@@ -0,0 +1,21 @@
+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 784x571
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 749x36
+          text run at (0,0) width 749: "This tests handling of duplicated properties in inline style declarations. Using !important should have an effect. See bug"
+          text run at (0,18) width 44: "#4128."
+      RenderBlock {H1} at (0,57) size 784x37 [color=#FF0000]
+        RenderText {#text} at (0,0) size 253x37
+          text run at (0,0) width 253: "This should be red"
+      RenderBlock {H1} at (0,115) size 784x37 [color=#00FF00]
+        RenderText {#text} at (0,0) size 283x37
+          text run at (0,0) width 283: "This should be green"
+      RenderBlock {H1} at (0,173) size 784x37 [color=#FF0000]
+        RenderText {#text} at (0,0) size 253x37
+          text run at (0,0) width 253: "This should be red"
+      RenderBlock {H1} at (0,231) size 784x37 [color=#FF0000]
+        RenderText {#text} at (0,0) size 253x37
+          text run at (0,0) width 253: "This should be red"
diff --git a/LayoutTests/fast/css/inline-properties-important.html b/LayoutTests/fast/css/inline-properties-important.html
new file mode 100644 (file)
index 0000000..03a6b7e
--- /dev/null
@@ -0,0 +1,5 @@
+<p>This tests handling of duplicated properties in inline style declarations. Using !important should have an effect. See bug #4128.</p>
+<h1 style="color: #0f0; color: #f00">This should be red</h1>
+<h1 style="color: #0f0 !important; color: #f00">This should be green</h1>
+<h1 style="color: #0f0; color: #f00 !important">This should be red</h1>
+<h1 style="color: #0f0 !important; color: #f00 !important">This should be red</h1>
index 8bb06c7..36d5b18 100644 (file)
@@ -1,3 +1,16 @@
+2007-02-27  Rob Buis  <buis@kde.org>
+
+        Reviewed by David Hyatt.
+
+        http://bugs.webkit.org/show_bug.cgi?id=4128
+        !important is ignored in inline styling.
+
+        Handle properties with !important flag better in inline
+        style declarations.
+
+        * css/CSSMutableStyleDeclaration.cpp:
+        (WebCore::CSSMutableStyleDeclaration::addParsedProperties):
+
 2007-02-27  David Hyatt  <hyatt@apple.com>
 
         Bug 11435.  Make sure RenderViews always paintBoxDecorations.  They used to before I removed RenderView's
index 6304601..6a8ada7 100644 (file)
@@ -508,8 +508,11 @@ void CSSMutableStyleDeclaration::parseDeclaration(const String& styleDeclaration
 void CSSMutableStyleDeclaration::addParsedProperties(const CSSProperty * const * properties, int numProperties)
 {
     for (int i = 0; i < numProperties; ++i) {
-        removeProperty(properties[i]->id(), false);
-        m_values.append(*properties[i]);
+        // Only add properties that have no !important counterpart present
+        if (!getPropertyPriority(properties[i]->id()) || properties[i]->isImportant()) {
+            removeProperty(properties[i]->id(), false);
+            m_values.append(*properties[i]);
+        }
     }
     // FIXME: This probably should have a call to setChanged() if something changed. We may also wish to add
     // a notifyChanged argument to this function to follow the model of other functions in this class.