layout/base/nsFrameManager.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/base/nsFrameManager.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,163 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * vim:cindent:ts=2:et:sw=2:
     1.6 + *
     1.7 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    1.10 + *
    1.11 + * This Original Code has been modified by IBM Corporation. Modifications made
    1.12 + * by IBM described herein are Copyright (c) International Business Machines
    1.13 + * Corporation, 2000. Modifications to Mozilla code or documentation identified
    1.14 + * per MPL Section 3.3
    1.15 + *
    1.16 + * Date             Modified by     Description of modification
    1.17 + * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
    1.18 + */
    1.19 +
    1.20 +/* storage of the frame tree and information about it */
    1.21 +
    1.22 +#ifndef _nsFrameManager_h_
    1.23 +#define _nsFrameManager_h_
    1.24 +
    1.25 +#include "nsIFrame.h"
    1.26 +#include "nsFrameManagerBase.h"
    1.27 +#include "nsIContent.h"
    1.28 +
    1.29 +namespace mozilla {
    1.30 +/**
    1.31 + * Node in a linked list, containing the style for an element that
    1.32 + * does not have a frame but whose parent does have a frame.
    1.33 + */
    1.34 +struct UndisplayedNode {
    1.35 +  UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle)
    1.36 +    : mContent(aContent),
    1.37 +      mStyle(aStyle),
    1.38 +      mNext(nullptr)
    1.39 +  {
    1.40 +    MOZ_COUNT_CTOR(mozilla::UndisplayedNode);
    1.41 +  }
    1.42 +
    1.43 +  NS_HIDDEN ~UndisplayedNode()
    1.44 +  {
    1.45 +    MOZ_COUNT_DTOR(mozilla::UndisplayedNode);
    1.46 +
    1.47 +    // Delete mNext iteratively to avoid blowing up the stack (bug 460461).
    1.48 +    UndisplayedNode* cur = mNext;
    1.49 +    while (cur) {
    1.50 +      UndisplayedNode* next = cur->mNext;
    1.51 +      cur->mNext = nullptr;
    1.52 +      delete cur;
    1.53 +      cur = next;
    1.54 +    }
    1.55 +  }
    1.56 +
    1.57 +  nsCOMPtr<nsIContent>      mContent;
    1.58 +  nsRefPtr<nsStyleContext>  mStyle;
    1.59 +  UndisplayedNode*          mNext;
    1.60 +};
    1.61 +
    1.62 +} // namespace mozilla
    1.63 +
    1.64 +/**
    1.65 + * Frame manager interface. The frame manager serves two purposes:
    1.66 + * <li>provides a service for mapping from content to frame and from
    1.67 + * out-of-flow frame to placeholder frame.
    1.68 + * <li>handles structural modifications to the frame model. If the frame model
    1.69 + * lock can be acquired, then the changes are processed immediately; otherwise,
    1.70 + * they're queued and processed later.
    1.71 + *
    1.72 + * Do not add virtual methods to this class, or bryner will punish you.
    1.73 + */
    1.74 +
    1.75 +class nsFrameManager : public nsFrameManagerBase
    1.76 +{
    1.77 +  typedef nsIFrame::ChildListID ChildListID;
    1.78 +
    1.79 +public:
    1.80 +  nsFrameManager(nsIPresShell *aPresShell, nsStyleSet* aStyleSet) NS_HIDDEN {
    1.81 +    mPresShell = aPresShell;
    1.82 +    mStyleSet = aStyleSet;
    1.83 +    MOZ_ASSERT(mPresShell, "need a pres shell");
    1.84 +    MOZ_ASSERT(mStyleSet, "need a style set");
    1.85 +  }
    1.86 +  ~nsFrameManager() NS_HIDDEN;
    1.87 +
    1.88 +  /*
    1.89 +   * After Destroy is called, it is an error to call any FrameManager methods.
    1.90 +   * Destroy should be called when the frame tree managed by the frame
    1.91 +   * manager is no longer being displayed.
    1.92 +   */
    1.93 +  NS_HIDDEN_(void) Destroy();
    1.94 +
    1.95 +  // Placeholder frame functions
    1.96 +  NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(const nsIFrame* aFrame);
    1.97 +  NS_HIDDEN_(nsresult)
    1.98 +    RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
    1.99 +
   1.100 +  NS_HIDDEN_(void)
   1.101 +    UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
   1.102 +
   1.103 +  NS_HIDDEN_(void)      ClearPlaceholderFrameMap();
   1.104 +
   1.105 +  // Mapping undisplayed content
   1.106 +  NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
   1.107 +  NS_HIDDEN_(mozilla::UndisplayedNode*)
   1.108 +    GetAllUndisplayedContentIn(nsIContent* aParentContent);
   1.109 +  NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
   1.110 +                                         nsStyleContext* aStyleContext);
   1.111 +  NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
   1.112 +                                            nsStyleContext* aStyleContext);
   1.113 +  NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
   1.114 +                                             nsIContent* aParentContent);
   1.115 +  NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
   1.116 +
   1.117 +  // Functions for manipulating the frame model
   1.118 +  NS_HIDDEN_(nsresult) AppendFrames(nsIFrame*       aParentFrame,
   1.119 +                                    ChildListID     aListID,
   1.120 +                                    nsFrameList&    aFrameList);
   1.121 +
   1.122 +  NS_HIDDEN_(nsresult) InsertFrames(nsIFrame*       aParentFrame,
   1.123 +                                    ChildListID     aListID,
   1.124 +                                    nsIFrame*       aPrevFrame,
   1.125 +                                    nsFrameList&    aFrameList);
   1.126 +
   1.127 +  NS_HIDDEN_(nsresult) RemoveFrame(ChildListID     aListID,
   1.128 +                                   nsIFrame*       aOldFrame);
   1.129 +
   1.130 +  /*
   1.131 +   * Notification that a frame is about to be destroyed. This allows any
   1.132 +   * outstanding references to the frame to be cleaned up.
   1.133 +   */
   1.134 +  NS_HIDDEN_(void)     NotifyDestroyingFrame(nsIFrame* aFrame);
   1.135 +
   1.136 +  /*
   1.137 +   * Capture/restore frame state for the frame subtree rooted at aFrame.
   1.138 +   * aState is the document state storage object onto which each frame
   1.139 +   * stores its state.  Callers of CaptureFrameState are responsible for
   1.140 +   * traversing next continuations of special siblings of aFrame as
   1.141 +   * needed; this method will only work with actual frametree descendants
   1.142 +   * of aFrame.
   1.143 +   */
   1.144 +
   1.145 +  NS_HIDDEN_(void) CaptureFrameState(nsIFrame*              aFrame,
   1.146 +                                     nsILayoutHistoryState* aState);
   1.147 +
   1.148 +  NS_HIDDEN_(void) RestoreFrameState(nsIFrame*              aFrame,
   1.149 +                                     nsILayoutHistoryState* aState);
   1.150 +
   1.151 +  /*
   1.152 +   * Add/restore state for one frame
   1.153 +   */
   1.154 +  NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame*              aFrame,
   1.155 +                                        nsILayoutHistoryState* aState);
   1.156 +
   1.157 +  NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame*              aFrame,
   1.158 +                                        nsILayoutHistoryState* aState);
   1.159 +
   1.160 +  NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
   1.161 +  NS_HIDDEN_(nsPresContext*) GetPresContext() const {
   1.162 +    return mPresShell->GetPresContext();
   1.163 +  }
   1.164 +};
   1.165 +
   1.166 +#endif

mercurial