1999-08-04 03:39:34 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2001-12-06 05:45:07 +00:00
|
|
|
* vim:cindent:ts=2:et:sw=2:
|
1999-08-04 03:39:34 +00:00
|
|
|
*
|
2012-05-21 11:12:37 +00: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-02 23:07:11 +00: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 03:39:34 +00:00
|
|
|
*/
|
2006-03-30 05:56:38 +00:00
|
|
|
|
|
|
|
/* storage of the frame tree and information about it */
|
|
|
|
|
2001-08-14 07:59:59 +00:00
|
|
|
#include "nscore.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1999-08-04 03:39:34 +00:00
|
|
|
#include "nsIPresShell.h"
|
2004-01-07 22:30:53 +00:00
|
|
|
#include "nsStyleSet.h"
|
2004-01-21 23:05:10 +00:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-21 07:53:14 +00:00
|
|
|
#include "nsStyleChangeList.h"
|
1999-08-05 20:17:44 +00:00
|
|
|
#include "nsIServiceManager.h"
|
1999-08-04 03:39:34 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-08-05 20:17:44 +00:00
|
|
|
#include "prthread.h"
|
1999-08-04 03:39:34 +00:00
|
|
|
#include "plhash.h"
|
|
|
|
#include "nsPlaceholderFrame.h"
|
2007-11-12 19:05:42 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2007-10-19 17:41:29 +00:00
|
|
|
#include "nsBlockFrame.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2003-01-05 05:05:17 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
1999-09-21 07:53:14 +00:00
|
|
|
#include "nsIStyleRule.h"
|
1999-08-04 03:39:34 +00:00
|
|
|
#endif
|
1999-08-31 14:35:50 +00:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2005-01-27 22:52:53 +00:00
|
|
|
#include "nsPresState.h"
|
1999-08-31 14:35:50 +00:00
|
|
|
#include "nsIContent.h"
|
1999-10-15 23:14:44 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2000-11-27 22:00:33 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIScrollableFrame.h"
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsIDOMHTMLCollection.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMHTMLFormElement.h"
|
|
|
|
#include "nsIForm.h"
|
2003-05-30 00:21:01 +00:00
|
|
|
#include "nsContentUtils.h"
|
2001-08-16 07:18:24 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2001-10-26 17:51:22 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2003-01-05 05:05:17 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-03-09 03:57:51 +00:00
|
|
|
#include "imgIRequest.h"
|
2009-10-08 03:22:42 +00:00
|
|
|
#include "nsTransitionManager.h"
|
2010-06-18 16:23:05 +00:00
|
|
|
#include "RestyleTracker.h"
|
2011-04-29 23:02:33 +00:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2001-05-30 11:26:21 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
2011-05-25 00:19:09 +00:00
|
|
|
#include "nsRuleProcessorData.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 12:39:26 +00:00
|
|
|
|
2010-11-13 17:49:26 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
2010-11-13 17:49:26 +00:00
|
|
|
#endif
|
|
|
|
|
2000-09-12 22:47:09 +00:00
|
|
|
#ifdef DEBUG
|
2002-04-02 21:14:43 +00:00
|
|
|
//#define NOISY_DEBUG
|
|
|
|
//#define DEBUG_UNDISPLAYED_MAP
|
2000-09-12 22:47:09 +00:00
|
|
|
#else
|
|
|
|
#undef NOISY_DEBUG
|
2002-04-02 21:14:43 +00:00
|
|
|
#undef DEBUG_UNDISPLAYED_MAP
|
2000-09-12 22:47:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NOISY_DEBUG
|
|
|
|
#define NOISY_TRACE(_msg) \
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s",_msg);
|
2000-09-12 22:47:09 +00:00
|
|
|
#define NOISY_TRACE_FRAME(_msg,_frame) \
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s ",_msg); nsFrame::ListTag(stdout,_frame); printf("\n");
|
2000-09-12 22:47:09 +00:00
|
|
|
#else
|
|
|
|
#define NOISY_TRACE(_msg);
|
|
|
|
#define NOISY_TRACE_FRAME(_msg,_frame);
|
|
|
|
#endif
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
using namespace mozilla;
|
2010-06-23 04:46:27 +00:00
|
|
|
using namespace mozilla::dom;
|
1999-08-04 03:39:34 +00:00
|
|
|
|
1999-08-05 20:17:44 +00:00
|
|
|
//----------------------------------------------------------------------
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-12-06 05:45:07 +00:00
|
|
|
struct PlaceholderMapEntry : public PLDHashEntryHdr {
|
|
|
|
// key (the out of flow frame) can be obtained through placeholder frame
|
|
|
|
nsPlaceholderFrame *placeholderFrame;
|
|
|
|
};
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool
|
2001-12-06 05:45:07 +00:00
|
|
|
PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|
|
|
const void *key)
|
|
|
|
{
|
|
|
|
const PlaceholderMapEntry *entry =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<const PlaceholderMapEntry*>(hdr);
|
2006-11-06 01:17:32 +00:00
|
|
|
NS_ASSERTION(entry->placeholderFrame->GetOutOfFlowFrame() !=
|
|
|
|
(void*)0xdddddddd,
|
|
|
|
"Dead placeholder in placeholder map");
|
2001-12-06 05:45:07 +00:00
|
|
|
return entry->placeholderFrame->GetOutOfFlowFrame() == key;
|
|
|
|
}
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-12-06 05:45:07 +00:00
|
|
|
static PLDHashTableOps PlaceholderMapOps = {
|
|
|
|
PL_DHashAllocTable,
|
|
|
|
PL_DHashFreeTable,
|
|
|
|
PL_DHashVoidPtrKeyStub,
|
|
|
|
PlaceholderMapMatchEntry,
|
|
|
|
PL_DHashMoveEntryStub,
|
|
|
|
PL_DHashClearEntryStub,
|
|
|
|
PL_DHashFinalizeStub,
|
|
|
|
NULL
|
|
|
|
};
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-12-06 05:45:07 +00:00
|
|
|
//----------------------------------------------------------------------
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-12-06 05:45:07 +00: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-08 20:41:19 +00:00
|
|
|
|
2000-03-24 21:50:40 +00:00
|
|
|
class UndisplayedNode {
|
|
|
|
public:
|
2003-02-22 00:32:13 +00:00
|
|
|
UndisplayedNode(nsIContent* aContent, nsStyleContext* aStyle)
|
2003-01-21 00:47:14 +00:00
|
|
|
: mContent(aContent),
|
|
|
|
mStyle(aStyle),
|
2012-07-30 14:20:58 +00:00
|
|
|
mNext(nullptr)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
MOZ_COUNT_CTOR(UndisplayedNode);
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
2003-01-21 00:47:14 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN ~UndisplayedNode()
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
MOZ_COUNT_DTOR(UndisplayedNode);
|
2008-11-02 16:05:14 +00:00
|
|
|
|
|
|
|
// Delete mNext iteratively to avoid blowing up the stack (bug 460461).
|
|
|
|
UndisplayedNode *cur = mNext;
|
|
|
|
while (cur) {
|
|
|
|
UndisplayedNode *next = cur->mNext;
|
2012-07-30 14:20:58 +00:00
|
|
|
cur->mNext = nullptr;
|
2008-11-02 16:05:14 +00:00
|
|
|
delete cur;
|
|
|
|
cur = next;
|
|
|
|
}
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 00:47:14 +00:00
|
|
|
nsCOMPtr<nsIContent> mContent;
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRefPtr<nsStyleContext> mStyle;
|
2003-01-21 00:47:14 +00:00
|
|
|
UndisplayedNode* mNext;
|
1999-10-02 04:25:29 +00:00
|
|
|
};
|
|
|
|
|
2004-03-06 04:46:11 +00:00
|
|
|
class nsFrameManagerBase::UndisplayedMap {
|
1999-10-02 04:25:29 +00:00
|
|
|
public:
|
2012-08-22 15:56:38 +00:00
|
|
|
UndisplayedMap(uint32_t aNumBuckets = 16) NS_HIDDEN;
|
2004-02-23 21:29:06 +00:00
|
|
|
~UndisplayedMap(void) NS_HIDDEN;
|
1999-10-02 04:25:29 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN_(UndisplayedNode*) GetFirstNode(nsIContent* aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN_(nsresult) AddNodeFor(nsIContent* aParentContent,
|
|
|
|
nsIContent* aChild, nsStyleContext* aStyle);
|
1999-10-02 04:25:29 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN_(void) RemoveNodeFor(nsIContent* aParentContent,
|
|
|
|
UndisplayedNode* aNode);
|
|
|
|
|
|
|
|
NS_HIDDEN_(void) RemoveNodesFor(nsIContent* aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
|
|
|
|
// Removes all entries from the hash table
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN_(void) Clear(void);
|
1999-10-02 04:25:29 +00:00
|
|
|
|
|
|
|
protected:
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_HIDDEN_(PLHashEntry**) GetEntryFor(nsIContent* aParentContent);
|
|
|
|
NS_HIDDEN_(void) AppendNodeFor(UndisplayedNode* aNode,
|
|
|
|
nsIContent* aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
|
|
|
|
PLHashTable* mTable;
|
|
|
|
PLHashEntry** mLastLookup;
|
|
|
|
};
|
|
|
|
|
1999-08-04 03:39:34 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsFrameManager::~nsFrameManager()
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_ASSERTION(!mPresShell, "nsFrameManager::Destroy never called");
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsresult
|
2012-02-02 10:06:46 +00:00
|
|
|
nsFrameManager::Init(nsStyleSet* aStyleSet)
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2012-02-02 10:06:46 +00:00
|
|
|
if (!mPresShell) {
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_ERROR("null pres shell");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-03-06 01:46:03 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
if (!aStyleSet) {
|
|
|
|
NS_ERROR("null style set");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-03-06 01:46:03 +00:00
|
|
|
|
|
|
|
mStyleSet = aStyleSet;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::Destroy()
|
2001-03-06 01:46:03 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mPresShell, "Frame manager already shut down.");
|
|
|
|
|
2004-08-24 18:50:29 +00:00
|
|
|
// Destroy the frame hierarchy.
|
2011-10-17 14:59:28 +00:00
|
|
|
mPresShell->SetIgnoreFrameDestruction(true);
|
2002-03-10 06:47:42 +00:00
|
|
|
|
2005-07-19 21:09:41 +00:00
|
|
|
// Unregister all placeholders before tearing down the frame tree
|
|
|
|
nsFrameManager::ClearPlaceholderFrameMap();
|
|
|
|
|
1999-10-18 22:20:37 +00:00
|
|
|
if (mRootFrame) {
|
2006-04-10 00:16:29 +00:00
|
|
|
mRootFrame->Destroy();
|
2012-07-30 14:20:58 +00:00
|
|
|
mRootFrame = nullptr;
|
1999-10-18 22:20:37 +00:00
|
|
|
}
|
|
|
|
|
1999-10-19 19:06:37 +00:00
|
|
|
delete mUndisplayedMap;
|
2012-07-30 14:20:58 +00:00
|
|
|
mUndisplayedMap = nullptr;
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mPresShell = nullptr;
|
1999-10-18 22:20:37 +00:00
|
|
|
}
|
|
|
|
|
1999-08-05 20:17:44 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-08-04 03:39:34 +00:00
|
|
|
// Placeholder frame functions
|
2004-02-23 21:29:06 +00:00
|
|
|
nsPlaceholderFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2001-12-06 05:45:07 +00:00
|
|
|
NS_PRECONDITION(aFrame, "null param unexpected");
|
1999-08-04 03:39:34 +00:00
|
|
|
|
2001-12-06 05:45:07 +00:00
|
|
|
if (mPlaceholderMap.ops) {
|
2007-07-08 07:08:04 +00:00
|
|
|
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
|
|
|
(PL_DHashTableOperate(const_cast<PLDHashTable*>(&mPlaceholderMap),
|
2001-12-06 05:45:07 +00:00
|
|
|
aFrame, PL_DHASH_LOOKUP));
|
|
|
|
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return entry->placeholderFrame;
|
2001-12-06 05:45:07 +00:00
|
|
|
}
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsresult
|
|
|
|
nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2001-12-06 05:45:07 +00:00
|
|
|
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
|
2006-12-26 17:47:52 +00:00
|
|
|
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
2001-12-06 05:45:07 +00:00
|
|
|
"unexpected frame type");
|
|
|
|
if (!mPlaceholderMap.ops) {
|
2012-07-30 14:20:58 +00:00
|
|
|
if (!PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps, nullptr,
|
2001-12-06 05:45:07 +00:00
|
|
|
sizeof(PlaceholderMapEntry), 16)) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mPlaceholderMap.ops = nullptr;
|
2001-12-06 05:45:07 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>(PL_DHashTableOperate(&mPlaceholderMap,
|
2001-12-06 05:45:07 +00:00
|
|
|
aPlaceholderFrame->GetOutOfFlowFrame(),
|
|
|
|
PL_DHASH_ADD));
|
|
|
|
if (!entry)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2002-11-12 03:30:13 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(!entry->placeholderFrame, "Registering a placeholder for a frame that already has a placeholder!");
|
2001-12-06 05:45:07 +00:00
|
|
|
entry->placeholderFrame = aPlaceholderFrame;
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2001-12-06 05:45:07 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
2001-12-06 05:45:07 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
|
2006-12-26 17:47:52 +00:00
|
|
|
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
2001-12-06 05:45:07 +00:00
|
|
|
"unexpected frame type");
|
|
|
|
|
2002-06-28 23:25:57 +00:00
|
|
|
if (mPlaceholderMap.ops) {
|
|
|
|
PL_DHashTableOperate(&mPlaceholderMap,
|
|
|
|
aPlaceholderFrame->GetOutOfFlowFrame(),
|
|
|
|
PL_DHASH_REMOVE);
|
|
|
|
}
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 15:04:34 +00:00
|
|
|
static PLDHashOperator
|
2005-07-19 21:09:41 +00:00
|
|
|
UnregisterPlaceholders(PLDHashTable* table, PLDHashEntryHdr* hdr,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t number, void* arg)
|
2005-07-19 21:09:41 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
PlaceholderMapEntry* entry = static_cast<PlaceholderMapEntry*>(hdr);
|
2012-07-30 14:20:58 +00:00
|
|
|
entry->placeholderFrame->SetOutOfFlowFrame(nullptr);
|
2005-07-19 21:09:41 +00:00
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearPlaceholderFrameMap()
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2001-12-06 05:45:07 +00:00
|
|
|
if (mPlaceholderMap.ops) {
|
2012-07-30 14:20:58 +00:00
|
|
|
PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr);
|
2001-12-06 05:45:07 +00:00
|
|
|
PL_DHashTableFinish(&mPlaceholderMap);
|
2012-07-30 14:20:58 +00:00
|
|
|
mPlaceholderMap.ops = nullptr;
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-05 20:17:44 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext*
|
2004-02-23 21:29:06 +00:00
|
|
|
nsFrameManager::GetUndisplayedContent(nsIContent* aContent)
|
2001-05-31 22:19:43 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
if (!aContent || !mUndisplayedMap)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2002-05-01 00:36:50 +00:00
|
|
|
|
2003-07-28 21:25:13 +00:00
|
|
|
nsIContent* parent = aContent->GetParent();
|
2002-05-01 00:36:50 +00:00
|
|
|
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(parent);
|
|
|
|
node; node = node->mNext) {
|
2003-02-22 00:32:13 +00:00
|
|
|
if (node->mContent == aContent)
|
|
|
|
return node->mStyle;
|
2002-05-01 00:36:50 +00:00
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-05-31 22:19:43 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2004-02-23 21:29:06 +00:00
|
|
|
nsFrameManager::SetUndisplayedContent(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2009-10-29 21:17:56 +00:00
|
|
|
NS_PRECONDITION(!aStyleContext->GetPseudo(),
|
2009-05-15 01:40:26 +00:00
|
|
|
"Should only have actual elements here");
|
|
|
|
|
2002-04-02 21:14:43 +00:00
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
2006-05-12 20:36:39 +00:00
|
|
|
static int i = 0;
|
|
|
|
printf("SetUndisplayedContent(%d): p=%p \n", i++, (void *)aContent);
|
2002-04-02 21:14:43 +00:00
|
|
|
#endif
|
|
|
|
|
2006-05-12 20:36:39 +00:00
|
|
|
NS_ASSERTION(!GetUndisplayedContent(aContent),
|
|
|
|
"Already have an undisplayed context entry for aContent");
|
|
|
|
|
1999-10-02 04:25:29 +00:00
|
|
|
if (! mUndisplayedMap) {
|
|
|
|
mUndisplayedMap = new UndisplayedMap;
|
|
|
|
}
|
2011-04-29 05:02:40 +00: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 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
2003-06-18 21:54:51 +00:00
|
|
|
void
|
2004-02-23 21:29:06 +00:00
|
|
|
nsFrameManager::ChangeUndisplayedContent(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext)
|
2003-06-18 21:54:51 +00: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-28 21:25:13 +00:00
|
|
|
for (UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aContent->GetParent());
|
2003-06-18 21:54:51 +00:00
|
|
|
node; node = node->mNext) {
|
|
|
|
if (node->mContent == aContent) {
|
|
|
|
node->mStyle = aStyleContext;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("no existing undisplayed content");
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearUndisplayedContentIn(nsIContent* aContent,
|
|
|
|
nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2002-04-02 21:14:43 +00: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 04:25:29 +00:00
|
|
|
if (mUndisplayedMap) {
|
|
|
|
UndisplayedNode* node = mUndisplayedMap->GetFirstNode(aParentContent);
|
|
|
|
while (node) {
|
|
|
|
if (node->mContent == aContent) {
|
2004-02-23 21:29:06 +00:00
|
|
|
mUndisplayedMap->RemoveNodeFor(aParentContent, node);
|
2002-04-02 21:14:43 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
2004-02-23 21:29:06 +00:00
|
|
|
printf( "REMOVED!\n");
|
2002-04-02 21:14:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
// make sure that there are no more entries for the same content
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext *context = GetUndisplayedContent(aContent);
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(context == nullptr, "Found more undisplayed content data after removal");
|
2002-04-02 21:14:43 +00:00
|
|
|
#endif
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2002-04-02 21:14:43 +00:00
|
|
|
#ifdef DEBUG_UNDISPLAYED_MAP
|
|
|
|
static int i = 0;
|
|
|
|
printf("ClearAllUndisplayedContentIn(%d): parent=%p \n", i++, (void*)aParentContent);
|
|
|
|
#endif
|
|
|
|
|
1999-10-02 04:25:29 +00:00
|
|
|
if (mUndisplayedMap) {
|
2004-02-23 21:29:06 +00:00
|
|
|
mUndisplayedMap->RemoveNodesFor(aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
2009-08-07 19:51:25 +00: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
|
|
|
|
// parent, but are treated as children of aParentContent. We get access to
|
|
|
|
// the content list via GetXBLChildNodesFor and just ignore any nodes we
|
|
|
|
// don't care about.
|
|
|
|
nsINodeList* list =
|
2011-10-18 10:53:36 +00:00
|
|
|
aParentContent->OwnerDoc()->BindingManager()->GetXBLChildNodesFor(aParentContent);
|
2009-08-07 19:51:25 +00:00
|
|
|
if (list) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length;
|
2009-08-07 19:51:25 +00:00
|
|
|
list->GetLength(&length);
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2009-08-07 19:51:25 +00:00
|
|
|
nsIContent* child = list->GetNodeAt(i);
|
|
|
|
if (child->GetParent() != aParentContent) {
|
|
|
|
ClearUndisplayedContentIn(child, child->GetParent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2011-04-29 23:02:33 +00: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 04:25:29 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsresult
|
|
|
|
nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
|
2011-08-24 20:54:30 +00:00
|
|
|
ChildListID aListID,
|
2004-02-23 21:29:06 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2007-11-12 19:05:42 +00:00
|
|
|
NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
|
2012-01-04 00:44:07 +00:00
|
|
|
|| (aPrevFrame->GetNextContinuation()->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER))
|
|
|
|
&& !(aPrevFrame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER),
|
2006-02-21 21:33:47 +00:00
|
|
|
"aPrevFrame must be the last continuation in its chain!");
|
2001-03-09 03:29:00 +00:00
|
|
|
|
2011-04-29 23:02:33 +00: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 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsresult
|
2011-08-24 20:54:30 +00:00
|
|
|
nsFrameManager::RemoveFrame(ChildListID aListID,
|
2012-07-04 00:24:55 +00:00
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
bool aInvalidate /* = true */)
|
1999-08-04 03:39:34 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool wasDestroyingFrames = mIsDestroyingFrames;
|
2011-10-17 14:59:28 +00:00
|
|
|
mIsDestroyingFrames = true;
|
2008-12-12 08:25:16 +00:00
|
|
|
|
2012-07-04 00:24:55 +00: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
|
|
|
|
if (aInvalidate) {
|
|
|
|
aOldFrame->InvalidateFrameSubtree();
|
|
|
|
}
|
|
|
|
|
2009-12-24 05:20:41 +00: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-29 23:02:33 +00: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 08:25:16 +00:00
|
|
|
|
2008-10-12 22:05:04 +00:00
|
|
|
mIsDestroyingFrames = wasDestroyingFrames;
|
2008-12-12 08:25:16 +00:00
|
|
|
|
2008-10-12 22:05:04 +00:00
|
|
|
return rv;
|
1999-08-04 03:39:34 +00:00
|
|
|
}
|
|
|
|
|
1999-08-05 20:17:44 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
|
1999-08-05 20:17:44 +00:00
|
|
|
{
|
2009-12-24 05:20:41 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2009-12-29 20:13:54 +00:00
|
|
|
if (content && content->GetPrimaryFrame() == aFrame) {
|
|
|
|
ClearAllUndisplayedContentIn(content);
|
2001-12-11 19:16:15 +00:00
|
|
|
}
|
1999-08-05 20:17:44 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 19:59:42 +00:00
|
|
|
#ifdef DEBUG
|
1999-09-21 07:53:14 +00:00
|
|
|
static void
|
2003-02-22 00:32:13 +00:00
|
|
|
DumpContext(nsIFrame* aFrame, nsStyleContext* aContext)
|
1999-09-21 07:53:14 +00:00
|
|
|
{
|
|
|
|
if (aFrame) {
|
|
|
|
fputs("frame: ", stdout);
|
|
|
|
nsAutoString name;
|
2009-08-20 21:52:48 +00:00
|
|
|
aFrame->GetFrameName(name);
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout);
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(stdout, " (%p)", static_cast<void*>(aFrame));
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
if (aContext) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(stdout, " style: %p ", static_cast<void*>(aContext));
|
1999-09-21 07:53:14 +00:00
|
|
|
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* pseudoTag = aContext->GetPseudo();
|
1999-09-21 07:53:14 +00:00
|
|
|
if (pseudoTag) {
|
|
|
|
nsAutoString buffer;
|
|
|
|
pseudoTag->ToString(buffer);
|
2006-02-03 14:18:39 +00:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), stdout);
|
1999-09-21 07:53:14 +00:00
|
|
|
fputs(" ", stdout);
|
|
|
|
}
|
2009-03-30 18:08:06 +00:00
|
|
|
fputs("{}\n", stdout);
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-16 15:26:56 +00:00
|
|
|
static void
|
2003-02-22 00:32:13 +00:00
|
|
|
VerifySameTree(nsStyleContext* aContext1, nsStyleContext* aContext2)
|
2002-03-16 15:26:56 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* top1 = aContext1;
|
|
|
|
nsStyleContext* top2 = aContext2;
|
|
|
|
nsStyleContext* parent;
|
2002-03-16 15:26:56 +00:00
|
|
|
for (;;) {
|
2002-10-09 01:46:15 +00:00
|
|
|
parent = top1->GetParent();
|
2002-03-16 15:26:56 +00:00
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
top1 = parent;
|
|
|
|
}
|
|
|
|
for (;;) {
|
2002-10-09 01:46:15 +00:00
|
|
|
parent = top2->GetParent();
|
2002-03-16 15:26:56 +00:00
|
|
|
if (!parent)
|
|
|
|
break;
|
|
|
|
top2 = parent;
|
|
|
|
}
|
2007-10-09 02:45:10 +00:00
|
|
|
NS_ASSERTION(top1 == top2,
|
|
|
|
"Style contexts are not in the same style context tree");
|
2002-03-16 15:26:56 +00:00
|
|
|
}
|
|
|
|
|
2000-09-12 22:47:09 +00:00
|
|
|
static void
|
2004-07-31 23:15:21 +00:00
|
|
|
VerifyContextParent(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aContext, nsStyleContext* aParentContext)
|
2000-09-12 22:47:09 +00:00
|
|
|
{
|
|
|
|
// get the contexts not provided
|
|
|
|
if (!aContext) {
|
2003-02-22 00:32:13 +00:00
|
|
|
aContext = aFrame->GetStyleContext();
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aParentContext) {
|
|
|
|
// Get the correct parent context from the frame
|
|
|
|
// - if the frame is a placeholder, we get the out of flow frame's context
|
|
|
|
// as the parent context instead of asking the frame
|
2002-03-27 02:38:13 +00:00
|
|
|
|
|
|
|
// get the parent context from the frame (indirectly)
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame();
|
2002-03-27 02:38:13 +00:00
|
|
|
if (providerFrame)
|
2003-02-22 00:32:13 +00:00
|
|
|
aParentContext = providerFrame->GetStyleContext();
|
2002-03-27 02:38:13 +00:00
|
|
|
// aParentContext could still be null
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(aContext, "Failure to get required contexts");
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* actualParentContext = aContext->GetParent();
|
2000-09-12 22:47:09 +00:00
|
|
|
|
|
|
|
if (aParentContext) {
|
|
|
|
if (aParentContext != actualParentContext) {
|
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
if (aContext == aParentContext) {
|
2007-10-09 02:45:10 +00:00
|
|
|
NS_ERROR("Using parent's style context");
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-10-09 02:45:10 +00:00
|
|
|
NS_ERROR("Wrong parent style context");
|
2000-09-12 22:47:09 +00:00
|
|
|
fputs("Wrong parent style context: ", stdout);
|
2012-07-30 14:20:58 +00:00
|
|
|
DumpContext(nullptr, actualParentContext);
|
2000-09-12 22:47:09 +00:00
|
|
|
fputs("should be using: ", stdout);
|
2012-07-30 14:20:58 +00:00
|
|
|
DumpContext(nullptr, aParentContext);
|
2002-03-16 15:26:56 +00:00
|
|
|
VerifySameTree(actualParentContext, aParentContext);
|
2000-09-12 22:47:09 +00:00
|
|
|
fputs("\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
2010-06-08 19:58:26 +00:00
|
|
|
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (actualParentContext) {
|
2007-10-09 02:45:10 +00:00
|
|
|
NS_ERROR("Have parent context and shouldn't");
|
2000-09-12 22:47:09 +00:00
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
fputs("Has parent context: ", stdout);
|
2012-07-30 14:20:58 +00:00
|
|
|
DumpContext(nullptr, actualParentContext);
|
2000-09-12 22:47:09 +00:00
|
|
|
fputs("Should be null\n\n", stdout);
|
|
|
|
}
|
|
|
|
}
|
2010-06-08 19:58:26 +00:00
|
|
|
|
|
|
|
nsStyleContext* childStyleIfVisited = aContext->GetStyleIfVisited();
|
2010-06-09 04:03:10 +00:00
|
|
|
// Either childStyleIfVisited has aContext->GetParent()->GetStyleIfVisited()
|
|
|
|
// as the parent or it has a different rulenode from aContext _and_ has
|
|
|
|
// aContext->GetParent() as the parent.
|
2010-06-08 19:58:26 +00:00
|
|
|
if (childStyleIfVisited &&
|
|
|
|
!((childStyleIfVisited->GetRuleNode() != aContext->GetRuleNode() &&
|
|
|
|
childStyleIfVisited->GetParent() == aContext->GetParent()) ||
|
2010-06-09 03:36:17 +00:00
|
|
|
childStyleIfVisited->GetParent() ==
|
|
|
|
aContext->GetParent()->GetStyleIfVisited())) {
|
2010-06-08 19:58:26 +00:00
|
|
|
NS_ERROR("Visited style has wrong parent");
|
|
|
|
DumpContext(aFrame, aContext);
|
|
|
|
fputs("\n", stdout);
|
|
|
|
}
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-07-31 23:15:21 +00:00
|
|
|
VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* aFrame,
|
2004-02-23 21:29:06 +00:00
|
|
|
nsStyleContext* aParentContext)
|
2000-09-12 22:47:09 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* context = aFrame->GetStyleContext();
|
2012-07-30 14:20:58 +00:00
|
|
|
VerifyContextParent(aPresContext, aFrame, context, nullptr);
|
2000-09-12 22:47:09 +00:00
|
|
|
|
2011-08-24 20:54:29 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2012-03-16 17:13:14 +00:00
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
// only do frames that are in flow
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) {
|
2005-04-14 15:30:35 +00:00
|
|
|
// placeholder: first recurse and verify the out of flow frame,
|
2000-09-12 22:47:09 +00:00
|
|
|
// then verify the placeholder's context
|
2005-04-14 15:30:35 +00:00
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
2000-09-12 22:47:09 +00:00
|
|
|
|
|
|
|
// recurse to out of flow frame, letting the parent context get resolved
|
2012-03-16 17:13:14 +00:00
|
|
|
do {
|
2012-07-30 14:20:58 +00:00
|
|
|
VerifyStyleTree(aPresContext, outOfFlowFrame, nullptr);
|
2012-03-16 17:13:14 +00:00
|
|
|
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation()));
|
2000-09-12 22:47:09 +00:00
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
// verify placeholder using the parent frame's context as
|
|
|
|
// parent context
|
2012-07-30 14:20:58 +00:00
|
|
|
VerifyContextParent(aPresContext, child, nullptr, nullptr);
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
else { // regular frame
|
2012-07-30 14:20:58 +00:00
|
|
|
VerifyStyleTree(aPresContext, child, nullptr);
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
2000-09-12 22:47:09 +00:00
|
|
|
|
|
|
|
// do additional contexts
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contextIndex = -1;
|
2003-02-22 00:32:13 +00:00
|
|
|
while (1) {
|
|
|
|
nsStyleContext* extraContext = aFrame->GetAdditionalStyleContext(++contextIndex);
|
2000-09-12 22:47:09 +00:00
|
|
|
if (extraContext) {
|
|
|
|
VerifyContextParent(aPresContext, aFrame, extraContext, context);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::DebugVerifyStyleTree(nsIFrame* aFrame)
|
2000-09-12 22:47:09 +00:00
|
|
|
{
|
|
|
|
if (aFrame) {
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* context = aFrame->GetStyleContext();
|
|
|
|
nsStyleContext* parentContext = context->GetParent();
|
2003-06-19 23:52:58 +00:00
|
|
|
VerifyStyleTree(GetPresContext(), aFrame, parentContext);
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DEBUG
|
1999-09-21 07:53:14 +00:00
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
// aContent must be the content for the frame in question, which may be
|
|
|
|
// :before/:after content
|
|
|
|
static void
|
|
|
|
TryStartingTransition(nsPresContext *aPresContext, nsIContent *aContent,
|
|
|
|
nsStyleContext *aOldStyleContext,
|
|
|
|
nsRefPtr<nsStyleContext> *aNewStyleContext /* inout */)
|
|
|
|
{
|
2010-05-14 17:04:51 +00:00
|
|
|
if (!aContent || !aContent->IsElement()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-08 03:22:42 +00:00
|
|
|
// Notify the transition manager, and if it starts a transition,
|
|
|
|
// it will give us back a transition-covering style rule which
|
|
|
|
// we'll use to get *another* style context. We want to ignore
|
|
|
|
// any already-running transitions, but cover up any that we're
|
|
|
|
// currently starting with their start value so we don't start
|
|
|
|
// them again for descendants that inherit that value.
|
|
|
|
nsCOMPtr<nsIStyleRule> coverRule =
|
|
|
|
aPresContext->TransitionManager()->StyleContextChanged(
|
2010-05-14 17:04:51 +00:00
|
|
|
aContent->AsElement(), aOldStyleContext, *aNewStyleContext);
|
2009-10-08 03:22:42 +00:00
|
|
|
if (coverRule) {
|
|
|
|
nsCOMArray<nsIStyleRule> rules;
|
|
|
|
rules.AppendObject(coverRule);
|
2010-04-03 01:58:25 +00:00
|
|
|
*aNewStyleContext = aPresContext->StyleSet()->
|
|
|
|
ResolveStyleByAddingRules(*aNewStyleContext, rules);
|
2009-10-08 03:22:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-23 04:46:27 +00:00
|
|
|
static inline Element*
|
|
|
|
ElementForStyleContext(nsIContent* aParentContent,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsCSSPseudoElements::Type aPseudoType)
|
|
|
|
{
|
|
|
|
// We don't expect XUL tree stuff here.
|
|
|
|
NS_PRECONDITION(aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
|
|
|
|
aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox ||
|
|
|
|
aPseudoType < nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected pseudo");
|
|
|
|
// XXX see the comments about the various element confusion in
|
|
|
|
// ReResolveStyleContext.
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
|
|
|
return aFrame->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-06-23 04:46:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aPseudoType == nsCSSPseudoElements::ePseudo_firstLetter) {
|
|
|
|
NS_ASSERTION(aFrame->GetType() == nsGkAtoms::letterFrame,
|
|
|
|
"firstLetter pseudoTag without a nsFirstLetterFrame");
|
|
|
|
nsBlockFrame* block = nsBlockFrame::GetNearestAncestorBlock(aFrame);
|
|
|
|
return block->GetContent()->AsElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent* content = aParentContent ? aParentContent : aFrame->GetContent();
|
|
|
|
return content->AsElement();
|
|
|
|
}
|
|
|
|
|
2011-08-12 03:52:21 +00:00
|
|
|
static nsIFrame*
|
|
|
|
GetPrevContinuationWithPossiblySameStyle(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Account for {ib} splits when looking for "prevContinuation". In
|
|
|
|
// particular, for the first-continuation of a part of an {ib} split we
|
|
|
|
// want to use the special prevsibling of the special prevsibling of
|
|
|
|
// aFrame, which should have the same style context as aFrame itself.
|
|
|
|
// In particular, if aFrame is the first continuation of an inline part
|
|
|
|
// of an {ib} split then its special prevsibling is a block, and the
|
|
|
|
// special prevsibling of _that_ is an inline, just like aFrame.
|
|
|
|
// Similarly, if aFrame is the first continuation of a block part of an
|
|
|
|
// {ib} split (an {ib} wrapper block), then its special prevsibling is
|
|
|
|
// an inline and the special prevsibling of that is either another {ib}
|
|
|
|
// wrapper block block or null.
|
|
|
|
nsIFrame *prevContinuation = aFrame->GetPrevContinuation();
|
|
|
|
if (!prevContinuation && (aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL)) {
|
|
|
|
// We're the first continuation, so we can just get the frame
|
|
|
|
// property directly
|
|
|
|
prevContinuation = static_cast<nsIFrame*>(
|
|
|
|
aFrame->Properties().Get(nsIFrame::IBSplitSpecialPrevSibling()));
|
|
|
|
if (prevContinuation) {
|
|
|
|
prevContinuation = static_cast<nsIFrame*>(
|
|
|
|
prevContinuation->Properties().Get(nsIFrame::IBSplitSpecialPrevSibling()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return prevContinuation;
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsresult
|
2010-04-02 06:07:43 +00:00
|
|
|
nsFrameManager::ReparentStyleContext(nsIFrame* aFrame)
|
2006-03-16 01:30:38 +00:00
|
|
|
{
|
2007-11-07 17:13:00 +00:00
|
|
|
if (nsGkAtoms::placeholderFrame == aFrame->GetType()) {
|
2010-08-10 22:04:43 +00:00
|
|
|
// Also reparent the out-of-flow and all its continuations.
|
2007-11-07 17:13:00 +00:00
|
|
|
nsIFrame* outOfFlow =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
|
|
|
|
NS_ASSERTION(outOfFlow, "no out-of-flow frame");
|
2010-08-10 22:04:43 +00:00
|
|
|
do {
|
|
|
|
ReparentStyleContext(outOfFlow);
|
2011-02-16 13:14:14 +00:00
|
|
|
} while ((outOfFlow = outOfFlow->GetNextContinuation()));
|
2007-11-07 17:13:00 +00:00
|
|
|
}
|
|
|
|
|
2006-03-16 01:30:38 +00:00
|
|
|
// DO NOT verify the style tree before reparenting. The frame
|
|
|
|
// tree has already been changed, so this check would just fail.
|
|
|
|
nsStyleContext* oldContext = aFrame->GetStyleContext();
|
|
|
|
// XXXbz can oldContext really ever be null?
|
|
|
|
if (oldContext) {
|
|
|
|
nsRefPtr<nsStyleContext> newContext;
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame();
|
|
|
|
bool isChild = providerFrame && providerFrame->GetParent() == aFrame;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsStyleContext* newParentContext = nullptr;
|
|
|
|
nsIFrame* providerChild = nullptr;
|
2011-09-12 16:08:07 +00:00
|
|
|
if (isChild) {
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentStyleContext(providerFrame);
|
2006-03-16 01:30:38 +00:00
|
|
|
newParentContext = providerFrame->GetStyleContext();
|
|
|
|
providerChild = providerFrame;
|
|
|
|
} else if (providerFrame) {
|
|
|
|
newParentContext = providerFrame->GetStyleContext();
|
|
|
|
} else {
|
|
|
|
NS_NOTREACHED("Reparenting something that has no usable parent? "
|
|
|
|
"Shouldn't happen!");
|
|
|
|
}
|
2009-09-18 18:00:21 +00:00
|
|
|
// XXX need to do something here to produce the correct style context for
|
|
|
|
// an IB split whose first inline part is inside a first-line frame.
|
|
|
|
// Currently the first IB anonymous block's style context takes the first
|
|
|
|
// part's style context as parent, which is wrong since first-line style
|
|
|
|
// should not apply to the anonymous block.
|
1999-09-21 07:53:14 +00:00
|
|
|
|
2009-10-17 14:31:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
// Check that our assumption that continuations of the same
|
|
|
|
// pseudo-type and with the same style context parent have the
|
|
|
|
// same style context is valid before the reresolution. (We need
|
|
|
|
// to check the pseudo-type and style context parent because of
|
|
|
|
// :first-letter and :first-line, where we create styled and
|
|
|
|
// unstyled letter/line frames distinguished by pseudo-type, and
|
|
|
|
// then need to distinguish their descendants based on having
|
|
|
|
// different parents.)
|
|
|
|
nsIFrame *nextContinuation = aFrame->GetNextContinuation();
|
|
|
|
if (nextContinuation) {
|
|
|
|
nsStyleContext *nextContinuationContext =
|
|
|
|
nextContinuation->GetStyleContext();
|
|
|
|
NS_ASSERTION(oldContext == nextContinuationContext ||
|
2009-10-29 21:17:56 +00:00
|
|
|
oldContext->GetPseudo() !=
|
|
|
|
nextContinuationContext->GetPseudo() ||
|
2009-10-17 14:31:47 +00:00
|
|
|
oldContext->GetParent() !=
|
|
|
|
nextContinuationContext->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-08-12 03:52:21 +00:00
|
|
|
nsIFrame *prevContinuation =
|
|
|
|
GetPrevContinuationWithPossiblySameStyle(aFrame);
|
2009-10-17 14:31:47 +00:00
|
|
|
nsStyleContext *prevContinuationContext;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool copyFromContinuation =
|
2009-10-17 14:31:47 +00:00
|
|
|
prevContinuation &&
|
|
|
|
(prevContinuationContext = prevContinuation->GetStyleContext())
|
2009-10-29 21:17:56 +00:00
|
|
|
->GetPseudo() == oldContext->GetPseudo() &&
|
2009-10-17 14:31:47 +00:00
|
|
|
prevContinuationContext->GetParent() == newParentContext;
|
|
|
|
if (copyFromContinuation) {
|
|
|
|
// Just use the style context from the frame's previous
|
|
|
|
// continuation (see assertion about aFrame->GetNextContinuation()
|
|
|
|
// above, which we would have previously hit for aFrame's previous
|
|
|
|
// continuation).
|
|
|
|
newContext = prevContinuationContext;
|
|
|
|
} else {
|
2010-06-23 04:46:27 +00:00
|
|
|
nsIFrame* parentFrame = aFrame->GetParent();
|
|
|
|
Element* element =
|
2012-07-30 14:20:58 +00:00
|
|
|
ElementForStyleContext(parentFrame ? parentFrame->GetContent() : nullptr,
|
2010-06-23 04:46:27 +00:00
|
|
|
aFrame,
|
|
|
|
oldContext->GetPseudoType());
|
2010-04-02 06:07:42 +00:00
|
|
|
newContext = mStyleSet->ReparentStyleContext(oldContext,
|
2010-06-23 04:46:27 +00:00
|
|
|
newParentContext,
|
|
|
|
element);
|
2009-10-17 14:31:47 +00:00
|
|
|
}
|
|
|
|
|
2006-03-16 01:30:38 +00:00
|
|
|
if (newContext) {
|
|
|
|
if (newContext != oldContext) {
|
2009-10-08 03:22:42 +00:00
|
|
|
// We probably don't want to initiate transitions from
|
2010-04-02 06:07:43 +00:00
|
|
|
// ReparentStyleContext, since we call it during frame
|
2009-10-08 03:22:42 +00:00
|
|
|
// construction rather than in response to dynamic changes.
|
|
|
|
// Also see the comment at the start of
|
|
|
|
// nsTransitionManager::ConsiderStartingTransition.
|
|
|
|
#if 0
|
2009-10-17 14:31:47 +00:00
|
|
|
if (!copyFromContinuation) {
|
2010-04-02 06:07:42 +00:00
|
|
|
TryStartingTransition(GetPresContext(), aFrame->GetContent(),
|
2009-10-17 14:31:47 +00:00
|
|
|
oldContext, &newContext);
|
|
|
|
}
|
2009-10-08 03:22:42 +00:00
|
|
|
#endif
|
|
|
|
|
2007-11-07 17:13:00 +00:00
|
|
|
// Make sure to call CalcStyleDifference so that the new context ends
|
|
|
|
// up resolving all the structs the old context resolved.
|
|
|
|
nsChangeHint styleChange = oldContext->CalcStyleDifference(newContext);
|
|
|
|
// The style change is always 0 because we have the same rulenode and
|
|
|
|
// CalcStyleDifference optimizes us away. That's OK, though:
|
|
|
|
// reparenting should never trigger a frame reconstruct, and whenever
|
|
|
|
// it's happening we already plan to reflow and repaint the frames.
|
|
|
|
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
|
|
|
|
"Our frame tree is likely to be bogus!");
|
|
|
|
|
2006-03-16 01:30:38 +00:00
|
|
|
aFrame->SetStyleContext(newContext);
|
1999-09-03 23:35:41 +00:00
|
|
|
|
2011-08-24 20:54:29 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2012-03-16 17:13:14 +00:00
|
|
|
// only do frames that are in flow
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
2007-11-07 17:13:00 +00:00
|
|
|
child != providerChild) {
|
|
|
|
#ifdef DEBUG
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) {
|
2006-03-16 01:30:38 +00:00
|
|
|
nsIFrame* outOfFlowFrame =
|
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
|
|
|
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
|
|
|
|
|
|
|
NS_ASSERTION(outOfFlowFrame != providerChild,
|
|
|
|
"Out of flow provider?");
|
1999-09-03 23:35:41 +00:00
|
|
|
}
|
2007-11-07 17:13:00 +00:00
|
|
|
#endif
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentStyleContext(child);
|
1999-09-03 23:35:41 +00:00
|
|
|
}
|
2006-03-16 01:30:38 +00:00
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
2006-03-16 01:30:38 +00:00
|
|
|
|
2006-12-21 20:03:09 +00:00
|
|
|
// If this frame is part of an IB split, then the style context of
|
|
|
|
// the next part of the split might be a child of our style context.
|
|
|
|
// Reparent its style context just in case one of our ancestors
|
|
|
|
// (split or not) hasn't done so already). It's not a problem to
|
|
|
|
// reparent the same frame twice because the "if (newContext !=
|
|
|
|
// oldContext)" check will prevent us from redoing work.
|
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL) &&
|
2009-09-18 18:00:20 +00:00
|
|
|
!aFrame->GetPrevContinuation()) {
|
2010-03-29 01:46:55 +00:00
|
|
|
nsIFrame* sib = static_cast<nsIFrame*>
|
|
|
|
(aFrame->Properties().Get(nsIFrame::IBSplitSpecialSibling()));
|
2006-12-21 20:03:09 +00:00
|
|
|
if (sib) {
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentStyleContext(sib);
|
2006-12-21 20:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-16 01:30:38 +00:00
|
|
|
// do additional contexts
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contextIndex = -1;
|
2006-03-16 01:30:38 +00:00
|
|
|
while (1) {
|
|
|
|
nsStyleContext* oldExtraContext =
|
|
|
|
aFrame->GetAdditionalStyleContext(++contextIndex);
|
|
|
|
if (oldExtraContext) {
|
|
|
|
nsRefPtr<nsStyleContext> newExtraContext;
|
2010-04-02 06:07:42 +00:00
|
|
|
newExtraContext = mStyleSet->ReparentStyleContext(oldExtraContext,
|
2010-06-23 04:46:27 +00:00
|
|
|
newContext,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr);
|
2006-03-16 01:30:38 +00:00
|
|
|
if (newExtraContext) {
|
2007-11-07 17:13:00 +00:00
|
|
|
if (newExtraContext != oldExtraContext) {
|
|
|
|
// Make sure to call CalcStyleDifference so that the new
|
|
|
|
// context ends up resolving all the structs the old context
|
|
|
|
// resolved.
|
|
|
|
styleChange =
|
|
|
|
oldExtraContext->CalcStyleDifference(newExtraContext);
|
|
|
|
// The style change is always 0 because we have the same
|
|
|
|
// rulenode and CalcStyleDifference optimizes us away. That's
|
|
|
|
// OK, though: reparenting should never trigger a frame
|
|
|
|
// reconstruct, and whenever it's happening we already plan to
|
|
|
|
// reflow and repaint the frames.
|
|
|
|
NS_ASSERTION(!(styleChange & nsChangeHint_ReconstructFrame),
|
|
|
|
"Our frame tree is likely to be bogus!");
|
|
|
|
}
|
|
|
|
|
2006-03-16 01:30:38 +00:00
|
|
|
aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext);
|
1999-09-03 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-16 01:30:38 +00:00
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-11-13 04:31:04 +00:00
|
|
|
#ifdef DEBUG
|
2006-03-16 01:30:38 +00:00
|
|
|
VerifyStyleTree(GetPresContext(), aFrame, newParentContext);
|
1999-09-21 07:53:14 +00:00
|
|
|
#endif
|
1999-09-03 23:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-16 01:30:38 +00:00
|
|
|
return NS_OK;
|
1999-09-03 23:35:41 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 14:41:28 +00:00
|
|
|
static nsChangeHint
|
2003-02-22 00:32:13 +00:00
|
|
|
CaptureChange(nsStyleContext* aOldContext, nsStyleContext* aNewContext,
|
1999-10-02 04:25:29 +00:00
|
|
|
nsIFrame* aFrame, nsIContent* aContent,
|
2005-01-25 02:14:31 +00:00
|
|
|
nsStyleChangeList* aChangeList, nsChangeHint aMinChange,
|
|
|
|
nsChangeHint aChangeToAssume)
|
1999-09-21 07:53:14 +00:00
|
|
|
{
|
2005-01-25 02:14:31 +00:00
|
|
|
nsChangeHint ourChange = aOldContext->CalcStyleDifference(aNewContext);
|
2009-08-10 14:54:21 +00:00
|
|
|
NS_ASSERTION(!(ourChange & nsChangeHint_ReflowFrame) ||
|
|
|
|
(ourChange & nsChangeHint_NeedReflow),
|
|
|
|
"Reflow hint bits set without actually asking for a reflow");
|
|
|
|
|
2005-01-25 02:14:31 +00:00
|
|
|
NS_UpdateHint(ourChange, aChangeToAssume);
|
2002-08-24 14:41:28 +00:00
|
|
|
if (NS_UpdateHint(aMinChange, ourChange)) {
|
2010-12-15 20:26:54 +00:00
|
|
|
if (!(ourChange & nsChangeHint_ReconstructFrame) || aContent) {
|
|
|
|
aChangeList->AppendChange(aFrame, aContent, ourChange);
|
|
|
|
}
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
return aMinChange;
|
|
|
|
}
|
|
|
|
|
2008-12-29 15:07:37 +00:00
|
|
|
/**
|
|
|
|
* Recompute style for aFrame and accumulate changes into aChangeList
|
|
|
|
* given that aMinChange is already accumulated for an ancestor.
|
|
|
|
* aParentContent is the content node used to resolve the parent style
|
|
|
|
* context. This means that, for pseudo-elements, it is the content
|
|
|
|
* that should be used for selector matching (rather than the fake
|
|
|
|
* content node attached to the frame).
|
|
|
|
*/
|
2004-02-23 21:29:06 +00:00
|
|
|
nsChangeHint
|
2008-12-29 15:07:37 +00:00
|
|
|
nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
|
2004-02-23 21:29:06 +00:00
|
|
|
nsIFrame *aFrame,
|
|
|
|
nsIContent *aParentContent,
|
|
|
|
nsStyleChangeList *aChangeList,
|
2009-07-30 07:55:51 +00:00
|
|
|
nsChangeHint aMinChange,
|
2010-06-18 16:23:05 +00:00
|
|
|
nsRestyleHint aRestyleHint,
|
2010-11-13 17:49:26 +00:00
|
|
|
RestyleTracker& aRestyleTracker,
|
|
|
|
DesiredA11yNotifications aDesiredA11yNotifications,
|
2011-05-25 00:19:09 +00:00
|
|
|
nsTArray<nsIContent*>& aVisibleKidsOfHiddenElement,
|
|
|
|
TreeMatchContext &aTreeMatchContext)
|
1999-09-21 07:53:14 +00:00
|
|
|
{
|
2009-08-04 01:22:13 +00:00
|
|
|
if (!NS_IsHintSubset(nsChangeHint_NeedDirtyReflow, aMinChange)) {
|
2009-08-10 14:54:21 +00:00
|
|
|
// If aMinChange doesn't include nsChangeHint_NeedDirtyReflow, clear out
|
|
|
|
// all the reflow change bits from it, so that we'll make sure to append a
|
|
|
|
// change to the list for ourselves if we need a reflow. We need this
|
|
|
|
// because the parent may or may not actually end up reflowing us
|
|
|
|
// otherwise.
|
|
|
|
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_ReflowFrame);
|
|
|
|
} else if (!NS_IsHintSubset(nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
aMinChange)) {
|
|
|
|
// If aMinChange doesn't include nsChangeHint_ClearDescendantIntrinsics,
|
|
|
|
// clear out the nsChangeHint_ClearAncestorIntrinsics flag, since it's
|
|
|
|
// possible that we had some random ancestor that cleared ancestor
|
|
|
|
// intrinsic widths, but we still need to clear intrinsic widths on frames
|
|
|
|
// that are our ancestors but its descendants.
|
|
|
|
aMinChange =
|
|
|
|
NS_SubtractHint(aMinChange, nsChangeHint_ClearAncestorIntrinsics);
|
2009-08-04 01:22:13 +00:00
|
|
|
}
|
2010-06-18 16:23:05 +00:00
|
|
|
|
2012-02-07 22:52:59 +00:00
|
|
|
// We need to generate a new change list entry for every frame whose style
|
|
|
|
// comparision returns one of these hints. These hints don't automatically
|
|
|
|
// update all their descendant frames.
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 04:53:48 +00:00
|
|
|
aMinChange = NS_SubtractHint(aMinChange, nsChangeHint_NonInherited_Hints);
|
2012-02-07 11:31:47 +00:00
|
|
|
|
2009-01-29 20:39:19 +00:00
|
|
|
// It would be nice if we could make stronger assertions here; they
|
|
|
|
// would let us simplify the ?: expressions below setting |content|
|
|
|
|
// and |pseudoContent| in sensible ways as well as making what
|
|
|
|
// |localContent|, |content|, and |pseudoContent| mean make more
|
|
|
|
// sense. However, we can't, because of frame trees like the one in
|
|
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=472353#c14 . Once we
|
|
|
|
// fix bug 242277 we should be able to make this make more sense.
|
|
|
|
NS_ASSERTION(aFrame->GetContent() || !aParentContent ||
|
|
|
|
!aParentContent->GetParent(),
|
|
|
|
"frame must have content (unless at the top of the tree)");
|
2002-03-16 15:26:56 +00:00
|
|
|
// XXXldb get new context from prev-in-flow if possible, to avoid
|
|
|
|
// duplication. (Or should we just let |GetContext| handle that?)
|
|
|
|
// Getting the hint would be nice too, but that's harder.
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
// XXXbryner we may be able to avoid some of the refcounting goop here.
|
|
|
|
// We do need a reference to oldContext for the lifetime of this function, and it's possible
|
|
|
|
// that the frame has the last reference to it, so AddRef it here.
|
|
|
|
|
2005-01-25 02:14:31 +00:00
|
|
|
nsChangeHint assumeDifferenceHint = NS_STYLE_HINT_NONE;
|
2007-10-04 02:58:48 +00:00
|
|
|
// XXXbz oldContext should just be an nsRefPtr
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* oldContext = aFrame->GetStyleContext();
|
2004-01-28 00:18:22 +00:00
|
|
|
nsStyleSet* styleSet = aPresContext->StyleSet();
|
2003-02-22 00:32:13 +00:00
|
|
|
|
2007-10-04 02:58:48 +00:00
|
|
|
// XXXbz the nsIFrame constructor takes an nsStyleContext, so how
|
|
|
|
// could oldContext be null?
|
2003-02-22 00:32:13 +00:00
|
|
|
if (oldContext) {
|
|
|
|
oldContext->AddRef();
|
2010-11-13 17:49:26 +00:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2011-09-29 06:19:26 +00:00
|
|
|
bool wasFrameVisible = nsIPresShell::IsAccessibilityActive() ?
|
2011-10-17 14:59:28 +00:00
|
|
|
oldContext->GetStyleVisibility()->IsVisible() : false;
|
2010-11-13 17:49:26 +00:00
|
|
|
#endif
|
|
|
|
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* const pseudoTag = oldContext->GetPseudo();
|
2009-12-11 07:37:40 +00:00
|
|
|
const nsCSSPseudoElements::Type pseudoType = oldContext->GetPseudoType();
|
2003-06-29 03:43:05 +00:00
|
|
|
nsIContent* localContent = aFrame->GetContent();
|
2008-12-29 15:07:37 +00:00
|
|
|
// |content| is the node that we used for rule matching of
|
|
|
|
// normal elements (not pseudo-elements) and for which we generate
|
|
|
|
// framechange hints if we need them.
|
2009-01-29 20:39:19 +00:00
|
|
|
// XXXldb Why does it make sense to use aParentContent? (See
|
|
|
|
// comment above assertion at start of function.)
|
2003-06-29 03:43:05 +00:00
|
|
|
nsIContent* content = localContent ? localContent : aParentContent;
|
|
|
|
|
2010-06-18 16:23:05 +00:00
|
|
|
if (content && content->IsElement()) {
|
2011-11-14 03:24:41 +00:00
|
|
|
content->OwnerDoc()->FlushPendingLinkUpdates();
|
2010-06-18 16:23:05 +00:00
|
|
|
RestyleTracker::RestyleData restyleData;
|
|
|
|
if (aRestyleTracker.GetRestyleData(content->AsElement(), &restyleData)) {
|
|
|
|
if (NS_UpdateHint(aMinChange, restyleData.mChangeHint)) {
|
|
|
|
aChangeList->AppendChange(aFrame, content, restyleData.mChangeHint);
|
|
|
|
}
|
2010-06-18 16:23:05 +00:00
|
|
|
aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint);
|
2010-06-18 16:23:05 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-18 16:23:05 +00:00
|
|
|
|
|
|
|
nsRestyleHint childRestyleHint = aRestyleHint;
|
|
|
|
|
|
|
|
if (childRestyleHint == eRestyle_Self) {
|
|
|
|
childRestyleHint = nsRestyleHint(0);
|
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* parentContext;
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* resolvedChild = nullptr;
|
2002-03-27 02:38:13 +00:00
|
|
|
// Get the frame providing the parent style context. If it is a
|
|
|
|
// child, then resolve the provider first.
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame* providerFrame = aFrame->GetParentStyleContextFrame();
|
|
|
|
bool isChild = providerFrame && providerFrame->GetParent() == aFrame;
|
|
|
|
if (!isChild) {
|
2002-03-27 02:38:13 +00:00
|
|
|
if (providerFrame)
|
2003-02-22 00:32:13 +00:00
|
|
|
parentContext = providerFrame->GetStyleContext();
|
|
|
|
else
|
2012-07-30 14:20:58 +00:00
|
|
|
parentContext = nullptr;
|
2002-03-12 15:21:35 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-13 03:54:15 +00:00
|
|
|
MOZ_ASSERT(providerFrame->GetContent() == aFrame->GetContent(),
|
|
|
|
"Postcondition for GetParentStyleContextFrame() violated. "
|
|
|
|
"That means we need to add the current element to the "
|
|
|
|
"ancestor filter.");
|
|
|
|
|
2005-01-25 02:14:31 +00:00
|
|
|
// resolve the provider here (before aFrame below).
|
|
|
|
|
|
|
|
// assumeDifferenceHint forces the parent's change to be also
|
|
|
|
// applied to this frame, no matter what
|
2008-01-10 20:56:49 +00:00
|
|
|
// nsStyleContext::CalcStyleDifference says. CalcStyleDifference
|
2005-01-25 02:14:31 +00:00
|
|
|
// can't be trusted because it assumes any changes to the parent
|
|
|
|
// style context provider will be automatically propagated to
|
|
|
|
// the frame(s) with child style contexts.
|
2009-07-30 07:55:51 +00:00
|
|
|
|
2005-01-25 02:14:31 +00:00
|
|
|
assumeDifferenceHint = ReResolveStyleContext(aPresContext, providerFrame,
|
2008-12-29 15:07:37 +00:00
|
|
|
aParentContent, aChangeList,
|
2010-06-18 16:23:05 +00:00
|
|
|
aMinChange, aRestyleHint,
|
2010-11-13 17:49:26 +00:00
|
|
|
aRestyleTracker,
|
|
|
|
aDesiredA11yNotifications,
|
2011-05-25 00:19:09 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
aTreeMatchContext);
|
2005-01-25 02:14:31 +00:00
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
// The provider's new context becomes the parent context of
|
|
|
|
// aFrame's context.
|
2003-02-22 00:32:13 +00:00
|
|
|
parentContext = providerFrame->GetStyleContext();
|
2002-03-27 02:38:13 +00:00
|
|
|
// Set |resolvedChild| so we don't bother resolving the
|
|
|
|
// provider again.
|
|
|
|
resolvedChild = providerFrame;
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
2009-10-17 14:31:47 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
// Check that our assumption that continuations of the same
|
|
|
|
// pseudo-type and with the same style context parent have the
|
|
|
|
// same style context is valid before the reresolution. (We need
|
|
|
|
// to check the pseudo-type and style context parent because of
|
|
|
|
// :first-letter and :first-line, where we create styled and
|
|
|
|
// unstyled letter/line frames distinguished by pseudo-type, and
|
|
|
|
// then need to distinguish their descendants based on having
|
|
|
|
// different parents.)
|
|
|
|
nsIFrame *nextContinuation = aFrame->GetNextContinuation();
|
|
|
|
if (nextContinuation) {
|
|
|
|
nsStyleContext *nextContinuationContext =
|
|
|
|
nextContinuation->GetStyleContext();
|
|
|
|
NS_ASSERTION(oldContext == nextContinuationContext ||
|
2009-10-29 21:17:56 +00:00
|
|
|
oldContext->GetPseudo() !=
|
|
|
|
nextContinuationContext->GetPseudo() ||
|
2009-10-17 14:31:47 +00:00
|
|
|
oldContext->GetParent() !=
|
|
|
|
nextContinuationContext->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
|
|
|
}
|
2011-08-12 03:52:21 +00:00
|
|
|
// And assert the same thing for {ib} splits. See the comments in
|
|
|
|
// GetPrevContinuationWithPossiblySameStyle for an explanation of
|
|
|
|
// why we step two forward in the special sibling chain.
|
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_IS_SPECIAL) &&
|
|
|
|
!aFrame->GetPrevContinuation()) {
|
|
|
|
nsIFrame *nextIBSibling = static_cast<nsIFrame*>(
|
|
|
|
aFrame->Properties().Get(nsIFrame::IBSplitSpecialSibling()));
|
|
|
|
if (nextIBSibling) {
|
|
|
|
nextIBSibling = static_cast<nsIFrame*>(
|
|
|
|
nextIBSibling->Properties().Get(nsIFrame::IBSplitSpecialSibling()));
|
|
|
|
}
|
|
|
|
if (nextIBSibling) {
|
|
|
|
nsStyleContext *nextIBSiblingContext =
|
|
|
|
nextIBSibling->GetStyleContext();
|
|
|
|
NS_ASSERTION(oldContext == nextIBSiblingContext ||
|
|
|
|
oldContext->GetPseudo() !=
|
|
|
|
nextIBSiblingContext->GetPseudo() ||
|
|
|
|
oldContext->GetParent() !=
|
|
|
|
nextIBSiblingContext->GetParent(),
|
|
|
|
"continuations should have the same style context");
|
|
|
|
}
|
|
|
|
}
|
2009-10-17 14:31:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-09-21 07:53:14 +00:00
|
|
|
// do primary context
|
2009-09-11 10:46:36 +00:00
|
|
|
nsRefPtr<nsStyleContext> newContext;
|
2011-08-12 03:52:21 +00:00
|
|
|
nsIFrame *prevContinuation =
|
|
|
|
GetPrevContinuationWithPossiblySameStyle(aFrame);
|
2009-10-17 14:31:47 +00:00
|
|
|
nsStyleContext *prevContinuationContext;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool copyFromContinuation =
|
2009-10-17 14:31:47 +00:00
|
|
|
prevContinuation &&
|
|
|
|
(prevContinuationContext = prevContinuation->GetStyleContext())
|
2009-10-29 21:17:56 +00:00
|
|
|
->GetPseudo() == oldContext->GetPseudo() &&
|
2009-10-17 14:31:47 +00:00
|
|
|
prevContinuationContext->GetParent() == parentContext;
|
|
|
|
if (copyFromContinuation) {
|
|
|
|
// Just use the style context from the frame's previous
|
|
|
|
// continuation (see assertion about aFrame->GetNextContinuation()
|
|
|
|
// above, which we would have previously hit for aFrame's previous
|
|
|
|
// continuation).
|
|
|
|
newContext = prevContinuationContext;
|
|
|
|
}
|
|
|
|
else if (pseudoTag == nsCSSAnonBoxes::mozNonElement) {
|
2002-03-27 02:38:13 +00:00
|
|
|
NS_ASSERTION(localContent,
|
|
|
|
"non pseudo-element frame without content node");
|
2009-09-11 10:46:36 +00:00
|
|
|
newContext = styleSet->ResolveStyleForNonElement(parentContext);
|
2002-03-27 02:38:13 +00:00
|
|
|
}
|
2011-08-12 03:52:21 +00:00
|
|
|
else if (!aRestyleHint && !prevContinuation) {
|
|
|
|
// Unfortunately, if prevContinuation is non-null then we may have
|
|
|
|
// already stolen the restyle tracker entry for this element while
|
|
|
|
// processing prevContinuation. So we don't know whether aRestyleHint
|
|
|
|
// should really be 0 here or whether it should be eRestyle_Self. Be
|
|
|
|
// pessimistic and force an actual reresolve in that situation. The good
|
|
|
|
// news is that in the common case when prevContinuation is non-null we
|
|
|
|
// just used prevContinuationContext anyway and aren't reaching this code
|
|
|
|
// to start with.
|
2010-06-23 04:46:27 +00:00
|
|
|
newContext =
|
|
|
|
styleSet->ReparentStyleContext(oldContext, parentContext,
|
|
|
|
ElementForStyleContext(aParentContent,
|
|
|
|
aFrame,
|
|
|
|
pseudoType));
|
|
|
|
} else if (pseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
|
|
|
newContext = styleSet->ResolveAnonymousBoxStyle(pseudoTag,
|
|
|
|
parentContext);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Element* element = ElementForStyleContext(aParentContent,
|
|
|
|
aFrame,
|
|
|
|
pseudoType);
|
|
|
|
if (pseudoTag) {
|
|
|
|
if (pseudoTag == nsCSSPseudoElements::before ||
|
|
|
|
pseudoTag == nsCSSPseudoElements::after) {
|
|
|
|
// XXX what other pseudos do we need to treat like this?
|
|
|
|
newContext = styleSet->ProbePseudoElementStyle(element,
|
2009-12-11 07:37:40 +00:00
|
|
|
pseudoType,
|
2011-05-25 00:19:09 +00:00
|
|
|
parentContext,
|
|
|
|
aTreeMatchContext);
|
2010-06-23 04:46:27 +00:00
|
|
|
if (!newContext) {
|
|
|
|
// This pseudo should no longer exist; gotta reframe
|
|
|
|
NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame);
|
|
|
|
aChangeList->AppendChange(aFrame, element,
|
|
|
|
nsChangeHint_ReconstructFrame);
|
|
|
|
// We're reframing anyway; just keep the same context
|
|
|
|
newContext = oldContext;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Don't expect XUL tree stuff here, since it needs a comparator and
|
|
|
|
// all.
|
|
|
|
NS_ASSERTION(pseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected pseudo type");
|
|
|
|
newContext = styleSet->ResolvePseudoElementStyle(element,
|
|
|
|
pseudoType,
|
|
|
|
parentContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(localContent,
|
|
|
|
"non pseudo-element frame without content node");
|
2011-05-25 00:19:09 +00:00
|
|
|
newContext = styleSet->ResolveStyleFor(element, parentContext,
|
|
|
|
aTreeMatchContext);
|
2003-01-05 05:05:17 +00:00
|
|
|
}
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
2010-06-18 16:23:05 +00:00
|
|
|
|
1999-09-21 07:53:14 +00:00
|
|
|
NS_ASSERTION(newContext, "failed to get new style context");
|
|
|
|
if (newContext) {
|
2002-03-31 16:59:00 +00:00
|
|
|
if (!parentContext) {
|
2011-04-23 01:36:24 +00:00
|
|
|
if (oldContext->GetRuleNode() == newContext->GetRuleNode() &&
|
|
|
|
oldContext->IsLinkContext() == newContext->IsLinkContext() &&
|
|
|
|
oldContext->RelevantLinkVisited() ==
|
|
|
|
newContext->RelevantLinkVisited()) {
|
2002-03-31 16:59:00 +00:00
|
|
|
// We're the root of the style context tree and the new style
|
|
|
|
// context returned has the same rule node. This means that
|
|
|
|
// we can use FindChildWithRules to keep a lot of the old
|
|
|
|
// style contexts around. However, we need to start from the
|
|
|
|
// same root.
|
|
|
|
newContext = oldContext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-21 07:53:14 +00:00
|
|
|
if (newContext != oldContext) {
|
2009-10-17 14:31:47 +00:00
|
|
|
if (!copyFromContinuation) {
|
|
|
|
TryStartingTransition(aPresContext, aFrame->GetContent(),
|
|
|
|
oldContext, &newContext);
|
|
|
|
}
|
2009-10-08 03:22:42 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
aMinChange = CaptureChange(oldContext, newContext, aFrame,
|
2005-01-25 02:14:31 +00:00
|
|
|
content, aChangeList, aMinChange,
|
|
|
|
assumeDifferenceHint);
|
2004-01-15 03:32:06 +00:00
|
|
|
if (!(aMinChange & nsChangeHint_ReconstructFrame)) {
|
2002-08-24 14:41:28 +00:00
|
|
|
// if frame gets regenerated, let it keep old context
|
2006-03-09 18:55:21 +00:00
|
|
|
aFrame->SetStyleContext(newContext);
|
1999-09-25 05:00:41 +00:00
|
|
|
}
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
oldContext->Release();
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("resolve style context failed");
|
2009-09-11 10:46:36 +00:00
|
|
|
newContext = oldContext; // new context failed, recover...
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 16:23:05 +00:00
|
|
|
// do additional contexts
|
|
|
|
// XXXbz might be able to avoid selector matching here in some
|
|
|
|
// cases; won't worry about it for now.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t contextIndex = -1;
|
1999-09-21 07:53:14 +00:00
|
|
|
while (1 == 1) {
|
2012-07-30 14:20:58 +00:00
|
|
|
nsStyleContext* oldExtraContext = nullptr;
|
2003-02-22 00:32:13 +00:00
|
|
|
oldExtraContext = aFrame->GetAdditionalStyleContext(++contextIndex);
|
|
|
|
if (oldExtraContext) {
|
2009-09-11 10:46:36 +00:00
|
|
|
nsRefPtr<nsStyleContext> newExtraContext;
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* const extraPseudoTag = oldExtraContext->GetPseudo();
|
2009-12-11 07:37:40 +00:00
|
|
|
const nsCSSPseudoElements::Type extraPseudoType =
|
|
|
|
oldExtraContext->GetPseudoType();
|
2004-04-12 22:42:50 +00:00
|
|
|
NS_ASSERTION(extraPseudoTag &&
|
|
|
|
extraPseudoTag != nsCSSAnonBoxes::mozNonElement,
|
2003-02-22 00:32:13 +00:00
|
|
|
"extra style context is not pseudo element");
|
2009-12-11 07:37:40 +00:00
|
|
|
if (extraPseudoType == nsCSSPseudoElements::ePseudo_AnonBox) {
|
|
|
|
newExtraContext = styleSet->ResolveAnonymousBoxStyle(extraPseudoTag,
|
|
|
|
newContext);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Don't expect XUL tree stuff here, since it needs a comparator and
|
|
|
|
// all.
|
|
|
|
NS_ASSERTION(extraPseudoType <
|
|
|
|
nsCSSPseudoElements::ePseudo_PseudoElementCount,
|
|
|
|
"Unexpected type");
|
2010-04-30 13:12:06 +00:00
|
|
|
newExtraContext = styleSet->ResolvePseudoElementStyle(content->AsElement(),
|
2009-12-11 07:37:40 +00:00
|
|
|
extraPseudoType,
|
|
|
|
newContext);
|
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
if (newExtraContext) {
|
|
|
|
if (oldExtraContext != newExtraContext) {
|
2004-02-23 21:29:06 +00:00
|
|
|
aMinChange = CaptureChange(oldExtraContext, newExtraContext,
|
|
|
|
aFrame, content, aChangeList,
|
2005-01-25 02:14:31 +00:00
|
|
|
aMinChange, assumeDifferenceHint);
|
2004-01-15 03:32:06 +00:00
|
|
|
if (!(aMinChange & nsChangeHint_ReconstructFrame)) {
|
2003-02-22 00:32:13 +00:00
|
|
|
aFrame->SetAdditionalStyleContext(contextIndex, newExtraContext);
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
}
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-02 04:25:29 +00:00
|
|
|
// now look for undisplayed child content and pseudos
|
2009-01-16 21:32:09 +00:00
|
|
|
|
|
|
|
// When the root element is display:none, we still construct *some*
|
|
|
|
// frames that have the root element as their mContent, down to the
|
|
|
|
// DocElementContainingBlock.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool checkUndisplayed;
|
2009-01-16 21:32:09 +00:00
|
|
|
nsIContent *undisplayedParent;
|
|
|
|
if (pseudoTag) {
|
|
|
|
checkUndisplayed = aFrame == mPresShell->FrameConstructor()->
|
|
|
|
GetDocElementContainingBlock();
|
2012-07-30 14:20:58 +00:00
|
|
|
undisplayedParent = nullptr;
|
2009-01-16 21:32:09 +00:00
|
|
|
} else {
|
|
|
|
checkUndisplayed = !!localContent;
|
|
|
|
undisplayedParent = localContent;
|
|
|
|
}
|
|
|
|
if (checkUndisplayed && mUndisplayedMap) {
|
2012-03-13 03:54:15 +00:00
|
|
|
UndisplayedNode* undisplayed =
|
|
|
|
mUndisplayedMap->GetFirstNode(undisplayedParent);
|
|
|
|
for (AncestorFilter::AutoAncestorPusher
|
|
|
|
pushAncestor(undisplayed, aTreeMatchContext.mAncestorFilter,
|
|
|
|
undisplayedParent ? undisplayedParent->AsElement()
|
2012-07-30 14:20:58 +00:00
|
|
|
: nullptr);
|
2003-01-21 00:47:14 +00:00
|
|
|
undisplayed; undisplayed = undisplayed->mNext) {
|
2009-01-16 21:32:09 +00:00
|
|
|
NS_ASSERTION(undisplayedParent ||
|
|
|
|
undisplayed->mContent ==
|
2010-04-30 13:12:05 +00:00
|
|
|
mPresShell->GetDocument()->GetRootElement(),
|
2009-01-16 21:32:09 +00:00
|
|
|
"undisplayed node child of null must be root");
|
2009-10-29 21:17:56 +00:00
|
|
|
NS_ASSERTION(!undisplayed->mStyle->GetPseudo(),
|
2009-05-15 01:40:26 +00:00
|
|
|
"Shouldn't have random pseudo style contexts in the "
|
|
|
|
"undisplayed map");
|
2010-06-18 16:23:05 +00:00
|
|
|
nsRestyleHint thisChildHint = childRestyleHint;
|
2010-06-18 16:23:05 +00:00
|
|
|
RestyleTracker::RestyleData undisplayedRestyleData;
|
|
|
|
if (aRestyleTracker.GetRestyleData(undisplayed->mContent->AsElement(),
|
|
|
|
&undisplayedRestyleData)) {
|
2010-06-18 16:23:05 +00:00
|
|
|
thisChildHint =
|
|
|
|
nsRestyleHint(thisChildHint | undisplayedRestyleData.mRestyleHint);
|
|
|
|
}
|
|
|
|
nsRefPtr<nsStyleContext> undisplayedContext;
|
|
|
|
if (thisChildHint) {
|
|
|
|
undisplayedContext =
|
|
|
|
styleSet->ResolveStyleFor(undisplayed->mContent->AsElement(),
|
2011-05-25 00:19:09 +00:00
|
|
|
newContext,
|
|
|
|
aTreeMatchContext);
|
2010-06-18 16:23:05 +00:00
|
|
|
} else {
|
|
|
|
undisplayedContext =
|
2010-06-23 04:46:27 +00:00
|
|
|
styleSet->ReparentStyleContext(undisplayed->mStyle, newContext,
|
|
|
|
undisplayed->mContent->AsElement());
|
2010-06-18 16:23:05 +00:00
|
|
|
}
|
1999-10-02 04:25:29 +00:00
|
|
|
if (undisplayedContext) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* display = undisplayedContext->GetStyleDisplay();
|
1999-10-02 04:25:29 +00:00
|
|
|
if (display->mDisplay != NS_STYLE_DISPLAY_NONE) {
|
2010-04-30 13:12:06 +00:00
|
|
|
NS_ASSERTION(undisplayed->mContent,
|
|
|
|
"Must have undisplayed content");
|
2012-07-30 14:20:58 +00:00
|
|
|
aChangeList->AppendChange(nullptr, undisplayed->mContent,
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_STYLE_HINT_FRAMECHANGE);
|
2002-05-01 00:36:50 +00:00
|
|
|
// The node should be removed from the undisplayed map when
|
|
|
|
// we reframe it.
|
2002-03-27 02:38:13 +00:00
|
|
|
} else {
|
|
|
|
// update the undisplayed node with the new context
|
|
|
|
undisplayed->mStyle = undisplayedContext;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 16:23:05 +00:00
|
|
|
// Check whether we might need to create a new ::before frame.
|
|
|
|
// There's no need to do this if we're planning to reframe already
|
|
|
|
// or if we're not forcing restyles on kids.
|
|
|
|
if (!(aMinChange & nsChangeHint_ReconstructFrame) &&
|
|
|
|
childRestyleHint) {
|
2012-05-30 03:45:17 +00:00
|
|
|
// Make sure not to do this for pseudo-frames or frames that
|
|
|
|
// can't have generated content.
|
|
|
|
if (!pseudoTag &&
|
2012-06-11 22:21:35 +00:00
|
|
|
((aFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
|
|
|
|
// Our content insertion frame might have gotten flagged
|
|
|
|
(aFrame->GetContentInsertionFrame()->GetStateBits() &
|
|
|
|
NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
|
2003-01-05 05:05:17 +00:00
|
|
|
// Check for a new :before pseudo and an existing :before
|
2006-04-08 14:17:35 +00:00
|
|
|
// frame, but only if the frame is the first continuation.
|
|
|
|
nsIFrame* prevContinuation = aFrame->GetPrevContinuation();
|
|
|
|
if (!prevContinuation) {
|
2003-01-05 05:05:17 +00:00
|
|
|
// Checking for a :before frame is cheaper than getting the
|
|
|
|
// :before style context.
|
2005-02-18 06:06:47 +00:00
|
|
|
if (!nsLayoutUtils::GetBeforeFrame(aFrame) &&
|
2003-04-21 23:06:40 +00:00
|
|
|
nsLayoutUtils::HasPseudoStyle(localContent, newContext,
|
2009-12-11 07:37:40 +00:00
|
|
|
nsCSSPseudoElements::ePseudo_before,
|
2003-04-21 23:06:40 +00:00
|
|
|
aPresContext)) {
|
|
|
|
// Have to create the new :before frame
|
|
|
|
NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame);
|
2004-02-23 21:29:06 +00:00
|
|
|
aChangeList->AppendChange(aFrame, content,
|
|
|
|
nsChangeHint_ReconstructFrame);
|
2003-01-05 05:05:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 16:23:05 +00:00
|
|
|
// Check whether we might need to create a new ::after frame.
|
|
|
|
// There's no need to do this if we're planning to reframe already
|
|
|
|
// or if we're not forcing restyles on kids.
|
|
|
|
if (!(aMinChange & nsChangeHint_ReconstructFrame) &&
|
|
|
|
childRestyleHint) {
|
2012-05-30 03:45:17 +00:00
|
|
|
// Make sure not to do this for pseudo-frames or frames that
|
|
|
|
// can't have generated content.
|
|
|
|
if (!pseudoTag &&
|
2012-06-11 22:21:35 +00:00
|
|
|
((aFrame->GetStateBits() & NS_FRAME_MAY_HAVE_GENERATED_CONTENT) ||
|
|
|
|
// Our content insertion frame might have gotten flagged
|
|
|
|
(aFrame->GetContentInsertionFrame()->GetStateBits() &
|
|
|
|
NS_FRAME_MAY_HAVE_GENERATED_CONTENT))) {
|
2003-04-21 23:06:40 +00:00
|
|
|
// Check for new :after content, but only if the frame is the
|
2006-04-08 14:17:35 +00:00
|
|
|
// last continuation.
|
|
|
|
nsIFrame* nextContinuation = aFrame->GetNextContinuation();
|
2003-01-05 05:05:17 +00:00
|
|
|
|
2006-04-08 14:17:35 +00:00
|
|
|
if (!nextContinuation) {
|
2003-04-21 23:06:40 +00:00
|
|
|
// Getting the :after frame is more expensive than getting the pseudo
|
|
|
|
// context, so get the pseudo context first.
|
|
|
|
if (nsLayoutUtils::HasPseudoStyle(localContent, newContext,
|
2009-12-11 07:37:40 +00:00
|
|
|
nsCSSPseudoElements::ePseudo_after,
|
2003-04-21 23:06:40 +00:00
|
|
|
aPresContext) &&
|
2005-02-18 06:06:47 +00:00
|
|
|
!nsLayoutUtils::GetAfterFrame(aFrame)) {
|
2003-04-21 23:06:40 +00:00
|
|
|
// have to create the new :after frame
|
|
|
|
NS_UpdateHint(aMinChange, nsChangeHint_ReconstructFrame);
|
2004-02-23 21:29:06 +00:00
|
|
|
aChangeList->AppendChange(aFrame, content,
|
|
|
|
nsChangeHint_ReconstructFrame);
|
2003-01-05 05:05:17 +00:00
|
|
|
}
|
2003-04-21 23:06:40 +00:00
|
|
|
}
|
2003-01-05 05:05:17 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-30 07:55:51 +00:00
|
|
|
|
2004-01-15 03:32:06 +00:00
|
|
|
if (!(aMinChange & nsChangeHint_ReconstructFrame)) {
|
2010-11-13 17:49:26 +00:00
|
|
|
DesiredA11yNotifications kidsDesiredA11yNotification =
|
|
|
|
aDesiredA11yNotifications;
|
|
|
|
#ifdef ACCESSIBILITY
|
2010-12-04 10:07:53 +00:00
|
|
|
A11yNotificationType ourA11yNotification = eDontNotify;
|
2010-11-13 17:49:26 +00:00
|
|
|
// Notify a11y for primary frame only if it's a root frame of visibility
|
|
|
|
// changes or its parent frame was hidden while it stays visible and
|
|
|
|
// it is not inside a {ib} split or is the first frame of {ib} split.
|
2011-07-19 08:30:19 +00:00
|
|
|
if (nsIPresShell::IsAccessibilityActive() &&
|
|
|
|
!aFrame->GetPrevContinuation() &&
|
2010-11-13 17:49:26 +00:00
|
|
|
!nsLayoutUtils::FrameIsNonFirstInIBSplit(aFrame)) {
|
|
|
|
if (aDesiredA11yNotifications == eSendAllNotifications) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isFrameVisible = newContext->GetStyleVisibility()->IsVisible();
|
2010-11-13 17:49:26 +00:00
|
|
|
if (isFrameVisible != wasFrameVisible) {
|
|
|
|
if (isFrameVisible) {
|
|
|
|
// Notify a11y the element (perhaps with its children) was shown.
|
|
|
|
// We don't fall into this case if this element gets or stays shown
|
|
|
|
// while its parent becomes hidden.
|
|
|
|
kidsDesiredA11yNotification = eSkipNotifications;
|
|
|
|
ourA11yNotification = eNotifyShown;
|
|
|
|
} else {
|
|
|
|
// The element is being hidden; its children may stay visible, or
|
|
|
|
// become visible after being hidden previously. If we'll find
|
|
|
|
// visible children then we should notify a11y about that as if
|
|
|
|
// they were inserted into tree. Notify a11y this element was
|
|
|
|
// hidden.
|
|
|
|
kidsDesiredA11yNotification = eNotifyIfShown;
|
|
|
|
ourA11yNotification = eNotifyHidden;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (aDesiredA11yNotifications == eNotifyIfShown &&
|
|
|
|
newContext->GetStyleVisibility()->IsVisible()) {
|
|
|
|
// Notify a11y that element stayed visible while its parent was
|
|
|
|
// hidden.
|
|
|
|
aVisibleKidsOfHiddenElement.AppendElement(aFrame->GetContent());
|
|
|
|
kidsDesiredA11yNotification = eSkipNotifications;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
// There is no need to waste time crawling into a frame's children on a frame change.
|
|
|
|
// The act of reconstructing frames will force new style contexts to be resolved on all
|
|
|
|
// of this frame's descendants anyway, so we want to avoid wasting time processing
|
|
|
|
// style contexts that we're just going to throw away anyway. - dwh
|
|
|
|
|
|
|
|
// now do children
|
2011-08-24 20:54:29 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
2012-03-13 03:54:15 +00:00
|
|
|
for (AncestorFilter::AutoAncestorPusher
|
|
|
|
pushAncestor(!lists.IsDone(),
|
|
|
|
aTreeMatchContext.mAncestorFilter,
|
|
|
|
content && content->IsElement() ? content->AsElement()
|
2012-07-30 14:20:58 +00:00
|
|
|
: nullptr);
|
2012-03-13 03:54:15 +00:00
|
|
|
!lists.IsDone(); lists.Next()) {
|
2011-08-24 20:54:29 +00:00
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* child = childFrames.get();
|
2012-03-16 17:13:14 +00:00
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
// only do frames that are in flow
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::placeholderFrame == child->GetType()) { // placeholder
|
2002-03-27 02:38:13 +00:00
|
|
|
// get out of flow frame and recur there
|
|
|
|
nsIFrame* outOfFlowFrame =
|
2005-04-14 15:30:35 +00:00
|
|
|
nsPlaceholderFrame::GetRealFrameForPlaceholder(child);
|
2001-12-17 22:51:39 +00:00
|
|
|
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
2002-03-27 02:38:13 +00:00
|
|
|
NS_ASSERTION(outOfFlowFrame != resolvedChild,
|
|
|
|
"out-of-flow frame not a true descendant");
|
2001-12-17 22:51:39 +00:00
|
|
|
|
2004-05-05 00:34:22 +00:00
|
|
|
// Note that the out-of-flow may not be a geometric descendant of
|
|
|
|
// the frame where we started the reresolve. Therefore, even if
|
|
|
|
// aMinChange already includes nsChangeHint_ReflowFrame we don't
|
|
|
|
// want to pass that on to the out-of-flow reresolve, since that
|
2009-07-27 08:47:02 +00:00
|
|
|
// can lead to the out-of-flow not getting reflowed when it should
|
2004-05-05 00:34:22 +00:00
|
|
|
// be (eg a reresolve starting at <body> that involves reflowing
|
|
|
|
// the <body> would miss reflowing fixed-pos nodes that also need
|
|
|
|
// reflow). In the cases when the out-of-flow _is_ a geometric
|
|
|
|
// descendant of a frame we already have a reflow hint for,
|
|
|
|
// reflow coalescing should keep us from doing the work twice.
|
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
// |nsFrame::GetParentStyleContextFrame| checks being out
|
|
|
|
// of flow so that this works correctly.
|
2010-08-10 22:04:43 +00:00
|
|
|
do {
|
|
|
|
ReResolveStyleContext(aPresContext, outOfFlowFrame,
|
|
|
|
content, aChangeList,
|
|
|
|
NS_SubtractHint(aMinChange,
|
|
|
|
nsChangeHint_ReflowFrame),
|
|
|
|
childRestyleHint,
|
2010-11-13 17:49:26 +00:00
|
|
|
aRestyleTracker,
|
|
|
|
kidsDesiredA11yNotification,
|
2011-05-25 00:19:09 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
aTreeMatchContext);
|
2011-02-16 13:14:14 +00:00
|
|
|
} while ((outOfFlowFrame = outOfFlowFrame->GetNextContinuation()));
|
2000-09-12 22:47:09 +00:00
|
|
|
|
2002-03-27 02:38:13 +00:00
|
|
|
// reresolve placeholder's context under the same parent
|
|
|
|
// as the out-of-flow frame
|
|
|
|
ReResolveStyleContext(aPresContext, child, content,
|
2009-07-30 07:55:51 +00:00
|
|
|
aChangeList, aMinChange,
|
2010-06-18 16:23:05 +00:00
|
|
|
childRestyleHint,
|
2010-11-13 17:49:26 +00:00
|
|
|
aRestyleTracker,
|
|
|
|
kidsDesiredA11yNotification,
|
2011-05-25 00:19:09 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
aTreeMatchContext);
|
2001-12-17 22:51:39 +00:00
|
|
|
}
|
|
|
|
else { // regular child frame
|
2002-03-27 02:38:13 +00:00
|
|
|
if (child != resolvedChild) {
|
|
|
|
ReResolveStyleContext(aPresContext, child, content,
|
2009-07-30 07:55:51 +00:00
|
|
|
aChangeList, aMinChange,
|
2010-06-18 16:23:05 +00:00
|
|
|
childRestyleHint,
|
2010-11-13 17:49:26 +00:00
|
|
|
aRestyleTracker,
|
|
|
|
kidsDesiredA11yNotification,
|
2011-05-25 00:19:09 +00:00
|
|
|
aVisibleKidsOfHiddenElement,
|
|
|
|
aTreeMatchContext);
|
2001-12-17 22:51:39 +00:00
|
|
|
} else {
|
2005-11-20 22:05:24 +00:00
|
|
|
NOISY_TRACE_FRAME("child frame already resolved as descendant, skipping",aFrame);
|
2001-12-17 22:51:39 +00:00
|
|
|
}
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
2001-12-17 22:51:39 +00:00
|
|
|
// XXX need to do overflow frames???
|
2000-09-12 22:47:09 +00:00
|
|
|
|
2010-11-13 17:49:26 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Send notifications about visibility changes.
|
|
|
|
if (ourA11yNotification == eNotifyShown) {
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2010-11-13 17:49:26 +00:00
|
|
|
if (accService) {
|
|
|
|
nsIPresShell* presShell = aFrame->PresContext()->GetPresShell();
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
|
|
|
|
accService->ContentRangeInserted(presShell, content->GetParent(),
|
|
|
|
content,
|
|
|
|
content->GetNextSibling());
|
|
|
|
}
|
|
|
|
} else if (ourA11yNotification == eNotifyHidden) {
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2010-11-13 17:49:26 +00:00
|
|
|
if (accService) {
|
|
|
|
nsIPresShell* presShell = aFrame->PresContext()->GetPresShell();
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
|
|
|
accService->ContentRemoved(presShell, content->GetParent(), content);
|
|
|
|
|
|
|
|
// Process children staying shown.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t visibleContentCount = aVisibleKidsOfHiddenElement.Length();
|
|
|
|
for (uint32_t idx = 0; idx < visibleContentCount; idx++) {
|
2010-11-13 17:49:26 +00:00
|
|
|
nsIContent* content = aVisibleKidsOfHiddenElement[idx];
|
|
|
|
accService->ContentRangeInserted(presShell, content->GetParent(),
|
|
|
|
content, content->GetNextSibling());
|
|
|
|
}
|
|
|
|
aVisibleKidsOfHiddenElement.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
2004-02-23 21:29:06 +00:00
|
|
|
|
2005-01-25 02:14:31 +00:00
|
|
|
return aMinChange;
|
2000-09-12 22:47:09 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 19:52:46 +00:00
|
|
|
void
|
2004-02-23 21:29:06 +00:00
|
|
|
nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame,
|
|
|
|
nsStyleChangeList *aChangeList,
|
2010-06-18 16:23:05 +00:00
|
|
|
nsChangeHint aMinChange,
|
2010-06-18 16:23:05 +00:00
|
|
|
RestyleTracker& aRestyleTracker,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRestyleDescendants)
|
1999-09-21 07:53:14 +00:00
|
|
|
{
|
2012-03-13 03:54:15 +00:00
|
|
|
nsIContent *content = aFrame->GetContent();
|
2008-02-08 19:52:46 +00:00
|
|
|
if (aMinChange) {
|
2012-03-13 03:54:15 +00:00
|
|
|
aChangeList->AppendChange(aFrame, content, aMinChange);
|
2008-02-08 19:52:46 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
nsChangeHint topLevelChange = aMinChange;
|
|
|
|
|
1999-10-15 23:14:44 +00:00
|
|
|
nsIFrame* frame = aFrame;
|
2002-09-12 20:33:11 +00:00
|
|
|
nsIFrame* frame2 = aFrame;
|
1999-09-21 07:53:14 +00:00
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
NS_ASSERTION(!frame->GetPrevContinuation(), "must start with the first in flow");
|
2002-03-16 15:26:56 +00:00
|
|
|
|
2002-09-12 20:33:11 +00:00
|
|
|
// We want to start with this frame and walk all its next-in-flows,
|
|
|
|
// as well as all its special siblings and their next-in-flows,
|
|
|
|
// reresolving style on all the frames we encounter in this walk.
|
2004-08-24 18:50:29 +00:00
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
FramePropertyTable *propTable = GetPresContext()->PropertyTable();
|
2004-08-24 18:50:29 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
TreeMatchContext treeMatchContext(true,
|
2011-05-25 00:19:09 +00:00
|
|
|
nsRuleWalker::eRelevantLinkUnvisited,
|
|
|
|
mPresShell->GetDocument());
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIContent *parent = content ? content->GetParent() : nullptr;
|
2012-03-13 03:54:15 +00:00
|
|
|
Element *parentElement =
|
2012-07-30 14:20:58 +00:00
|
|
|
parent && parent->IsElement() ? parent->AsElement() : nullptr;
|
2012-03-13 03:54:15 +00:00
|
|
|
treeMatchContext.mAncestorFilter.Init(parentElement);
|
2010-11-13 17:49:26 +00:00
|
|
|
nsTArray<nsIContent*> visibleKidsOfHiddenElement;
|
1999-10-15 23:14:44 +00:00
|
|
|
do {
|
2002-09-12 20:33:11 +00:00
|
|
|
// Outer loop over special siblings
|
|
|
|
do {
|
|
|
|
// Inner loop over next-in-flows of the current frame
|
2004-02-23 21:29:06 +00:00
|
|
|
nsChangeHint frameChange =
|
2012-07-30 14:20:58 +00:00
|
|
|
ReResolveStyleContext(GetPresContext(), frame, nullptr,
|
2010-06-18 16:23:05 +00:00
|
|
|
aChangeList, topLevelChange,
|
|
|
|
aRestyleDescendants ?
|
|
|
|
eRestyle_Subtree : eRestyle_Self,
|
2010-11-13 17:49:26 +00:00
|
|
|
aRestyleTracker,
|
|
|
|
eSendAllNotifications,
|
2011-05-25 00:19:09 +00:00
|
|
|
visibleKidsOfHiddenElement,
|
|
|
|
treeMatchContext);
|
2004-02-23 21:29:06 +00:00
|
|
|
NS_UpdateHint(topLevelChange, frameChange);
|
1999-09-21 07:53:14 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
if (topLevelChange & nsChangeHint_ReconstructFrame) {
|
2002-09-12 20:33:11 +00:00
|
|
|
// If it's going to cause a framechange, then don't bother
|
|
|
|
// with the continuations or special siblings since they'll be
|
|
|
|
// clobbered by the frame reconstruct anyway.
|
2006-02-21 21:33:47 +00:00
|
|
|
NS_ASSERTION(!frame->GetPrevContinuation(),
|
2004-09-14 02:28:03 +00:00
|
|
|
"continuing frame had more severe impact than first-in-flow");
|
2008-02-08 19:52:46 +00:00
|
|
|
return;
|
2002-09-12 20:33:11 +00:00
|
|
|
}
|
2001-05-23 06:39:34 +00:00
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
frame = frame->GetNextContinuation();
|
2002-09-12 20:33:11 +00:00
|
|
|
} while (frame);
|
|
|
|
|
|
|
|
// Might we have special siblings?
|
2003-06-29 03:43:05 +00:00
|
|
|
if (!(frame2->GetStateBits() & NS_FRAME_IS_SPECIAL)) {
|
2002-09-12 20:33:11 +00:00
|
|
|
// nothing more to do here
|
2008-02-08 19:52:46 +00:00
|
|
|
return;
|
2002-09-12 20:33:11 +00:00
|
|
|
}
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
frame2 = static_cast<nsIFrame*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(propTable->Get(frame2, nsIFrame::IBSplitSpecialSibling()));
|
2002-09-12 20:33:11 +00:00
|
|
|
frame = frame2;
|
|
|
|
} while (frame2);
|
1999-09-21 07:53:14 +00:00
|
|
|
}
|
|
|
|
|
2000-06-15 00:35:46 +00:00
|
|
|
// Capture state for a given frame.
|
|
|
|
// Accept a content id here, in some cases we may not have content (scroll position)
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState,
|
|
|
|
nsIStatefulFrame::SpecialStateID aID)
|
1999-08-31 14:35:50 +00:00
|
|
|
{
|
2004-02-23 21:29:06 +00:00
|
|
|
if (!aFrame || !aState) {
|
|
|
|
NS_WARNING("null frame, or state");
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Only capture state for stateful frames
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
|
2001-05-30 11:26:21 +00:00
|
|
|
if (!statefulFrame) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
2001-05-30 11:26:21 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Capture the state, exit early if we get null (nothing to save)
|
2005-01-27 22:52:53 +00:00
|
|
|
nsAutoPtr<nsPresState> frameState;
|
2005-12-06 23:56:17 +00:00
|
|
|
nsresult rv = statefulFrame->SaveState(aID, getter_Transfers(frameState));
|
2001-05-30 11:26:21 +00:00
|
|
|
if (!frameState) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
2001-05-30 11:26:21 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Generate the hash key to store the state under
|
|
|
|
// Exit early if we get empty key
|
|
|
|
nsCAutoString stateKey;
|
2005-01-15 17:47:23 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIDocument* doc = content ? content->GetCurrentDoc() : nullptr;
|
2005-01-15 17:47:23 +00:00
|
|
|
rv = nsContentUtils::GenerateStateKey(content, doc, aID, stateKey);
|
2001-05-30 11:26:21 +00:00
|
|
|
if(NS_FAILED(rv) || stateKey.IsEmpty()) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
1999-08-31 14:35:50 +00:00
|
|
|
}
|
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Store the state
|
2005-01-27 22:52:53 +00:00
|
|
|
rv = aState->AddState(stateKey, frameState);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// aState owns frameState now.
|
|
|
|
frameState.forget();
|
|
|
|
}
|
1999-10-23 01:43:49 +00:00
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::CaptureFrameState(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState)
|
1999-10-23 01:43:49 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
CaptureFrameStateFor(aFrame, aState);
|
1999-10-23 01:43:49 +00:00
|
|
|
|
|
|
|
// Now capture state recursively for the frame hierarchy rooted at aFrame
|
2011-08-24 20:54:29 +00:00
|
|
|
nsIFrame::ChildListIterator lists(aFrame);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
2012-05-10 01:27:47 +00: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 01:43:49 +00:00
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
}
|
|
|
|
|
2000-06-15 00:35:46 +00:00
|
|
|
// Restore state for a given frame.
|
|
|
|
// Accept a content id here, in some cases we may not have content (scroll position)
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::RestoreFrameStateFor(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState,
|
|
|
|
nsIStatefulFrame::SpecialStateID aID)
|
1999-08-31 14:35:50 +00:00
|
|
|
{
|
2004-02-23 21:29:06 +00:00
|
|
|
if (!aFrame || !aState) {
|
|
|
|
NS_WARNING("null frame or state");
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2008-12-03 17:55:14 +00:00
|
|
|
// Only restore state for stateful frames
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
|
2001-05-30 11:26:21 +00:00
|
|
|
if (!statefulFrame) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
2001-05-30 11:26:21 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Generate the hash key the state was stored under
|
|
|
|
// Exit early if we get empty key
|
2003-06-29 03:43:05 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2001-09-29 17:50:15 +00: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-23 21:29:06 +00:00
|
|
|
return;
|
2001-09-29 17:50:15 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
nsCAutoString stateKey;
|
2005-01-15 17:47:23 +00:00
|
|
|
nsIDocument* doc = content->GetCurrentDoc();
|
|
|
|
nsresult rv = nsContentUtils::GenerateStateKey(content, doc, aID, stateKey);
|
2001-11-02 07:40:01 +00:00
|
|
|
if (NS_FAILED(rv) || stateKey.IsEmpty()) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
2001-05-30 11:26:21 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Get the state from the hash
|
2005-01-27 22:52:53 +00:00
|
|
|
nsPresState *frameState;
|
|
|
|
rv = aState->GetState(stateKey, &frameState);
|
2001-05-30 11:26:21 +00:00
|
|
|
if (!frameState) {
|
2004-02-23 21:29:06 +00:00
|
|
|
return;
|
2001-05-30 11:26:21 +00:00
|
|
|
}
|
2000-06-15 00:35:46 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// Restore it
|
2005-12-06 23:56:17 +00:00
|
|
|
rv = statefulFrame->RestoreState(frameState);
|
2004-02-23 21:29:06 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2001-05-30 11:26:21 +00:00
|
|
|
// If we restore ok, remove the state from the state table
|
2004-02-23 21:29:06 +00:00
|
|
|
aState->RemoveState(stateKey);
|
1999-10-23 01:43:49 +00:00
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
|
|
|
nsFrameManager::RestoreFrameState(nsIFrame* aFrame,
|
|
|
|
nsILayoutHistoryState* aState)
|
1999-10-23 01:43:49 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_PRECONDITION(nullptr != aFrame && nullptr != aState, "null parameters passed in");
|
1999-10-23 01:43:49 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
RestoreFrameStateFor(aFrame, aState);
|
1999-10-23 01:43:49 +00:00
|
|
|
|
|
|
|
// Now restore state recursively for the frame hierarchy rooted at aFrame
|
2011-08-24 20:54:29 +00: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 01:43:49 +00:00
|
|
|
}
|
2011-08-24 20:54:29 +00:00
|
|
|
}
|
1999-08-31 14:35:50 +00:00
|
|
|
}
|
|
|
|
|
1999-08-05 20:17:44 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
static PLHashNumber
|
|
|
|
HashKey(void* key)
|
|
|
|
{
|
2001-08-14 07:59:59 +00:00
|
|
|
return NS_PTR_TO_INT32(key);
|
1999-08-05 20:17:44 +00:00
|
|
|
}
|
|
|
|
|
2012-08-09 07:09:40 +00:00
|
|
|
static int
|
1999-08-05 20:17:44 +00:00
|
|
|
CompareKeys(void* key1, void* key2)
|
|
|
|
{
|
|
|
|
return key1 == key2;
|
|
|
|
}
|
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::UndisplayedMap(uint32_t aNumBuckets)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2004-03-06 04:46:11 +00:00
|
|
|
MOZ_COUNT_CTOR(nsFrameManagerBase::UndisplayedMap);
|
1999-10-02 04:25:29 +00:00
|
|
|
mTable = PL_NewHashTable(aNumBuckets, (PLHashFunction)HashKey,
|
|
|
|
(PLHashComparator)CompareKeys,
|
2012-07-30 14:20:58 +00:00
|
|
|
(PLHashComparator)nullptr,
|
|
|
|
nullptr, nullptr);
|
|
|
|
mLastLookup = nullptr;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::~UndisplayedMap(void)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2004-03-06 04:46:11 +00:00
|
|
|
MOZ_COUNT_DTOR(nsFrameManagerBase::UndisplayedMap);
|
1999-10-02 04:25:29 +00:00
|
|
|
Clear();
|
|
|
|
PL_HashTableDestroy(mTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
PLHashEntry**
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::GetEntryFor(nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
if (mLastLookup && (aParentContent == (*mLastLookup)->key)) {
|
|
|
|
return mLastLookup;
|
|
|
|
}
|
2001-08-14 07:59:59 +00:00
|
|
|
PLHashNumber hashCode = NS_PTR_TO_INT32(aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
PLHashEntry** entry = PL_HashTableRawLookup(mTable, hashCode, aParentContent);
|
|
|
|
if (*entry) {
|
|
|
|
mLastLookup = entry;
|
|
|
|
}
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
UndisplayedNode*
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::GetFirstNode(nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
PLHashEntry** entry = GetEntryFor(aParentContent);
|
|
|
|
if (*entry) {
|
|
|
|
return (UndisplayedNode*)((*entry)->value);
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::AppendNodeFor(UndisplayedNode* aNode,
|
|
|
|
nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
PLHashEntry** entry = GetEntryFor(aParentContent);
|
|
|
|
if (*entry) {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
|
|
|
while (node->mNext) {
|
2002-05-16 13:30:57 +00: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-23 21:29:06 +00:00
|
|
|
return;
|
2002-05-16 13:30:57 +00:00
|
|
|
}
|
1999-10-02 04:25:29 +00:00
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
node->mNext = aNode;
|
|
|
|
}
|
|
|
|
else {
|
2001-08-14 07:59:59 +00:00
|
|
|
PLHashNumber hashCode = NS_PTR_TO_INT32(aParentContent);
|
1999-10-02 04:25:29 +00:00
|
|
|
PL_HashTableRawAdd(mTable, entry, hashCode, aParentContent, aNode);
|
2012-07-30 14:20:58 +00:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::AddNodeFor(nsIContent* aParentContent,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsStyleContext* aStyle)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
UndisplayedNode* node = new UndisplayedNode(aChild, aStyle);
|
2004-02-23 21:29:06 +00:00
|
|
|
|
|
|
|
AppendNodeFor(node, aParentContent);
|
|
|
|
return NS_OK;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::RemoveNodeFor(nsIContent* aParentContent,
|
|
|
|
UndisplayedNode* aNode)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
PLHashEntry** entry = GetEntryFor(aParentContent);
|
|
|
|
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 14:20:58 +00:00
|
|
|
aNode->mNext = nullptr;
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
PL_HashTableRawRemove(mTable, entry, *entry);
|
2012-07-30 14:20:58 +00:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
|
|
|
while (node->mNext) {
|
|
|
|
if (node->mNext == aNode) {
|
|
|
|
node->mNext = aNode->mNext;
|
2012-07-30 14:20:58 +00:00
|
|
|
aNode->mNext = nullptr;
|
1999-10-02 04:25:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
node = node->mNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete aNode;
|
|
|
|
}
|
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
void
|
2004-03-06 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::RemoveNodesFor(nsIContent* aParentContent)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
|
|
|
PLHashEntry** entry = GetEntryFor(aParentContent);
|
|
|
|
NS_ASSERTION(entry, "content not in map");
|
|
|
|
if (*entry) {
|
|
|
|
UndisplayedNode* node = (UndisplayedNode*)((*entry)->value);
|
2002-04-02 21:14:43 +00:00
|
|
|
NS_ASSERTION(node, "null node for non-null entry in UndisplayedMap");
|
1999-10-02 04:25:29 +00:00
|
|
|
delete node;
|
|
|
|
PL_HashTableRawRemove(mTable, entry, *entry);
|
2012-07-30 14:20:58 +00:00
|
|
|
mLastLookup = nullptr; // hashtable may have shifted bucket out from under us
|
1999-10-02 04:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-09 07:09:40 +00:00
|
|
|
static int
|
|
|
|
RemoveUndisplayedEntry(PLHashEntry* he, int i, void* arg)
|
1999-10-02 04:25:29 +00: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 04:46:11 +00:00
|
|
|
nsFrameManagerBase::UndisplayedMap::Clear(void)
|
1999-10-02 04:25:29 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mLastLookup = nullptr;
|
1999-10-02 04:25:29 +00:00
|
|
|
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
|
|
|
|
}
|
2012-07-04 15:42:29 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t nsFrameManagerBase::sGlobalGenerationNumber;
|