Title: [96078] trunk
- Revision
- 96078
- Author
- [email protected]
- Date
- 2011-09-27 00:34:16 -0700 (Tue, 27 Sep 2011)
Log Message
<input> with autofocus doesn't lose focus when it has a certain onblur listener
https://bugs.webkit.org/show_bug.cgi?id=68513
Patch by Rakesh KN <[email protected]> on 2011-09-27
Reviewed by Kent Tamura.
Source/WebCore:
Test: fast/forms/autofocus-focus-only-once.html
These changes make sure that an element is focused only once when autofocus attribute is used.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::HTMLFormControlElement):
(WebCore::shouldAutofocus):
(WebCore::HTMLFormControlElement::attach):
* html/HTMLFormControlElement.h:
(WebCore::HTMLFormControlElement::hasAutofocused):
(WebCore::HTMLFormControlElement::setAutofocused):
LayoutTests:
These changes make sure that an element is focused only once when autofocus attribute is used.
* fast/forms/autofocus-focus-only-once-expected.txt: Added.
* fast/forms/autofocus-focus-only-once.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (96077 => 96078)
--- trunk/LayoutTests/ChangeLog 2011-09-27 07:05:21 UTC (rev 96077)
+++ trunk/LayoutTests/ChangeLog 2011-09-27 07:34:16 UTC (rev 96078)
@@ -1,3 +1,15 @@
+2011-09-27 Rakesh KN <[email protected]>
+
+ <input> with autofocus doesn't lose focus when it has a certain onblur listener
+ https://bugs.webkit.org/show_bug.cgi?id=68513
+
+ Reviewed by Kent Tamura.
+
+ These changes make sure that an element is focused only once when autofocus attribute is used.
+
+ * fast/forms/autofocus-focus-only-once-expected.txt: Added.
+ * fast/forms/autofocus-focus-only-once.html: Added.
+
2011-09-27 Renata Hodovan <[email protected]>
[Qt] Add missing test expecteds after r95924.
Added: trunk/LayoutTests/fast/forms/autofocus-focus-only-once-expected.txt (0 => 96078)
--- trunk/LayoutTests/fast/forms/autofocus-focus-only-once-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/autofocus-focus-only-once-expected.txt 2011-09-27 07:34:16 UTC (rev 96078)
@@ -0,0 +1,9 @@
+
+This form control should have a green background and active state:
+
+
+PASS document.activeElement is document.getElementById("input2")
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/autofocus-focus-only-once.html (0 => 96078)
--- trunk/LayoutTests/fast/forms/autofocus-focus-only-once.html (rev 0)
+++ trunk/LayoutTests/fast/forms/autofocus-focus-only-once.html 2011-09-27 07:34:16 UTC (rev 96078)
@@ -0,0 +1,38 @@
+<html>
+<head>
+<title>basic "autofocus" test</title>
+<style>
+input { background:red }
+input:focus { background:lime }
+</style>
+<script src=""
+<script language="_javascript_" type="text/_javascript_">
+window.jsTestIsAsync = true;
+
+function elementBlur() {
+ document.getElementById("input1").type = "password";
+}
+function elementFocus() {
+ document.getElementById("input1").type = "text";
+}
+
+function test() {
+ document.getElementById("input2").focus();
+ shouldBe('document.activeElement', 'document.getElementById("input2")');
+ finishJSTest();
+}
+
+successfullyParsed = true;
+</script>
+</head>
+<body _onload_="test()">
+<input id="input1" type="text" autofocus _onblur_="elementBlur()" _onfocus_="elementFocus()"/>
+<br/>
+<p>This form control should have a green background and active state:<input id="input2">
+<hr>
+<pre id="console">
+
+</pre>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (96077 => 96078)
--- trunk/Source/WebCore/ChangeLog 2011-09-27 07:05:21 UTC (rev 96077)
+++ trunk/Source/WebCore/ChangeLog 2011-09-27 07:34:16 UTC (rev 96078)
@@ -1,3 +1,22 @@
+2011-09-27 Rakesh KN <[email protected]>
+
+ <input> with autofocus doesn't lose focus when it has a certain onblur listener
+ https://bugs.webkit.org/show_bug.cgi?id=68513
+
+ Reviewed by Kent Tamura.
+
+ Test: fast/forms/autofocus-focus-only-once.html
+
+ These changes make sure that an element is focused only once when autofocus attribute is used.
+
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::HTMLFormControlElement):
+ (WebCore::shouldAutofocus):
+ (WebCore::HTMLFormControlElement::attach):
+ * html/HTMLFormControlElement.h:
+ (WebCore::HTMLFormControlElement::hasAutofocused):
+ (WebCore::HTMLFormControlElement::setAutofocused):
+
2011-09-26 Kentaro Hara <[email protected]>
Implement PopStateEvent.state with SerializedScriptValue and ScriptValue
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (96077 => 96078)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2011-09-27 07:05:21 UTC (rev 96077)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2011-09-27 07:34:16 UTC (rev 96078)
@@ -59,6 +59,7 @@
, m_willValidate(true)
, m_isValid(true)
, m_wasChangedSinceLastFormControlChangeEvent(false)
+ , m_hasAutofocused(false)
{
if (!this->form())
setForm(findFormAncestor());
@@ -129,6 +130,8 @@
return false;
if (element->isReadOnlyFormControl())
return false;
+ if (element->hasAutofocused())
+ return false;
// FIXME: Should this set of hasTagName checks be replaced by a
// virtual member function?
@@ -167,6 +170,7 @@
renderer()->updateFromElement();
if (shouldAutofocus(this)) {
+ setAutofocused();
ref();
queuePostAttachCallback(focusPostAttach, this);
}
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (96077 => 96078)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2011-09-27 07:05:21 UTC (rev 96077)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2011-09-27 07:34:16 UTC (rev 96078)
@@ -99,6 +99,9 @@
bool readOnly() const { return m_readOnly; }
+ bool hasAutofocused() { return m_hasAutofocused; }
+ void setAutofocused() { m_hasAutofocused = true; }
+
using TreeShared<ContainerNode>::ref;
using TreeShared<ContainerNode>::deref;
@@ -159,6 +162,8 @@
bool m_isValid : 1;
bool m_wasChangedSinceLastFormControlChangeEvent : 1;
+
+ bool m_hasAutofocused : 1;
};
// FIXME: Give this class its own header file.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes