OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies) |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/dom/shadow/ShadowRoot.h" | 28 #include "core/dom/shadow/ShadowRoot.h" |
29 #include "core/html/HTMLSummaryElement.h" | 29 #include "core/html/HTMLSummaryElement.h" |
30 #include "core/html/shadow/HTMLContentElement.h" | 30 #include "core/html/shadow/HTMLContentElement.h" |
31 #include "core/platform/LocalizedStrings.h" | 31 #include "core/platform/LocalizedStrings.h" |
32 #include "core/rendering/RenderBlock.h" | 32 #include "core/rendering/RenderBlock.h" |
33 | 33 |
34 namespace WebCore { | 34 namespace WebCore { |
35 | 35 |
36 using namespace HTMLNames; | 36 using namespace HTMLNames; |
37 | 37 |
38 PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(const QualifiedName& t
agName, Document* document) | 38 PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(const QualifiedName& t
agName, Document& document) |
39 { | 39 { |
40 RefPtr<HTMLDetailsElement> details = adoptRef(new HTMLDetailsElement(tagName
, document)); | 40 RefPtr<HTMLDetailsElement> details = adoptRef(new HTMLDetailsElement(tagName
, document)); |
41 details->ensureUserAgentShadowRoot(); | 41 details->ensureUserAgentShadowRoot(); |
42 return details.release(); | 42 return details.release(); |
43 } | 43 } |
44 | 44 |
45 HTMLDetailsElement::HTMLDetailsElement(const QualifiedName& tagName, Document* d
ocument) | 45 HTMLDetailsElement::HTMLDetailsElement(const QualifiedName& tagName, Document& d
ocument) |
46 : HTMLElement(tagName, document) | 46 : HTMLElement(tagName, document) |
47 , m_isOpen(false) | 47 , m_isOpen(false) |
48 { | 48 { |
49 ASSERT(hasTagName(detailsTag)); | 49 ASSERT(hasTagName(detailsTag)); |
50 ScriptWrappable::init(this); | 50 ScriptWrappable::init(this); |
51 } | 51 } |
52 | 52 |
53 RenderObject* HTMLDetailsElement::createRenderer(RenderStyle*) | 53 RenderObject* HTMLDetailsElement::createRenderer(RenderStyle*) |
54 { | 54 { |
55 return new RenderBlock(this); | 55 return new RenderBlock(this); |
56 } | 56 } |
57 | 57 |
58 void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot* root) | 58 void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot* root) |
59 { | 59 { |
60 DEFINE_STATIC_LOCAL(AtomicString, summarySelector, ("summary:first-of-type",
AtomicString::ConstructFromLiteral)); | 60 DEFINE_STATIC_LOCAL(AtomicString, summarySelector, ("summary:first-of-type",
AtomicString::ConstructFromLiteral)); |
61 | 61 |
62 RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summa
ryTag, &document()); | 62 RefPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(summa
ryTag, document()); |
63 defaultSummary->appendChild(Text::create(&document(), defaultDetailsSummaryT
ext())); | 63 defaultSummary->appendChild(Text::create(&document(), defaultDetailsSummaryT
ext())); |
64 | 64 |
65 RefPtr<HTMLContentElement> content = HTMLContentElement::create(&document())
; | 65 RefPtr<HTMLContentElement> content = HTMLContentElement::create(document()); |
66 content->setAttribute(selectAttr, summarySelector); | 66 content->setAttribute(selectAttr, summarySelector); |
67 content->appendChild(defaultSummary); | 67 content->appendChild(defaultSummary); |
68 | 68 |
69 root->appendChild(content); | 69 root->appendChild(content); |
70 root->appendChild(HTMLContentElement::create(&document())); | 70 root->appendChild(HTMLContentElement::create(document())); |
71 } | 71 } |
72 | 72 |
73 Element* HTMLDetailsElement::findMainSummary() const | 73 Element* HTMLDetailsElement::findMainSummary() const |
74 { | 74 { |
75 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 75 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
76 if (child->hasTagName(summaryTag)) | 76 if (child->hasTagName(summaryTag)) |
77 return toElement(child); | 77 return toElement(child); |
78 } | 78 } |
79 | 79 |
80 HTMLContentElement* content = toHTMLContentElement(userAgentShadowRoot()->fi
rstChild()); | 80 HTMLContentElement* content = toHTMLContentElement(userAgentShadowRoot()->fi
rstChild()); |
(...skipping 20 matching lines...) Expand all Loading... |
101 return false; | 101 return false; |
102 return childContext.node() == findMainSummary() && HTMLElement::childShouldC
reateRenderer(childContext); | 102 return childContext.node() == findMainSummary() && HTMLElement::childShouldC
reateRenderer(childContext); |
103 } | 103 } |
104 | 104 |
105 void HTMLDetailsElement::toggleOpen() | 105 void HTMLDetailsElement::toggleOpen() |
106 { | 106 { |
107 setAttribute(openAttr, m_isOpen ? nullAtom : emptyAtom); | 107 setAttribute(openAttr, m_isOpen ? nullAtom : emptyAtom); |
108 } | 108 } |
109 | 109 |
110 } | 110 } |
OLD | NEW |