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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLMenuItemElement.cpp

Issue 2805633002: Count 'icon' attribute of MENUITEM element. (Closed)
Patch Set: Created 3 years, 8 months 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 unified diff | Download patch
OLDNEW
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"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 using namespace HTMLNames; 14 using namespace HTMLNames;
15 15
16 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document) 16 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document)
17 : HTMLElement(HTMLNames::menuitemTag, document) { 17 : HTMLElement(HTMLNames::menuitemTag, document) {
18 UseCounter::count(document, UseCounter::MenuItemElement); 18 UseCounter::count(document, UseCounter::MenuItemElement);
19 } 19 }
20 20
21 bool HTMLMenuItemElement::isURLAttribute(const Attribute& attribute) const { 21 bool HTMLMenuItemElement::isURLAttribute(const Attribute& attribute) const {
22 return attribute.name() == iconAttr || HTMLElement::isURLAttribute(attribute); 22 return attribute.name() == iconAttr || HTMLElement::isURLAttribute(attribute);
23 } 23 }
24 24
25 void HTMLMenuItemElement::parseAttribute(
26 const AttributeModificationParams& params) {
27 if (params.name == iconAttr)
28 UseCounter::count(document(), UseCounter::MenuItemElementIconAttribute);
29 HTMLElement::parseAttribute(params);
30 }
31
25 void HTMLMenuItemElement::defaultEventHandler(Event* event) { 32 void HTMLMenuItemElement::defaultEventHandler(Event* event) {
26 if (event->type() == EventTypeNames::click) { 33 if (event->type() == EventTypeNames::click) {
27 if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) { 34 if (equalIgnoringCase(fastGetAttribute(typeAttr), "checkbox")) {
28 if (fastHasAttribute(checkedAttr)) 35 if (fastHasAttribute(checkedAttr))
29 removeAttribute(checkedAttr); 36 removeAttribute(checkedAttr);
30 else 37 else
31 setAttribute(checkedAttr, "checked"); 38 setAttribute(checkedAttr, "checked");
32 } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) { 39 } else if (equalIgnoringCase(fastGetAttribute(typeAttr), "radio")) {
33 if (Element* parent = parentElement()) { 40 if (Element* parent = parentElement()) {
34 AtomicString group = fastGetAttribute(radiogroupAttr); 41 AtomicString group = fastGetAttribute(radiogroupAttr);
35 for (HTMLMenuItemElement& menuItem : 42 for (HTMLMenuItemElement& menuItem :
36 Traversal<HTMLMenuItemElement>::childrenOf(*parent)) { 43 Traversal<HTMLMenuItemElement>::childrenOf(*parent)) {
37 if (!menuItem.fastHasAttribute(checkedAttr)) 44 if (!menuItem.fastHasAttribute(checkedAttr))
38 continue; 45 continue;
39 const AtomicString& groupAttr = 46 const AtomicString& groupAttr =
40 menuItem.fastGetAttribute(radiogroupAttr); 47 menuItem.fastGetAttribute(radiogroupAttr);
41 if (equalIgnoringNullity(groupAttr.impl(), group.impl())) 48 if (equalIgnoringNullity(groupAttr.impl(), group.impl()))
42 menuItem.removeAttribute(checkedAttr); 49 menuItem.removeAttribute(checkedAttr);
43 } 50 }
44 } 51 }
45 setAttribute(checkedAttr, "checked"); 52 setAttribute(checkedAttr, "checked");
46 } 53 }
47 event->setDefaultHandled(); 54 event->setDefaultHandled();
48 } 55 }
49 } 56 }
50 57
51 DEFINE_NODE_FACTORY(HTMLMenuItemElement) 58 DEFINE_NODE_FACTORY(HTMLMenuItemElement)
52 59
53 } // namespace blink 60 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMenuItemElement.h ('k') | third_party/WebKit/Source/core/html/HTMLUnknownElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698