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

Unified Diff: Source/core/html/HTMLMenuItemElement.cpp

Issue 786753003: Implement type=radio and radiogroup attribute for menuitem. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review comments and added more tests Created 6 years 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
« no previous file with comments | « Source/core/html/HTMLAttributeNames.in ('k') | Source/core/html/HTMLMenuItemElement.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMenuItemElement.cpp
diff --git a/Source/core/html/HTMLMenuItemElement.cpp b/Source/core/html/HTMLMenuItemElement.cpp
index 79d6759ffca96ab5b80873e38fc0bade7e363d41..7bfc4613d07dc48e781292ab49af06dac2fe4a24 100644
--- a/Source/core/html/HTMLMenuItemElement.cpp
+++ b/Source/core/html/HTMLMenuItemElement.cpp
@@ -6,6 +6,7 @@
#include "core/html/HTMLMenuItemElement.h"
#include "core/HTMLNames.h"
+#include "core/dom/ElementTraversal.h"
#include "core/events/Event.h"
namespace blink {
@@ -25,6 +26,18 @@ void HTMLMenuItemElement::defaultEventHandler(Event* event)
removeAttribute(checkedAttr);
else
setAttribute(checkedAttr, "checked");
+ } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) {
+ if (Element* parent = parentElement()) {
+ String group = fastHasAttribute(radiogroupAttr) ? fastGetAttribute(radiogroupAttr) : "";
tkent 2014/12/10 06:50:49 This code searches the element for radiogroupAttr
pals 2014/12/10 07:11:46 Done.
+ for (HTMLMenuItemElement& menuItem : Traversal<HTMLMenuItemElement>::childrenOf(*parent)) {
+ if (equalIgnoringCase(menuItem.fastGetAttribute(typeAttr), "radio") && menuItem.fastHasAttribute(checkedAttr)) {
tkent 2014/12/10 06:50:49 Don't check type=radio here. The specification do
pals 2014/12/10 07:11:46 But, this looks like a specification bug. I shall
+ String groupAttr = menuItem.fastHasAttribute(radiogroupAttr) ? menuItem.fastGetAttribute(radiogroupAttr) : "";
tkent 2014/12/10 06:50:49 Don't need to call fastHasAttribute like line. 31.
pals 2014/12/10 07:11:46 Done.
+ if (groupAttr.stripWhiteSpace() == group.stripWhiteSpace())
tkent 2014/12/10 06:50:49 Don't use stripWhiteSpace(). The specification do
pals 2014/12/10 07:11:46 Done.
+ menuItem.removeAttribute(checkedAttr);
+ }
+ }
+ }
+ setAttribute(checkedAttr, "checked");
}
event->setDefaultHandled();
}
« no previous file with comments | « Source/core/html/HTMLAttributeNames.in ('k') | Source/core/html/HTMLMenuItemElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698