[webkit-changes] cvs commit: WebCore/layout-tests/fast/forms
focus-expected.txt focus.html legend-access-key-expected.txt
legend-access-key.html
Darin
darin at opensource.apple.com
Sat Jun 18 22:00:26 PDT 2005
darin 05/06/18 22:00:26
Modified: . ChangeLog
khtml/ecma kjs_html.cpp kjs_html.h
khtml/html html_formimpl.cpp html_formimpl.h
khtml/xml dom_docimpl.cpp
Added: layout-tests/fast/forms focus-expected.txt focus.html
legend-access-key-expected.txt
legend-access-key.html
Log:
Changes by Anders Carlsson.
Reviewed by me.
Test cases added:
* layout-tests/fast/forms/focus-expected.txt: Added.
* layout-tests/fast/forms/focus.html: Added.
* layout-tests/fast/forms/legend-access-key-expected.txt: Added.
* layout-tests/fast/forms/legend-access-key.html: Added.
- fixed <rdar://problem/3481846> HTML4: accesskey not supported by HTML legend elements
also <http://bugzilla.opendarwin.org/show_bug.cgi?id=3407>
- added focus methods for <label> and <legend> elements
- fixed crash when using JavaScript-created events that prevented tests from running
* khtml/ecma/kjs_html.h: Added focus methods.
* khtml/ecma/kjs_html.cpp: (KJS::KJS::HTMLElementFunction::tryCall): Added bindings for
focus for <label> and <legend>. (Sorry about the merging, Dave.)
* khtml/html/html_formimpl.h: Added new functions.
* khtml/html/html_formimpl.cpp:
(DOM::HTMLLabelElementImpl::focus): Added.
(DOM::HTMLLegendElementImpl::formElement): Added.
(DOM::HTMLLegendElementImpl::focus): Added.
(DOM::HTMLLegendElementImpl::accessKeyAction): Added.
* khtml/xml/dom_docimpl.cpp: (DocumentImpl::defaultEventHandler): If there's no QKeyEvent,
then get the key name from keyIdentifier() instead of the QKeyEvent's unmodifiedText().
The old code would just do a nil-deref.
Revision Changes Path
1.4279 +31 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4278
retrieving revision 1.4279
diff -u -r1.4278 -r1.4279
--- ChangeLog 19 Jun 2005 03:39:51 -0000 1.4278
+++ ChangeLog 19 Jun 2005 05:00:19 -0000 1.4279
@@ -1,5 +1,36 @@
2005-06-18 Darin Adler <darin at apple.com>
+ Changes by Anders Carlsson.
+ Reviewed by me.
+
+ Test cases added:
+ * layout-tests/fast/forms/focus-expected.txt: Added.
+ * layout-tests/fast/forms/focus.html: Added.
+ * layout-tests/fast/forms/legend-access-key-expected.txt: Added.
+ * layout-tests/fast/forms/legend-access-key.html: Added.
+
+ - fixed <rdar://problem/3481846> HTML4: accesskey not supported by HTML legend elements
+ also <http://bugzilla.opendarwin.org/show_bug.cgi?id=3407>
+ - added focus methods for <label> and <legend> elements
+ - fixed crash when using JavaScript-created events that prevented tests from running
+
+ * khtml/ecma/kjs_html.h: Added focus methods.
+ * khtml/ecma/kjs_html.cpp: (KJS::KJS::HTMLElementFunction::tryCall): Added bindings for
+ focus for <label> and <legend>. (Sorry about the merging, Dave.)
+
+ * khtml/html/html_formimpl.h: Added new functions.
+ * khtml/html/html_formimpl.cpp:
+ (DOM::HTMLLabelElementImpl::focus): Added.
+ (DOM::HTMLLegendElementImpl::formElement): Added.
+ (DOM::HTMLLegendElementImpl::focus): Added.
+ (DOM::HTMLLegendElementImpl::accessKeyAction): Added.
+
+ * khtml/xml/dom_docimpl.cpp: (DocumentImpl::defaultEventHandler): If there's no QKeyEvent,
+ then get the key name from keyIdentifier() instead of the QKeyEvent's unmodifiedText().
+ The old code would just do a nil-deref.
+
+2005-06-18 Darin Adler <darin at apple.com>
+
Change by Niels Leenheer (also done by Dave Hyatt on stage at WWDC).
Reviewed by me.
1.115 +22 -2 WebCore/khtml/ecma/kjs_html.cpp
Index: kjs_html.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.cpp,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- kjs_html.cpp 23 May 2005 00:57:42 -0000 1.114
+++ kjs_html.cpp 19 Jun 2005 05:00:23 -0000 1.115
@@ -876,18 +876,20 @@
blur KJS::HTMLElement::ButtonBlur DontDelete|Function 0
focus KJS::HTMLElement::ButtonFocus DontDelete|Function 0
@end
- at begin HTMLLabelElementTable 3
+ at begin HTMLLabelElementTable 4
form KJS::HTMLElement::LabelForm DontDelete|ReadOnly
accessKey KJS::HTMLElement::LabelAccessKey DontDelete
htmlFor KJS::HTMLElement::LabelHtmlFor DontDelete
+ focus KJS::HTMLElement::LabelFocus DontDelete|Function 0
@end
@begin HTMLFieldSetElementTable 1
form KJS::HTMLElement::FieldSetForm DontDelete|ReadOnly
@end
- at begin HTMLLegendElementTable 3
+ at begin HTMLLegendElementTable 4
form KJS::HTMLElement::LegendForm DontDelete|ReadOnly
accessKey KJS::HTMLElement::LegendAccessKey DontDelete
align KJS::HTMLElement::LegendAlign DontDelete
+ focus KJS::HTMLElement::LegendFocus DontDelete|Function 0
@end
@begin HTMLUListElementTable 2
compact KJS::HTMLElement::UListCompact DontDelete
@@ -2179,6 +2181,24 @@
}
}
break;
+ case ID_LABEL: {
+ HTMLLabelElementImpl &label = static_cast<HTMLLabelElementImpl &>(element);
+
+ if (id == KJS::HTMLElement::LabelFocus) {
+ label.focus();
+ return Undefined();
+ }
+ }
+ break;
+ case ID_LEGEND: {
+ HTMLLegendElementImpl &legend = static_cast<HTMLLegendElementImpl &>(element);
+
+ if (id == KJS::HTMLElement::LegendFocus) {
+ legend.focus();
+ return Undefined();
+ }
+ }
+ break;
case ID_BUTTON: {
HTMLButtonElementImpl &button = static_cast<HTMLButtonElementImpl &>(element);
1.45 +2 -2 WebCore/khtml/ecma/kjs_html.h
Index: kjs_html.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_html.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- kjs_html.h 12 May 2005 17:11:21 -0000 1.44
+++ kjs_html.h 19 Jun 2005 05:00:23 -0000 1.45
@@ -108,8 +108,8 @@
TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue,
TextAreaBlur, TextAreaFocus, ButtonBlur, ButtonFocus, ButtonForm, ButtonTabIndex, ButtonName,
ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor,
- LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
- LegendAlign, UListType, UListCompact, OListStart, OListCompact,
+ LabelForm, LabelFocus, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
+ LegendAlign, LegendFocus, UListType, UListCompact, OListStart, OListCompact,
OListType, DListCompact, DirectoryCompact, MenuCompact, LIType,
LIValue, DivAlign, ParagraphAlign, HeadingAlign, BlockQuoteCite,
QuoteCite, PreWidth, BRClear, BaseFontColor, BaseFontSize,
1.163 +43 -8 WebCore/khtml/html/html_formimpl.cpp
Index: html_formimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.cpp,v
retrieving revision 1.162
retrieving revision 1.163
diff -u -r1.162 -r1.163
--- html_formimpl.cpp 17 Jun 2005 18:14:27 -0000 1.162
+++ html_formimpl.cpp 19 Jun 2005 05:00:24 -0000 1.163
@@ -2377,14 +2377,9 @@
DOMString formElementId = getAttribute(ATTR_FOR);
if (formElementId.isNull()) {
// Search children of the label element for a form element.
- NodeImpl *node = this;
- while ((node = node->traverseNextNode(this))) {
- if (node->isHTMLElement()) {
- HTMLElementImpl *element = static_cast<HTMLElementImpl *>(node);
- if (element->isGenericFormElement()) {
- return element;
- }
- }
+ for (NodeImpl *node = this; node; node = node->traverseNextNode(this)) {
+ if (node->isHTMLElement() && static_cast<HTMLElementImpl *>(node)->isGenericFormElement())
+ return element;
}
return 0;
}
@@ -2393,6 +2388,12 @@
return getDocument()->getElementById(formElementId);
}
+void HTMLLabelElementImpl::focus()
+{
+ if (ElementImpl *element = formElement())
+ getDocument()->setFocusNode(element);
+}
+
void HTMLLabelElementImpl::accessKeyAction(bool sendToAnyElement)
{
ElementImpl *element = formElement();
@@ -2479,6 +2480,40 @@
setAttribute(ATTR_ALIGN, value);
}
+ElementImpl *HTMLLegendElementImpl::formElement()
+{
+ // Check if there's a fieldset belonging to this legend.
+ NodeImpl *fieldset = parentNode();
+ while (fieldset && fieldset->id() != ID_FIELDSET)
+ fieldset = fieldset->parentNode();
+ if (!fieldset)
+ return 0;
+
+ // Find first form element inside the fieldset.
+ // FIXME: Should we care about tabindex?
+ for (NodeImpl *node = fieldset; node; node = node->traverseNextNode(fieldset)) {
+ if (node->isHTMLElement()) {
+ HTMLElementImpl *element = static_cast<HTMLElementImpl *>(node);
+ if (element->id() != ID_LEGEND && element->isGenericFormElement())
+ return element;
+ }
+ }
+
+ return 0;
+}
+
+void HTMLLegendElementImpl::focus()
+{
+ if (ElementImpl *element = formElement())
+ getDocument()->setFocusNode(element);
+}
+
+void HTMLLegendElementImpl::accessKeyAction(bool sendToAnyElement)
+{
+ if (ElementImpl *element = formElement())
+ element->accessKeyAction(sendToAnyElement);
+}
+
// -------------------------------------------------------------------------
HTMLSelectElementImpl::HTMLSelectElementImpl(DocumentPtr *doc, HTMLFormElementImpl *f)
1.73 +11 -0 WebCore/khtml/html/html_formimpl.h
Index: html_formimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_formimpl.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- html_formimpl.h 17 Jun 2005 18:14:27 -0000 1.72
+++ html_formimpl.h 19 Jun 2005 05:00:24 -0000 1.73
@@ -470,6 +470,8 @@
DOMString htmlFor() const;
void setHtmlFor(const DOMString &);
+ void focus();
+
private:
DOMString m_formElementID;
};
@@ -489,11 +491,20 @@
virtual DOMString type() const;
+ virtual void accessKeyAction(bool sendToAnyElement);
+
+ /**
+ * The first form element in the legend's fieldset
+ */
+ ElementImpl *formElement();
+
DOMString accessKey() const;
void setAccessKey(const DOMString &);
DOMString align() const;
void setAlign(const DOMString &);
+
+ void focus();
};
// -------------------------------------------------------------------------
1.229 +2 -1 WebCore/khtml/xml/dom_docimpl.cpp
Index: dom_docimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -r1.228 -r1.229
--- dom_docimpl.cpp 31 May 2005 05:48:41 -0000 1.228
+++ dom_docimpl.cpp 19 Jun 2005 05:00:25 -0000 1.229
@@ -2689,7 +2689,8 @@
if (evt->id()==EventImpl::KEYDOWN_EVENT) {
KeyboardEventImpl *kevt = static_cast<KeyboardEventImpl *>(evt);
if (kevt->ctrlKey()) {
- QString key = kevt->qKeyEvent()->unmodifiedText().lower();
+ QKeyEvent *qevt = kevt->qKeyEvent();
+ QString key = (qevt ? qevt->unmodifiedText() : kevt->keyIdentifier().string()).lower();
ElementImpl *elem = getElementByAccessKey(key);
if (elem) {
elem->accessKeyAction(false);
1.1 WebCore/layout-tests/fast/forms/focus-expected.txt
Index: focus-expected.txt
===================================================================
This test checks to see if focus methods work on a couple types of elements.
If the test passes, you should see a line saying "focused 1", then 2, then 3.
LegendLabel2 Label3
focused 1
focused 2
focused 3
1.1 WebCore/layout-tests/fast/forms/focus.html
Index: focus.html
===================================================================
<html>
<head>
<script>
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
document.getElementById("console").appendChild(item);
}
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
document.getElementById("1").focus();
document.getElementById("2").focus();
document.getElementById("3").focus();
}
</script>
</head>
<body onload="test()">
<p>This test checks to see if focus methods work on a couple types of elements.</p>
<p>If the test passes, you should see a line saying "focused 1", then 2, then 3.</p>
<hr>
<p>
<fieldset><legend id="1">Legend</legend><input onfocus="log('focused 1')" type="text"></fieldset>
<label id="2">Label2<input onfocus="log('focused 2')" type="text"></label></td>
<label id="3" for="input3">Label3</label><input onfocus="log('focused 3')" id="input3" type="text">
<p>
<hr>
<ol id="console"></ol>
</body>
</html>
1.1 WebCore/layout-tests/fast/forms/legend-access-key-expected.txt
Index: legend-access-key-expected.txt
===================================================================
This test checks to see if accesskey attributes work on legend elements.
If the test passes, you should see one line saying "focused" and the text field should have focus.
Information:
focused
1.1 WebCore/layout-tests/fast/forms/legend-access-key.html
Index: legend-access-key.html
===================================================================
<html>
<head>
<script>
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
document.getElementById("console").appendChild(item);
}
function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
var event = document.createEvent("KeyboardEvent");
event.initKeyboardEvent("keydown", true, true, document.defaultView, "f", 0, true, false, false, false, false);
document.dispatchEvent(event);
}
</script>
</head>
<body onload="test()">
<p>This test checks to see if accesskey attributes work on legend elements.</p>
<p>If the test passes, you should see one line saying "focused" and the text field should have focus.</p>
<hr>
<p><fieldset><legend accesskey="f">Information:</legend><input onfocus="log('focused')" type="text"></fieldset><p>
<hr>
<ol id="console"></ol>
</body>
</html>
More information about the webkit-changes
mailing list