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