OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/html/HTMLMenuItemElement.h" | 5 #include "core/html/HTMLMenuItemElement.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
10 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 void HTMLMenuItemElement::defaultEventHandler(Event* event) | 22 void HTMLMenuItemElement::defaultEventHandler(Event* event) |
23 { | 23 { |
24 if (event->type() == EventTypeNames::click) { | 24 if (event->type() == EventTypeNames::click) { |
25 if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) { | 25 if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) { |
26 if (fastHasAttribute(checkedAttr)) | 26 if (fastHasAttribute(checkedAttr)) |
27 removeAttribute(checkedAttr); | 27 removeAttribute(checkedAttr); |
28 else | 28 else |
29 setAttribute(checkedAttr, "checked"); | 29 setAttribute(checkedAttr, "checked"); |
30 } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) { | 30 } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) { |
31 if (Element* parent = parentElement()) { | 31 if (Element* parent = parentElement()) { |
32 const AtomicString& group = fastGetAttribute(radiogroupAttr); | 32 AtomicString group = fastGetAttribute(radiogroupAttr); |
33 for (HTMLMenuItemElement& menuItem : Traversal<HTMLMenuItemEleme
nt>::childrenOf(*parent)) { | 33 for (HTMLMenuItemElement& menuItem : Traversal<HTMLMenuItemEleme
nt>::childrenOf(*parent)) { |
34 if (!menuItem.fastHasAttribute(checkedAttr)) | 34 if (!menuItem.fastHasAttribute(checkedAttr)) |
35 continue; | 35 continue; |
36 const AtomicString& groupAttr = menuItem.fastGetAttribute(ra
diogroupAttr); | 36 const AtomicString& groupAttr = menuItem.fastGetAttribute(ra
diogroupAttr); |
37 if (equalIgnoringNullity(groupAttr.impl(), group.impl())) | 37 if (equalIgnoringNullity(groupAttr.impl(), group.impl())) |
38 menuItem.removeAttribute(checkedAttr); | 38 menuItem.removeAttribute(checkedAttr); |
39 } | 39 } |
40 } | 40 } |
41 setAttribute(checkedAttr, "checked"); | 41 setAttribute(checkedAttr, "checked"); |
42 } | 42 } |
43 event->setDefaultHandled(); | 43 event->setDefaultHandled(); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 DEFINE_NODE_FACTORY(HTMLMenuItemElement) | 47 DEFINE_NODE_FACTORY(HTMLMenuItemElement) |
48 | 48 |
49 } // namespace blink | 49 } // namespace blink |
OLD | NEW |