Line data Source code
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/. */
5 :
6 : /*
7 : * interface for rendering objects that manually create subtrees of
8 : * anonymous content
9 : */
10 :
11 : #ifndef nsIAnonymousContentCreator_h___
12 : #define nsIAnonymousContentCreator_h___
13 :
14 : #include "nsQueryFrame.h"
15 : #include "nsStyleContext.h"
16 : #include "nsTArrayForwardDeclare.h"
17 :
18 : class nsIContent;
19 : class nsIFrame;
20 :
21 : /**
22 : * Any source for anonymous content can implement this interface to provide it.
23 : * HTML frames like nsFileControlFrame currently use this.
24 : *
25 : * @see nsCSSFrameConstructor
26 : */
27 94 : class nsIAnonymousContentCreator
28 : {
29 : public:
30 : NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator)
31 :
32 62 : struct ContentInfo {
33 62 : explicit ContentInfo(nsIContent* aContent) :
34 62 : mContent(aContent)
35 62 : {}
36 :
37 : nsIContent* mContent;
38 : nsTArray<ContentInfo> mChildren;
39 : };
40 :
41 : /**
42 : * Creates "native" anonymous content and adds the created content to
43 : * the aElements array. None of the returned elements can be nullptr.
44 : *
45 : * If the anonymous content creator sets the editable flag on some
46 : * of the elements that it creates, the flag will be applied to the node
47 : * upon being bound to the document.
48 : *
49 : * @note The returned elements are owned by this object. This object is
50 : * responsible for calling UnbindFromTree on the elements it returned
51 : * from CreateAnonymousContent when appropriate (i.e. before releasing
52 : * them).
53 : *
54 : * @note Implementations of this method that add items to mChildren must not
55 : * hook them up to any parent since frame construction takes care of
56 : * that.
57 : */
58 : virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements)=0;
59 :
60 : /**
61 : * Appends "native" anonymous children created by CreateAnonymousContent()
62 : * to the given content list depending on the filter.
63 : *
64 : * @see nsIContent::GetChildren for set of values used for filter. Currently,
65 : * eSkipPlaceholderContent is the only flag that any implementation of
66 : * this method heeds.
67 : */
68 : virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
69 : uint32_t aFilter) = 0;
70 : };
71 :
72 : #endif
73 :
|