gecko/layout/base/nsFrameManagerBase.h
Nicholas Nethercote a5c8dbfaf4 Bug 1123151 (part 1) - Set PLDHashTable::ops consistently. r=froydnj.
Currently the setting of PLDHashTable::ops is very haphazard.

- PLDHashTable has no constructor, so it's not auto-nulled, so lots of places
  null it themselves.

- In the fallible PLDHashTable::Init() function, if the entry storage
  allocation fails we'll be left with a table that has |ops| set -- indicating
  it's been initialized -- but has null entry storage. I'm not certain this can
  cause problems but it feels unsafe, and some (but not all) callers of Init()
  null it on failure.

- PLDHashTable does not null |ops| in Finish(), so some (but not all) callers
  do this themselves.

This patch makes things simpler.

- It adds a constructor that zeroes |ops|.

- It modifies Init() so that it only sets |ops| once success is ensured.

- It zeroes |ops| in Finish().

- Finally, it removes all the now-unnecessary |ops| nulling done by the users
  of PLDHashTable.

--HG--
extra : rebase_source : bb34979c218d152562a2f9c7e5215256c111cc5b
2015-01-19 16:01:24 -08:00

83 lines
2.7 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=2:
*
* 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/.
*
* 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.
*/
/* part of nsFrameManager, to work around header inclusionordering */
#ifndef _nsFrameManagerBase_h_
#define _nsFrameManagerBase_h_
#include "nsDebug.h"
#include "pldhash.h"
class nsIFrame;
class nsIPresShell;
class nsStyleSet;
class nsFrameManagerBase
{
public:
nsFrameManagerBase()
: mPresShell(nullptr)
, mStyleSet(nullptr)
, mRootFrame(nullptr)
, mUndisplayedMap(nullptr)
, mDisplayContentsMap(nullptr)
, mIsDestroyingFrames(false)
{
}
bool IsDestroyingFrames() { return mIsDestroyingFrames; }
/*
* Gets and sets the root frame (typically the viewport). The lifetime of the
* root frame is controlled by the frame manager. When the frame manager is
* destroyed, it destroys the entire frame hierarchy.
*/
nsIFrame* GetRootFrame() const { return mRootFrame; }
void SetRootFrame(nsIFrame* aRootFrame)
{
NS_ASSERTION(!mRootFrame, "already have a root frame");
mRootFrame = aRootFrame;
}
static uint32_t GetGlobalGenerationNumber() { return sGlobalGenerationNumber; }
protected:
class UndisplayedMap;
// weak link, because the pres shell owns us
nsIPresShell* mPresShell;
// the pres shell owns the style set
nsStyleSet* mStyleSet;
nsIFrame* mRootFrame;
PLDHashTable mPlaceholderMap;
UndisplayedMap* mUndisplayedMap;
UndisplayedMap* mDisplayContentsMap;
bool mIsDestroyingFrames; // The frame manager is destroying some frame(s).
// The frame tree generation number
// We use this to avoid unnecessary screenshotting
// on Android. Unfortunately, this is static to match
// the single consumer which is also static. Keeping
// this the same greatly simplifies lifetime issues and
// makes sure we always using the correct number.
// A per PresContext generation number is available
// via nsPresContext::GetDOMGeneration
static uint32_t sGlobalGenerationNumber;
};
#endif