1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/nsIAnonymousContentCreator.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * interface for rendering objects that manually create subtrees of 1.11 + * anonymous content 1.12 + */ 1.13 + 1.14 +#ifndef nsIAnonymousContentCreator_h___ 1.15 +#define nsIAnonymousContentCreator_h___ 1.16 + 1.17 +#include "nsQueryFrame.h" 1.18 +#include "nsIContent.h" 1.19 +#include "nsStyleContext.h" 1.20 +#include "nsTArrayForwardDeclare.h" 1.21 + 1.22 +class nsBaseContentList; 1.23 +class nsIFrame; 1.24 + 1.25 +/** 1.26 + * Any source for anonymous content can implement this interface to provide it. 1.27 + * HTML frames like nsFileControlFrame currently use this. 1.28 + * 1.29 + * @see nsCSSFrameConstructor 1.30 + */ 1.31 +class nsIAnonymousContentCreator 1.32 +{ 1.33 +public: 1.34 + NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator) 1.35 + 1.36 + struct ContentInfo { 1.37 + ContentInfo(nsIContent* aContent) : 1.38 + mContent(aContent) 1.39 + {} 1.40 + 1.41 + ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) : 1.42 + mContent(aContent), mStyleContext(aStyleContext) 1.43 + {} 1.44 + 1.45 + nsIContent* mContent; 1.46 + nsRefPtr<nsStyleContext> mStyleContext; 1.47 + nsTArray<ContentInfo> mChildren; 1.48 + }; 1.49 + 1.50 + /** 1.51 + * Creates "native" anonymous content and adds the created content to 1.52 + * the aElements array. None of the returned elements can be nullptr. 1.53 + * 1.54 + * If the anonymous content creator sets the editable flag on some 1.55 + * of the elements that it creates, the flag will be applied to the node 1.56 + * upon being bound to the document. 1.57 + * 1.58 + * @note The returned elements are owned by this object. This object is 1.59 + * responsible for calling UnbindFromTree on the elements it returned 1.60 + * from CreateAnonymousContent when appropriate (i.e. before releasing 1.61 + * them). 1.62 + * 1.63 + * @note Implementations of this method that add items to mChildren must not 1.64 + * hook them up to any parent since frame construction takes care of 1.65 + * that. 1.66 + */ 1.67 + virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements)=0; 1.68 + 1.69 + /** 1.70 + * Appends "native" anonymous children created by CreateAnonymousContent() 1.71 + * to the given content list depending on the filter. 1.72 + * 1.73 + * @see nsIContent::GetChildren for set of values used for filter. 1.74 + */ 1.75 + virtual void AppendAnonymousContentTo(nsBaseContentList& aElements, 1.76 + uint32_t aFilter) = 0; 1.77 + 1.78 + /** 1.79 + * Implementations can override this method to create special frames for the 1.80 + * anonymous content returned from CreateAnonymousContent. 1.81 + * By default this method returns nullptr, which means the default frame 1.82 + * is created. 1.83 + */ 1.84 + virtual nsIFrame* CreateFrameFor(nsIContent* aContent) { return nullptr; } 1.85 +}; 1.86 + 1.87 +#endif 1.88 +