Merge m-c to fx-team.
[gecko.git] / layout / generic / nsIAnonymousContentCreator.h
blob12bb89c90e58482047c188b0870a8a70f266a084
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * interface for rendering objects that manually create subtrees of
8 * anonymous content
9 */
11 #ifndef nsIAnonymousContentCreator_h___
12 #define nsIAnonymousContentCreator_h___
14 #include "nsQueryFrame.h"
15 #include "nsIContent.h"
16 #include "nsStyleContext.h"
17 #include "nsTArrayForwardDeclare.h"
19 class nsBaseContentList;
20 class nsIFrame;
22 /**
23 * Any source for anonymous content can implement this interface to provide it.
24 * HTML frames like nsFileControlFrame currently use this.
26 * @see nsCSSFrameConstructor
28 class nsIAnonymousContentCreator
30 public:
31 NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator)
33 struct ContentInfo {
34 ContentInfo(nsIContent* aContent) :
35 mContent(aContent)
38 ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) :
39 mContent(aContent), mStyleContext(aStyleContext)
42 nsIContent* mContent;
43 nsRefPtr<nsStyleContext> mStyleContext;
44 nsTArray<ContentInfo> mChildren;
47 /**
48 * Creates "native" anonymous content and adds the created content to
49 * the aElements array. None of the returned elements can be nullptr.
51 * If the anonymous content creator sets the editable flag on some
52 * of the elements that it creates, the flag will be applied to the node
53 * upon being bound to the document.
55 * @note The returned elements are owned by this object. This object is
56 * responsible for calling UnbindFromTree on the elements it returned
57 * from CreateAnonymousContent when appropriate (i.e. before releasing
58 * them).
60 * @note Implementations of this method that add items to mChildren must not
61 * hook them up to any parent since frame construction takes care of
62 * that.
64 virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements)=0;
66 /**
67 * Appends "native" anonymous children created by CreateAnonymousContent()
68 * to the given content list depending on the filter.
70 * @see nsIContent::GetChildren for set of values used for filter.
72 virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
73 uint32_t aFilter) = 0;
75 /**
76 * Implementations can override this method to create special frames for the
77 * anonymous content returned from CreateAnonymousContent.
78 * By default this method returns nullptr, which means the default frame
79 * is created.
81 virtual nsIFrame* CreateFrameFor(nsIContent* aContent) { return nullptr; }
84 #endif