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