Second try at landing support for content node properties (bug 253888). r=jst, sr=dbaron.

This commit is contained in:
bryner%brianryner.com 2004-08-22 04:58:44 +00:00
Родитель 01147f5d80
Коммит d86c91ac3a
50 изменённых файлов: 1235 добавлений и 945 удалений

Просмотреть файл

@ -94,4 +94,10 @@
#define NS_CONTENT_BLOCKED_SHOW_ALT \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 13)
#define NS_PROPTABLE_PROP_NOT_THERE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_CONTENT, 14)
#define NS_PROPTABLE_PROP_OVERWRITTEN \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_CONTENT, 15)
#endif // nsContentErrors_h___

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsEvent.h"
#include "nsAString.h"
#include "nsContentErrors.h"
#include "nsPropertyTable.h"
// Forward declarations
class nsIAtom;
@ -611,6 +612,27 @@ public:
return PR_TRUE;
}
/* Methods for manipulating content node properties. For documentation on
* properties, see nsPropertyTable.h.
*/
virtual void* GetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull) const
{ if (aStatus) *aStatus = NS_ERROR_NOT_IMPLEMENTED; return nsnull; }
virtual nsresult SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor = nsnull)
{ return NS_ERROR_NOT_IMPLEMENTED; }
virtual nsresult DeleteProperty(nsIAtom *aPropertyName)
{ return NS_ERROR_NOT_IMPLEMENTED; }
virtual void* UnsetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull)
{ if (aStatus) *aStatus = NS_ERROR_NOT_IMPLEMENTED; return nsnull; }
#ifdef DEBUG
/**
* List the content (and anything it contains) out to the given

Просмотреть файл

@ -51,6 +51,7 @@
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "mozFlushType.h"
#include "nsPropertyTable.h"
class nsIAtom;
class nsIContent;
@ -626,6 +627,8 @@ public:
*/
virtual PRInt32 GetDefaultNamespaceID() const = 0;
nsPropertyTable* PropertyTable() { return &mPropertyTable; }
protected:
nsString mDocumentTitle;
nsCOMPtr<nsIURI> mDocumentURI;
@ -652,6 +655,9 @@ protected:
nsCOMPtr<nsIBindingManager> mBindingManager;
nsNodeInfoManager* mNodeInfoManager; // [STRONG]
// Table of element properties for this document.
nsPropertyTable mPropertyTable;
// True if BIDI is enabled.
PRBool mBidiEnabled;

Просмотреть файл

@ -1731,7 +1731,13 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
// check the document on the nodeinfo to see whether we need a
// new nodeinfo
if (aDocument != GetOwnerDoc()) {
nsIDocument *ownerDocument = GetOwnerDoc();
if (aDocument != ownerDocument) {
if (HasProperties()) {
ownerDocument->PropertyTable()->DeleteAllPropertiesFor(this);
}
// get a new nodeinfo
nsNodeInfoManager* nodeInfoManager = aDocument->NodeInfoManager();
if (nodeInfoManager) {
@ -3640,3 +3646,50 @@ nsGenericElement::GetContentsAsText(nsAString& aText)
}
}
}
void*
nsGenericElement::GetProperty(nsIAtom *aPropertyName, nsresult *aStatus) const
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->GetProperty(this, aPropertyName, aStatus);
}
nsresult
nsGenericElement::SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor)
{
nsIDocument *doc = GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
nsresult rv = doc->PropertyTable()->SetProperty(this, aPropertyName,
aValue, aDtor, nsnull);
if (NS_SUCCEEDED(rv))
SetFlags(GENERIC_ELEMENT_HAS_PROPERTIES);
return rv;
}
nsresult
nsGenericElement::DeleteProperty(nsIAtom *aPropertyName)
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->DeleteProperty(this, aPropertyName);
}
void*
nsGenericElement::UnsetProperty(nsIAtom *aPropertyName, nsresult *aStatus)
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->UnsetProperty(this, aPropertyName, aStatus);
}

Просмотреть файл

@ -85,8 +85,11 @@ typedef unsigned long PtrBits;
/** Whether this content is anonymous */
#define GENERIC_ELEMENT_IS_ANONYMOUS 0x00000008U
/** Whether this content has had any properties set on it */
#define GENERIC_ELEMENT_HAS_PROPERTIES 0x00000010U
/** The number of bits to shift the bit field to get at the content ID */
#define GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET 4
#define GENERIC_ELEMENT_CONTENT_ID_BITS_OFFSET 5
/** This mask masks out the bits that are used for the content ID */
#define GENERIC_ELEMENT_CONTENT_ID_MASK \
@ -412,6 +415,14 @@ public:
virtual PRBool IsContentOfType(PRUint32 aFlags) const;
virtual nsresult GetListenerManager(nsIEventListenerManager** aResult);
virtual already_AddRefed<nsIURI> GetBaseURI() const;
virtual void* GetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull) const;
virtual nsresult SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor);
virtual nsresult DeleteProperty(nsIAtom *aPropertyName);
virtual void* UnsetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull);
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;
virtual void DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
@ -736,6 +747,13 @@ protected:
sEventListenerManagersHash.ops);
}
PRBool HasProperties() const
{
PtrBits flags = GetFlags();
return (flags & GENERIC_ELEMENT_HAS_PROPERTIES) != 0;
}
/**
* GetContentsAsText will take all the textnodes that are children
* of |this| and concatenate the text in them into aText. It

Просмотреть файл

@ -0,0 +1,263 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* 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.
*/
#include "nsPropertyTable.h"
#include "pldhash.h"
#include "nsContentErrors.h"
#include "nsIAtom.h"
struct PropertyListMapEntry : public PLDHashEntryHdr {
const void *key;
void *value;
};
//----------------------------------------------------------------------
struct nsPropertyTable::PropertyList {
nsCOMPtr<nsIAtom> mName; // property name
PLDHashTable mObjectValueMap; // map of object/value pairs
NSPropertyDtorFunc mDtorFunc; // property specific value dtor function
void* mDtorData;
PropertyList* mNext;
PropertyList(nsIAtom* aName,
NSPropertyDtorFunc aDtorFunc) NS_HIDDEN;
~PropertyList() NS_HIDDEN;
// Removes the property associated with the given object, and destroys
// the property value
NS_HIDDEN_(PRBool) DeletePropertyFor(const void * aObject);
// Destroy all remaining properties (without removing them)
NS_HIDDEN_(void) Destroy();
};
nsPropertyTable::~nsPropertyTable()
{
if (mPropertyList) {
while (mPropertyList) {
PropertyList* tmp = mPropertyList;
mPropertyList = mPropertyList->mNext;
tmp->Destroy();
delete tmp;
}
}
}
void
nsPropertyTable::DeleteAllPropertiesFor(const void *aObject)
{
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
prop->DeletePropertyFor(aObject);
}
}
void*
nsPropertyTable::GetPropertyInternal(const void *aObject,
nsIAtom *aPropertyName,
PRBool aRemove,
nsresult *aResult)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
void *propValue = nsnull;
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mObjectValueMap, aObject,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
propValue = entry->value;
if (aRemove) {
// don't call propertyList->mDtorFunc. That's the caller's job now.
PL_DHashTableRawRemove(&propertyList->mObjectValueMap, entry);
}
rv = NS_OK;
}
}
if (aResult)
*aResult = rv;
return propValue;
}
nsresult
nsPropertyTable::SetProperty(const void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
NSPropertyDtorFunc aPropDtorFunc,
void *aPropDtorData)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
// Make sure the dtor function matches
if (aPropDtorFunc != propertyList->mDtorFunc) {
return NS_ERROR_INVALID_ARG;
}
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc);
if (!propertyList)
return NS_ERROR_OUT_OF_MEMORY;
if (!propertyList->mObjectValueMap.ops) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}
propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
// The current property value (if there is one) is replaced and the current
// value is destroyed
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mObjectValueMap, aObject, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {
propertyList->mDtorFunc(NS_CONST_CAST(void*, entry->key), aPropertyName,
entry->value, propertyList->mDtorData);
result = NS_PROPTABLE_PROP_OVERWRITTEN;
}
entry->key = aObject;
entry->value = aPropertyValue;
return result;
}
nsresult
nsPropertyTable::DeleteProperty(const void *aObject,
nsIAtom *aPropertyName)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
if (propertyList->DeletePropertyFor(aObject))
return NS_OK;
}
return NS_PROPTABLE_PROP_NOT_THERE;
}
nsPropertyTable::PropertyList*
nsPropertyTable::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
for (result = mPropertyList; result; result = result->mNext) {
if (result->mName.get() == aPropertyName) {
break;
}
}
return result;
}
//----------------------------------------------------------------------
nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
NSPropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mDtorData(nsnull), mNext(nsnull)
{
PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsPropertyTable::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mObjectValueMap);
}
PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsPropertyTable::PropertyList *propList =
NS_STATIC_CAST(nsPropertyTable::PropertyList*, table->data);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
propList->mDtorFunc(NS_CONST_CAST(void*, entry->key), propList->mName,
entry->value, propList->mDtorData);
return PL_DHASH_NEXT;
}
void
nsPropertyTable::PropertyList::Destroy()
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
PL_DHashTableEnumerate(&mObjectValueMap, DestroyPropertyEnumerator,
nsnull);
}
PRBool
nsPropertyTable::PropertyList::DeletePropertyFor(const void* aObject)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mObjectValueMap, aObject, PL_DHASH_LOOKUP));
if (!PL_DHASH_ENTRY_IS_BUSY(entry))
return PR_FALSE;
if (mDtorFunc)
mDtorFunc(NS_CONST_CAST(void*, aObject), mName,
entry->value, mDtorData);
PL_DHashTableRawRemove(&mObjectValueMap, entry);
return PR_TRUE;
}

Просмотреть файл

@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* 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.
*/
/**
* nsPropertyTable allows a set of arbitrary key/value pairs to be stored
* for any number of nodes, in a global hashtable rather than on the nodes
* themselves. Nodes can be any type of object; the hashtable keys are
* nsIAtom pointers, and the values are void pointers.
*/
#ifndef nsPropertyTable_h_
#define nsPropertyTable_h_
#include "nscore.h"
class nsIAtom;
/**
* Callback type for property destructors. |aObject| is the object
* the property is being removed for, |aPropertyName| is the property
* being removed, |aPropertyValue| is the value of the property, and |aData|
* is the opaque destructor data that was passed to SetProperty().
**/
typedef void
(*NSPropertyDtorFunc)(void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
void *aData);
class nsPropertyTable
{
public:
/**
* Get the value of the property |aPropertyName| for node |aObject|.
* |aResult|, if supplied, is filled in with a return status code.
**/
void* GetProperty(const void *aObject,
nsIAtom *aPropertyName,
nsresult *aResult = nsnull)
{ return GetPropertyInternal(aObject, aPropertyName, PR_FALSE, aResult); }
/**
* Set the value of the property |aPropertyName| to |aPropertyValue|
* for node |aObject|. |aDtor| is a destructor for the property value
* to be called if the property is removed. It can be null if no
* destructor is required. |aDtorData| is an optional opaque context to
* be passed to the property destructor. Note that the destructor is
* global for each property name regardless of node; it is an error
* to set a given property with a different destructor than was used before
* (this will return NS_ERROR_INVALID_ARG).
**/
NS_HIDDEN_(nsresult) SetProperty(const void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
NSPropertyDtorFunc aDtor,
void *aDtorData);
/**
* Delete the property |aPropertyName| for object |aObject|.
* The property's destructor function will be called.
**/
NS_HIDDEN_(nsresult) DeleteProperty(const void *aObject,
nsIAtom *aPropertyName);
/**
* Unset the property |aPropertyName| for object |aObject|, but do not
* call the property's destructor function. The property value is returned.
**/
void* UnsetProperty(const void *aObject,
nsIAtom *aPropertyName,
nsresult *aStatus = nsnull)
{ return GetPropertyInternal(aObject, aPropertyName, PR_TRUE, aStatus); }
/**
* Deletes all of the properties for object |aObject|, calling the
* destructor function for each property.
**/
NS_HIDDEN_(void) DeleteAllPropertiesFor(const void *aObject);
~nsPropertyTable() NS_HIDDEN;
struct PropertyList;
private:
NS_HIDDEN_(void) DestroyPropertyList();
NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom *aPropertyName) const;
NS_HIDDEN_(void*) GetPropertyInternal(const void *aObject,
nsIAtom *aPropertyName,
PRBool aRemove,
nsresult *aStatus);
PropertyList *mPropertyList;
};
#endif

Просмотреть файл

@ -45,6 +45,7 @@
#include "nsIDOMAbstractView.h"
#include "nsIPrivateCompositionEvent.h"
#include "nsDOMEvent.h"
#include "nsIDOMAbstractView.h"
class nsDOMUIEvent : public nsIDOMUIEvent,
public nsIDOMNSUIEvent,

Просмотреть файл

@ -68,6 +68,7 @@ nsHTMLValue.h \
nsImageMapUtils.h \
nsLayoutAtomList.h \
nsLayoutAtoms.h \
nsPropertyTable.h \
nsRuleNode.h \
nsRuleWalker.h \
nsStyleContext.h \

Просмотреть файл

@ -55,9 +55,6 @@
#include "nsChangeHint.h"
#include "nsFrameManagerBase.h"
// Option flags for GetFrameProperty() member function
#define NS_IFRAME_MGR_REMOVE_PROP 0x0001
/**
* Frame manager interface. The frame manager serves two purposes:
* <li>provides a service for mapping from content to frame and from
@ -222,68 +219,6 @@ public:
nsIStatefulFrame::SpecialStateID aID =
nsIStatefulFrame::eNoID);
/**
* Gets a property value for a given frame.
*
* @param aFrame the frame with the property
* @param aPropertyName property name as an atom
* @param aOptions optional flags
* NS_IFRAME_MGR_REMOVE_PROP removes the property
* @param aResult NS_OK if the property is set,
* NS_IFRAME_MGR_PROP_NOT_THERE is it is not set
* @param aPropertyValue the property value or 0 if the
property is not set
* @return The property value or 0 if the property is not set
*/
NS_HIDDEN_(void*) GetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
PRUint32 aOptions,
nsresult* aResult = nsnull);
/**
* Sets the property value for a given frame.
*
* A frame may only have one property value at a time for a given property
* name. The existing property value (if there is one) is overwritten, and
* the old value destroyed
*
* @param aFrame the frame to set the property on
* @param aPropertyName property name as an atom
* @param aPropertyValue the property value
* @param aPropertyDtorFunc when setting a property you can specify the
* dtor function (can be NULL) that will be used
* to destroy the property value. There can be
* only one dtor function for a given property
* name
* @return NS_OK if successful,
* NS_IFRAME_MGR_PROP_OVERWRITTEN if there is an existing property
* value that was overwritten,
* NS_ERROR_INVALID_ARG if the dtor function does not match the
* existing dtor function
*/
NS_HIDDEN_(nsresult) SetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue,
NSFramePropertyDtorFunc aPropDtorFunc);
/**
* Removes a property and destroys its property value by calling the dtor
* function associated with the property name.
*
* When a frame is destroyed any remaining properties are automatically
* removed.
*
* @param aFrame the frame to set the property on
* @param aPropertyName property name as an atom
* @return NS_OK if the property is successfully removed,
* NS_IFRAME_MGR_PROP_NOT_THERE if the property is not set
*/
NS_HIDDEN_(nsresult) RemoveFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName);
#ifdef NS_DEBUG
/**
* DEBUG ONLY method to verify integrity of style tree versus frame tree
@ -312,10 +247,6 @@ private:
FindPostedEventFor(nsIFrame* aFrame);
NS_HIDDEN_(void) DequeuePostedEventFor(nsIFrame* aFrame);
NS_HIDDEN_(void) DestroyPropertyList(nsPresContext* aPresContext);
NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom* aPropertyName) const;
NS_HIDDEN_(void) RemoveAllPropertiesFor(nsPresContext *aPresContext,
nsIFrame *aFrame);
static NS_HIDDEN_(void)
HandlePLEvent(CantRenderReplacedElementEvent* aEvent);

Просмотреть файл

@ -67,9 +67,6 @@ struct CantRenderReplacedElementEvent;
class nsFrameManagerBase
{
public:
struct PropertyList;
protected:
class UndisplayedMap;
@ -82,7 +79,6 @@ protected:
PLDHashTable mPlaceholderMap;
UndisplayedMap* mUndisplayedMap;
CantRenderReplacedElementEvent* mPostedEvents;
PropertyList* mPropertyList;
PRBool mIsDestroyingFrames;
};

Просмотреть файл

@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* 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.
*/
/**
* nsPropertyTable allows a set of arbitrary key/value pairs to be stored
* for any number of nodes, in a global hashtable rather than on the nodes
* themselves. Nodes can be any type of object; the hashtable keys are
* nsIAtom pointers, and the values are void pointers.
*/
#ifndef nsPropertyTable_h_
#define nsPropertyTable_h_
#include "nscore.h"
class nsIAtom;
/**
* Callback type for property destructors. |aObject| is the object
* the property is being removed for, |aPropertyName| is the property
* being removed, |aPropertyValue| is the value of the property, and |aData|
* is the opaque destructor data that was passed to SetProperty().
**/
typedef void
(*NSPropertyDtorFunc)(void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
void *aData);
class nsPropertyTable
{
public:
/**
* Get the value of the property |aPropertyName| for node |aObject|.
* |aResult|, if supplied, is filled in with a return status code.
**/
void* GetProperty(const void *aObject,
nsIAtom *aPropertyName,
nsresult *aResult = nsnull)
{ return GetPropertyInternal(aObject, aPropertyName, PR_FALSE, aResult); }
/**
* Set the value of the property |aPropertyName| to |aPropertyValue|
* for node |aObject|. |aDtor| is a destructor for the property value
* to be called if the property is removed. It can be null if no
* destructor is required. |aDtorData| is an optional opaque context to
* be passed to the property destructor. Note that the destructor is
* global for each property name regardless of node; it is an error
* to set a given property with a different destructor than was used before
* (this will return NS_ERROR_INVALID_ARG).
**/
NS_HIDDEN_(nsresult) SetProperty(const void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
NSPropertyDtorFunc aDtor,
void *aDtorData);
/**
* Delete the property |aPropertyName| for object |aObject|.
* The property's destructor function will be called.
**/
NS_HIDDEN_(nsresult) DeleteProperty(const void *aObject,
nsIAtom *aPropertyName);
/**
* Unset the property |aPropertyName| for object |aObject|, but do not
* call the property's destructor function. The property value is returned.
**/
void* UnsetProperty(const void *aObject,
nsIAtom *aPropertyName,
nsresult *aStatus = nsnull)
{ return GetPropertyInternal(aObject, aPropertyName, PR_TRUE, aStatus); }
/**
* Deletes all of the properties for object |aObject|, calling the
* destructor function for each property.
**/
NS_HIDDEN_(void) DeleteAllPropertiesFor(const void *aObject);
~nsPropertyTable() NS_HIDDEN;
struct PropertyList;
private:
NS_HIDDEN_(void) DestroyPropertyList();
NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom *aPropertyName) const;
NS_HIDDEN_(void*) GetPropertyInternal(const void *aObject,
nsIAtom *aPropertyName,
PRBool aRemove,
nsresult *aStatus);
PropertyList *mPropertyList;
};
#endif

Просмотреть файл

@ -73,6 +73,7 @@ CPPSRCS = \
nsStyleCoord.cpp \
nsStyleStruct.cpp \
nsBidiUtils.cpp \
nsPropertyTable.cpp \
$(NULL)
ifdef MOZ_SVG

Просмотреть файл

@ -0,0 +1,263 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:cindent:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
*
* 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.
*/
#include "nsPropertyTable.h"
#include "pldhash.h"
#include "nsContentErrors.h"
#include "nsIAtom.h"
struct PropertyListMapEntry : public PLDHashEntryHdr {
const void *key;
void *value;
};
//----------------------------------------------------------------------
struct nsPropertyTable::PropertyList {
nsCOMPtr<nsIAtom> mName; // property name
PLDHashTable mObjectValueMap; // map of object/value pairs
NSPropertyDtorFunc mDtorFunc; // property specific value dtor function
void* mDtorData;
PropertyList* mNext;
PropertyList(nsIAtom* aName,
NSPropertyDtorFunc aDtorFunc) NS_HIDDEN;
~PropertyList() NS_HIDDEN;
// Removes the property associated with the given object, and destroys
// the property value
NS_HIDDEN_(PRBool) DeletePropertyFor(const void * aObject);
// Destroy all remaining properties (without removing them)
NS_HIDDEN_(void) Destroy();
};
nsPropertyTable::~nsPropertyTable()
{
if (mPropertyList) {
while (mPropertyList) {
PropertyList* tmp = mPropertyList;
mPropertyList = mPropertyList->mNext;
tmp->Destroy();
delete tmp;
}
}
}
void
nsPropertyTable::DeleteAllPropertiesFor(const void *aObject)
{
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
prop->DeletePropertyFor(aObject);
}
}
void*
nsPropertyTable::GetPropertyInternal(const void *aObject,
nsIAtom *aPropertyName,
PRBool aRemove,
nsresult *aResult)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
nsresult rv = NS_PROPTABLE_PROP_NOT_THERE;
void *propValue = nsnull;
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mObjectValueMap, aObject,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
propValue = entry->value;
if (aRemove) {
// don't call propertyList->mDtorFunc. That's the caller's job now.
PL_DHashTableRawRemove(&propertyList->mObjectValueMap, entry);
}
rv = NS_OK;
}
}
if (aResult)
*aResult = rv;
return propValue;
}
nsresult
nsPropertyTable::SetProperty(const void *aObject,
nsIAtom *aPropertyName,
void *aPropertyValue,
NSPropertyDtorFunc aPropDtorFunc,
void *aPropDtorData)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
// Make sure the dtor function matches
if (aPropDtorFunc != propertyList->mDtorFunc) {
return NS_ERROR_INVALID_ARG;
}
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc);
if (!propertyList)
return NS_ERROR_OUT_OF_MEMORY;
if (!propertyList->mObjectValueMap.ops) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}
propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
// The current property value (if there is one) is replaced and the current
// value is destroyed
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mObjectValueMap, aObject, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {
propertyList->mDtorFunc(NS_CONST_CAST(void*, entry->key), aPropertyName,
entry->value, propertyList->mDtorData);
result = NS_PROPTABLE_PROP_OVERWRITTEN;
}
entry->key = aObject;
entry->value = aPropertyValue;
return result;
}
nsresult
nsPropertyTable::DeleteProperty(const void *aObject,
nsIAtom *aPropertyName)
{
NS_PRECONDITION(aPropertyName && aObject, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
if (propertyList->DeletePropertyFor(aObject))
return NS_OK;
}
return NS_PROPTABLE_PROP_NOT_THERE;
}
nsPropertyTable::PropertyList*
nsPropertyTable::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
for (result = mPropertyList; result; result = result->mNext) {
if (result->mName.get() == aPropertyName) {
break;
}
}
return result;
}
//----------------------------------------------------------------------
nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
NSPropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mDtorData(nsnull), mNext(nsnull)
{
PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsPropertyTable::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mObjectValueMap);
}
PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsPropertyTable::PropertyList *propList =
NS_STATIC_CAST(nsPropertyTable::PropertyList*, table->data);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
propList->mDtorFunc(NS_CONST_CAST(void*, entry->key), propList->mName,
entry->value, propList->mDtorData);
return PL_DHASH_NEXT;
}
void
nsPropertyTable::PropertyList::Destroy()
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
PL_DHashTableEnumerate(&mObjectValueMap, DestroyPropertyEnumerator,
nsnull);
}
PRBool
nsPropertyTable::PropertyList::DeletePropertyFor(const void* aObject)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mObjectValueMap, aObject, PL_DHASH_LOOKUP));
if (!PL_DHASH_ENTRY_IS_BUSY(entry))
return PR_FALSE;
if (mDtorFunc)
mDtorFunc(NS_CONST_CAST(void*, aObject), mName,
entry->value, mDtorData);
PL_DHashTableRawRemove(&mObjectValueMap, entry);
return PR_TRUE;
}

Просмотреть файл

@ -1616,6 +1616,10 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
nsCOMPtr<nsIDOMNSDocument> nsDoc(do_QueryInterface(mDocument));
nsDoc->SetBoxObjectFor(this, nsnull);
if (mSlots && mSlots->mHasProperties) {
mDocument->PropertyTable()->DeleteAllPropertiesFor(this);
}
}
// mControllers can own objects that are implemented
@ -2928,6 +2932,55 @@ nsXULElement::GetRangeList() const
}
void*
nsXULElement::GetProperty(nsIAtom *aPropertyName, nsresult *aStatus) const
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->GetProperty(this, aPropertyName, aStatus);
}
nsresult
nsXULElement::SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor)
{
nsIDocument *doc = GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
nsresult rv = doc->PropertyTable()->SetProperty(this, aPropertyName,
aValue, aDtor, nsnull);
if (NS_SUCCEEDED(rv)) {
EnsureSlots();
mSlots->mHasProperties = PR_TRUE;
}
return rv;
}
nsresult
nsXULElement::DeleteProperty(nsIAtom *aPropertyName)
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->DeleteProperty(this, aPropertyName);
}
void*
nsXULElement::UnsetProperty(nsIAtom *aPropertyName, nsresult *aStatus)
{
nsIDocument *doc = GetDocument();
if (!doc)
return nsnull;
return doc->PropertyTable()->UnsetProperty(this, aPropertyName, aStatus);
}
// XXX This _should_ be an implementation method, _not_ publicly exposed :-(
NS_IMETHODIMP
nsXULElement::GetResource(nsIRDFResource** aResource)
@ -4044,8 +4097,8 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide)
//
nsXULElement::Slots::Slots()
: mLazyState(0)
{
mLazyState = mHasProperties = 0;
MOZ_COUNT_CTOR(nsXULElement::Slots);
}

Просмотреть файл

@ -506,6 +506,14 @@ public:
virtual already_AddRefed<nsIURI> GetBaseURI() const;
virtual nsresult GetListenerManager(nsIEventListenerManager** aResult);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
virtual void* GetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull) const;
virtual nsresult SetProperty(nsIAtom *aPropertyName,
void *aValue,
NSPropertyDtorFunc aDtor);
virtual nsresult DeleteProperty(nsIAtom *aPropertyName);
virtual void* UnsetProperty(nsIAtom *aPropertyName,
nsresult *aStatus = nsnull);
// nsIXMLContent
NS_IMETHOD MaybeTriggerAutoLink(nsIDocShell *aShell);
@ -607,7 +615,8 @@ protected:
nsRefPtr<nsDOMCSSDeclaration> mDOMStyle; // [OWNER]
nsRefPtr<nsDOMAttributeMap> mAttributeMap; // [OWNER]
nsRefPtr<nsChildContentList> mChildNodes; // [OWNER]
PRUint32 mLazyState;
unsigned mLazyState : 3;
unsigned mHasProperties : 1;
};
friend struct Slots;

Просмотреть файл

@ -787,22 +787,21 @@ nsBidiPresUtils::RemoveBidiContinuation(nsPresContext* aPresContext,
nsIFrame* thisFramesNextBidiFrame;
nsIFrame* previousFramesNextBidiFrame;
nsFrameManager* frameManager = presShell->FrameManager();
thisFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*,
frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::nextBidi, 0));
thisFramesNextBidiFrame =
NS_STATIC_CAST(nsIFrame*, aFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (thisFramesNextBidiFrame) {
// Remove nextBidi property, associated with the current frame
// and with all of its prev-in-flow.
frame = aFrame;
do {
frameManager->RemoveFrameProperty(frame, nsLayoutAtoms::nextBidi);
frame->DeleteProperty(nsLayoutAtoms::nextBidi);
frame->GetPrevInFlow(&frame);
if (!frame) {
break;
}
previousFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*,
frameManager->GetFrameProperty(frame, nsLayoutAtoms::nextBidi, 0));
previousFramesNextBidiFrame =
NS_STATIC_CAST(nsIFrame*, frame->GetProperty(nsLayoutAtoms::nextBidi));
} while (thisFramesNextBidiFrame == previousFramesNextBidiFrame);
} // if (thisFramesNextBidiFrame)
}

Просмотреть файл

@ -384,9 +384,7 @@ GetSpecialSibling(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aR
// frame in the flow. Walk back to find that frame now.
aFrame = aFrame->GetFirstInFlow();
void* value =
aFrameManager->GetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialSibling, 0);
void* value = aFrame->GetProperty(nsLayoutAtoms::IBSplitSpecialSibling);
*aResult = NS_STATIC_CAST(nsIFrame*, value);
}
@ -438,9 +436,8 @@ SetFrameIsSpecial(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame* aSp
// Store the "special sibling" (if we were given one) with the
// first frame in the flow.
aFrameManager->SetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialSibling,
aSpecialSibling, nsnull);
aFrame->SetProperty(nsLayoutAtoms::IBSplitSpecialSibling,
aSpecialSibling, nsnull);
}
}
@ -571,10 +568,8 @@ MarkIBSpecialPrevSibling(nsPresContext* aPresContext,
nsIFrame *aAnonymousFrame,
nsIFrame *aSpecialParent)
{
aFrameManager->SetFrameProperty(aAnonymousFrame,
nsLayoutAtoms::IBSplitSpecialPrevSibling,
aSpecialParent,
nsnull);
aAnonymousFrame->SetProperty(nsLayoutAtoms::IBSplitSpecialPrevSibling,
aSpecialParent, nsnull);
}
// -----------------------------------------------------------
@ -4749,9 +4744,9 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell,
// there is no reasonable way to get the value there.
// so we store it as a frame property.
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
aState.mFrameManager->SetFrameProperty(newFrame,
contentParentAtom,
aParentFrame, nsnull);
aPresContext->PropertyTable()->SetProperty(newFrame, contentParentAtom,
aParentFrame, nsnull,
nsnull);
}
}
}
@ -9826,8 +9821,6 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
if (!count)
return NS_OK;
nsFrameManager *frameManager = aPresContext->FrameManager();
// Mark frames so that we skip frames that die along the way, bug 123049.
// A frame can be in the list multiple times with different hints. Further
// optmization is possible if nsStyleChangeList::AppendChange could coalesce
@ -9836,8 +9829,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
const nsStyleChangeData* changeData;
aChangeList.ChangeAt(index, &changeData);
if (changeData->mFrame) {
frameManager->SetFrameProperty(changeData->mFrame,
nsLayoutAtoms::changeListProperty, nsnull, nsnull);
changeData->mFrame->SetProperty(nsLayoutAtoms::changeListProperty,
nsnull, nsnull);
}
}
@ -9852,12 +9845,9 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
if (frame) {
nsresult res;
void* dummy =
frameManager->GetFrameProperty(frame,
nsLayoutAtoms::changeListProperty, 0,
&res);
void* dummy = frame->GetProperty(nsLayoutAtoms::changeListProperty, &res);
if (NS_IFRAME_MGR_PROP_NOT_THERE == res)
if (NS_PROPTABLE_PROP_NOT_THERE == res)
continue;
}
@ -9893,8 +9883,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
const nsStyleChangeData* changeData;
aChangeList.ChangeAt(index, &changeData);
if (changeData->mFrame) {
frameManager->RemoveFrameProperty(changeData->mFrame,
nsLayoutAtoms::changeListProperty);
changeData->mFrame->DeleteProperty(nsLayoutAtoms::changeListProperty);
}
}

Просмотреть файл

@ -154,13 +154,6 @@ static PLDHashTableOps PlaceholderMapOps = {
//----------------------------------------------------------------------
struct PropertyListMapEntry : public PLDHashEntryHdr {
const nsIFrame *key;
void *value;
};
//----------------------------------------------------------------------
struct PrimaryFrameMapEntry : public PLDHashEntryHdr {
// key (the content node) can almost always be obtained through the
// frame. If it weren't for the way image maps (mis)used the primary
@ -277,26 +270,6 @@ struct CantRenderReplacedElementEvent : public PLEvent {
nsWeakPtr mPresShell; // for removing load group request later
};
struct nsFrameManagerBase::PropertyList {
nsCOMPtr<nsIAtom> mName; // property name
PLDHashTable mFrameValueMap; // map of frame/value pairs
NSFramePropertyDtorFunc mDtorFunc; // property specific value dtor function
PropertyList* mNext;
PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc) NS_HIDDEN;
~PropertyList() NS_HIDDEN;
// Removes the property associated with the given frame, and destroys
// the property value
NS_HIDDEN_(PRBool) RemovePropertyForFrame(nsPresContext* aPresContext,
const nsIFrame* aFrame);
// Destroy all remaining properties (without removing them)
NS_HIDDEN_(void) Destroy(nsPresContext* aPresContext);
};
//----------------------------------------------------------------------
nsFrameManager::nsFrameManager()
@ -334,9 +307,7 @@ nsFrameManager::Destroy()
nsPresContext *presContext = mPresShell->GetPresContext();
// Destroy the frame hierarchy. Don't destroy the property lists until after
// we've destroyed the frame hierarchy because some frames may expect to be
// able to retrieve their properties during destruction
// Destroy the frame hierarchy.
mPresShell->SetIgnoreFrameDestruction(PR_TRUE);
mIsDestroyingFrames = PR_TRUE; // This flag prevents GetPrimaryFrameFor from returning pointers to destroyed frames
@ -355,7 +326,6 @@ nsFrameManager::Destroy()
mPlaceholderMap.ops = nsnull;
}
delete mUndisplayedMap;
DestroyPropertyList(presContext);
// If we're not going to be used anymore, we should revoke the
// pending |CantRenderReplacedElementEvent|s being sent to us.
@ -735,10 +705,8 @@ nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
// Insert aFrameList after the last bidi continuation of aPrevFrame.
nsIFrame* nextBidi;
for (; ;) {
nextBidi =
NS_STATIC_CAST(nsIFrame*, GetFrameProperty(aPrevFrame,
nsLayoutAtoms::nextBidi,
0));
nextBidi = NS_STATIC_CAST(nsIFrame*,
aPrevFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (!nextBidi) {
break;
}
@ -759,8 +727,7 @@ nsFrameManager::RemoveFrame(nsIFrame* aParentFrame,
#ifdef IBMBIDI
// Don't let the parent remove next bidi. In the other cases the it should NOT be removed.
nsIFrame* nextBidi =
NS_STATIC_CAST(nsIFrame*, GetFrameProperty(aOldFrame,
nsLayoutAtoms::nextBidi, 0));
NS_STATIC_CAST(nsIFrame*, aOldFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (nextBidi) {
RemoveFrame(aParentFrame, aListName, nextBidi);
}
@ -778,10 +745,6 @@ nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
// Dequeue and destroy and posted events for this frame
DequeuePostedEventFor(aFrame);
// Remove all properties associated with the frame
nsPresContext *presContext = mPresShell->GetPresContext();
RemoveAllPropertiesFor(presContext, aFrame);
#ifdef DEBUG
if (mPrimaryFrameMap.ops) {
PrimaryFrameMapEntry *entry = NS_STATIC_CAST(PrimaryFrameMapEntry*,
@ -1699,8 +1662,8 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame,
return topLevelChange;
}
frame2 = NS_STATIC_CAST(nsIFrame*, GetFrameProperty(frame2,
nsLayoutAtoms::IBSplitSpecialSibling, 0));
frame2 = NS_STATIC_CAST(nsIFrame*,
frame2->GetProperty(nsLayoutAtoms::IBSplitSpecialSibling));
frame = frame2;
} while (frame2);
return topLevelChange;
@ -1876,140 +1839,6 @@ CompareKeys(void* key1, void* key2)
return key1 == key2;
}
void
nsFrameManager::DestroyPropertyList(nsPresContext* aPresContext)
{
if (mPropertyList) {
while (mPropertyList) {
PropertyList* tmp = mPropertyList;
mPropertyList = mPropertyList->mNext;
tmp->Destroy(aPresContext);
delete tmp;
}
}
}
nsFrameManagerBase::PropertyList*
nsFrameManager::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
for (result = mPropertyList; result; result = result->mNext) {
if (result->mName.get() == aPropertyName) {
break;
}
}
return result;
}
void
nsFrameManager::RemoveAllPropertiesFor(nsPresContext* aPresContext,
nsIFrame* aFrame)
{
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
prop->RemovePropertyForFrame(aPresContext, aFrame);
}
}
void*
nsFrameManager::GetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
PRUint32 aOptions,
nsresult* aResult)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
nsresult rv = NS_IFRAME_MGR_PROP_NOT_THERE;
void *propValue = nsnull;
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
propValue = entry->value;
if (aOptions & NS_IFRAME_MGR_REMOVE_PROP) {
// don't call propertyList->mDtorFunc. That's the caller's job now.
PL_DHashTableRawRemove(&propertyList->mFrameValueMap, entry);
}
rv = NS_OK;
}
}
if (aResult)
*aResult = rv;
return propValue;
}
nsresult
nsFrameManager::SetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue,
NSFramePropertyDtorFunc aPropDtorFunc)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
// Make sure the dtor function matches
if (aPropDtorFunc != propertyList->mDtorFunc) {
return NS_ERROR_INVALID_ARG;
}
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc);
if (!propertyList)
return NS_ERROR_OUT_OF_MEMORY;
if (!propertyList->mFrameValueMap.ops) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}
propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
// The current property value (if there is one) is replaced and the current
// value is destroyed
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {
propertyList->mDtorFunc(mPresShell->GetPresContext(),
NS_CONST_CAST(nsIFrame*, entry->key),
aPropertyName, entry->value);
result = NS_IFRAME_MGR_PROP_OVERWRITTEN;
}
entry->key = aFrame;
entry->value = aPropertyValue;
return result;
}
nsresult
nsFrameManager::RemoveFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
if (propertyList->RemovePropertyForFrame(mPresShell->GetPresContext(),
aFrame))
return NS_OK;
}
return NS_IFRAME_MGR_PROP_NOT_THERE;
}
//----------------------------------------------------------------------
MOZ_DECL_CTOR_COUNTER(UndisplayedMap)
@ -2157,59 +1986,3 @@ nsFrameManagerBase::UndisplayedMap::Clear(void)
mLastLookup = nsnull;
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
}
//----------------------------------------------------------------------
nsFrameManagerBase::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mNext(nsnull)
{
PL_DHashTableInit(&mFrameValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsFrameManagerBase::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mFrameValueMap);
}
PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsFrameManagerBase::PropertyList *propList =
NS_STATIC_CAST(nsFrameManagerBase::PropertyList*, table->data);
nsPresContext *presContext = NS_STATIC_CAST(nsPresContext*, arg);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
propList->mDtorFunc(presContext, NS_CONST_CAST(nsIFrame*, entry->key),
propList->mName, entry->value);
return PL_DHASH_NEXT;
}
void
nsFrameManagerBase::PropertyList::Destroy(nsPresContext* aPresContext)
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
PL_DHashTableEnumerate(&mFrameValueMap, DestroyPropertyEnumerator,
aPresContext);
}
PRBool
nsFrameManagerBase::PropertyList::RemovePropertyForFrame(nsPresContext* aPresContext,
const nsIFrame* aFrame)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mFrameValueMap, aFrame, PL_DHASH_LOOKUP));
if (!PL_DHASH_ENTRY_IS_BUSY(entry))
return PR_FALSE;
if (mDtorFunc)
mDtorFunc(aPresContext, NS_CONST_CAST(nsIFrame*, aFrame),
mName, entry->value);
PL_DHashTableRawRemove(&mFrameValueMap, entry);
return PR_TRUE;
}

Просмотреть файл

@ -55,9 +55,6 @@
#include "nsChangeHint.h"
#include "nsFrameManagerBase.h"
// Option flags for GetFrameProperty() member function
#define NS_IFRAME_MGR_REMOVE_PROP 0x0001
/**
* Frame manager interface. The frame manager serves two purposes:
* <li>provides a service for mapping from content to frame and from
@ -222,68 +219,6 @@ public:
nsIStatefulFrame::SpecialStateID aID =
nsIStatefulFrame::eNoID);
/**
* Gets a property value for a given frame.
*
* @param aFrame the frame with the property
* @param aPropertyName property name as an atom
* @param aOptions optional flags
* NS_IFRAME_MGR_REMOVE_PROP removes the property
* @param aResult NS_OK if the property is set,
* NS_IFRAME_MGR_PROP_NOT_THERE is it is not set
* @param aPropertyValue the property value or 0 if the
property is not set
* @return The property value or 0 if the property is not set
*/
NS_HIDDEN_(void*) GetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
PRUint32 aOptions,
nsresult* aResult = nsnull);
/**
* Sets the property value for a given frame.
*
* A frame may only have one property value at a time for a given property
* name. The existing property value (if there is one) is overwritten, and
* the old value destroyed
*
* @param aFrame the frame to set the property on
* @param aPropertyName property name as an atom
* @param aPropertyValue the property value
* @param aPropertyDtorFunc when setting a property you can specify the
* dtor function (can be NULL) that will be used
* to destroy the property value. There can be
* only one dtor function for a given property
* name
* @return NS_OK if successful,
* NS_IFRAME_MGR_PROP_OVERWRITTEN if there is an existing property
* value that was overwritten,
* NS_ERROR_INVALID_ARG if the dtor function does not match the
* existing dtor function
*/
NS_HIDDEN_(nsresult) SetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue,
NSFramePropertyDtorFunc aPropDtorFunc);
/**
* Removes a property and destroys its property value by calling the dtor
* function associated with the property name.
*
* When a frame is destroyed any remaining properties are automatically
* removed.
*
* @param aFrame the frame to set the property on
* @param aPropertyName property name as an atom
* @return NS_OK if the property is successfully removed,
* NS_IFRAME_MGR_PROP_NOT_THERE if the property is not set
*/
NS_HIDDEN_(nsresult) RemoveFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName);
#ifdef NS_DEBUG
/**
* DEBUG ONLY method to verify integrity of style tree versus frame tree
@ -312,10 +247,6 @@ private:
FindPostedEventFor(nsIFrame* aFrame);
NS_HIDDEN_(void) DequeuePostedEventFor(nsIFrame* aFrame);
NS_HIDDEN_(void) DestroyPropertyList(nsPresContext* aPresContext);
NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom* aPropertyName) const;
NS_HIDDEN_(void) RemoveAllPropertiesFor(nsPresContext *aPresContext,
nsIFrame *aFrame);
static NS_HIDDEN_(void)
HandlePLEvent(CantRenderReplacedElementEvent* aEvent);

Просмотреть файл

@ -67,9 +67,6 @@ struct CantRenderReplacedElementEvent;
class nsFrameManagerBase
{
public:
struct PropertyList;
protected:
class UndisplayedMap;
@ -82,7 +79,6 @@ protected:
PLDHashTable mPlaceholderMap;
UndisplayedMap* mUndisplayedMap;
CantRenderReplacedElementEvent* mPostedEvents;
PropertyList* mPropertyList;
PRBool mIsDestroyingFrames;
};

Просмотреть файл

@ -43,15 +43,6 @@
#define NS_TABLELAYOUT_CELL_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 0)
/** Error codes for frame property functions */
#define NS_IFRAME_MGR_PROP_NOT_THERE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 1)
#define NS_IFRAME_MGR_PROP_OVERWRITTEN \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 2)
/** Error codes for nsFrame::GetNextPrevLineFromeBlockFrame */
#define NS_POSITION_BEFORE_TABLE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 3)

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIDOMDocument.h"
#include "nsAutoPtr.h"
#include "nsEventStateManager.h"
#include "nsPropertyTable.h"
#ifdef IBMBIDI
#include "nsBidiPresUtils.h"
#endif // IBMBIDI

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#include "nsPropertyTable.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -572,6 +573,9 @@ public:
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
/* Accessor for table of frame properties */
nsPropertyTable* PropertyTable() { return &mPropertyTable; }
#ifdef MOZ_REFLOW_PERF
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
@ -621,6 +625,8 @@ protected:
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsPropertyTable mPropertyTable;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;

Просмотреть файл

@ -6808,20 +6808,12 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
// verify that neither frame has a space manager,
// or they both do and the space managers are equivalent
nsFrameManager *fm1 = aFirstPresContext->FrameManager();
NS_ASSERTION(fm1, "no frame manager for primary tree!");
nsSpaceManager *sm1 =
NS_STATIC_CAST(nsSpaceManager*, fm1->GetFrameProperty(k1,
nsLayoutAtoms::spaceManagerProperty, 0));
nsSpaceManager *sm1 = NS_STATIC_CAST(nsSpaceManager*,
k1->GetProperty(nsLayoutAtoms::spaceManagerProperty));
// look at the test frame
nsFrameManager *fm2 = aSecondPresContext->FrameManager();
NS_ASSERTION(fm2, "no frame manager for test tree!");
nsSpaceManager *sm2 =
NS_STATIC_CAST(nsSpaceManager*, fm2->GetFrameProperty(k2,
nsLayoutAtoms::spaceManagerProperty, 0));
nsSpaceManager *sm2 = NS_STATIC_CAST(nsSpaceManager*,
k2->GetProperty(nsLayoutAtoms::spaceManagerProperty));
// now compare the space managers
if (((nsnull == sm1) && (nsnull != sm2)) ||

Просмотреть файл

@ -89,13 +89,6 @@ struct nsRect;
struct nsSize;
struct nsMargin;
// Calback function used to destroy the value associated with a property.
typedef void
(*NSFramePropertyDtorFunc)(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue);
// IID for the nsIFrame interface
// a6cf9050-15b3-11d2-932e-00805f8add32
#define NS_IFRAME_IID \
@ -1215,13 +1208,17 @@ public:
}
void* GetProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const;
virtual void* GetPropertyExternal(nsIAtom* aPropertyName,
nsresult* aStatus) const;
void* RemoveProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const;
nsresult SetProperty(nsIAtom* aPropertyName,
void* aValue,
NSFramePropertyDtorFunc aDestructor = nsnull);
NS_HIDDEN_(void*) GetProperty(nsIAtom* aPropertyName,
nsresult* aStatus = nsnull) const;
virtual NS_HIDDEN_(void*) GetPropertyExternal(nsIAtom* aPropertyName,
nsresult* aStatus) const;
NS_HIDDEN_(nsresult) SetProperty(nsIAtom* aPropertyName,
void* aValue,
NSPropertyDtorFunc aDestructor = nsnull,
void* aDtorData = nsnull);
NS_HIDDEN_(nsresult) DeleteProperty(nsIAtom* aPropertyName) const;
NS_HIDDEN_(void*) UnsetProperty(nsIAtom* aPropertyName,
nsresult* aStatus = nsnull) const;
#define NS_GET_BASE_LEVEL(frame) \
NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::baseLevel))

Просмотреть файл

@ -43,15 +43,6 @@
#define NS_TABLELAYOUT_CELL_NOT_FOUND \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 0)
/** Error codes for frame property functions */
#define NS_IFRAME_MGR_PROP_NOT_THERE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 1)
#define NS_IFRAME_MGR_PROP_OVERWRITTEN \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 2)
/** Error codes for nsFrame::GetNextPrevLineFromeBlockFrame */
#define NS_POSITION_BEFORE_TABLE \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_LAYOUT, 3)

Просмотреть файл

@ -54,6 +54,7 @@
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#include "nsPropertyTable.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -572,6 +573,9 @@ public:
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
/* Accessor for table of frame properties */
nsPropertyTable* PropertyTable() { return &mPropertyTable; }
#ifdef MOZ_REFLOW_PERF
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
@ -621,6 +625,8 @@ protected:
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsPropertyTable mPropertyTable;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;

Просмотреть файл

@ -787,22 +787,21 @@ nsBidiPresUtils::RemoveBidiContinuation(nsPresContext* aPresContext,
nsIFrame* thisFramesNextBidiFrame;
nsIFrame* previousFramesNextBidiFrame;
nsFrameManager* frameManager = presShell->FrameManager();
thisFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*,
frameManager->GetFrameProperty(aFrame, nsLayoutAtoms::nextBidi, 0));
thisFramesNextBidiFrame =
NS_STATIC_CAST(nsIFrame*, aFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (thisFramesNextBidiFrame) {
// Remove nextBidi property, associated with the current frame
// and with all of its prev-in-flow.
frame = aFrame;
do {
frameManager->RemoveFrameProperty(frame, nsLayoutAtoms::nextBidi);
frame->DeleteProperty(nsLayoutAtoms::nextBidi);
frame->GetPrevInFlow(&frame);
if (!frame) {
break;
}
previousFramesNextBidiFrame = NS_STATIC_CAST(nsIFrame*,
frameManager->GetFrameProperty(frame, nsLayoutAtoms::nextBidi, 0));
previousFramesNextBidiFrame =
NS_STATIC_CAST(nsIFrame*, frame->GetProperty(nsLayoutAtoms::nextBidi));
} while (thisFramesNextBidiFrame == previousFramesNextBidiFrame);
} // if (thisFramesNextBidiFrame)
}

Просмотреть файл

@ -68,6 +68,7 @@
#include "nsIDOMDocument.h"
#include "nsAutoPtr.h"
#include "nsEventStateManager.h"
#include "nsPropertyTable.h"
#ifdef IBMBIDI
#include "nsBidiPresUtils.h"
#endif // IBMBIDI

Просмотреть файл

@ -927,10 +927,9 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsHTMLReflowState& reflowState = (nsHTMLReflowState&)aReflowState;
rv = shell->FrameManager()->SetFrameProperty(
this, nsLayoutAtoms::spaceManagerProperty,
reflowState.mSpaceManager,
nsnull /* should be nsSpaceManagerDestroyer*/);
rv = SetProperty(nsLayoutAtoms::spaceManagerProperty,
reflowState.mSpaceManager,
nsnull /* should be nsSpaceManagerDestroyer*/);
autoSpaceManager.DebugOrphanSpaceManager();
}
@ -4306,21 +4305,22 @@ nsBlockFrame::RemoveOverflowLines() const
{
nsLineList* lines =
NS_STATIC_CAST(nsLineList*,
RemoveProperty(nsLayoutAtoms::overflowLinesProperty));
UnsetProperty(nsLayoutAtoms::overflowLinesProperty));
NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty");
return lines;
}
// Destructor function for the overflowLines frame property
static void
DestroyOverflowLines(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowLines(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
if (aPropertyValue) {
nsLineList* lines = NS_STATIC_CAST(nsLineList*, aPropertyValue);
nsLineBox::DeleteLineList(aPresContext, *lines);
nsPresContext *context = NS_STATIC_CAST(nsPresContext*, aDtorData);
nsLineBox::DeleteLineList(context, *lines);
delete lines;
}
}
@ -4334,9 +4334,10 @@ nsBlockFrame::SetOverflowLines(nsLineList* aOverflowLines)
NS_ASSERTION(!aOverflowLines->empty(), "empty lines");
nsresult rv = SetProperty(nsLayoutAtoms::overflowLinesProperty,
aOverflowLines, DestroyOverflowLines);
aOverflowLines, DestroyOverflowLines,
GetPresContext());
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow list");
return rv;
}
@ -4351,15 +4352,15 @@ nsFrameList*
nsBlockFrame::RemoveOverflowOutOfFlows() const
{
return NS_STATIC_CAST(nsFrameList*,
RemoveProperty(nsLayoutAtoms::overflowOutOfFlowsProperty));
UnsetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty));
}
// Destructor function for the overflowPlaceholders frame property
static void
DestroyOverflowOOFs(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowOOFs(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
NS_NOTREACHED("This helper method should never be called!");
delete NS_STATIC_CAST(nsFrameList*, aPropertyValue);
@ -4372,7 +4373,7 @@ nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs)
nsresult rv = SetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty,
aOOFs, DestroyOverflowOOFs);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow float list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow float list");
return rv;
}
@ -4389,15 +4390,15 @@ nsBlockFrame::RemoveOverflowPlaceholders() const
{
return
NS_STATIC_CAST(nsFrameList*,
RemoveProperty(nsLayoutAtoms::overflowPlaceholdersProperty));
UnsetProperty(nsLayoutAtoms::overflowPlaceholdersProperty));
}
// Destructor function for the overflowPlaceholders frame property
static void
DestroyOverflowPlaceholders(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowPlaceholders(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
nsFrameList* overflowPlace = NS_STATIC_CAST(nsFrameList*, aPropertyValue);
delete overflowPlace;
@ -4411,7 +4412,7 @@ nsBlockFrame::SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders)
nsresult rv = SetProperty(nsLayoutAtoms::overflowPlaceholdersProperty,
aOverflowPlaceholders, DestroyOverflowPlaceholders);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow placeholder list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow placeholder list");
return rv;
}
@ -5726,7 +5727,7 @@ void nsBlockFrame::ClearLineCursor() {
return;
}
RemoveProperty(nsLayoutAtoms::lineCursorProperty);
UnsetProperty(nsLayoutAtoms::lineCursorProperty);
RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR);
}

Просмотреть файл

@ -292,8 +292,8 @@ ComputeShrinkwrapMargins(const nsStyleMargin* aStyleMargin, nscoord aWidth,
}
static void
nsPointDtor(nsPresContext *aPresContext, nsIFrame *aFrame,
nsIAtom *aPropertyName, void *aPropertyValue)
nsPointDtor(void *aFrame, nsIAtom *aPropertyName,
void *aPropertyValue, void *aDtorData)
{
nsPoint *point = NS_STATIC_CAST(nsPoint*, aPropertyValue);
delete point;
@ -382,21 +382,16 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
aComputedOffsets = aFrameRS.mComputedOffsets;
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
nsFrameManager *frameManager = mPresContext->FrameManager();
nsPoint *offsets = NS_STATIC_CAST(nsPoint*,
frameManager->GetFrameProperty(mFrame,
nsLayoutAtoms::computedOffsetProperty,
0));
mFrame->GetProperty(nsLayoutAtoms::computedOffsetProperty));
if (offsets)
offsets->MoveTo(aComputedOffsets.left, aComputedOffsets.top);
else {
offsets = new nsPoint(aComputedOffsets.left, aComputedOffsets.top);
if (offsets)
frameManager->SetFrameProperty(mFrame,
nsLayoutAtoms::computedOffsetProperty,
offsets, nsPointDtor);
mFrame->SetProperty(nsLayoutAtoms::computedOffsetProperty,
offsets, nsPointDtor);
}
}

Просмотреть файл

@ -495,8 +495,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine,
// at their original position.
if (NS_STYLE_POSITION_RELATIVE == kid->GetStyleDisplay()->mPosition) {
nsPoint *offsets = NS_STATIC_CAST(nsPoint*,
mPresContext->FrameManager()->GetFrameProperty(kid,
nsLayoutAtoms::computedOffsetProperty, 0));
kid->GetProperty(nsLayoutAtoms::computedOffsetProperty));
if (offsets) {
tx -= offsets->x;

Просмотреть файл

@ -1166,27 +1166,24 @@ nsIFrame*
nsContainerFrame::GetOverflowFrames(nsPresContext* aPresContext,
PRBool aRemoveProperty) const
{
PRUint32 options = 0;
if (aRemoveProperty) {
options |= NS_IFRAME_MGR_REMOVE_PROP;
return (nsIFrame*) UnsetProperty(nsLayoutAtoms::overflowProperty);
}
return (nsIFrame*) aPresContext->FrameManager()->
GetFrameProperty(this, nsLayoutAtoms::overflowProperty, options);
return (nsIFrame*) GetProperty(nsLayoutAtoms::overflowProperty);
}
// Destructor function for the overflow frame property
static void
DestroyOverflowFrames(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowFrames(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
if (aPropertyValue) {
nsFrameList frames((nsIFrame*)aPropertyValue);
frames.DestroyFrames(aPresContext);
frames.DestroyFrames(NS_STATIC_CAST(nsPresContext*, aDtorData));
}
}
@ -1194,12 +1191,12 @@ nsresult
nsContainerFrame::SetOverflowFrames(nsPresContext* aPresContext,
nsIFrame* aOverflowFrames)
{
nsresult rv = aPresContext->FrameManager()->
SetFrameProperty(this, nsLayoutAtoms::overflowProperty,
aOverflowFrames, DestroyOverflowFrames);
nsresult rv = SetProperty(nsLayoutAtoms::overflowProperty,
aOverflowFrames, DestroyOverflowFrames,
aPresContext);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow list");
return rv;
}

Просмотреть файл

@ -2269,8 +2269,7 @@ nsIFrame::GetView() const
// Check for a property on the frame
nsresult rv;
void* value = GetPresContext()->FrameManager()->
GetFrameProperty(this, nsLayoutAtoms::viewProperty, 0, &rv);
void *value = GetProperty(nsLayoutAtoms::viewProperty, &rv);
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ASSERTION(value, "frame state bit was set but frame has no view");
@ -2290,8 +2289,7 @@ nsIFrame::SetView(nsIView* aView)
aView->SetClientData(this);
// Set a property on the frame
nsresult rv = GetPresContext()->FrameManager()->
SetFrameProperty(this, nsLayoutAtoms::viewProperty, aView, nsnull);
nsresult rv = SetProperty(nsLayoutAtoms::viewProperty, aView, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// Set the frame state bit that says the frame has a view
@ -4209,10 +4207,10 @@ nsFrame::GetAccessible(nsIAccessible** aAccessible)
// Destructor function for the overflow area property
static void
DestroyRectFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyRectFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nsRect*)aPropertyValue;
}
@ -4224,11 +4222,7 @@ nsIFrame::GetOverflowAreaProperty(PRBool aCreateIfNecessary)
return nsnull;
}
nsFrameManager *frameManager = GetPresContext()->FrameManager();
void *value =
frameManager->GetFrameProperty(this, nsLayoutAtoms::overflowAreaProperty,
0);
void *value = GetProperty(nsLayoutAtoms::overflowAreaProperty);
if (value) {
return (nsRect*)value; // the property already exists
@ -4236,9 +4230,8 @@ nsIFrame::GetOverflowAreaProperty(PRBool aCreateIfNecessary)
// The property isn't set yet, so allocate a new rect, set the property,
// and return the newly allocated rect
nsRect* overflow = new nsRect(0, 0, 0, 0);
frameManager->SetFrameProperty(this, nsLayoutAtoms::overflowAreaProperty,
overflow, DestroyRectFunc);
SetProperty(nsLayoutAtoms::overflowAreaProperty,
overflow, DestroyRectFunc);
return overflow;
}
@ -4271,8 +4264,7 @@ nsIFrame::FinishAndStoreOverflow(nsRect* aOverflowArea, nsSize aNewSize)
else {
if (mState & NS_FRAME_OUTSIDE_CHILDREN) {
// remove the previously stored overflow area
GetPresContext()->FrameManager()->
RemoveFrameProperty(this, nsLayoutAtoms::overflowAreaProperty);
DeleteProperty(nsLayoutAtoms::overflowAreaProperty);
}
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
@ -4338,8 +4330,7 @@ GetIBSpecialSibling(nsPresContext* aPresContext,
*/
nsresult rv;
nsIFrame *specialSibling = NS_STATIC_CAST(nsIFrame*,
aPresContext->FrameManager()->GetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialPrevSibling, 0, &rv));
aFrame->GetProperty(nsLayoutAtoms::IBSplitSpecialPrevSibling, &rv));
if (NS_OK == rv) {
NS_ASSERTION(specialSibling, "null special sibling");
@ -4545,19 +4536,20 @@ nsFrame::IsMouseCaptured(nsPresContext* aPresContext)
}
nsresult
nsIFrame::SetProperty(nsIAtom* aPropName,
void* aPropValue,
NSFramePropertyDtorFunc aPropDtorFunc)
nsIFrame::SetProperty(nsIAtom* aPropName,
void* aPropValue,
NSPropertyDtorFunc aPropDtorFunc,
void* aDtorData)
{
return GetPresContext()->FrameManager()->
SetFrameProperty(this, aPropName, aPropValue, aPropDtorFunc);
return GetPresContext()->PropertyTable()->
SetProperty(this, aPropName, aPropValue, aPropDtorFunc, aDtorData);
}
void*
nsIFrame::GetProperty(nsIAtom* aPropName, nsresult* aStatus) const
{
return GetPresContext()->FrameManager()->
GetFrameProperty(this, aPropName, 0, aStatus);
return GetPresContext()->PropertyTable()->GetProperty(this, aPropName,
aStatus);
}
/* virtual */ void*
@ -4566,11 +4558,17 @@ nsIFrame::GetPropertyExternal(nsIAtom* aPropName, nsresult* aStatus) const
return GetProperty(aPropName, aStatus);
}
void*
nsIFrame::RemoveProperty(nsIAtom* aPropName, nsresult* aStatus) const
nsresult
nsIFrame::DeleteProperty(nsIAtom* aPropName) const
{
return GetPresContext()->FrameManager()->
GetFrameProperty(this, aPropName, NS_IFRAME_MGR_REMOVE_PROP, aStatus);
return GetPresContext()->PropertyTable()->DeleteProperty(this, aPropName);
}
void*
nsIFrame::UnsetProperty(nsIAtom* aPropName, nsresult* aStatus) const
{
return GetPresContext()->PropertyTable()->UnsetProperty(this, aPropName,
aStatus);
}
/* virtual */ const nsStyleStruct*

Просмотреть файл

@ -240,10 +240,7 @@ nsSubDocumentFrame::Init(nsPresContext* aPresContext,
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
nsIFrame* contentParent = nsnull;
void *value =
aPresContext->FrameManager()->GetFrameProperty(this, contentParentAtom,
NS_IFRAME_MGR_REMOVE_PROP,
&rv);
void *value = UnsetProperty(contentParentAtom, &rv);
if (NS_SUCCEEDED(rv)) {
contentParent = (nsIFrame*)value;
}

Просмотреть файл

@ -89,13 +89,6 @@ struct nsRect;
struct nsSize;
struct nsMargin;
// Calback function used to destroy the value associated with a property.
typedef void
(*NSFramePropertyDtorFunc)(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue);
// IID for the nsIFrame interface
// a6cf9050-15b3-11d2-932e-00805f8add32
#define NS_IFRAME_IID \
@ -1215,13 +1208,17 @@ public:
}
void* GetProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const;
virtual void* GetPropertyExternal(nsIAtom* aPropertyName,
nsresult* aStatus) const;
void* RemoveProperty(nsIAtom* aPropertyName, nsresult* aStatus = nsnull) const;
nsresult SetProperty(nsIAtom* aPropertyName,
void* aValue,
NSFramePropertyDtorFunc aDestructor = nsnull);
NS_HIDDEN_(void*) GetProperty(nsIAtom* aPropertyName,
nsresult* aStatus = nsnull) const;
virtual NS_HIDDEN_(void*) GetPropertyExternal(nsIAtom* aPropertyName,
nsresult* aStatus) const;
NS_HIDDEN_(nsresult) SetProperty(nsIAtom* aPropertyName,
void* aValue,
NSPropertyDtorFunc aDestructor = nsnull,
void* aDtorData = nsnull);
NS_HIDDEN_(nsresult) DeleteProperty(nsIAtom* aPropertyName) const;
NS_HIDDEN_(void*) UnsetProperty(nsIAtom* aPropertyName,
nsresult* aStatus = nsnull) const;
#define NS_GET_BASE_LEVEL(frame) \
NS_PTR_TO_INT32(frame->GetProperty(nsLayoutAtoms::baseLevel))

Просмотреть файл

@ -927,10 +927,9 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
nsIPresShell *shell = aPresContext->GetPresShell();
if (shell) {
nsHTMLReflowState& reflowState = (nsHTMLReflowState&)aReflowState;
rv = shell->FrameManager()->SetFrameProperty(
this, nsLayoutAtoms::spaceManagerProperty,
reflowState.mSpaceManager,
nsnull /* should be nsSpaceManagerDestroyer*/);
rv = SetProperty(nsLayoutAtoms::spaceManagerProperty,
reflowState.mSpaceManager,
nsnull /* should be nsSpaceManagerDestroyer*/);
autoSpaceManager.DebugOrphanSpaceManager();
}
@ -4306,21 +4305,22 @@ nsBlockFrame::RemoveOverflowLines() const
{
nsLineList* lines =
NS_STATIC_CAST(nsLineList*,
RemoveProperty(nsLayoutAtoms::overflowLinesProperty));
UnsetProperty(nsLayoutAtoms::overflowLinesProperty));
NS_ASSERTION(!lines || !lines->empty(), "value should never be stored as empty");
return lines;
}
// Destructor function for the overflowLines frame property
static void
DestroyOverflowLines(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowLines(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
if (aPropertyValue) {
nsLineList* lines = NS_STATIC_CAST(nsLineList*, aPropertyValue);
nsLineBox::DeleteLineList(aPresContext, *lines);
nsPresContext *context = NS_STATIC_CAST(nsPresContext*, aDtorData);
nsLineBox::DeleteLineList(context, *lines);
delete lines;
}
}
@ -4334,9 +4334,10 @@ nsBlockFrame::SetOverflowLines(nsLineList* aOverflowLines)
NS_ASSERTION(!aOverflowLines->empty(), "empty lines");
nsresult rv = SetProperty(nsLayoutAtoms::overflowLinesProperty,
aOverflowLines, DestroyOverflowLines);
aOverflowLines, DestroyOverflowLines,
GetPresContext());
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow list");
return rv;
}
@ -4351,15 +4352,15 @@ nsFrameList*
nsBlockFrame::RemoveOverflowOutOfFlows() const
{
return NS_STATIC_CAST(nsFrameList*,
RemoveProperty(nsLayoutAtoms::overflowOutOfFlowsProperty));
UnsetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty));
}
// Destructor function for the overflowPlaceholders frame property
static void
DestroyOverflowOOFs(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowOOFs(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
NS_NOTREACHED("This helper method should never be called!");
delete NS_STATIC_CAST(nsFrameList*, aPropertyValue);
@ -4372,7 +4373,7 @@ nsBlockFrame::SetOverflowOutOfFlows(nsFrameList* aOOFs)
nsresult rv = SetProperty(nsLayoutAtoms::overflowOutOfFlowsProperty,
aOOFs, DestroyOverflowOOFs);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow float list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow float list");
return rv;
}
@ -4389,15 +4390,15 @@ nsBlockFrame::RemoveOverflowPlaceholders() const
{
return
NS_STATIC_CAST(nsFrameList*,
RemoveProperty(nsLayoutAtoms::overflowPlaceholdersProperty));
UnsetProperty(nsLayoutAtoms::overflowPlaceholdersProperty));
}
// Destructor function for the overflowPlaceholders frame property
static void
DestroyOverflowPlaceholders(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowPlaceholders(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
nsFrameList* overflowPlace = NS_STATIC_CAST(nsFrameList*, aPropertyValue);
delete overflowPlace;
@ -4411,7 +4412,7 @@ nsBlockFrame::SetOverflowPlaceholders(nsFrameList* aOverflowPlaceholders)
nsresult rv = SetProperty(nsLayoutAtoms::overflowPlaceholdersProperty,
aOverflowPlaceholders, DestroyOverflowPlaceholders);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow placeholder list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow placeholder list");
return rv;
}
@ -5726,7 +5727,7 @@ void nsBlockFrame::ClearLineCursor() {
return;
}
RemoveProperty(nsLayoutAtoms::lineCursorProperty);
UnsetProperty(nsLayoutAtoms::lineCursorProperty);
RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR);
}

Просмотреть файл

@ -292,8 +292,8 @@ ComputeShrinkwrapMargins(const nsStyleMargin* aStyleMargin, nscoord aWidth,
}
static void
nsPointDtor(nsPresContext *aPresContext, nsIFrame *aFrame,
nsIAtom *aPropertyName, void *aPropertyValue)
nsPointDtor(void *aFrame, nsIAtom *aPropertyName,
void *aPropertyValue, void *aDtorData)
{
nsPoint *point = NS_STATIC_CAST(nsPoint*, aPropertyValue);
delete point;
@ -382,21 +382,16 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
aComputedOffsets = aFrameRS.mComputedOffsets;
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
nsFrameManager *frameManager = mPresContext->FrameManager();
nsPoint *offsets = NS_STATIC_CAST(nsPoint*,
frameManager->GetFrameProperty(mFrame,
nsLayoutAtoms::computedOffsetProperty,
0));
mFrame->GetProperty(nsLayoutAtoms::computedOffsetProperty));
if (offsets)
offsets->MoveTo(aComputedOffsets.left, aComputedOffsets.top);
else {
offsets = new nsPoint(aComputedOffsets.left, aComputedOffsets.top);
if (offsets)
frameManager->SetFrameProperty(mFrame,
nsLayoutAtoms::computedOffsetProperty,
offsets, nsPointDtor);
mFrame->SetProperty(nsLayoutAtoms::computedOffsetProperty,
offsets, nsPointDtor);
}
}

Просмотреть файл

@ -495,8 +495,7 @@ nsBlockReflowState::RecoverFloats(nsLineList::iterator aLine,
// at their original position.
if (NS_STYLE_POSITION_RELATIVE == kid->GetStyleDisplay()->mPosition) {
nsPoint *offsets = NS_STATIC_CAST(nsPoint*,
mPresContext->FrameManager()->GetFrameProperty(kid,
nsLayoutAtoms::computedOffsetProperty, 0));
kid->GetProperty(nsLayoutAtoms::computedOffsetProperty));
if (offsets) {
tx -= offsets->x;

Просмотреть файл

@ -1166,27 +1166,24 @@ nsIFrame*
nsContainerFrame::GetOverflowFrames(nsPresContext* aPresContext,
PRBool aRemoveProperty) const
{
PRUint32 options = 0;
if (aRemoveProperty) {
options |= NS_IFRAME_MGR_REMOVE_PROP;
return (nsIFrame*) UnsetProperty(nsLayoutAtoms::overflowProperty);
}
return (nsIFrame*) aPresContext->FrameManager()->
GetFrameProperty(this, nsLayoutAtoms::overflowProperty, options);
return (nsIFrame*) GetProperty(nsLayoutAtoms::overflowProperty);
}
// Destructor function for the overflow frame property
static void
DestroyOverflowFrames(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyOverflowFrames(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
if (aPropertyValue) {
nsFrameList frames((nsIFrame*)aPropertyValue);
frames.DestroyFrames(aPresContext);
frames.DestroyFrames(NS_STATIC_CAST(nsPresContext*, aDtorData));
}
}
@ -1194,12 +1191,12 @@ nsresult
nsContainerFrame::SetOverflowFrames(nsPresContext* aPresContext,
nsIFrame* aOverflowFrames)
{
nsresult rv = aPresContext->FrameManager()->
SetFrameProperty(this, nsLayoutAtoms::overflowProperty,
aOverflowFrames, DestroyOverflowFrames);
nsresult rv = SetProperty(nsLayoutAtoms::overflowProperty,
aOverflowFrames, DestroyOverflowFrames,
aPresContext);
// Verify that we didn't overwrite an existing overflow list
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN, "existing overflow list");
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow list");
return rv;
}

Просмотреть файл

@ -2269,8 +2269,7 @@ nsIFrame::GetView() const
// Check for a property on the frame
nsresult rv;
void* value = GetPresContext()->FrameManager()->
GetFrameProperty(this, nsLayoutAtoms::viewProperty, 0, &rv);
void *value = GetProperty(nsLayoutAtoms::viewProperty, &rv);
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ASSERTION(value, "frame state bit was set but frame has no view");
@ -2290,8 +2289,7 @@ nsIFrame::SetView(nsIView* aView)
aView->SetClientData(this);
// Set a property on the frame
nsresult rv = GetPresContext()->FrameManager()->
SetFrameProperty(this, nsLayoutAtoms::viewProperty, aView, nsnull);
nsresult rv = SetProperty(nsLayoutAtoms::viewProperty, aView, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// Set the frame state bit that says the frame has a view
@ -4209,10 +4207,10 @@ nsFrame::GetAccessible(nsIAccessible** aAccessible)
// Destructor function for the overflow area property
static void
DestroyRectFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyRectFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nsRect*)aPropertyValue;
}
@ -4224,11 +4222,7 @@ nsIFrame::GetOverflowAreaProperty(PRBool aCreateIfNecessary)
return nsnull;
}
nsFrameManager *frameManager = GetPresContext()->FrameManager();
void *value =
frameManager->GetFrameProperty(this, nsLayoutAtoms::overflowAreaProperty,
0);
void *value = GetProperty(nsLayoutAtoms::overflowAreaProperty);
if (value) {
return (nsRect*)value; // the property already exists
@ -4236,9 +4230,8 @@ nsIFrame::GetOverflowAreaProperty(PRBool aCreateIfNecessary)
// The property isn't set yet, so allocate a new rect, set the property,
// and return the newly allocated rect
nsRect* overflow = new nsRect(0, 0, 0, 0);
frameManager->SetFrameProperty(this, nsLayoutAtoms::overflowAreaProperty,
overflow, DestroyRectFunc);
SetProperty(nsLayoutAtoms::overflowAreaProperty,
overflow, DestroyRectFunc);
return overflow;
}
@ -4271,8 +4264,7 @@ nsIFrame::FinishAndStoreOverflow(nsRect* aOverflowArea, nsSize aNewSize)
else {
if (mState & NS_FRAME_OUTSIDE_CHILDREN) {
// remove the previously stored overflow area
GetPresContext()->FrameManager()->
RemoveFrameProperty(this, nsLayoutAtoms::overflowAreaProperty);
DeleteProperty(nsLayoutAtoms::overflowAreaProperty);
}
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
}
@ -4338,8 +4330,7 @@ GetIBSpecialSibling(nsPresContext* aPresContext,
*/
nsresult rv;
nsIFrame *specialSibling = NS_STATIC_CAST(nsIFrame*,
aPresContext->FrameManager()->GetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialPrevSibling, 0, &rv));
aFrame->GetProperty(nsLayoutAtoms::IBSplitSpecialPrevSibling, &rv));
if (NS_OK == rv) {
NS_ASSERTION(specialSibling, "null special sibling");
@ -4545,19 +4536,20 @@ nsFrame::IsMouseCaptured(nsPresContext* aPresContext)
}
nsresult
nsIFrame::SetProperty(nsIAtom* aPropName,
void* aPropValue,
NSFramePropertyDtorFunc aPropDtorFunc)
nsIFrame::SetProperty(nsIAtom* aPropName,
void* aPropValue,
NSPropertyDtorFunc aPropDtorFunc,
void* aDtorData)
{
return GetPresContext()->FrameManager()->
SetFrameProperty(this, aPropName, aPropValue, aPropDtorFunc);
return GetPresContext()->PropertyTable()->
SetProperty(this, aPropName, aPropValue, aPropDtorFunc, aDtorData);
}
void*
nsIFrame::GetProperty(nsIAtom* aPropName, nsresult* aStatus) const
{
return GetPresContext()->FrameManager()->
GetFrameProperty(this, aPropName, 0, aStatus);
return GetPresContext()->PropertyTable()->GetProperty(this, aPropName,
aStatus);
}
/* virtual */ void*
@ -4566,11 +4558,17 @@ nsIFrame::GetPropertyExternal(nsIAtom* aPropName, nsresult* aStatus) const
return GetProperty(aPropName, aStatus);
}
void*
nsIFrame::RemoveProperty(nsIAtom* aPropName, nsresult* aStatus) const
nsresult
nsIFrame::DeleteProperty(nsIAtom* aPropName) const
{
return GetPresContext()->FrameManager()->
GetFrameProperty(this, aPropName, NS_IFRAME_MGR_REMOVE_PROP, aStatus);
return GetPresContext()->PropertyTable()->DeleteProperty(this, aPropName);
}
void*
nsIFrame::UnsetProperty(nsIAtom* aPropName, nsresult* aStatus) const
{
return GetPresContext()->PropertyTable()->UnsetProperty(this, aPropName,
aStatus);
}
/* virtual */ const nsStyleStruct*

Просмотреть файл

@ -154,13 +154,6 @@ static PLDHashTableOps PlaceholderMapOps = {
//----------------------------------------------------------------------
struct PropertyListMapEntry : public PLDHashEntryHdr {
const nsIFrame *key;
void *value;
};
//----------------------------------------------------------------------
struct PrimaryFrameMapEntry : public PLDHashEntryHdr {
// key (the content node) can almost always be obtained through the
// frame. If it weren't for the way image maps (mis)used the primary
@ -277,26 +270,6 @@ struct CantRenderReplacedElementEvent : public PLEvent {
nsWeakPtr mPresShell; // for removing load group request later
};
struct nsFrameManagerBase::PropertyList {
nsCOMPtr<nsIAtom> mName; // property name
PLDHashTable mFrameValueMap; // map of frame/value pairs
NSFramePropertyDtorFunc mDtorFunc; // property specific value dtor function
PropertyList* mNext;
PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc) NS_HIDDEN;
~PropertyList() NS_HIDDEN;
// Removes the property associated with the given frame, and destroys
// the property value
NS_HIDDEN_(PRBool) RemovePropertyForFrame(nsPresContext* aPresContext,
const nsIFrame* aFrame);
// Destroy all remaining properties (without removing them)
NS_HIDDEN_(void) Destroy(nsPresContext* aPresContext);
};
//----------------------------------------------------------------------
nsFrameManager::nsFrameManager()
@ -334,9 +307,7 @@ nsFrameManager::Destroy()
nsPresContext *presContext = mPresShell->GetPresContext();
// Destroy the frame hierarchy. Don't destroy the property lists until after
// we've destroyed the frame hierarchy because some frames may expect to be
// able to retrieve their properties during destruction
// Destroy the frame hierarchy.
mPresShell->SetIgnoreFrameDestruction(PR_TRUE);
mIsDestroyingFrames = PR_TRUE; // This flag prevents GetPrimaryFrameFor from returning pointers to destroyed frames
@ -355,7 +326,6 @@ nsFrameManager::Destroy()
mPlaceholderMap.ops = nsnull;
}
delete mUndisplayedMap;
DestroyPropertyList(presContext);
// If we're not going to be used anymore, we should revoke the
// pending |CantRenderReplacedElementEvent|s being sent to us.
@ -735,10 +705,8 @@ nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
// Insert aFrameList after the last bidi continuation of aPrevFrame.
nsIFrame* nextBidi;
for (; ;) {
nextBidi =
NS_STATIC_CAST(nsIFrame*, GetFrameProperty(aPrevFrame,
nsLayoutAtoms::nextBidi,
0));
nextBidi = NS_STATIC_CAST(nsIFrame*,
aPrevFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (!nextBidi) {
break;
}
@ -759,8 +727,7 @@ nsFrameManager::RemoveFrame(nsIFrame* aParentFrame,
#ifdef IBMBIDI
// Don't let the parent remove next bidi. In the other cases the it should NOT be removed.
nsIFrame* nextBidi =
NS_STATIC_CAST(nsIFrame*, GetFrameProperty(aOldFrame,
nsLayoutAtoms::nextBidi, 0));
NS_STATIC_CAST(nsIFrame*, aOldFrame->GetProperty(nsLayoutAtoms::nextBidi));
if (nextBidi) {
RemoveFrame(aParentFrame, aListName, nextBidi);
}
@ -778,10 +745,6 @@ nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame)
// Dequeue and destroy and posted events for this frame
DequeuePostedEventFor(aFrame);
// Remove all properties associated with the frame
nsPresContext *presContext = mPresShell->GetPresContext();
RemoveAllPropertiesFor(presContext, aFrame);
#ifdef DEBUG
if (mPrimaryFrameMap.ops) {
PrimaryFrameMapEntry *entry = NS_STATIC_CAST(PrimaryFrameMapEntry*,
@ -1699,8 +1662,8 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame,
return topLevelChange;
}
frame2 = NS_STATIC_CAST(nsIFrame*, GetFrameProperty(frame2,
nsLayoutAtoms::IBSplitSpecialSibling, 0));
frame2 = NS_STATIC_CAST(nsIFrame*,
frame2->GetProperty(nsLayoutAtoms::IBSplitSpecialSibling));
frame = frame2;
} while (frame2);
return topLevelChange;
@ -1876,140 +1839,6 @@ CompareKeys(void* key1, void* key2)
return key1 == key2;
}
void
nsFrameManager::DestroyPropertyList(nsPresContext* aPresContext)
{
if (mPropertyList) {
while (mPropertyList) {
PropertyList* tmp = mPropertyList;
mPropertyList = mPropertyList->mNext;
tmp->Destroy(aPresContext);
delete tmp;
}
}
}
nsFrameManagerBase::PropertyList*
nsFrameManager::GetPropertyListFor(nsIAtom* aPropertyName) const
{
PropertyList* result;
for (result = mPropertyList; result; result = result->mNext) {
if (result->mName.get() == aPropertyName) {
break;
}
}
return result;
}
void
nsFrameManager::RemoveAllPropertiesFor(nsPresContext* aPresContext,
nsIFrame* aFrame)
{
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
prop->RemovePropertyForFrame(aPresContext, aFrame);
}
}
void*
nsFrameManager::GetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
PRUint32 aOptions,
nsresult* aResult)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
nsresult rv = NS_IFRAME_MGR_PROP_NOT_THERE;
void *propValue = nsnull;
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame,
PL_DHASH_LOOKUP));
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
propValue = entry->value;
if (aOptions & NS_IFRAME_MGR_REMOVE_PROP) {
// don't call propertyList->mDtorFunc. That's the caller's job now.
PL_DHashTableRawRemove(&propertyList->mFrameValueMap, entry);
}
rv = NS_OK;
}
}
if (aResult)
*aResult = rv;
return propValue;
}
nsresult
nsFrameManager::SetFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue,
NSFramePropertyDtorFunc aPropDtorFunc)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
// Make sure the dtor function matches
if (aPropDtorFunc != propertyList->mDtorFunc) {
return NS_ERROR_INVALID_ARG;
}
} else {
propertyList = new PropertyList(aPropertyName, aPropDtorFunc);
if (!propertyList)
return NS_ERROR_OUT_OF_MEMORY;
if (!propertyList->mFrameValueMap.ops) {
delete propertyList;
return NS_ERROR_OUT_OF_MEMORY;
}
propertyList->mNext = mPropertyList;
mPropertyList = propertyList;
}
// The current property value (if there is one) is replaced and the current
// value is destroyed
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {
propertyList->mDtorFunc(mPresShell->GetPresContext(),
NS_CONST_CAST(nsIFrame*, entry->key),
aPropertyName, entry->value);
result = NS_IFRAME_MGR_PROP_OVERWRITTEN;
}
entry->key = aFrame;
entry->value = aPropertyValue;
return result;
}
nsresult
nsFrameManager::RemoveFrameProperty(const nsIFrame* aFrame,
nsIAtom* aPropertyName)
{
NS_PRECONDITION(aPropertyName && aFrame, "unexpected null param");
PropertyList* propertyList = GetPropertyListFor(aPropertyName);
if (propertyList) {
if (propertyList->RemovePropertyForFrame(mPresShell->GetPresContext(),
aFrame))
return NS_OK;
}
return NS_IFRAME_MGR_PROP_NOT_THERE;
}
//----------------------------------------------------------------------
MOZ_DECL_CTOR_COUNTER(UndisplayedMap)
@ -2157,59 +1986,3 @@ nsFrameManagerBase::UndisplayedMap::Clear(void)
mLastLookup = nsnull;
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
}
//----------------------------------------------------------------------
nsFrameManagerBase::PropertyList::PropertyList(nsIAtom* aName,
NSFramePropertyDtorFunc aDtorFunc)
: mName(aName), mDtorFunc(aDtorFunc), mNext(nsnull)
{
PL_DHashTableInit(&mFrameValueMap, PL_DHashGetStubOps(), this,
sizeof(PropertyListMapEntry), 16);
}
nsFrameManagerBase::PropertyList::~PropertyList()
{
PL_DHashTableFinish(&mFrameValueMap);
}
PR_STATIC_CALLBACK(PLDHashOperator)
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
PRUint32 number, void *arg)
{
nsFrameManagerBase::PropertyList *propList =
NS_STATIC_CAST(nsFrameManagerBase::PropertyList*, table->data);
nsPresContext *presContext = NS_STATIC_CAST(nsPresContext*, arg);
PropertyListMapEntry* entry = NS_STATIC_CAST(PropertyListMapEntry*, hdr);
propList->mDtorFunc(presContext, NS_CONST_CAST(nsIFrame*, entry->key),
propList->mName, entry->value);
return PL_DHASH_NEXT;
}
void
nsFrameManagerBase::PropertyList::Destroy(nsPresContext* aPresContext)
{
// Enumerate any remaining frame/value pairs and destroy the value object
if (mDtorFunc)
PL_DHashTableEnumerate(&mFrameValueMap, DestroyPropertyEnumerator,
aPresContext);
}
PRBool
nsFrameManagerBase::PropertyList::RemovePropertyForFrame(nsPresContext* aPresContext,
const nsIFrame* aFrame)
{
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&mFrameValueMap, aFrame, PL_DHASH_LOOKUP));
if (!PL_DHASH_ENTRY_IS_BUSY(entry))
return PR_FALSE;
if (mDtorFunc)
mDtorFunc(aPresContext, NS_CONST_CAST(nsIFrame*, aFrame),
mName, entry->value);
PL_DHashTableRawRemove(&mFrameValueMap, entry);
return PR_TRUE;
}

Просмотреть файл

@ -6808,20 +6808,12 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
// verify that neither frame has a space manager,
// or they both do and the space managers are equivalent
nsFrameManager *fm1 = aFirstPresContext->FrameManager();
NS_ASSERTION(fm1, "no frame manager for primary tree!");
nsSpaceManager *sm1 =
NS_STATIC_CAST(nsSpaceManager*, fm1->GetFrameProperty(k1,
nsLayoutAtoms::spaceManagerProperty, 0));
nsSpaceManager *sm1 = NS_STATIC_CAST(nsSpaceManager*,
k1->GetProperty(nsLayoutAtoms::spaceManagerProperty));
// look at the test frame
nsFrameManager *fm2 = aSecondPresContext->FrameManager();
NS_ASSERTION(fm2, "no frame manager for test tree!");
nsSpaceManager *sm2 =
NS_STATIC_CAST(nsSpaceManager*, fm2->GetFrameProperty(k2,
nsLayoutAtoms::spaceManagerProperty, 0));
nsSpaceManager *sm2 = NS_STATIC_CAST(nsSpaceManager*,
k2->GetProperty(nsLayoutAtoms::spaceManagerProperty));
// now compare the space managers
if (((nsnull == sm1) && (nsnull != sm2)) ||

Просмотреть файл

@ -240,10 +240,7 @@ nsSubDocumentFrame::Init(nsPresContext* aPresContext,
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
nsIFrame* contentParent = nsnull;
void *value =
aPresContext->FrameManager()->GetFrameProperty(this, contentParentAtom,
NS_IFRAME_MGR_REMOVE_PROP,
&rv);
void *value = UnsetProperty(contentParentAtom, &rv);
if (NS_SUCCEEDED(rv)) {
contentParent = (nsIFrame*)value;
}

Просмотреть файл

@ -384,9 +384,7 @@ GetSpecialSibling(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame** aR
// frame in the flow. Walk back to find that frame now.
aFrame = aFrame->GetFirstInFlow();
void* value =
aFrameManager->GetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialSibling, 0);
void* value = aFrame->GetProperty(nsLayoutAtoms::IBSplitSpecialSibling);
*aResult = NS_STATIC_CAST(nsIFrame*, value);
}
@ -438,9 +436,8 @@ SetFrameIsSpecial(nsFrameManager* aFrameManager, nsIFrame* aFrame, nsIFrame* aSp
// Store the "special sibling" (if we were given one) with the
// first frame in the flow.
aFrameManager->SetFrameProperty(aFrame,
nsLayoutAtoms::IBSplitSpecialSibling,
aSpecialSibling, nsnull);
aFrame->SetProperty(nsLayoutAtoms::IBSplitSpecialSibling,
aSpecialSibling, nsnull);
}
}
@ -571,10 +568,8 @@ MarkIBSpecialPrevSibling(nsPresContext* aPresContext,
nsIFrame *aAnonymousFrame,
nsIFrame *aSpecialParent)
{
aFrameManager->SetFrameProperty(aAnonymousFrame,
nsLayoutAtoms::IBSplitSpecialPrevSibling,
aSpecialParent,
nsnull);
aAnonymousFrame->SetProperty(nsLayoutAtoms::IBSplitSpecialPrevSibling,
aSpecialParent, nsnull);
}
// -----------------------------------------------------------
@ -4749,9 +4744,9 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell,
// there is no reasonable way to get the value there.
// so we store it as a frame property.
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
aState.mFrameManager->SetFrameProperty(newFrame,
contentParentAtom,
aParentFrame, nsnull);
aPresContext->PropertyTable()->SetProperty(newFrame, contentParentAtom,
aParentFrame, nsnull,
nsnull);
}
}
}
@ -9826,8 +9821,6 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
if (!count)
return NS_OK;
nsFrameManager *frameManager = aPresContext->FrameManager();
// Mark frames so that we skip frames that die along the way, bug 123049.
// A frame can be in the list multiple times with different hints. Further
// optmization is possible if nsStyleChangeList::AppendChange could coalesce
@ -9836,8 +9829,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
const nsStyleChangeData* changeData;
aChangeList.ChangeAt(index, &changeData);
if (changeData->mFrame) {
frameManager->SetFrameProperty(changeData->mFrame,
nsLayoutAtoms::changeListProperty, nsnull, nsnull);
changeData->mFrame->SetProperty(nsLayoutAtoms::changeListProperty,
nsnull, nsnull);
}
}
@ -9852,12 +9845,9 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
if (frame) {
nsresult res;
void* dummy =
frameManager->GetFrameProperty(frame,
nsLayoutAtoms::changeListProperty, 0,
&res);
void* dummy = frame->GetProperty(nsLayoutAtoms::changeListProperty, &res);
if (NS_IFRAME_MGR_PROP_NOT_THERE == res)
if (NS_PROPTABLE_PROP_NOT_THERE == res)
continue;
}
@ -9893,8 +9883,7 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList,
const nsStyleChangeData* changeData;
aChangeList.ChangeAt(index, &changeData);
if (changeData->mFrame) {
frameManager->RemoveFrameProperty(changeData->mFrame,
nsLayoutAtoms::changeListProperty);
changeData->mFrame->DeleteProperty(nsLayoutAtoms::changeListProperty);
}
}

Просмотреть файл

@ -7375,30 +7375,30 @@ PRBool nsTableFrame::ColIsSpannedInto(PRInt32 aColIndex)
// Destructor function for nscoord properties
static void
DestroyCoordFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyCoordFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nscoord*)aPropertyValue;
}
// Destructor function point properties
static void
DestroyPointFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyPointFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nsPoint*)aPropertyValue;
}
// Destructor function for nscoord properties
static void
DestroyBCPropertyDataFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyBCPropertyDataFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (BCPropertyData*)aPropertyValue;
}
@ -7409,16 +7409,14 @@ nsTableFrame::GetProperty(nsPresContext* aPresContext,
nsIAtom* aPropertyName,
PRBool aCreateIfNecessary)
{
nsFrameManager *frameManager = aPresContext->FrameManager();
void *value = frameManager->GetFrameProperty(aFrame, aPropertyName, 0);
void *value = aFrame->GetProperty(aPropertyName);
if (value) {
return (nsPoint*)value; // the property already exists
} else if (aCreateIfNecessary) {
// The property isn't set yet, so allocate a new value, set the property,
// and return the newly allocated value
void* value = nsnull;
NSFramePropertyDtorFunc dtorFunc = nsnull;
NSPropertyDtorFunc dtorFunc = nsnull;
if (aPropertyName == nsLayoutAtoms::collapseOffsetProperty) {
value = new nsPoint(0, 0);
dtorFunc = DestroyPointFunc;
@ -7433,7 +7431,7 @@ nsTableFrame::GetProperty(nsPresContext* aPresContext,
}
if (!value) return nsnull;
frameManager->SetFrameProperty(aFrame, aPropertyName, value, dtorFunc);
aFrame->SetProperty(aPropertyName, value, dtorFunc);
return value;
}

Просмотреть файл

@ -116,10 +116,10 @@ struct nsValueList
// The code doesn't include hooks for AttributeChanged() notifications.
static void
DestroyValueListFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyValueListFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete NS_STATIC_CAST(nsValueList*, aPropertyValue);
}
@ -133,9 +133,8 @@ GetValueAt(nsPresContext* aPresContext,
PRUnichar* result = nsnull;
nsValueList* valueList;
nsFrameManager *frameManager = aPresContext->FrameManager();
valueList = NS_STATIC_CAST(nsValueList*,
frameManager->GetFrameProperty(aTableOrRowFrame, aAttributeAtom, 0));
aTableOrRowFrame->GetProperty(aAttributeAtom));
if (!valueList) {
// The property isn't there yet, so set it
@ -144,8 +143,8 @@ GetValueAt(nsPresContext* aPresContext,
aTableOrRowFrame->GetContent()->GetAttr(kNameSpaceID_None, aAttributeAtom, values)) {
valueList = new nsValueList(values);
if (valueList) {
frameManager->SetFrameProperty(aTableOrRowFrame, aAttributeAtom,
valueList, DestroyValueListFunc);
aTableOrRowFrame->SetProperty(aAttributeAtom,
valueList, DestroyValueListFunc);
}
}
}

Просмотреть файл

@ -7375,30 +7375,30 @@ PRBool nsTableFrame::ColIsSpannedInto(PRInt32 aColIndex)
// Destructor function for nscoord properties
static void
DestroyCoordFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyCoordFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nscoord*)aPropertyValue;
}
// Destructor function point properties
static void
DestroyPointFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyPointFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (nsPoint*)aPropertyValue;
}
// Destructor function for nscoord properties
static void
DestroyBCPropertyDataFunc(nsPresContext* aPresContext,
nsIFrame* aFrame,
DestroyBCPropertyDataFunc(void* aFrame,
nsIAtom* aPropertyName,
void* aPropertyValue)
void* aPropertyValue,
void* aDtorData)
{
delete (BCPropertyData*)aPropertyValue;
}
@ -7409,16 +7409,14 @@ nsTableFrame::GetProperty(nsPresContext* aPresContext,
nsIAtom* aPropertyName,
PRBool aCreateIfNecessary)
{
nsFrameManager *frameManager = aPresContext->FrameManager();
void *value = frameManager->GetFrameProperty(aFrame, aPropertyName, 0);
void *value = aFrame->GetProperty(aPropertyName);
if (value) {
return (nsPoint*)value; // the property already exists
} else if (aCreateIfNecessary) {
// The property isn't set yet, so allocate a new value, set the property,
// and return the newly allocated value
void* value = nsnull;
NSFramePropertyDtorFunc dtorFunc = nsnull;
NSPropertyDtorFunc dtorFunc = nsnull;
if (aPropertyName == nsLayoutAtoms::collapseOffsetProperty) {
value = new nsPoint(0, 0);
dtorFunc = DestroyPointFunc;
@ -7433,7 +7431,7 @@ nsTableFrame::GetProperty(nsPresContext* aPresContext,
}
if (!value) return nsnull;
frameManager->SetFrameProperty(aFrame, aPropertyName, value, dtorFunc);
aFrame->SetProperty(aPropertyName, value, dtorFunc);
return value;
}

Просмотреть файл

@ -570,8 +570,7 @@ nsBox::SetBounds(nsBoxLayoutState& aState, const nsRect& aRect, PRBool aRemoveOv
// it if necessary.
if (aRemoveOverflowArea && (frame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN)) {
// remove the previously stored overflow area
frame->GetPresContext()->FrameManager()->
RemoveFrameProperty(frame, nsLayoutAtoms::overflowAreaProperty);
frame->DeleteProperty(nsLayoutAtoms::overflowAreaProperty);
frame->RemoveStateBits(NS_FRAME_OUTSIDE_CHILDREN);
}