Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1076)

Unified Diff: Source/core/html/forms/RadioInputType.cpp

Issue 546753002: Fix to Handle downkey event on last and first radio button of a radio button list (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/forms/RadioInputType.cpp
diff --git a/Source/core/html/forms/RadioInputType.cpp b/Source/core/html/forms/RadioInputType.cpp
index 4e992f650156e2874b2a8c1e9af574347c232a5a..2273243556875910b6c171949fd9ec002008a898 100644
--- a/Source/core/html/forms/RadioInputType.cpp
+++ b/Source/core/html/forms/RadioInputType.cpp
@@ -93,10 +93,24 @@ void RadioInputType::handleKeydownEvent(KeyboardEvent* event)
// We can only stay within the form's children if the form hasn't been demoted to a leaf because
// of malformed HTML.
- for (HTMLElement* htmlElement = nextElement(element(), forward); htmlElement; htmlElement = nextElement(*htmlElement, forward)) {
- // Once we encounter a form element, we know we're through.
- if (isHTMLFormElement(*htmlElement))
- break;
+ for (HTMLElement* htmlElement = nextElement(element(), forward); ; htmlElement = nextElement(*htmlElement, forward)) {
+ // Once we encounter no element or an input element of ootside this form or form element in backward traversal, we know we're through.
+ if (!htmlElement || (isHTMLInputElement(*htmlElement) && toHTMLInputElement(htmlElement)->form() != element().form()) || isHTMLFormElement(*htmlElement)) {
Habib Virji 2014/09/10 09:31:52 If htmlElement is null, this line will result in c
+ // Traverse in reverse direction for any radio button
+ forward = !(forward);
+ htmlElement = &element();
+ HTMLElement* nextHtmlElement = nextElement(*htmlElement, forward);
+ HTMLInputElement* inputElement;
+ while (!isHTMLFormElement(*nextHtmlElement) && nextHtmlElement) {
Habib Virji 2014/09/10 09:31:52 is this loop necessary and should not nextHTMLElem
+ if (isHTMLInputElement(*nextHtmlElement)) {
+ inputElement = toHTMLInputElement(nextHtmlElement);
+ if (inputElement->form() == element().form() && inputElement->isRadioButton() && inputElement->name() == element().name() && inputElement->isFocusable())
Habib Virji 2014/09/10 09:31:52 Should not there be a break, if we found the radio
+ htmlElement = nextHtmlElement;
+ }
+ nextHtmlElement = nextElement(*nextHtmlElement, forward);
+ }
+ }
+
// Look for more radio buttons.
if (!isHTMLInputElement(*htmlElement))
continue;

Powered by Google App Engine
This is Rietveld 408576698