Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / html / HTMLMenuItemElement.cpp
blob94163c35f73fedf373981631f63e689f1d148f20
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/html/HTMLMenuItemElement.h"
8 #include "core/HTMLNames.h"
9 #include "core/dom/ElementTraversal.h"
10 #include "core/events/Event.h"
12 namespace blink {
14 using namespace HTMLNames;
16 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document)
17 : HTMLElement(HTMLNames::menuitemTag, document)
21 void HTMLMenuItemElement::defaultEventHandler(Event* event)
23 if (event->type() == EventTypeNames::click) {
24 if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) {
25 if (fastHasAttribute(checkedAttr))
26 removeAttribute(checkedAttr);
27 else
28 setAttribute(checkedAttr, "checked");
29 } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) {
30 if (Element* parent = parentElement()) {
31 const AtomicString& group = fastGetAttribute(radiogroupAttr);
32 for (HTMLMenuItemElement& menuItem : Traversal<HTMLMenuItemElement>::childrenOf(*parent)) {
33 if (!menuItem.fastHasAttribute(checkedAttr))
34 continue;
35 const AtomicString& groupAttr = menuItem.fastGetAttribute(radiogroupAttr);
36 if (equalIgnoringNullity(groupAttr.impl(), group.impl()))
37 menuItem.removeAttribute(checkedAttr);
40 setAttribute(checkedAttr, "checked");
42 event->setDefaultHandled();
46 DEFINE_NODE_FACTORY(HTMLMenuItemElement)
48 } // namespace blink