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

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

Issue 2905763003: Rollback ContextMenu (Closed)
Patch Set: Rebase Created 3 years, 6 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
(Empty)
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.
4
5 #include "core/html/HTMLMenuItemElement.h"
6
7 #include "core/HTMLNames.h"
8 #include "core/dom/ElementTraversal.h"
9 #include "core/events/Event.h"
10 #include "core/frame/UseCounter.h"
11 #include "core/html/parser/HTMLParserIdioms.h"
12
13 namespace blink {
14
15 using namespace HTMLNames;
16
17 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document)
18 : HTMLElement(HTMLNames::menuitemTag, document) {
19 UseCounter::Count(document, UseCounter::kMenuItemElement);
20 }
21
22 bool HTMLMenuItemElement::IsURLAttribute(const Attribute& attribute) const {
23 return attribute.GetName() == iconAttr ||
24 HTMLElement::IsURLAttribute(attribute);
25 }
26
27 void HTMLMenuItemElement::ParseAttribute(
28 const AttributeModificationParams& params) {
29 if (params.name == iconAttr)
30 UseCounter::Count(GetDocument(), UseCounter::kMenuItemElementIconAttribute);
31 HTMLElement::ParseAttribute(params);
32 }
33
34 void HTMLMenuItemElement::DefaultEventHandler(Event* event) {
35 if (event->type() == EventTypeNames::click) {
36 if (DeprecatedEqualIgnoringCase(FastGetAttribute(typeAttr), "checkbox")) {
37 if (FastHasAttribute(checkedAttr))
38 removeAttribute(checkedAttr);
39 else
40 setAttribute(checkedAttr, "checked");
41 } else if (DeprecatedEqualIgnoringCase(FastGetAttribute(typeAttr),
42 "radio")) {
43 if (Element* parent = parentElement()) {
44 AtomicString group = FastGetAttribute(radiogroupAttr);
45 for (HTMLMenuItemElement& menu_item :
46 Traversal<HTMLMenuItemElement>::ChildrenOf(*parent)) {
47 if (!menu_item.FastHasAttribute(checkedAttr))
48 continue;
49 const AtomicString& group_attr =
50 menu_item.FastGetAttribute(radiogroupAttr);
51 if (EqualIgnoringNullity(group_attr.Impl(), group.Impl()))
52 menu_item.removeAttribute(checkedAttr);
53 }
54 }
55 setAttribute(checkedAttr, "checked");
56 }
57 event->SetDefaultHandled();
58 }
59 }
60
61 String HTMLMenuItemElement::label() const {
62 const AtomicString label = FastGetAttribute(labelAttr);
63 if (!label.IsNull())
64 return label;
65 return conceptualLabel();
66 }
67
68 void HTMLMenuItemElement::setLabel(const AtomicString& label) {
69 setAttribute(labelAttr, label);
70 }
71
72 String HTMLMenuItemElement::conceptualLabel() const {
73 const AtomicString label = FastGetAttribute(labelAttr);
74 if (!label.IsEmpty())
75 return label;
76 return this->textContent(false)
77 .StripWhiteSpace(IsHTMLSpace<UChar>)
78 .SimplifyWhiteSpace(IsHTMLSpace<UChar>);
79 }
80
81 DEFINE_NODE_FACTORY(HTMLMenuItemElement)
82
83 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMenuItemElement.h ('k') | third_party/WebKit/Source/core/html/HTMLMenuItemElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698