michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim:cindent:ts=2:et:sw=2: michael@0: * 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: * This Original Code has been modified by IBM Corporation. Modifications made michael@0: * by IBM described herein are Copyright (c) International Business Machines michael@0: * Corporation, 2000. Modifications to Mozilla code or documentation identified michael@0: * per MPL Section 3.3 michael@0: * michael@0: * Date Modified by Description of modification michael@0: * 04/20/2000 IBM Corp. OS/2 VisualAge build. michael@0: */ michael@0: michael@0: /* storage of the frame tree and information about it */ michael@0: michael@0: #ifndef _nsFrameManager_h_ michael@0: #define _nsFrameManager_h_ michael@0: michael@0: #include "nsIFrame.h" michael@0: #include "nsFrameManagerBase.h" michael@0: #include "nsIContent.h" michael@0: michael@0: namespace mozilla { michael@0: /** michael@0: * Node in a linked list, containing the style for an element that michael@0: * does not have a frame but whose parent does have a frame. michael@0: */ michael@0: struct UndisplayedNode { michael@0: UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle) michael@0: : mContent(aContent), michael@0: mStyle(aStyle), michael@0: mNext(nullptr) michael@0: { michael@0: MOZ_COUNT_CTOR(mozilla::UndisplayedNode); michael@0: } michael@0: michael@0: NS_HIDDEN ~UndisplayedNode() michael@0: { michael@0: MOZ_COUNT_DTOR(mozilla::UndisplayedNode); michael@0: michael@0: // Delete mNext iteratively to avoid blowing up the stack (bug 460461). michael@0: UndisplayedNode* cur = mNext; michael@0: while (cur) { michael@0: UndisplayedNode* next = cur->mNext; michael@0: cur->mNext = nullptr; michael@0: delete cur; michael@0: cur = next; michael@0: } michael@0: } michael@0: michael@0: nsCOMPtr mContent; michael@0: nsRefPtr mStyle; michael@0: UndisplayedNode* mNext; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: /** michael@0: * Frame manager interface. The frame manager serves two purposes: michael@0: *
  • provides a service for mapping from content to frame and from michael@0: * out-of-flow frame to placeholder frame. michael@0: *
  • handles structural modifications to the frame model. If the frame model michael@0: * lock can be acquired, then the changes are processed immediately; otherwise, michael@0: * they're queued and processed later. michael@0: * michael@0: * Do not add virtual methods to this class, or bryner will punish you. michael@0: */ michael@0: michael@0: class nsFrameManager : public nsFrameManagerBase michael@0: { michael@0: typedef nsIFrame::ChildListID ChildListID; michael@0: michael@0: public: michael@0: nsFrameManager(nsIPresShell *aPresShell, nsStyleSet* aStyleSet) NS_HIDDEN { michael@0: mPresShell = aPresShell; michael@0: mStyleSet = aStyleSet; michael@0: MOZ_ASSERT(mPresShell, "need a pres shell"); michael@0: MOZ_ASSERT(mStyleSet, "need a style set"); michael@0: } michael@0: ~nsFrameManager() NS_HIDDEN; michael@0: michael@0: /* michael@0: * After Destroy is called, it is an error to call any FrameManager methods. michael@0: * Destroy should be called when the frame tree managed by the frame michael@0: * manager is no longer being displayed. michael@0: */ michael@0: NS_HIDDEN_(void) Destroy(); michael@0: michael@0: // Placeholder frame functions michael@0: NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(const nsIFrame* aFrame); michael@0: NS_HIDDEN_(nsresult) michael@0: RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); michael@0: michael@0: NS_HIDDEN_(void) michael@0: UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame); michael@0: michael@0: NS_HIDDEN_(void) ClearPlaceholderFrameMap(); michael@0: michael@0: // Mapping undisplayed content michael@0: NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent); michael@0: NS_HIDDEN_(mozilla::UndisplayedNode*) michael@0: GetAllUndisplayedContentIn(nsIContent* aParentContent); michael@0: NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent, michael@0: nsStyleContext* aStyleContext); michael@0: NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent, michael@0: nsStyleContext* aStyleContext); michael@0: NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent, michael@0: nsIContent* aParentContent); michael@0: NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent); michael@0: michael@0: // Functions for manipulating the frame model michael@0: NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame, michael@0: ChildListID aListID, michael@0: nsFrameList& aFrameList); michael@0: michael@0: NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame, michael@0: ChildListID aListID, michael@0: nsIFrame* aPrevFrame, michael@0: nsFrameList& aFrameList); michael@0: michael@0: NS_HIDDEN_(nsresult) RemoveFrame(ChildListID aListID, michael@0: nsIFrame* aOldFrame); michael@0: michael@0: /* michael@0: * Notification that a frame is about to be destroyed. This allows any michael@0: * outstanding references to the frame to be cleaned up. michael@0: */ michael@0: NS_HIDDEN_(void) NotifyDestroyingFrame(nsIFrame* aFrame); michael@0: michael@0: /* michael@0: * Capture/restore frame state for the frame subtree rooted at aFrame. michael@0: * aState is the document state storage object onto which each frame michael@0: * stores its state. Callers of CaptureFrameState are responsible for michael@0: * traversing next continuations of special siblings of aFrame as michael@0: * needed; this method will only work with actual frametree descendants michael@0: * of aFrame. michael@0: */ michael@0: michael@0: NS_HIDDEN_(void) CaptureFrameState(nsIFrame* aFrame, michael@0: nsILayoutHistoryState* aState); michael@0: michael@0: NS_HIDDEN_(void) RestoreFrameState(nsIFrame* aFrame, michael@0: nsILayoutHistoryState* aState); michael@0: michael@0: /* michael@0: * Add/restore state for one frame michael@0: */ michael@0: NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame* aFrame, michael@0: nsILayoutHistoryState* aState); michael@0: michael@0: NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame* aFrame, michael@0: nsILayoutHistoryState* aState); michael@0: michael@0: NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; } michael@0: NS_HIDDEN_(nsPresContext*) GetPresContext() const { michael@0: return mPresShell->GetPresContext(); michael@0: } michael@0: }; michael@0: michael@0: #endif