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 #ifndef DetailsFrame_h
8 #define DetailsFrame_h
9 
10 #include "nsBlockFrame.h"
11 #include "nsIAnonymousContentCreator.h"
12 
13 class nsContainerFrame;
14 
15 namespace mozilla {
16 
17 // DetailsFrame is generated by HTMLDetailsElement. See
18 // nsCSSFrameConstructor::ConstructDetailsFrame for the structure of a
19 // DetailsFrame.
20 //
21 class DetailsFrame final : public nsBlockFrame,
22                            public nsIAnonymousContentCreator {
23  public:
24   NS_DECL_FRAMEARENA_HELPERS(DetailsFrame)
25   NS_DECL_QUERYFRAME
26 
27   explicit DetailsFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
28 
29   virtual ~DetailsFrame();
30 
31 #ifdef DEBUG_FRAME_DUMP
GetFrameName(nsAString & aResult)32   nsresult GetFrameName(nsAString& aResult) const override {
33     return MakeFrameName(NS_LITERAL_STRING("Details"), aResult);
34   }
35 #endif
36 
37 #ifdef DEBUG
38   // Check the frame of the main summary element is the first child in the frame
39   // list. Returns true if we found the main summary frame; false otherwise.
40   bool CheckValidMainSummary(const nsFrameList& aFrameList) const;
41 #endif
42 
43   void SetInitialChildList(ChildListID aListID,
44                            nsFrameList& aChildList) override;
45 
46   void DestroyFrom(nsIFrame* aDestructRoot,
47                    PostDestroyData& aPostDestroyData) override;
48 
49   // nsIAnonymousContentCreator
50   nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
51 
52   void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
53                                 uint32_t aFilter) override;
54   // Returns true if |aSummaryFrame| is the main summary (i.e. the first child
55   // of this details frame).
56   // This function is used when the summary element is removed from the parent
57   // details element since at that moment the summary element has been already
58   // removed from the details element children.
59   bool HasMainSummaryFrame(nsIFrame* aSummaryFrame);
60 
61  private:
62   nsCOMPtr<nsIContent> mDefaultSummary;
63 };
64 
65 }  // namespace mozilla
66 
67 #endif  // DetailsFrame_h
68