| 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 28 matching lines...) Expand all Loading... |
| 39 #include "platform/text/PlatformLocale.h" | 39 #include "platform/text/PlatformLocale.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 using namespace HTMLNames; | 43 using namespace HTMLNames; |
| 44 | 44 |
| 45 class FirstSummarySelectFilter final : public HTMLContentSelectFilter { | 45 class FirstSummarySelectFilter final : public HTMLContentSelectFilter { |
| 46 public: | 46 public: |
| 47 virtual ~FirstSummarySelectFilter() { } | 47 virtual ~FirstSummarySelectFilter() { } |
| 48 | 48 |
| 49 static PassOwnPtrWillBeRawPtr<FirstSummarySelectFilter> create() | 49 static RawPtr<FirstSummarySelectFilter> create() |
| 50 { | 50 { |
| 51 return adoptPtrWillBeNoop(new FirstSummarySelectFilter()); | 51 return new FirstSummarySelectFilter(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool canSelectNode(const WillBeHeapVector<RawPtrWillBeMember<Node>, 32>& sib
lings, int nth) const override | 54 bool canSelectNode(const HeapVector<Member<Node>, 32>& siblings, int nth) co
nst override |
| 55 { | 55 { |
| 56 if (!siblings[nth]->hasTagName(HTMLNames::summaryTag)) | 56 if (!siblings[nth]->hasTagName(HTMLNames::summaryTag)) |
| 57 return false; | 57 return false; |
| 58 for (int i = nth - 1; i >= 0; --i) { | 58 for (int i = nth - 1; i >= 0; --i) { |
| 59 if (siblings[i]->hasTagName(HTMLNames::summaryTag)) | 59 if (siblings[i]->hasTagName(HTMLNames::summaryTag)) |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 | 64 |
| 65 DEFINE_INLINE_VIRTUAL_TRACE() | 65 DEFINE_INLINE_VIRTUAL_TRACE() |
| 66 { | 66 { |
| 67 HTMLContentSelectFilter::trace(visitor); | 67 HTMLContentSelectFilter::trace(visitor); |
| 68 } | 68 } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 FirstSummarySelectFilter() { } | 71 FirstSummarySelectFilter() { } |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 static DetailsEventSender& detailsToggleEventSender() | 74 static DetailsEventSender& detailsToggleEventSender() |
| 75 { | 75 { |
| 76 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<DetailsEventSender>, sharedToggle
EventSender, (DetailsEventSender::create(EventTypeNames::toggle))); | 76 DEFINE_STATIC_LOCAL(Persistent<DetailsEventSender>, sharedToggleEventSender,
(DetailsEventSender::create(EventTypeNames::toggle))); |
| 77 return *sharedToggleEventSender; | 77 return *sharedToggleEventSender; |
| 78 } | 78 } |
| 79 | 79 |
| 80 PassRefPtrWillBeRawPtr<HTMLDetailsElement> HTMLDetailsElement::create(Document&
document) | 80 RawPtr<HTMLDetailsElement> HTMLDetailsElement::create(Document& document) |
| 81 { | 81 { |
| 82 RefPtrWillBeRawPtr<HTMLDetailsElement> details = adoptRefWillBeNoop(new HTML
DetailsElement(document)); | 82 RawPtr<HTMLDetailsElement> details = new HTMLDetailsElement(document); |
| 83 details->ensureUserAgentShadowRoot(); | 83 details->ensureUserAgentShadowRoot(); |
| 84 return details.release(); | 84 return details.release(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 HTMLDetailsElement::HTMLDetailsElement(Document& document) | 87 HTMLDetailsElement::HTMLDetailsElement(Document& document) |
| 88 : HTMLElement(detailsTag, document) | 88 : HTMLElement(detailsTag, document) |
| 89 , m_isOpen(false) | 89 , m_isOpen(false) |
| 90 { | 90 { |
| 91 UseCounter::count(document, UseCounter::DetailsElement); | 91 UseCounter::count(document, UseCounter::DetailsElement); |
| 92 } | 92 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 LayoutObject* HTMLDetailsElement::createLayoutObject(const ComputedStyle&) | 108 LayoutObject* HTMLDetailsElement::createLayoutObject(const ComputedStyle&) |
| 109 { | 109 { |
| 110 return new LayoutBlockFlow(this); | 110 return new LayoutBlockFlow(this); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot& root) | 113 void HTMLDetailsElement::didAddUserAgentShadowRoot(ShadowRoot& root) |
| 114 { | 114 { |
| 115 RefPtrWillBeRawPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::
create(document()); | 115 RawPtr<HTMLSummaryElement> defaultSummary = HTMLSummaryElement::create(docum
ent()); |
| 116 defaultSummary->appendChild(Text::create(document(), locale().queryString(We
bLocalizedString::DetailsLabel))); | 116 defaultSummary->appendChild(Text::create(document(), locale().queryString(We
bLocalizedString::DetailsLabel))); |
| 117 | 117 |
| 118 RefPtrWillBeRawPtr<HTMLContentElement> summary = HTMLContentElement::create(
document(), FirstSummarySelectFilter::create()); | 118 RawPtr<HTMLContentElement> summary = HTMLContentElement::create(document(),
FirstSummarySelectFilter::create()); |
| 119 summary->setIdAttribute(ShadowElementNames::detailsSummary()); | 119 summary->setIdAttribute(ShadowElementNames::detailsSummary()); |
| 120 summary->appendChild(defaultSummary); | 120 summary->appendChild(defaultSummary); |
| 121 root.appendChild(summary.release()); | 121 root.appendChild(summary.release()); |
| 122 | 122 |
| 123 RefPtrWillBeRawPtr<HTMLDivElement> content = HTMLDivElement::create(document
()); | 123 RawPtr<HTMLDivElement> content = HTMLDivElement::create(document()); |
| 124 content->setIdAttribute(ShadowElementNames::detailsContent()); | 124 content->setIdAttribute(ShadowElementNames::detailsContent()); |
| 125 content->appendChild(HTMLContentElement::create(document())); | 125 content->appendChild(HTMLContentElement::create(document())); |
| 126 content->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | 126 content->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 127 root.appendChild(content.release()); | 127 root.appendChild(content.release()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 Element* HTMLDetailsElement::findMainSummary() const | 130 Element* HTMLDetailsElement::findMainSummary() const |
| 131 { | 131 { |
| 132 if (HTMLSummaryElement* summary = Traversal<HTMLSummaryElement>::firstChild(
*this)) | 132 if (HTMLSummaryElement* summary = Traversal<HTMLSummaryElement>::firstChild(
*this)) |
| 133 return summary; | 133 return summary; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 { | 174 { |
| 175 setAttribute(openAttr, m_isOpen ? nullAtom : emptyAtom); | 175 setAttribute(openAttr, m_isOpen ? nullAtom : emptyAtom); |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool HTMLDetailsElement::isInteractiveContent() const | 178 bool HTMLDetailsElement::isInteractiveContent() const |
| 179 { | 179 { |
| 180 return true; | 180 return true; |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |