| 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" |
| 11 #include "core/html/parser/HTMLParserIdioms.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 using namespace HTMLNames; | 15 using namespace HTMLNames; |
| 15 | 16 |
| 16 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document) | 17 inline HTMLMenuItemElement::HTMLMenuItemElement(Document& document) |
| 17 : HTMLElement(HTMLNames::menuitemTag, document) { | 18 : HTMLElement(HTMLNames::menuitemTag, document) { |
| 18 UseCounter::Count(document, UseCounter::kMenuItemElement); | 19 UseCounter::Count(document, UseCounter::kMenuItemElement); |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 if (EqualIgnoringNullity(group_attr.Impl(), group.Impl())) | 51 if (EqualIgnoringNullity(group_attr.Impl(), group.Impl())) |
| 51 menu_item.removeAttribute(checkedAttr); | 52 menu_item.removeAttribute(checkedAttr); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 setAttribute(checkedAttr, "checked"); | 55 setAttribute(checkedAttr, "checked"); |
| 55 } | 56 } |
| 56 event->SetDefaultHandled(); | 57 event->SetDefaultHandled(); |
| 57 } | 58 } |
| 58 } | 59 } |
| 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 |
| 60 DEFINE_NODE_FACTORY(HTMLMenuItemElement) | 81 DEFINE_NODE_FACTORY(HTMLMenuItemElement) |
| 61 | 82 |
| 62 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |