/src/mozilla-central/dom/html/HTMLDetailsElement.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/dom/HTMLDetailsElement.h" |
8 | | |
9 | | #include "mozilla/dom/HTMLDetailsElementBinding.h" |
10 | | |
11 | | NS_IMPL_NS_NEW_HTML_ELEMENT(Details) |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | HTMLDetailsElement::~HTMLDetailsElement() |
17 | 0 | { |
18 | 0 | } |
19 | | |
20 | | NS_IMPL_ELEMENT_CLONE(HTMLDetailsElement) |
21 | | |
22 | | nsIContent* |
23 | | HTMLDetailsElement::GetFirstSummary() const |
24 | 0 | { |
25 | 0 | // XXX: Bug 1245032: Might want to cache the first summary element. |
26 | 0 | for (nsIContent* child = nsINode::GetFirstChild(); |
27 | 0 | child; |
28 | 0 | child = child->GetNextSibling()) { |
29 | 0 | if (child->IsHTMLElement(nsGkAtoms::summary)) { |
30 | 0 | return child; |
31 | 0 | } |
32 | 0 | } |
33 | 0 | return nullptr; |
34 | 0 | } |
35 | | |
36 | | nsChangeHint |
37 | | HTMLDetailsElement::GetAttributeChangeHint(const nsAtom* aAttribute, |
38 | | int32_t aModType) const |
39 | 0 | { |
40 | 0 | nsChangeHint hint = |
41 | 0 | nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType); |
42 | 0 | if (aAttribute == nsGkAtoms::open) { |
43 | 0 | hint |= nsChangeHint_ReconstructFrame; |
44 | 0 | } |
45 | 0 | return hint; |
46 | 0 | } |
47 | | |
48 | | nsresult |
49 | | HTMLDetailsElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, |
50 | | const nsAttrValueOrString* aValue, bool aNotify) |
51 | 0 | { |
52 | 0 | if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::open) { |
53 | 0 | bool setOpen = aValue != nullptr; |
54 | 0 | if (Open() != setOpen) { |
55 | 0 | if (mToggleEventDispatcher) { |
56 | 0 | mToggleEventDispatcher->Cancel(); |
57 | 0 | } |
58 | 0 | // According to the html spec, a 'toggle' event is a simple event which |
59 | 0 | // does not bubble. |
60 | 0 | mToggleEventDispatcher = |
61 | 0 | new AsyncEventDispatcher(this, |
62 | 0 | NS_LITERAL_STRING("toggle"), |
63 | 0 | CanBubble::eNo); |
64 | 0 | mToggleEventDispatcher->PostDOMEvent(); |
65 | 0 | } |
66 | 0 | } |
67 | 0 |
|
68 | 0 | return nsGenericHTMLElement::BeforeSetAttr(aNameSpaceID, aName, aValue, |
69 | 0 | aNotify); |
70 | 0 | } |
71 | | |
72 | | void |
73 | | HTMLDetailsElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) |
74 | 0 | { |
75 | 0 | if (mToggleEventDispatcher == aEvent) { |
76 | 0 | mToggleEventDispatcher = nullptr; |
77 | 0 | } |
78 | 0 | } |
79 | | |
80 | | JSObject* |
81 | | HTMLDetailsElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
82 | 0 | { |
83 | 0 | return HTMLDetailsElement_Binding::Wrap(aCx, this, aGivenProto); |
84 | 0 | } |
85 | | |
86 | | } // namespace dom |
87 | | } // namespace mozilla |