Commit fdf354c6 authored by adele@apple.com's avatar adele@apple.com

WebCore:

2008-07-07  Michelangelo De Simone  <m.des@mac.com>

        Reviewed by Adele.

        Support for CSS3 :read-only and :read-write pseudoclasses for readonly text controls.

        URL: http://www.w3.org/TR/web-forms-2/#relation

        Tests: fast/css/readonly-pseudoclass-opera-001.html
               fast/css/readonly-pseudoclass-opera-002.html
               fast/css/readonly-pseudoclass-opera-003.html
               fast/css/readonly-pseudoclass-opera-004.html
               fast/css/readonly-pseudoclass-opera-005.html

        * css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType):
        Added "read-only" and "read-write" values for PseudoType extraction.
        * css/CSSSelector.h: (WebCore::CSSSelector::):
        Added PseudoReadOnly and PseudoReadWrite entries in PseudoType enum.
        * css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
        Checks to determine whether to match :read-only and :read-write pseudoclasses on
        text controls.

LayoutTests:

2008-07-07  Michelangelo De Simone  <m.des@mac.com>

        Reviewed by Adele.

        Test suite for :read-only and :read-write pseudoclasses, imported from
        Opera.

        * fast/css/readonly-pseudoclass-opera-001-expected.txt: Added.
        * fast/css/readonly-pseudoclass-opera-001.html: Added.
        * fast/css/readonly-pseudoclass-opera-002-expected.txt: Added.
        * fast/css/readonly-pseudoclass-opera-002.html: Added.
        * fast/css/readonly-pseudoclass-opera-003-expected.txt: Added.
        * fast/css/readonly-pseudoclass-opera-003.html: Added.
        * fast/css/readonly-pseudoclass-opera-004-expected.txt: Added.
        * fast/css/readonly-pseudoclass-opera-004.html: Added.
        * fast/css/readonly-pseudoclass-opera-005-expected.txt: Added.
        * fast/css/readonly-pseudoclass-opera-005.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35042 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4c74be06
2008-07-07 Michelangelo De Simone <m.des@mac.com>
Reviewed by Adele.
Test suite for :read-only and :read-write pseudoclasses, imported from
Opera.
* fast/css/readonly-pseudoclass-opera-001-expected.txt: Added.
* fast/css/readonly-pseudoclass-opera-001.html: Added.
* fast/css/readonly-pseudoclass-opera-002-expected.txt: Added.
* fast/css/readonly-pseudoclass-opera-002.html: Added.
* fast/css/readonly-pseudoclass-opera-003-expected.txt: Added.
* fast/css/readonly-pseudoclass-opera-003.html: Added.
* fast/css/readonly-pseudoclass-opera-004-expected.txt: Added.
* fast/css/readonly-pseudoclass-opera-004.html: Added.
* fast/css/readonly-pseudoclass-opera-005-expected.txt: Added.
* fast/css/readonly-pseudoclass-opera-005.html: Added.
2008-07-07 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
This test checks for :read-only right behavior on checkboxes. Fails if FAILURE is shown below.
SUCCESS
<html>
<head>
<title>&lt;input type="checkbox"&gt; and "readonly"</title>
<style>
input:read-only { background:red }
input { display:none }
</style>
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#readonly">
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#relation">
<script language="JavaScript" type="text/javascript">
function log(message) {
document.getElementById("console").innerHTML += "<li>"+message+"</li>";
}
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var i = document.getElementById("victim");
if (document.defaultView.getComputedStyle(i, null).getPropertyValue('display') == "none")
log("SUCCESS");
else
log("FAILURE");
}
</script>
</head>
<body onload="test()">
<p>This test checks for :read-only right behavior on checkboxes. Fails if FAILURE is shown below.</p>
<p><input type="checkbox" id="victim" readonly/></p>
<hr>
<ol id="console"></ol>
</body>
</html>
This test checks for :read-only right behavior. Fails if FAILURE is shown below.
SUCCESS
<html>
<head>
<title>&lt;input&gt; and "readonly"</title>
<style>
input:read-only { background:lime }
input { background:red }
</style>
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#readonly">
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#relation">
<script language="JavaScript" type="text/javascript">
function log(message) {
document.getElementById("console").innerHTML += "<li>"+message+"</li>";
}
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var i = document.getElementById("victim");
if (document.defaultView.getComputedStyle(i, null).getPropertyValue('background-color') == "rgb(0, 255, 0)")
log("SUCCESS");
else
log("FAILURE");
}
</script>
</head>
<body onload="test()">
<p>This test checks for :read-only right behavior. Fails if FAILURE is shown below.</p>
<p><input id="victim" readonly/></p>
<hr>
<ol id="console"></ol>
</body>
</html>
:read-only doesn't apply to following controls. Fails if FAILURE is shown somewhere.
0: SUCCESS
1: SUCCESS
2: SUCCESS
3: SUCCESS
4: SUCCESS
5: SUCCESS
6: SUCCESS
7: SUCCESS
8: SUCCESS
9: SUCCESS
<html>
<head>
<title>"readonly" and elements it does not apply to</title>
<style>
input:read-only { background:red }
input { display: none }
select:read-only { background:red }
select { display: none }
button:read-only { background:red }
button { display: none }
</style>
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#readonly">
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#relation">
<script language="JavaScript" type="text/javascript">
function log(message) {
document.getElementById("console").innerHTML += "<li>"+message+"</li>";
}
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var i = document.getElementsByName("victim");
for (c = 0; c < i.length; c++) {
if (document.defaultView.getComputedStyle(i[c], null).getPropertyValue('display') == "none")
log(c + ": SUCCESS");
else
log(c + ": FAILURE");
}
}
</script>
</head>
<body onload="test()">
<p>:read-only doesn't apply to following controls. Fails if FAILURE is shown somewhere.</p>
<input name="victim" type="radio" readonly>
<input name="victim" type="file" readonly>
<input name="victim" type="range" readonly disabled>
<input name="victim" type="button" readonly>
<input name="victim" type="submit" readonly>
<input name="victim" type="reset" readonly>
<select name="victim" readonly></select>
<button name="victim" readonly></button>
<button name="victim" readonly type="reset"></button>
<button name="victim" readonly type="submit"></button>
<hr>
<ol id="console"></ol>
</body>
</html>
\ No newline at end of file
This test checks for :read-only right behavior. Fails if FAILURE is shown below.
SUCCESS
<html>
<head>
<title>&lt;textarea&gt; and "readonly"</title>
<style>
textarea:read-only { background:lime }
textarea { background:red }
</style>
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#readonly">
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#relation">
<script language="JavaScript" type="text/javascript">
function log(message) {
document.getElementById("console").innerHTML += "<li>"+message+"</li>";
}
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var t = document.getElementById("victim");
if (document.defaultView.getComputedStyle(t, null).getPropertyValue('background-color') == "rgb(0, 255, 0)")
log("SUCCESS");
else
log("FAILURE");
}
</script>
</head>
<body onload="test()">
<p>This test checks for :read-only right behavior. Fails if FAILURE is shown below.</p>
<p><textarea id="victim" readonly></textarea></p>
<hr>
<ol id="console"></ol>
</body>
</html>
This test checks for :read-only and :read-write right behavior along with readonly attribute. Fails if some FAILURE is shown below.
0: SUCCESS
1: SUCCESS
2: SUCCESS
3: SUCCESS
4: SUCCESS
5: SUCCESS
<html>
<head>
<title>"readonly", :read-only and :read-write</title>
<style>
input { background: red; }
#i1:read-write { background: lime; }
#i2 { background: lime; }
#i2:read-only { background: red; }
#i3:read-write { background: lime; }
#i4:read-only { background: lime; }
#i5:read-only { background: lime; }
#i6:read-write { background: lime; }
</style>
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#readonly">
<link rel="help" href="http://whatwg.org/specs/web-forms/current-work/#relation">
<script language="JavaScript" type="text/javascript">
function log(message) {
document.getElementById("console").innerHTML += "<li>"+message+"</li>";
}
function test() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
document.getElementById('i3').removeAttribute('readonly');
document.getElementById('i4').readOnly = true;
document.getElementById('i5').setAttribute('readonly','readonly');
document.getElementById('i6').readOnly = false;
var i = document.getElementsByTagName("input");
for (c = 0; c < i.length; c++) {
if (document.defaultView.getComputedStyle(i[c], null).getPropertyValue('background-color') == "rgb(0, 255, 0)")
log(c + ": SUCCESS");
else
log(c + ": FAILURE");
}
}
</script>
</head>
<body onload="test()">
<p>This test checks for :read-only and :read-write right behavior along with readonly attribute. Fails if some FAILURE is shown below.</p>
<input id="i1"/>
<input type="radio" readonly="readonly" id="i2"/>
<input readonly="readonly" id="i3"/>
<input id="i4"/>
<input id="i5"/>
<input readonly="readonly" id="i6"/>
<hr>
<ol id="console"></ol>
</body>
</html>
\ No newline at end of file
2008-07-07 Michelangelo De Simone <m.des@mac.com>
Reviewed by Adele.
Support for CSS3 :read-only and :read-write pseudoclasses for readonly text controls.
URL: http://www.w3.org/TR/web-forms-2/#relation
Tests: fast/css/readonly-pseudoclass-opera-001.html
fast/css/readonly-pseudoclass-opera-002.html
fast/css/readonly-pseudoclass-opera-003.html
fast/css/readonly-pseudoclass-opera-004.html
fast/css/readonly-pseudoclass-opera-005.html
* css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType):
Added "read-only" and "read-write" values for PseudoType extraction.
* css/CSSSelector.h: (WebCore::CSSSelector::):
Added PseudoReadOnly and PseudoReadWrite entries in PseudoType enum.
* css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
Checks to determine whether to match :read-only and :read-write pseudoclasses on
text controls.
2008-07-07 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
......@@ -76,6 +76,8 @@ void CSSSelector::extractPseudoType() const
static AtomicString checked("checked");
static AtomicString fileUploadButton("-webkit-file-upload-button");
static AtomicString disabled("disabled");
static AtomicString readOnly("read-only");
static AtomicString readWrite("read-write");
static AtomicString drag("-webkit-drag");
static AtomicString dragAlias("-khtml-drag"); // was documented with this name in Apple documentation, so keep an alias
static AtomicString empty("empty");
......@@ -141,6 +143,10 @@ void CSSSelector::extractPseudoType() const
element = true;
} else if (m_value == disabled)
m_pseudoType = PseudoDisabled;
else if (m_value == readOnly)
m_pseudoType = PseudoReadOnly;
else if (m_value == readWrite)
m_pseudoType = PseudoReadWrite;
else if (m_value == drag || m_value == dragAlias)
m_pseudoType = PseudoDrag;
else if (m_value == enabled)
......
......@@ -142,6 +142,8 @@ namespace WebCore {
PseudoChecked,
PseudoEnabled,
PseudoDisabled,
PseudoReadOnly,
PseudoReadWrite,
PseudoIndeterminate,
PseudoTarget,
PseudoBefore,
......
......@@ -56,6 +56,7 @@
#include "HTMLDocument.h"
#include "HTMLElement.h"
#include "HTMLInputElement.h"
#include "HTMLTextAreaElement.h"
#include "HTMLNames.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
......@@ -2052,6 +2053,24 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
// that are non-"hidden" controls.
return !e->isEnabled();
break;
case CSSSelector::PseudoReadOnly:
if (e && e->isControl()) {
if (e->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(e);
return (input->isTextField() && input->isReadOnlyControl());
} else if (e->hasTagName(textareaTag))
return ((static_cast<HTMLTextAreaElement*>(e))->isReadOnlyControl());
}
break;
case CSSSelector::PseudoReadWrite:
if (e && e->isControl()) {
if (e->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(e);
return (input->isTextField() && !input->isReadOnlyControl());
} else if (e->hasTagName(textareaTag))
return (!(static_cast<HTMLTextAreaElement*>(e))->isReadOnlyControl());
}
break;
case CSSSelector::PseudoChecked:
// Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
// you can't be both checked and indeterminate. We will behave like WinIE behind the scenes and just
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment