2004-02-24 00:29:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim:cindent:ts=2:et:sw=2:
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2004-02-24 00:29:06 +03:00
|
|
|
*
|
|
|
|
* This Original Code has been modified by IBM Corporation. Modifications made
|
|
|
|
* by IBM described herein are Copyright (c) International Business Machines
|
|
|
|
* Corporation, 2000. Modifications to Mozilla code or documentation identified
|
|
|
|
* per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
|
|
|
|
*/
|
|
|
|
|
2006-03-30 09:56:38 +04:00
|
|
|
/* storage of the frame tree and information about it */
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
#ifndef _nsFrameManager_h_
|
|
|
|
#define _nsFrameManager_h_
|
|
|
|
|
2004-03-06 07:46:11 +03:00
|
|
|
#include "nsFrameManagerBase.h"
|
2014-06-12 21:09:31 +04:00
|
|
|
|
|
|
|
#include "nsFrameList.h"
|
2014-06-12 03:10:29 +04:00
|
|
|
#include "nsIContent.h"
|
2014-06-12 21:09:31 +04:00
|
|
|
#include "nsStyleContext.h"
|
2004-02-24 03:36:35 +03:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
class nsContainerFrame;
|
2014-06-12 21:09:31 +04:00
|
|
|
class nsPlaceholderFrame;
|
2014-05-25 02:20:40 +04:00
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
namespace mozilla {
|
2013-07-20 23:14:25 +04:00
|
|
|
/**
|
|
|
|
* Node in a linked list, containing the style for an element that
|
|
|
|
* does not have a frame but whose parent does have a frame.
|
|
|
|
*/
|
2017-03-19 22:19:06 +03:00
|
|
|
struct UndisplayedNode : public LinkedListElement<UndisplayedNode>
|
2017-03-19 14:11:34 +03:00
|
|
|
{
|
2013-07-20 23:14:25 +04:00
|
|
|
UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle)
|
2017-03-19 14:11:34 +03:00
|
|
|
: mContent(aContent)
|
|
|
|
, mStyle(aStyle)
|
2013-07-20 23:14:25 +04:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(mozilla::UndisplayedNode);
|
|
|
|
}
|
|
|
|
|
2017-03-19 22:19:06 +03:00
|
|
|
~UndisplayedNode() { MOZ_COUNT_DTOR(mozilla::UndisplayedNode); }
|
2013-07-20 23:14:25 +04:00
|
|
|
|
2017-03-19 14:11:34 +03:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
RefPtr<nsStyleContext> mStyle;
|
2013-07-20 23:14:25 +04:00
|
|
|
};
|
|
|
|
|
2010-06-18 20:23:05 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
/**
|
2017-05-31 22:29:49 +03:00
|
|
|
* Frame manager interface. The frame manager serves one purpose:
|
2004-02-24 00:29:06 +03:00
|
|
|
* <li>handles structural modifications to the frame model. If the frame model
|
|
|
|
* lock can be acquired, then the changes are processed immediately; otherwise,
|
|
|
|
* they're queued and processed later.
|
2004-03-06 07:53:30 +03:00
|
|
|
*
|
2014-06-12 02:38:17 +04:00
|
|
|
* Do not add virtual methods (a vtable pointer) or members to this class, or
|
|
|
|
* else you'll break the validity of the reinterpret_cast in nsIPresShell's
|
|
|
|
* FrameManager() method.
|
2004-02-24 00:29:06 +03:00
|
|
|
*/
|
2004-03-06 07:46:11 +03:00
|
|
|
class nsFrameManager : public nsFrameManagerBase
|
2004-02-24 00:29:06 +03:00
|
|
|
{
|
2014-06-12 21:09:31 +04:00
|
|
|
typedef mozilla::layout::FrameChildListID ChildListID;
|
2010-06-18 20:23:05 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
public:
|
2015-11-10 04:27:47 +03:00
|
|
|
explicit nsFrameManager(nsIPresShell* aPresShell) {
|
2012-02-02 14:06:46 +04:00
|
|
|
mPresShell = aPresShell;
|
2013-04-01 02:43:04 +04:00
|
|
|
MOZ_ASSERT(mPresShell, "need a pres shell");
|
2004-03-06 07:46:11 +03:00
|
|
|
}
|
2014-06-02 16:08:24 +04:00
|
|
|
~nsFrameManager();
|
2004-03-06 07:46:11 +03:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
/*
|
|
|
|
* After Destroy is called, it is an error to call any FrameManager methods.
|
|
|
|
* Destroy should be called when the frame tree managed by the frame
|
|
|
|
* manager is no longer being displayed.
|
|
|
|
*/
|
2014-06-02 16:08:21 +04:00
|
|
|
void Destroy();
|
2004-02-24 00:29:06 +03:00
|
|
|
|
|
|
|
// Mapping undisplayed content
|
2017-02-21 16:21:07 +03:00
|
|
|
nsStyleContext* GetUndisplayedContent(const nsIContent* aContent)
|
2014-11-20 21:24:09 +03:00
|
|
|
{
|
|
|
|
if (!mUndisplayedMap) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return GetStyleContextInMap(mUndisplayedMap, aContent);
|
|
|
|
}
|
2014-06-02 16:08:21 +04:00
|
|
|
mozilla::UndisplayedNode*
|
2013-07-20 23:14:25 +04:00
|
|
|
GetAllUndisplayedContentIn(nsIContent* aParentContent);
|
2014-06-02 16:08:21 +04:00
|
|
|
void SetUndisplayedContent(nsIContent* aContent,
|
2014-11-20 21:24:09 +03:00
|
|
|
nsStyleContext* aStyleContext);
|
2014-06-02 16:08:21 +04:00
|
|
|
void ChangeUndisplayedContent(nsIContent* aContent,
|
2014-11-20 21:24:09 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
|
|
|
{
|
|
|
|
ChangeStyleContextInMap(mUndisplayedMap, aContent, aStyleContext);
|
|
|
|
}
|
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
void ClearUndisplayedContentIn(nsIContent* aContent,
|
2014-11-20 21:24:09 +03:00
|
|
|
nsIContent* aParentContent);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
2014-11-20 21:24:09 +03:00
|
|
|
// display:contents related methods:
|
|
|
|
/**
|
|
|
|
* Return the registered display:contents style context for aContent, if any.
|
|
|
|
*/
|
2017-02-21 16:21:07 +03:00
|
|
|
nsStyleContext* GetDisplayContentsStyleFor(const nsIContent* aContent)
|
2014-11-20 21:24:09 +03:00
|
|
|
{
|
|
|
|
if (!mDisplayContentsMap) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return GetStyleContextInMap(mDisplayContentsMap, aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the linked list of UndisplayedNodes containing the registered
|
|
|
|
* display:contents children of aParentContent, if any.
|
|
|
|
*/
|
|
|
|
mozilla::UndisplayedNode* GetAllDisplayContentsIn(nsIContent* aParentContent);
|
2017-02-21 13:25:11 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the relevant undisplayed node for a given content with display:
|
|
|
|
* contents style.
|
|
|
|
*/
|
|
|
|
mozilla::UndisplayedNode* GetDisplayContentsNodeFor(
|
|
|
|
const nsIContent* aContent) {
|
|
|
|
if (!mDisplayContentsMap) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return GetUndisplayedNodeInMapFor(mDisplayContentsMap, aContent);
|
|
|
|
}
|
|
|
|
|
2014-11-20 21:24:09 +03:00
|
|
|
/**
|
|
|
|
* Register aContent having a display:contents style context.
|
|
|
|
*/
|
2017-03-19 14:11:34 +03:00
|
|
|
void SetDisplayContents(nsIContent* aContent, nsStyleContext* aStyleContext);
|
2014-11-20 21:24:09 +03:00
|
|
|
/**
|
|
|
|
* Change the registered style context for aContent to aStyleContext.
|
|
|
|
*/
|
|
|
|
void ChangeDisplayContents(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
|
|
|
{
|
|
|
|
ChangeStyleContextInMap(mDisplayContentsMap, aContent, aStyleContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unregister the display:contents style context for aContent, if any.
|
|
|
|
* If found, then also unregister any display:contents and display:none
|
|
|
|
* style contexts for its descendants.
|
|
|
|
*/
|
2017-03-19 14:11:34 +03:00
|
|
|
void ClearDisplayContentsIn(nsIContent* aContent, nsIContent* aParentContent);
|
2014-11-20 21:24:09 +03:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
// Functions for manipulating the frame model
|
2014-06-02 16:08:21 +04:00
|
|
|
void AppendFrames(nsContainerFrame* aParentFrame,
|
2017-03-19 14:11:34 +03:00
|
|
|
ChildListID aListID,
|
|
|
|
nsFrameList& aFrameList);
|
2014-05-25 02:20:40 +04:00
|
|
|
|
2014-06-02 16:08:21 +04:00
|
|
|
void InsertFrames(nsContainerFrame* aParentFrame,
|
2017-03-19 14:11:34 +03:00
|
|
|
ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
2017-03-19 14:11:34 +03:00
|
|
|
void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Notification that a frame is about to be destroyed. This allows any
|
|
|
|
* outstanding references to the frame to be cleaned up.
|
|
|
|
*/
|
2017-03-19 14:11:34 +03:00
|
|
|
void NotifyDestroyingFrame(nsIFrame* aFrame);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Capture/restore frame state for the frame subtree rooted at aFrame.
|
|
|
|
* aState is the document state storage object onto which each frame
|
2012-05-10 05:27:47 +04:00
|
|
|
* stores its state. Callers of CaptureFrameState are responsible for
|
|
|
|
* traversing next continuations of special siblings of aFrame as
|
|
|
|
* needed; this method will only work with actual frametree descendants
|
|
|
|
* of aFrame.
|
2004-02-24 00:29:06 +03:00
|
|
|
*/
|
|
|
|
|
2017-03-19 14:11:34 +03:00
|
|
|
void CaptureFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
2017-03-19 14:11:34 +03:00
|
|
|
void RestoreFrameState(nsIFrame* aFrame, nsILayoutHistoryState* aState);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add/restore state for one frame
|
|
|
|
*/
|
2017-03-19 14:11:34 +03:00
|
|
|
void CaptureFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
|
|
|
|
|
|
|
|
void RestoreFrameStateFor(nsIFrame* aFrame, nsILayoutHistoryState* aState);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
2014-11-20 21:24:09 +03:00
|
|
|
protected:
|
2017-06-08 13:48:31 +03:00
|
|
|
void ClearAllMapsFor(nsIContent* aParentContent);
|
|
|
|
|
2014-11-20 21:24:09 +03:00
|
|
|
static nsStyleContext* GetStyleContextInMap(UndisplayedMap* aMap,
|
2017-02-21 16:21:07 +03:00
|
|
|
const nsIContent* aContent);
|
2017-02-21 13:25:11 +03:00
|
|
|
static mozilla::UndisplayedNode*
|
|
|
|
GetUndisplayedNodeInMapFor(UndisplayedMap* aMap,
|
|
|
|
const nsIContent* aContent);
|
2014-11-20 21:24:09 +03:00
|
|
|
static mozilla::UndisplayedNode*
|
|
|
|
GetAllUndisplayedNodesInMapFor(UndisplayedMap* aMap,
|
|
|
|
nsIContent* aParentContent);
|
|
|
|
static void SetStyleContextInMap(UndisplayedMap* aMap,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext);
|
|
|
|
static void ChangeStyleContextInMap(UndisplayedMap* aMap,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext);
|
2004-02-24 00:29:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|