1999-08-04 07:39:34 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-12-06 08:45:07 +03:00
|
|
|
* vim:cindent:ts=2:et:sw=2:
|
1999-08-04 07:39:34 +04:00
|
|
|
*
|
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/.
|
2000-05-03 03:07:11 +04: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.
|
1999-08-04 07:39:34 +04:00
|
|
|
*/
|
2006-03-30 09:56:38 +04:00
|
|
|
|
|
|
|
/* storage of the frame tree and information about it */
|
|
|
|
|
2001-08-14 11:59:59 +04:00
|
|
|
#include "nscore.h"
|
1999-08-04 07:39:34 +04:00
|
|
|
#include "nsIPresShell.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-08-04 07:39:34 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "plhash.h"
|
|
|
|
#include "nsPlaceholderFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-08-31 18:35:50 +04:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2005-01-28 01:52:53 +03:00
|
|
|
#include "nsPresState.h"
|
2013-08-20 02:55:18 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2000-11-28 01:00:33 +03:00
|
|
|
#include "nsIDocument.h"
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2003-05-30 04:21:01 +04:00
|
|
|
#include "nsContentUtils.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2011-04-30 03:02:33 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2013-05-02 02:50:08 +04:00
|
|
|
#include "ChildIterator.h"
|
2001-05-30 15:26:21 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
2013-03-18 18:25:50 +04:00
|
|
|
#include "GeckoProfiler.h"
|
2013-08-20 02:55:18 +04:00
|
|
|
#include "nsIStatefulFrame.h"
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2000-09-13 02:47:09 +04:00
|
|
|
#ifdef DEBUG
|
2002-04-03 01:14:43 +04:00
|
|
|
//#define DEBUG_UNDISPLAYED_MAP
|
2000-09-13 02:47:09 +04:00
|
|
|
#else
|
2002-04-03 01:14:43 +04:00
|
|
|
#undef DEBUG_UNDISPLAYED_MAP
|
2000-09-13 02:47:09 +04:00
|
|
|
#endif
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
2010-06-23 08:46:27 +04:00
|
|
|
using namespace mozilla::dom;
|
1999-08-04 07:39:34 +04:00
|
|
|
|
1999-08-06 00:17:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2001-12-06 08:45:07 +03:00
|
|
|
struct PlaceholderMapEntry : public PLDHashEntryHdr {
|
|
|
|
// key (the out of flow frame) can be obtained through placeholder frame
|
|
|
|
nsPlaceholderFrame *placeholderFrame;
|
|
|
|
};
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2001-12-06 08:45:07 +03:00
|
|
|
PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|
|
|
const void *key)
|
|
|
|
{
|
|
|
|
const PlaceholderMapEntry *entry =
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<const PlaceholderMapEntry*>(hdr);
|
2006-11-06 04:17:32 +03:00
|
|
|
NS_ASSERTION(entry->placeholderFrame->GetOutOfFlowFrame() !=
|
|
|
|
(void*)0xdddddddd,
|
|
|
|
"Dead placeholder in placeholder map");
|
2001-12-06 08:45:07 +03:00
|
|
|
return entry->placeholderFrame->GetOutOfFlowFrame() == key;
|
|
|
|
}
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2013-11-19 06:51:48 +04:00
|
|
|
static const PLDHashTableOps PlaceholderMapOps = {
|
2001-12-06 08:45:07 +03:00
|
|
|
PL_DHashAllocTable,
|
|
|
|
PL_DHashFreeTable,
|
|
|
|
PL_DHashVoidPtrKeyStub,
|
|
|
|
PlaceholderMapMatchEntry,
|
|
|
|
PL_DHashMoveEntryStub,
|
|
|
|
PL_DHashClearEntryStub,
|
|
|
|
PL_DHashFinalizeStub,
|
2013-10-08 22:47:21 +04:00
|
|
|
nullptr
|
2001-12-06 08:45:07 +03:00
|
|
|
};
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2001-12-06 08:45:07 +03:00
|
|
|
//----------------------------------------------------------------------
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2001-12-06 08:45:07 +03:00
|
|
|
// XXXldb This seems too complicated for what I think it's doing, and it
|
|
|
|
// should also be using pldhash rather than plhash to use less memory.
|
1999-10-09 00:41:19 +04:00
|
|
|
|
2004-03-06 07:46:11 +03:00
|
|
|
class nsFrameManagerBase::UndisplayedMap {
|
1999-10-02 08:25:29 +04:00
|
|
|
public:
|
2012-08-22 19:56:38 +04:00
|
|
|
UndisplayedMap(uint32_t aNumBuckets = 16) NS_HIDDEN;
|
2004-02-24 00:29:06 +03:00
|
|
|
~UndisplayedMap(void) NS_HIDDEN;
|
1999-10-02 08:25:29 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_HIDDEN_(UndisplayedNode*) GetFirstNode(nsIContent* aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_HIDDEN_(nsresult) AddNodeFor(nsIContent* aParentContent,
|
|
|
|
nsIContent* aChild, nsStyleContext* aStyle);
|
1999-10-02 08:25:29 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_HIDDEN_(void) RemoveNodeFor(nsIContent* aParentContent,
|
|
|
|
UndisplayedNode* aNode);
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) RemoveNodesFor(nsIContent* aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
|
|
|
|
// Removes all entries from the hash table
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_HIDDEN_(void) Clear(void);
|
1999-10-02 08:25:29 +04:00
|
|
|
|
|
|
|
protected:
|
2013-06-21 03:21:15 +04:00
|
|
|
/**
|
|
|
|
* Gets the entry for the provided parent content. If the content
|
|
|
|
* is a <xbl:children> element, |**aParentContent| is set to
|
|
|
|
* the parent of the children element.
|
|
|
|
*/
|
|
|
|
NS_HIDDEN_(PLHashEntry**) GetEntryFor(nsIContent** aParentContent);
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_HIDDEN_(void) AppendNodeFor(UndisplayedNode* aNode,
|
|
|
|
nsIContent* aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
|
|
|
|
PLHashTable* mTable;
|
|
|
|
PLHashEntry** mLastLookup;
|
|
|
|
};
|
|
|
|
|
1999-08-04 07:39:34 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager::~nsFrameManager()
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2004-02-24 00:29:06 +03:00
|
|
|
NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called");
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::Destroy()
|
2001-03-06 04:46:03 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mPresShell, "Frame manager already shut down.");
|
|
|
|
|
2004-08-24 22:50:29 +04:00
|
|
|
// Destroy the frame hierarchy.
|
2011-10-17 18:59:28 +04:00
|
|
|
mPresShell->SetIgnoreFrameDestruction(true);
|
2002-03-10 09:47:42 +03:00
|
|
|
|
2005-07-20 01:09:41 +04:00
|
|
|
// Unregister all placeholders before tearing down the frame tree
|
|
|
|
nsFrameManager::ClearPlaceholderFrameMap();
|
|
|
|
|
1999-10-19 02:20:37 +04:00
|
|
|
if (mRootFrame) {
|
2006-04-10 04:16:29 +04:00
|
|
|
mRootFrame->Destroy();
|
2012-07-30 18:20:58 +04:00
|
|
|
mRootFrame = nullptr;
|
1999-10-19 02:20:37 +04:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:06:37 +04:00
|
|
|
delete mUndisplayedMap;
|
2012-07-30 18:20:58 +04:00
|
|
|
mUndisplayedMap = nullptr;
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mPresShell = nullptr;
|
1999-10-19 02:20:37 +04:00
|
|
|
}
|
|
|
|
|
1999-08-06 00:17:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-08-04 07:39:34 +04:00
|
|
|
// Placeholder frame functions
|
2004-02-24 00:29:06 +03:00
|
|
|
nsPlaceholderFrame*
|
2012-02-15 13:28:21 +04:00
|
|
|
nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2001-12-06 08:45:07 +03:00
|
|
|
NS_PRECONDITION(aFrame, "null param unexpected");
|
1999-08-04 07:39:34 +04:00
|
|
|
|
2001-12-06 08:45:07 +03:00
|
|
|
if (mPlaceholderMap.ops) {
|
2007-07-08 11:08:04 +04:00
|
|
|
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
|
|
|
(PL_DHashTableOperate(const_cast<PLDHashTable*>(&mPlaceholderMap),
|
2001-12-06 08:45:07 +03:00
|
|
|
aFrame, PL_DHASH_LOOKUP));
|
|
|
|
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return entry->placeholderFrame;
|
2001-12-06 08:45:07 +03:00
|
|
|
}
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
nsresult
|
|
|
|
nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2001-12-06 08:45:07 +03:00
|
|
|
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
|
2006-12-26 20:47:52 +03:00
|
|
|
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
2001-12-06 08:45:07 +03:00
|
|
|
"unexpected frame type");
|
|
|
|
if (!mPlaceholderMap.ops) {
|
2012-07-30 18:20:58 +04:00
|
|
|
if (!PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps, nullptr,
|
2001-12-06 08:45:07 +03:00
|
|
|
sizeof(PlaceholderMapEntry), 16)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mPlaceholderMap.ops = nullptr;
|
2001-12-06 08:45:07 +03:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>(PL_DHashTableOperate(&mPlaceholderMap,
|
2001-12-06 08:45:07 +03:00
|
|
|
aPlaceholderFrame->GetOutOfFlowFrame(),
|
|
|
|
PL_DHASH_ADD));
|
|
|
|
if (!entry)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-11-12 06:30:13 +03:00
|
|
|
|
|
|
|
NS_ASSERTION(!entry->placeholderFrame, "Registering a placeholder for a frame that already has a placeholder!");
|
2001-12-06 08:45:07 +03:00
|
|
|
entry->placeholderFrame = aPlaceholderFrame;
|
2005-03-23 06:35:08 +03:00
|
|
|
|
2001-12-06 08:45:07 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
2001-12-06 08:45:07 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
|
2006-12-26 20:47:52 +03:00
|
|
|
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
2001-12-06 08:45:07 +03:00
|
|
|
"unexpected frame type");
|
|
|
|
|
2002-06-29 03:25:57 +04:00
|
|
|
if (mPlaceholderMap.ops) {
|
|
|
|
PL_DHashTableOperate(&mPlaceholderMap,
|
|
|
|
aPlaceholderFrame->GetOutOfFlowFrame(),
|
|
|
|
PL_DHASH_REMOVE);
|
|
|
|
}
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
2008-10-10 19:04:34 +04:00
|
|
|
static PLDHashOperator
|
2005-07-20 01:09:41 +04:00
|
|
|
UnregisterPlaceholders(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t number, void* arg)
|
2005-07-20 01:09:41 +04:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
PlaceholderMapEntry* entry = static_cast<PlaceholderMapEntry*>(hdr);
|
2012-07-30 18:20:58 +04:00
|
|
|
entry->placeholderFrame->SetOutOfFlowFrame(nullptr);
|
2005-07-20 01:09:41 +04:00
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearPlaceholderFrameMap()
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2001-12-06 08:45:07 +03:00
|
|
|
if (mPlaceholderMap.ops) {
|
2012-07-30 18:20:58 +04:00
|
|
|
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
|
2001-12-06 08:45:07 +03:00
|
|
|
PL_DHashTableFinish(&mPlaceholderMap);
|
2012-07-30 18:20:58 +04:00
|
|
|
mPlaceholderMap.ops = nullptr;
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-06 00:17:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext*
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager::GetUndisplayedContent(nsIContent* aContent)
|
2001-06-01 02:19:43 +04:00
|
|
|
{
|
2003-02-22 03:32:13 +03:00
|
|
|
if (!aContent || !mUndisplayedMap)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2002-05-01 04:36:50 +04:00
|
|
|
|
2003-07-29 01:25:13 +04:00
|
|
|
nsIContent* parent = aContent->GetParent();
|
2002-05-01 04:36:50 +04:00
|
|
|
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent);
|
|
|
|
node; node = node->mNext) {
|
2003-02-22 03:32:13 +03:00
|
|
|
if (node->mContent == aContent)
|
|
|
|
return node->mStyle;
|
2002-05-01 04:36:50 +04:00
|
|
|
}
|
2003-02-22 03:32:13 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-06-01 02:19:43 +04:00
|
|
|
}
|
2013-07-20 23:14:25 +04:00
|
|
|
|
|
|
|
UndisplayedNode*
|
|
|
|
nsFrameManager::GetAllUndisplayedContentIn(nsIContent* aParentContent)
|
|
|
|
{
|
|
|
|
if (!mUndisplayedMap)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return mUndisplayedMap->GetFirstNode(aParentContent);
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
void
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager::SetUndisplayedContent(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2009-10-30 00:17:56 +03:00
|
|
|
NS_PRECONDITION(!aStyleContext->GetPseudo(),
|
2009-05-15 05:40:26 +04:00
|
|
|
"Should only have actual elements here");
|
|
|
|
|
2002-04-03 01:14:43 +04:00
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
2006-05-13 00:36:39 +04:00
|
|
|
static int i = 0;
|
|
|
|
printf("SetUndisplayedContent(%d): p=%p \n", i++, (void *)aContent);
|
2002-04-03 01:14:43 +04:00
|
|
|
#endif
|
|
|
|
|
2006-05-13 00:36:39 +04:00
|
|
|
NS_ASSERTION(!GetUndisplayedContent(aContent),
|
|
|
|
"Already have an undisplayed context entry for aContent");
|
|
|
|
|
1999-10-02 08:25:29 +04:00
|
|
|
if (! mUndisplayedMap) {
|
|
|
|
mUndisplayedMap = new UndisplayedMap;
|
|
|
|
}
|
2011-04-29 09:02:40 +04:00
|
|
|
nsIContent* parent = aContent->GetParent();
|
|
|
|
NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() &&
|
|
|
|
mPresShell->GetDocument()->GetRootElement() == aContent),
|
|
|
|
"undisplayed content must have a parent, unless it's the root "
|
|
|
|
"element");
|
|
|
|
mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
|
2003-06-19 01:54:51 +04:00
|
|
|
void
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager::ChangeUndisplayedContent(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
2003-06-19 01:54:51 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mUndisplayedMap, "no existing undisplayed content");
|
|
|
|
|
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
|
|
|
static int i = 0;
|
|
|
|
printf("ChangeUndisplayedContent(%d): p=%p \n", i++, (void *)aContent);
|
|
|
|
#endif
|
|
|
|
|
2003-07-29 01:25:13 +04:00
|
|
|
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aContent->GetParent());
|
2003-06-19 01:54:51 +04:00
|
|
|
node; node = node->mNext) {
|
|
|
|
if (node->mContent == aContent) {
|
|
|
|
node->mStyle = aStyleContext;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("no existing undisplayed content");
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearUndisplayedContentIn(nsIContent* aContent,
|
|
|
|
nsIContent* aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2002-04-03 01:14:43 +04:00
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
|
|
|
static int i = 0;
|
|
|
|
printf("ClearUndisplayedContent(%d): content=%p parent=%p --> ", i++, (void *)aContent, (void*)aParentContent);
|
|
|
|
#endif
|
|
|
|
|
1999-10-02 08:25:29 +04:00
|
|
|
if (mUndisplayedMap) {
|
|
|
|
UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aParentContent);
|
|
|
|
while (node) {
|
|
|
|
if (node->mContent == aContent) {
|
2004-02-24 00:29:06 +03:00
|
|
|
mUndisplayedMap->RemoveNodeFor(aParentContent, node);
|
2002-04-03 01:14:43 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
2004-02-24 00:29:06 +03:00
|
|
|
printf( "REMOVED!\n");
|
2002-04-03 01:14:43 +04:00
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
// make sure that there are no more entries for the same content
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext *context = GetUndisplayedContent(aContent);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(context == nullptr, "Found more undisplayed content data after removal");
|
2002-04-03 01:14:43 +04:00
|
|
|
#endif
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2002-04-03 01:14:43 +04:00
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
|
|
|
static int i = 0;
|
|
|
|
printf("ClearAllUndisplayedContentIn(%d): parent=%p \n", i++, (void*)aParentContent);
|
|
|
|
#endif
|
|
|
|
|
1999-10-02 08:25:29 +04:00
|
|
|
if (mUndisplayedMap) {
|
2004-02-24 00:29:06 +03:00
|
|
|
mUndisplayedMap->RemoveNodesFor(aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
2009-08-07 23:51:25 +04:00
|
|
|
|
|
|
|
// Need to look at aParentContent's content list due to XBL insertions.
|
|
|
|
// Nodes in aParentContent's content list do not have aParentContent as a
|
2013-05-02 02:50:08 +04:00
|
|
|
// parent, but are treated as children of aParentContent. We iterate over
|
|
|
|
// the flattened content list and just ignore any nodes we don't care about.
|
|
|
|
FlattenedChildIterator iter(aParentContent);
|
|
|
|
for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
|
|
|
|
if (child->GetParent() != aParentContent) {
|
|
|
|
ClearUndisplayedContentIn(child, child->GetParent());
|
2009-08-07 23:51:25 +04:00
|
|
|
}
|
|
|
|
}
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2011-04-30 03:02:33 +04:00
|
|
|
nsresult
|
|
|
|
nsFrameManager::AppendFrames(nsIFrame* aParentFrame,
|
|
|
|
ChildListID aListID,
|
|
|
|
nsFrameList& aFrameList)
|
|
|
|
{
|
|
|
|
if (aParentFrame->IsAbsoluteContainer() &&
|
|
|
|
aListID == aParentFrame->GetAbsoluteListID()) {
|
|
|
|
return aParentFrame->GetAbsoluteContainingBlock()->
|
|
|
|
AppendFrames(aParentFrame, aListID, aFrameList);
|
|
|
|
} else {
|
|
|
|
return aParentFrame->AppendFrames(aListID, aFrameList);
|
|
|
|
}
|
|
|
|
}
|
1999-10-02 08:25:29 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
nsresult
|
|
|
|
nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
|
2011-08-25 00:54:30 +04:00
|
|
|
ChildListID aListID,
|
2004-02-24 00:29:06 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2007-11-12 22:05:42 +03:00
|
|
|
NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
|
2012-10-15 09:42:40 +04:00
|
|
|
|| (((aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))
|
|
|
|
&& !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))),
|
2006-02-22 00:33:47 +03:00
|
|
|
"aPrevFrame must be the last continuation in its chain!");
|
2001-03-09 06:29:00 +03:00
|
|
|
|
2011-04-30 03:02:33 +04:00
|
|
|
if (aParentFrame->IsAbsoluteContainer() &&
|
|
|
|
aListID == aParentFrame->GetAbsoluteListID()) {
|
|
|
|
return aParentFrame->GetAbsoluteContainingBlock()->
|
|
|
|
InsertFrames(aParentFrame, aListID, aPrevFrame, aFrameList);
|
|
|
|
} else {
|
|
|
|
return aParentFrame->InsertFrames(aListID, aPrevFrame, aFrameList);
|
|
|
|
}
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
nsresult
|
2011-08-25 00:54:30 +04:00
|
|
|
nsFrameManager::RemoveFrame(ChildListID aListID,
|
2012-08-29 09:39:31 +04:00
|
|
|
nsIFrame* aOldFrame)
|
1999-08-04 07:39:34 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wasDestroyingFrames = mIsDestroyingFrames;
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsDestroyingFrames = true;
|
2008-12-12 11:25:16 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
// In case the reflow doesn't invalidate anything since it just leaves
|
|
|
|
// a gap where the old frame was, we invalidate it here. (This is
|
|
|
|
// reasonably likely to happen when removing a last child in a way
|
|
|
|
// that doesn't change the size of the parent.)
|
|
|
|
// This has to sure to invalidate the entire overflow rect; this
|
|
|
|
// is important in the presence of absolute positioning
|
|
|
|
aOldFrame->InvalidateFrameForRemoval();
|
|
|
|
|
2009-12-24 08:20:41 +03:00
|
|
|
NS_ASSERTION(!aOldFrame->GetPrevContinuation() ||
|
|
|
|
// exception for nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames
|
|
|
|
aOldFrame->GetType() == nsGkAtoms::textFrame,
|
|
|
|
"Must remove first continuation.");
|
|
|
|
NS_ASSERTION(!(aOldFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW &&
|
|
|
|
GetPlaceholderFrameFor(aOldFrame)),
|
|
|
|
"Must call RemoveFrame on placeholder for out-of-flows.");
|
2011-04-30 03:02:33 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame* parentFrame = aOldFrame->GetParent();
|
|
|
|
if (parentFrame->IsAbsoluteContainer() &&
|
|
|
|
aListID == parentFrame->GetAbsoluteListID()) {
|
|
|
|
parentFrame->GetAbsoluteContainingBlock()->
|
|
|
|
RemoveFrame(parentFrame, aListID, aOldFrame);
|
|
|
|
} else {
|
|
|
|
rv = parentFrame->RemoveFrame(aListID, aOldFrame);
|
|
|
|
}
|
2008-12-12 11:25:16 +03:00
|
|
|
|
2008-10-13 02:05:04 +04:00
|
|
|
mIsDestroyingFrames = wasDestroyingFrames;
|
2008-12-12 11:25:16 +03:00
|
|
|
|
2008-10-13 02:05:04 +04:00
|
|
|
return rv;
|
1999-08-04 07:39:34 +04:00
|
|
|
}
|
|
|
|
|
1999-08-06 00:17:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
|
1999-08-06 00:17:44 +04:00
|
|
|
{
|
2009-12-24 08:20:41 +03:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2009-12-29 23:13:54 +03:00
|
|
|
if (content && content->GetPrimaryFrame() == aFrame) {
|
|
|
|
ClearAllUndisplayedContentIn(content);
|
2001-12-11 22:16:15 +03:00
|
|
|
}
|
1999-08-06 00:17:44 +04:00
|
|
|
}
|
|
|
|
|
2000-06-15 04:35:46 +04:00
|
|
|
// Capture state for a given frame.
|
|
|
|
// Accept a content id here, in some cases we may not have content (scroll position)
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
|
2012-11-15 10:40:17 +04:00
|
|
|
nsILayoutHistoryState* aState)
|
1999-08-31 18:35:50 +04:00
|
|
|
{
|
2004-02-24 00:29:06 +03:00
|
|
|
if (!aFrame || !aState) {
|
|
|
|
NS_WARNING("null frame, or state");
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Only capture state for stateful frames
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
|
2001-05-30 15:26:21 +04:00
|
|
|
if (!statefulFrame) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-05-30 15:26:21 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Capture the state, exit early if we get null (nothing to save)
|
2005-01-28 01:52:53 +03:00
|
|
|
nsAutoPtr<nsPresState> frameState;
|
2012-11-15 10:40:17 +04:00
|
|
|
nsresult rv = statefulFrame->SaveState(getter_Transfers(frameState));
|
2001-05-30 15:26:21 +04:00
|
|
|
if (!frameState) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-05-30 15:26:21 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Generate the hash key to store the state under
|
|
|
|
// Exit early if we get empty key
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString stateKey;
|
2005-01-15 20:47:23 +03:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIDocument* doc = content ? content->GetCurrentDoc() : nullptr;
|
2012-11-15 10:40:17 +04:00
|
|
|
rv = nsContentUtils::GenerateStateKey(content, doc, stateKey);
|
2001-05-30 15:26:21 +04:00
|
|
|
if(NS_FAILED(rv) || stateKey.IsEmpty()) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
1999-08-31 18:35:50 +04:00
|
|
|
}
|
|
|
|
|
2013-07-24 11:38:13 +04:00
|
|
|
// Store the state. aState owns frameState now.
|
|
|
|
aState->AddState(stateKey, frameState.forget());
|
1999-10-23 05:43:49 +04:00
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::CaptureFrameState(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState)
|
1999-10-23 05:43:49 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
CaptureFrameStateFor(aFrame, aState);
|
1999-10-23 05:43:49 +04:00
|
|
|
|
|
|
|
// Now capture state recursively for the frame hierarchy rooted at aFrame
|
2011-08-25 00:54:29 +04:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
2012-05-10 05:27:47 +04:00
|
|
|
nsIFrame* child = childFrames.get();
|
|
|
|
if (child->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
|
|
|
// We'll pick it up when we get to its placeholder
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Make sure to walk through placeholders as needed, so that we
|
|
|
|
// save state for out-of-flows which may not be our descendants
|
|
|
|
// themselves but whose placeholders are our descendants.
|
|
|
|
CaptureFrameState(nsPlaceholderFrame::GetRealFrameFor(child), aState);
|
1999-10-23 05:43:49 +04:00
|
|
|
}
|
2011-08-25 00:54:29 +04:00
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
}
|
|
|
|
|
2000-06-15 04:35:46 +04:00
|
|
|
// Restore state for a given frame.
|
|
|
|
// Accept a content id here, in some cases we may not have content (scroll position)
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::RestoreFrameStateFor(nsIFrame* aFrame,
|
2012-11-15 10:40:17 +04:00
|
|
|
nsILayoutHistoryState* aState)
|
1999-08-31 18:35:50 +04:00
|
|
|
{
|
2004-02-24 00:29:06 +03:00
|
|
|
if (!aFrame || !aState) {
|
|
|
|
NS_WARNING("null frame or state");
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2008-12-03 20:55:14 +03:00
|
|
|
// Only restore state for stateful frames
|
2009-01-12 22:20:59 +03:00
|
|
|
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
|
2001-05-30 15:26:21 +04:00
|
|
|
if (!statefulFrame) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-05-30 15:26:21 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Generate the hash key the state was stored under
|
|
|
|
// Exit early if we get empty key
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2001-09-29 21:50:15 +04:00
|
|
|
// If we don't have content, we can't generate a hash
|
|
|
|
// key and there's probably no state information for us.
|
|
|
|
if (!content) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-09-29 21:50:15 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString stateKey;
|
2005-01-15 20:47:23 +03:00
|
|
|
nsIDocument* doc = content->GetCurrentDoc();
|
2012-11-15 10:40:17 +04:00
|
|
|
nsresult rv = nsContentUtils::GenerateStateKey(content, doc, stateKey);
|
2001-11-02 10:40:01 +03:00
|
|
|
if (NS_FAILED(rv) || stateKey.IsEmpty()) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-05-30 15:26:21 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Get the state from the hash
|
2013-07-24 11:38:13 +04:00
|
|
|
nsPresState* frameState = aState->GetState(stateKey);
|
2001-05-30 15:26:21 +04:00
|
|
|
if (!frameState) {
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2001-05-30 15:26:21 +04:00
|
|
|
}
|
2000-06-15 04:35:46 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// Restore it
|
2005-12-07 02:56:17 +03:00
|
|
|
rv = statefulFrame->RestoreState(frameState);
|
2004-02-24 00:29:06 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2001-05-30 15:26:21 +04:00
|
|
|
// If we restore ok, remove the state from the state table
|
2004-02-24 00:29:06 +03:00
|
|
|
aState->RemoveState(stateKey);
|
1999-10-23 05:43:49 +04:00
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
|
|
|
nsFrameManager::RestoreFrameState(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState)
|
1999-10-23 05:43:49 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
|
1999-10-23 05:43:49 +04:00
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
RestoreFrameStateFor(aFrame, aState);
|
1999-10-23 05:43:49 +04:00
|
|
|
|
|
|
|
// Now restore state recursively for the frame hierarchy rooted at aFrame
|
2011-08-25 00:54:29 +04:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
RestoreFrameState(childFrames.get(), aState);
|
1999-10-23 05:43:49 +04:00
|
|
|
}
|
2011-08-25 00:54:29 +04:00
|
|
|
}
|
1999-08-31 18:35:50 +04:00
|
|
|
}
|
|
|
|
|
1999-08-06 00:17:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static PLHashNumber
|
|
|
|
HashKey(void* key)
|
|
|
|
{
|
2001-08-14 11:59:59 +04:00
|
|
|
return NS_PTR_TO_INT32(key);
|
1999-08-06 00:17:44 +04:00
|
|
|
}
|
|
|
|
|
2012-08-09 11:09:40 +04:00
|
|
|
static int
|
1999-08-06 00:17:44 +04:00
|
|
|
CompareKeys(void* key1, void* key2)
|
|
|
|
{
|
|
|
|
return key1 == key2;
|
|
|
|
}
|
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsFrameManagerBase::UndisplayedMap::UndisplayedMap(uint32_t aNumBuckets)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2004-03-06 07:46:11 +03:00
|
|
|
MOZ_COUNT_CTOR(nsFrameManagerBase::UndisplayedMap);
|
1999-10-02 08:25:29 +04:00
|
|
|
mTable = PL_NewHashTable(aNumBuckets, (PLHashFunction)HashKey,
|
|
|
|
(PLHashComparator)CompareKeys,
|
2012-07-30 18:20:58 +04:00
|
|
|
(PLHashComparator)nullptr,
|
|
|
|
nullptr, nullptr);
|
|
|
|
mLastLookup = nullptr;
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::~UndisplayedMap(void)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2004-03-06 07:46:11 +03:00
|
|
|
MOZ_COUNT_DTOR(nsFrameManagerBase::UndisplayedMap);
|
1999-10-02 08:25:29 +04:00
|
|
|
Clear();
|
|
|
|
PL_HashTableDestroy(mTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
PLHashEntry**
|
2013-06-21 03:21:15 +04:00
|
|
|
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent** aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2013-06-21 03:21:15 +04:00
|
|
|
nsIContent* parentContent = *aParentContent;
|
|
|
|
|
|
|
|
if (mLastLookup && (parentContent == (*mLastLookup)->key)) {
|
1999-10-02 08:25:29 +04:00
|
|
|
return mLastLookup;
|
|
|
|
}
|
2013-06-21 03:21:15 +04:00
|
|
|
|
|
|
|
// In the case of XBL default content, <xbl:children> elements do not get a
|
|
|
|
// frame causing a mismatch between the content tree and the frame tree.
|
|
|
|
// |GetEntryFor| is sometimes called with the content tree parent (which may
|
|
|
|
// be a <xbl:children> element) but the parent in the frame tree would be the
|
|
|
|
// insertion parent (parent of the <xbl:children> element). Here the children
|
|
|
|
// elements are normalized to the insertion parent to correct for the mismatch.
|
2013-07-12 01:52:49 +04:00
|
|
|
if (parentContent && parentContent->IsActiveChildrenElement()) {
|
2013-06-21 03:21:15 +04:00
|
|
|
parentContent = parentContent->GetParent();
|
|
|
|
// Change the caller's pointer for the parent content to be the insertion parent.
|
|
|
|
*aParentContent = parentContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
PLHashNumber hashCode = NS_PTR_TO_INT32(parentContent);
|
|
|
|
PLHashEntry** entry = PL_HashTableRawLookup(mTable, hashCode, parentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
if (*entry) {
|
|
|
|
mLastLookup = entry;
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
UndisplayedNode*
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2013-06-21 03:21:15 +04:00
|
|
|
PLHashEntry** entry = GetEntryFor(&aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
if (*entry) {
|
|
|
|
return (UndisplayedNode*)((*entry)->value);
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
|
|
|
|
nsIContent* aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2013-06-21 03:21:15 +04:00
|
|
|
PLHashEntry** entry = GetEntryFor(&aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
if (*entry) {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
|
|
|
while (node->mNext) {
|
2002-05-16 17:30:57 +04:00
|
|
|
if (node->mContent == aNode->mContent) {
|
|
|
|
// We actually need to check this in optimized builds because
|
|
|
|
// there are some callers that do this. See bug 118014, bug
|
|
|
|
// 136704, etc.
|
|
|
|
NS_NOTREACHED("node in map twice");
|
|
|
|
delete aNode;
|
2004-02-24 00:29:06 +03:00
|
|
|
return;
|
2002-05-16 17:30:57 +04:00
|
|
|
}
|
1999-10-02 08:25:29 +04:00
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
node->mNext = aNode;
|
|
|
|
}
|
|
|
|
else {
|
2001-08-14 11:59:59 +04:00
|
|
|
PLHashNumber hashCode = NS_PTR_TO_INT32(aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
PL_HashTableRawAdd(mTable, entry, hashCode, aParentContent, aNode);
|
2012-07-30 18:20:58 +04:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsStyleContext* aStyle)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
|
|
|
UndisplayedNode* node = new UndisplayedNode(aChild, aStyle);
|
2004-02-24 00:29:06 +03:00
|
|
|
|
|
|
|
AppendNodeFor(node, aParentContent);
|
|
|
|
return NS_OK;
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
|
|
|
|
UndisplayedNode* aNode)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2013-06-21 03:21:15 +04:00
|
|
|
PLHashEntry** entry = GetEntryFor(&aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
NS_ASSERTION(*entry, "content not in map");
|
|
|
|
if (*entry) {
|
|
|
|
if ((UndisplayedNode*)((*entry)->value) == aNode) { // first node
|
|
|
|
if (aNode->mNext) {
|
|
|
|
(*entry)->value = aNode->mNext;
|
2012-07-30 18:20:58 +04:00
|
|
|
aNode->mNext = nullptr;
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PL_HashTableRawRemove(mTable, entry, *entry);
|
2012-07-30 18:20:58 +04:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
|
|
|
while (node->mNext) {
|
|
|
|
if (node->mNext == aNode) {
|
|
|
|
node->mNext = aNode->mNext;
|
2012-07-30 18:20:58 +04:00
|
|
|
aNode->mNext = nullptr;
|
1999-10-02 08:25:29 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete aNode;
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:29:06 +03:00
|
|
|
void
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2013-06-21 03:21:15 +04:00
|
|
|
PLHashEntry** entry = GetEntryFor(&aParentContent);
|
1999-10-02 08:25:29 +04:00
|
|
|
NS_ASSERTION(entry, "content not in map");
|
|
|
|
if (*entry) {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
2002-04-03 01:14:43 +04:00
|
|
|
NS_ASSERTION(node, "null node for non-null entry in UndisplayedMap");
|
1999-10-02 08:25:29 +04:00
|
|
|
delete node;
|
|
|
|
PL_HashTableRawRemove(mTable, entry, *entry);
|
2012-07-30 18:20:58 +04:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 08:25:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 11:09:40 +04:00
|
|
|
static int
|
|
|
|
RemoveUndisplayedEntry(PLHashEntry* he, int i, void* arg)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)(he->value);
|
|
|
|
delete node;
|
|
|
|
// Remove and free this entry and continue enumerating
|
|
|
|
return HT_ENUMERATE_REMOVE | HT_ENUMERATE_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-06 07:46:11 +03:00
|
|
|
nsFrameManagerBase::UndisplayedMap::Clear(void)
|
1999-10-02 08:25:29 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mLastLookup = nullptr;
|
1999-10-02 08:25:29 +04:00
|
|
|
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
|
|
|
|
}
|
2012-07-04 19:42:29 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t nsFrameManagerBase::sGlobalGenerationNumber;
|