michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * interface for rendering objects that manually create subtrees of michael@0: * anonymous content michael@0: */ michael@0: michael@0: #ifndef nsIAnonymousContentCreator_h___ michael@0: #define nsIAnonymousContentCreator_h___ michael@0: michael@0: #include "nsQueryFrame.h" michael@0: #include "nsIContent.h" michael@0: #include "nsStyleContext.h" michael@0: #include "nsTArrayForwardDeclare.h" michael@0: michael@0: class nsBaseContentList; michael@0: class nsIFrame; michael@0: michael@0: /** michael@0: * Any source for anonymous content can implement this interface to provide it. michael@0: * HTML frames like nsFileControlFrame currently use this. michael@0: * michael@0: * @see nsCSSFrameConstructor michael@0: */ michael@0: class nsIAnonymousContentCreator michael@0: { michael@0: public: michael@0: NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator) michael@0: michael@0: struct ContentInfo { michael@0: ContentInfo(nsIContent* aContent) : michael@0: mContent(aContent) michael@0: {} michael@0: michael@0: ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) : michael@0: mContent(aContent), mStyleContext(aStyleContext) michael@0: {} michael@0: michael@0: nsIContent* mContent; michael@0: nsRefPtr mStyleContext; michael@0: nsTArray mChildren; michael@0: }; michael@0: michael@0: /** michael@0: * Creates "native" anonymous content and adds the created content to michael@0: * the aElements array. None of the returned elements can be nullptr. michael@0: * michael@0: * If the anonymous content creator sets the editable flag on some michael@0: * of the elements that it creates, the flag will be applied to the node michael@0: * upon being bound to the document. michael@0: * michael@0: * @note The returned elements are owned by this object. This object is michael@0: * responsible for calling UnbindFromTree on the elements it returned michael@0: * from CreateAnonymousContent when appropriate (i.e. before releasing michael@0: * them). michael@0: * michael@0: * @note Implementations of this method that add items to mChildren must not michael@0: * hook them up to any parent since frame construction takes care of michael@0: * that. michael@0: */ michael@0: virtual nsresult CreateAnonymousContent(nsTArray& aElements)=0; michael@0: michael@0: /** michael@0: * Appends "native" anonymous children created by CreateAnonymousContent() michael@0: * to the given content list depending on the filter. michael@0: * michael@0: * @see nsIContent::GetChildren for set of values used for filter. michael@0: */ michael@0: virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, michael@0: uint32_t aFilter) = 0; michael@0: michael@0: /** michael@0: * Implementations can override this method to create special frames for the michael@0: * anonymous content returned from CreateAnonymousContent. michael@0: * By default this method returns nullptr, which means the default frame michael@0: * is created. michael@0: */ michael@0: virtual nsIFrame* CreateFrameFor(nsIContent* aContent) { return nullptr; } michael@0: }; michael@0: michael@0: #endif michael@0: