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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved. 3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // (and so moves to the right). Seems strange, but we'll match it. However, 86 // (and so moves to the right). Seems strange, but we'll match it. However,
87 // when using Spatial Navigation, we need to be able to navigate without 87 // when using Spatial Navigation, we need to be able to navigate without
88 // changing the selection. 88 // changing the selection.
89 Document& document = element().document(); 89 Document& document = element().document();
90 if (isSpatialNavigationEnabled(document.frame())) 90 if (isSpatialNavigationEnabled(document.frame()))
91 return; 91 return;
92 bool forward = (key == "Down" || key == "Right"); 92 bool forward = (key == "Down" || key == "Right");
93 93
94 // We can only stay within the form's children if the form hasn't been demot ed to a leaf because 94 // We can only stay within the form's children if the form hasn't been demot ed to a leaf because
95 // of malformed HTML. 95 // of malformed HTML.
96 for (HTMLElement* htmlElement = nextElement(element(), forward); htmlElement ; htmlElement = nextElement(*htmlElement, forward)) { 96 for (HTMLElement* htmlElement = nextElement(element(), forward); ; htmlElem ent = nextElement(*htmlElement, forward)) {
97 // Once we encounter a form element, we know we're through. 97 // Once we encounter no element or an input element of ootside this form or form element in backward traversal, we know we're through.
98 if (isHTMLFormElement(*htmlElement)) 98 if (!htmlElement || (isHTMLInputElement(*htmlElement) && toHTMLInputElem ent(htmlElement)->form() != element().form()) || isHTMLFormElement(*htmlElement) ) {
Habib Virji 2014/09/10 09:31:52 If htmlElement is null, this line will result in c
99 break; 99 // Traverse in reverse direction for any radio button
100 forward = !(forward);
101 htmlElement = &element();
102 HTMLElement* nextHtmlElement = nextElement(*htmlElement, forward);
103 HTMLInputElement* inputElement;
104 while (!isHTMLFormElement(*nextHtmlElement) && nextHtmlElement) {
Habib Virji 2014/09/10 09:31:52 is this loop necessary and should not nextHTMLElem
105 if (isHTMLInputElement(*nextHtmlElement)) {
106 inputElement = toHTMLInputElement(nextHtmlElement);
107 if (inputElement->form() == element().form() && inputElement ->isRadioButton() && inputElement->name() == element().name() && inputElement->i sFocusable())
Habib Virji 2014/09/10 09:31:52 Should not there be a break, if we found the radio
108 htmlElement = nextHtmlElement;
109 }
110 nextHtmlElement = nextElement(*nextHtmlElement, forward);
111 }
112 }
113
100 // Look for more radio buttons. 114 // Look for more radio buttons.
101 if (!isHTMLInputElement(*htmlElement)) 115 if (!isHTMLInputElement(*htmlElement))
102 continue; 116 continue;
103 HTMLInputElement* inputElement = toHTMLInputElement(htmlElement); 117 HTMLInputElement* inputElement = toHTMLInputElement(htmlElement);
104 if (inputElement->form() != element().form()) 118 if (inputElement->form() != element().form())
105 break; 119 break;
106 if (inputElement->isRadioButton() && inputElement->name() == element().n ame() && inputElement->isFocusable()) { 120 if (inputElement->isRadioButton() && inputElement->name() == element().n ame() && inputElement->isFocusable()) {
107 RefPtrWillBeRawPtr<HTMLInputElement> protector(inputElement); 121 RefPtrWillBeRawPtr<HTMLInputElement> protector(inputElement);
108 document.setFocusedElement(inputElement); 122 document.setFocusedElement(inputElement);
109 inputElement->dispatchSimulatedClick(event, SendNoEvents); 123 inputElement->dispatchSimulatedClick(event, SendNoEvents);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 { 208 {
195 return true; 209 return true;
196 } 210 }
197 211
198 bool RadioInputType::supportsIndeterminateAppearance() const 212 bool RadioInputType::supportsIndeterminateAppearance() const
199 { 213 {
200 return false; 214 return false;
201 } 215 }
202 216
203 } // namespace blink 217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698