WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2008 05:13:25 +0000 (05:13 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2008 05:13:25 +0000 (05:13 +0000)
        Reviewed by Oliver.

        Fix for http://bugs.webkit.org/show_bug.cgi?id=16704 input with
        type="hidden" matches :enabled/:disabled (Acid3 bug)

        Prevent :enabled and :disabled from applying to input type="hidden"

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::checkOneSelector): Rather than
        allowing :enabled and :disabled to apply to all controls, only
        allow it to apply to non-"hidden" controls
        * dom/Element.h:
        (WebCore::Element::isInputTypeHidden):
        * html/HTMLInputElement.h:
        (WebCore::HTMLInputElement::isInputTypeHidden):

LayoutTests:

        Reviewed by Oliver.

        Test for http://bugs.webkit.org/show_bug.cgi?id=16704 input with
        type="hidden" matches :enabled/:disabled (Acid3 bug)

        * fast/forms/hidden-input-not-enabled-expected.txt: Added.
        * fast/forms/hidden-input-not-enabled.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/hidden-input-not-enabled-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/hidden-input-not-enabled.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/CSSStyleSelector.cpp
WebCore/dom/Element.h
WebCore/html/HTMLInputElement.h

index 58022b51949239f044eaf9d24439b8a6772c5c07..81dfb990f976a625a81188cfaa826bb1af5705cb 100644 (file)
@@ -1,3 +1,13 @@
+2008-01-04  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver.
+
+        Test for http://bugs.webkit.org/show_bug.cgi?id=16704 input with 
+        type="hidden" matches :enabled/:disabled (Acid3 bug)
+
+        * fast/forms/hidden-input-not-enabled-expected.txt: Added.
+        * fast/forms/hidden-input-not-enabled.html: Added.
+
 2008-01-04  Sam Weinig  <sam@webkit.org>
 
         Add missing expected result.
diff --git a/LayoutTests/fast/forms/hidden-input-not-enabled-expected.txt b/LayoutTests/fast/forms/hidden-input-not-enabled-expected.txt
new file mode 100644 (file)
index 0000000..d4ee3f2
--- /dev/null
@@ -0,0 +1 @@
+PASSED! Hidden input types should not respond to :enabled or :disabled
diff --git a/LayoutTests/fast/forms/hidden-input-not-enabled.html b/LayoutTests/fast/forms/hidden-input-not-enabled.html
new file mode 100644 (file)
index 0000000..6c94b9a
--- /dev/null
@@ -0,0 +1,38 @@
+<head>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+
+<style>
+    #input {
+        color:purple;
+    }
+    
+    #input:enabled {
+        color:red;
+    }
+    
+    #input:disabled {
+        color:green;
+    }
+</style>
+</head>
+
+<body>    
+    <div id="result"></div>
+    <input id="input" type="hidden"></input>
+    
+    <script>
+        var input = document.getElementById("input");
+        var result = document.getElementById("result");
+        if (document.defaultView.getComputedStyle(input, null).color == "rgb(255, 0, 0)")
+            // :enabled
+            result.innerHTML = "FAILED!";
+        else if (document.defaultView.getComputedStyle(input, null).color == "rgb(0, 255, 0)")
+            // :disabled
+            result.innerHTML = "FAILED!";
+        else
+            result.innerHTML = "PASSED! Hidden input types should not respond to :enabled or :disabled";
+    </script>
+</body>
index 6634a5857d53318627a55ab7f18f7cfbe7c36da7..22311decd10c267973a1737d51c98e89ac462d80 100644 (file)
@@ -1,3 +1,21 @@
+2008-01-04  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver.
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=16704 input with 
+        type="hidden" matches :enabled/:disabled (Acid3 bug)
+
+        Prevent :enabled and :disabled from applying to input type="hidden" 
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::checkOneSelector): Rather than 
+        allowing :enabled and :disabled to apply to all controls, only 
+        allow it to apply to non-"hidden" controls
+        * dom/Element.h:
+        (WebCore::Element::isInputTypeHidden): 
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::isInputTypeHidden):
+
 2008-01-04  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver Hunt.
index ab95a9548f43c80db50ef4d2465dc48d5c292f3c..08e62451c13180b3393e077cde13618c4a13ece7 100644 (file)
@@ -1599,17 +1599,17 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAnc
                 }
                 break;
             case CSSSelector::PseudoEnabled:
-                if (e && e->isControl())
+                if (e && e->isControl() && !e->isInputTypeHidden())
                     // The UI spec states that you can't match :enabled unless you are an object that can
                     // "receive focus and be activated."  We will limit matching of this pseudo-class to elements
-                    // that are controls.
+                    // that are non-"hidden" controls.
                     return e->isEnabled();                    
                 break;
             case CSSSelector::PseudoDisabled:
-                if (e && e->isControl())
+                if (e && e->isControl() && !e->isInputTypeHidden())
                     // The UI spec states that you can't match :enabled unless you are an object that can
                     // "receive focus and be activated."  We will limit matching of this pseudo-class to elements
-                    // that are controls.
+                    // that are non-"hidden" controls.
                     return !e->isEnabled();                    
                 break;
             case CSSSelector::PseudoChecked:
index c866028b69aa7cd0922e8f08a12687bbe196477b..71ede340adee460818b32396cd05db29ea154014 100644 (file)
@@ -119,6 +119,8 @@ public:
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
 
+    virtual bool isInputTypeHidden() const { return false; }
+
     String nodeNamePreservingCase() const;
 
     // convenience methods which ignore exceptions
index 694adf54b2c1539a088b52672a5edcb3094392f7..55515113c514488077c0ae1ca67b19c24de31cd7 100644 (file)
@@ -79,6 +79,7 @@ public:
     virtual bool isRadioButton() const { return m_type == RADIO; }
     bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX; }
     bool isSearchField() const { return m_type == SEARCH; }
+    virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
 
     bool checked() const { return m_checked; }
     void setChecked(bool, bool sendChangeEvent = false);