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

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: Rebaselined 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..94163c35f73fedf373981631f63e689f1d148f20 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()) {
+ const AtomicString& group = fastGetAttribute(radiogroupAttr);
+ for (HTMLMenuItemElement& menuItem : Traversal<HTMLMenuItemElement>::childrenOf(*parent)) {
+ if (!menuItem.fastHasAttribute(checkedAttr))
+ continue;
+ const AtomicString& groupAttr = menuItem.fastGetAttribute(radiogroupAttr);
+ if (equalIgnoringNullity(groupAttr.impl(), group.impl()))
+ 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