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

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: 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
Index: Source/core/html/HTMLMenuItemElement.cpp
diff --git a/Source/core/html/HTMLMenuItemElement.cpp b/Source/core/html/HTMLMenuItemElement.cpp
index 79d6759ffca96ab5b80873e38fc0bade7e363d41..25b231252321a4d4818dc8afd2779fe98e4bc528 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()) {
+ Element* nextElement = ElementTraversal::firstWithin(*parent);
+ String group = fastGetAttribute(radiogroupAttr);
+ while (nextElement) {
tkent 2014/12/09 13:02:26 for (HTMLMenuItemElement& menuItem : Traversal<HTM
+ if (isHTMLMenuItemElement(*nextElement) && nextElement->fastHasAttribute(checkedAttr) && equalIgnoringCase(nextElement->fastGetAttribute(radiogroupAttr), group)) {
tkent 2014/12/09 12:43:43 Why equalsIgnoringCase? The specification says "e
+ nextElement->removeAttribute(checkedAttr);
+ }
+ nextElement = Traversal<HTMLElement>::nextSibling(*nextElement);
+ }
+ }
+ setAttribute(checkedAttr, "checked");
}
event->setDefaultHandled();
}

Powered by Google App Engine
This is Rietveld 408576698