Title: [161334] trunk
Revision
161334
Author
[email protected]
Date
2014-01-06 01:04:51 -0800 (Mon, 06 Jan 2014)

Log Message

<hr> appears gray instead of green because of color attribute is defined followed by noshade attribute
https://bugs.webkit.org/show_bug.cgi?id=17674

Patch by Gurpreet Kaur <[email protected]> on 2014-01-06
Reviewed by Simon Fraser.

Source/WebCore:

The noshade attribute is a boolean attribute and when set on hr element
it shows a gray color. When there is color attribute the default gray
color should be replaced by the color mentioned by the color attribute.
Firefox and IE show the same behaviour but Webkit is different. Making
the behaviour of Webkit similiar to Firefox and IE's behaviour.

Test: fast/dom/HTMLHrElement/hr-color-noshade-attribute.html

* html/HTMLHRElement.cpp:
(WebCore::HTMLHRElement::collectStyleForPresentationAttribute):
When the color attribute is present that value is applied and the
default gray color is ignored. Incase of no color attribute the default
gray color is applied.

LayoutTests:

* fast/dom/HTMLHrElement: Added.
* fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt: Added.
* fast/dom/HTMLHrElement/hr-color-noshade-attribute.html: Added.
Added new test cases to test the functionality of noshade and color
attribute of hr element when color attribute is present along with
noshade attribute, invalid color attribute and color noshade attributes
added via _javascript_.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161333 => 161334)


--- trunk/LayoutTests/ChangeLog	2014-01-06 08:56:46 UTC (rev 161333)
+++ trunk/LayoutTests/ChangeLog	2014-01-06 09:04:51 UTC (rev 161334)
@@ -1,3 +1,18 @@
+2014-01-06  Gurpreet Kaur  <[email protected]>
+
+        <hr> appears gray instead of green because of color attribute is defined followed by noshade attribute
+        https://bugs.webkit.org/show_bug.cgi?id=17674
+
+        Reviewed by Simon Fraser.
+
+        * fast/dom/HTMLHrElement: Added.
+        * fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt: Added.
+        * fast/dom/HTMLHrElement/hr-color-noshade-attribute.html: Added.
+        Added new test cases to test the functionality of noshade and color
+        attribute of hr element when color attribute is present along with 
+        noshade attribute, invalid color attribute and color noshade attributes
+        added via _javascript_.
+
 2014-01-05  Sam Weinig  <[email protected]>
 
         [JS] Implement Promise.race()

Added: trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt (0 => 161334)


--- trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt	2014-01-06 09:04:51 UTC (rev 161334)
@@ -0,0 +1,18 @@
+Tests various scenarios of noshade and color attributes of hr element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(document.getElementById('hrElement1'),null).getPropertyValue('border-color') is "rgb(255, 0, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement1'),null).getPropertyValue('background-color') is "rgb(255, 0, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement2'),null).getPropertyValue('border-color') is "rgb(0, 0, 255)"
+PASS window.getComputedStyle(document.getElementById('hrElement2'),null).getPropertyValue('background-color') is "rgb(0, 0, 255)"
+PASS window.getComputedStyle(document.getElementById('hrElement3'),null).getPropertyValue('border-color') is "rgb(0, 0, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement3'),null).getPropertyValue('background-color') is "rgb(0, 0, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement4'),null).getPropertyValue('border-color') is "rgb(128, 128, 128)"
+PASS window.getComputedStyle(document.getElementById('hrElement4'),null).getPropertyValue('background-color') is "rgb(128, 128, 128)"
+PASS window.getComputedStyle(document.getElementById('hrElement5'),null).getPropertyValue('border-color') is "rgb(255, 255, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement5'),null).getPropertyValue('background-color') is "rgb(255, 255, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement6'),null).getPropertyValue('border-color') is "rgb(0, 128, 0)"
+PASS window.getComputedStyle(document.getElementById('hrElement6'),null).getPropertyValue('background-color') is "rgb(0, 128, 0)"
+
Property changes on: trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute-expected.txt
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute.html (0 => 161334)


--- trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute.html	2014-01-06 09:04:51 UTC (rev 161334)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script>
+            function runTest() {
+                description('Tests various scenarios of noshade and color attributes of hr element.');
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement1'),null).getPropertyValue('border-color')","rgb(255, 0, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement1'),null).getPropertyValue('background-color')","rgb(255, 0, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement2'),null).getPropertyValue('border-color')","rgb(0, 0, 255)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement2'),null).getPropertyValue('background-color')","rgb(0, 0, 255)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement3'),null).getPropertyValue('border-color')","rgb(0, 0, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement3'),null).getPropertyValue('background-color')","rgb(0, 0, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement4'),null).getPropertyValue('border-color')","rgb(128, 128, 128)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement4'),null).getPropertyValue('background-color')","rgb(128, 128, 128)");
+                document.getElementById('hrElement5').setAttribute("color","yellow");
+                document.getElementById('hrElement5').setAttribute("noshade");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement5'),null).getPropertyValue('border-color')","rgb(255, 255, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement5'),null).getPropertyValue('background-color')","rgb(255, 255, 0)");
+                document.getElementById('hrElement6').setAttribute("noshade");
+                document.getElementById('hrElement6').setAttribute("color","green");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement6'),null).getPropertyValue('border-color')","rgb(0, 128, 0)");
+                shouldBeEqualToString("window.getComputedStyle(document.getElementById('hrElement6'),null).getPropertyValue('background-color')","rgb(0, 128, 0)");
+            }
+        </script>
+    </head>
+    <body _onload_="runTest()">
+       	<hr id="hrElement1" color="red" noshade>
+        <hr id="hrElement2" noshade color="blue">
+        <hr id="hrElement3" noshade color="^&*(">
+        <hr id="hrElement4" noshade>
+        <hr id="hrElement5">
+        <hr id="hrElement6">
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/dom/HTMLHrElement/hr-color-noshade-attribute.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (161333 => 161334)


--- trunk/Source/WebCore/ChangeLog	2014-01-06 08:56:46 UTC (rev 161333)
+++ trunk/Source/WebCore/ChangeLog	2014-01-06 09:04:51 UTC (rev 161334)
@@ -1,3 +1,24 @@
+2014-01-06  Gurpreet Kaur  <[email protected]>
+
+        <hr> appears gray instead of green because of color attribute is defined followed by noshade attribute
+        https://bugs.webkit.org/show_bug.cgi?id=17674
+
+        Reviewed by Simon Fraser.
+
+        The noshade attribute is a boolean attribute and when set on hr element
+        it shows a gray color. When there is color attribute the default gray
+        color should be replaced by the color mentioned by the color attribute.
+        Firefox and IE show the same behaviour but Webkit is different. Making
+        the behaviour of Webkit similiar to Firefox and IE's behaviour.
+
+        Test: fast/dom/HTMLHrElement/hr-color-noshade-attribute.html
+
+        * html/HTMLHRElement.cpp:
+        (WebCore::HTMLHRElement::collectStyleForPresentationAttribute):
+        When the color attribute is present that value is applied and the 
+        default gray color is ignored. Incase of no color attribute the default
+        gray color is applied.
+
 2014-01-06  Mark Rowe  <[email protected]>
 
         <https://webkit.org/b/126499> Move WebKit off the legacy WebKit availability macros

Modified: trunk/Source/WebCore/html/HTMLHRElement.cpp (161333 => 161334)


--- trunk/Source/WebCore/html/HTMLHRElement.cpp	2014-01-06 08:56:46 UTC (rev 161333)
+++ trunk/Source/WebCore/html/HTMLHRElement.cpp	2014-01-06 09:04:51 UTC (rev 161334)
@@ -82,11 +82,13 @@
         addHTMLColorToStyle(style, CSSPropertyBorderColor, value);
         addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value);
     } else if (name == noshadeAttr) {
-        addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
+        if (!hasAttribute(colorAttr)) {
+            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
 
-        RefPtr<CSSPrimitiveValue> darkGrayValue = cssValuePool().createColorValue(Color::darkGray);
-        style.setProperty(CSSPropertyBorderColor, darkGrayValue);
-        style.setProperty(CSSPropertyBackgroundColor, darkGrayValue);
+            RefPtr<CSSPrimitiveValue> darkGrayValue = cssValuePool().createColorValue(Color::darkGray);
+            style.setProperty(CSSPropertyBorderColor, darkGrayValue);
+            style.setProperty(CSSPropertyBackgroundColor, darkGrayValue);
+        }
     } else if (name == sizeAttr) {
         StringImpl* si = value.impl();
         int size = si->toInt();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to