layout/generic/nsIAnonymousContentCreator.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 /*
     7  * interface for rendering objects that manually create subtrees of
     8  * anonymous content
     9  */
    11 #ifndef nsIAnonymousContentCreator_h___
    12 #define nsIAnonymousContentCreator_h___
    14 #include "nsQueryFrame.h"
    15 #include "nsIContent.h"
    16 #include "nsStyleContext.h"
    17 #include "nsTArrayForwardDeclare.h"
    19 class nsBaseContentList;
    20 class nsIFrame;
    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 {
    30 public:
    31   NS_DECL_QUERYFRAME_TARGET(nsIAnonymousContentCreator)
    33   struct ContentInfo {
    34     ContentInfo(nsIContent* aContent) :
    35       mContent(aContent)
    36     {}
    38     ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) :
    39       mContent(aContent), mStyleContext(aStyleContext)
    40     {}
    42     nsIContent* mContent;
    43     nsRefPtr<nsStyleContext> mStyleContext;
    44     nsTArray<ContentInfo> mChildren;
    45   };
    47   /**
    48    * Creates "native" anonymous content and adds the created content to
    49    * the aElements array. None of the returned elements can be nullptr.
    50    *
    51    * If the anonymous content creator sets the editable flag on some
    52    * of the elements that it creates, the flag will be applied to the node
    53    * upon being bound to the document.
    54    *
    55    * @note The returned elements are owned by this object. This object is
    56    *       responsible for calling UnbindFromTree on the elements it returned
    57    *       from CreateAnonymousContent when appropriate (i.e. before releasing
    58    *       them).
    59    *
    60    * @note Implementations of this method that add items to mChildren must not
    61    *       hook them up to any parent since frame construction takes care of
    62    *       that.
    63    */
    64   virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements)=0;
    66   /**
    67    * Appends "native" anonymous children created by CreateAnonymousContent()
    68    * to the given content list depending on the filter.
    69    *
    70    * @see nsIContent::GetChildren for set of values used for filter.
    71    */
    72   virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
    73                                         uint32_t aFilter) = 0;
    75   /**
    76    * Implementations can override this method to create special frames for the
    77    * anonymous content returned from CreateAnonymousContent.
    78    * By default this method returns nullptr, which means the default frame
    79    * is created.
    80    */
    81   virtual nsIFrame* CreateFrameFor(nsIContent* aContent) { return nullptr; }
    82 };
    84 #endif

mercurial