From 37d2cef78cf1db5dc614f83da03bfbbfbfe58a64 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 11 Aug 2004 23:47:18 +0000 Subject: [PATCH] Refactor frame property code so it can be used as a generic object-property mechanism for content nodes and frames. Add an interface for manipulating content node properties, for now just on elements. Bug 253888, r=jst, sr=dbaron. (This will land on the trunk once it reopens) git-svn-id: svn://10.0.0.236/branches/FORMS_20040722_BRANCH@160690 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsContentErrors.h | 6 + mozilla/content/base/public/nsIContent.h | 22 ++ mozilla/content/base/public/nsIDocument.h | 6 + mozilla/content/base/src/nsGenericElement.cpp | 51 ++++ mozilla/content/base/src/nsGenericElement.h | 20 +- mozilla/content/shared/public/Makefile.in | 1 + .../content/shared/public/nsFrameManager.h | 69 ----- .../shared/public/nsFrameManagerBase.h | 4 - .../content/shared/public/nsPropertyTable.h | 138 +++++++++ mozilla/content/shared/src/Makefile.in | 1 + .../content/shared/src/nsPropertyTable.cpp | 263 ++++++++++++++++++ .../content/xul/content/src/nsXULElement.cpp | 55 +++- .../content/xul/content/src/nsXULElement.h | 11 +- mozilla/layout/base/public/nsIFrame.h | 25 +- mozilla/layout/base/public/nsIPresContext.h | 6 + mozilla/layout/base/public/nsLayoutErrors.h | 9 - mozilla/layout/base/src/nsBidiPresUtils.cpp | 11 +- mozilla/layout/base/src/nsPresContext.cpp | 1 + mozilla/layout/html/base/src/nsBlockFrame.cpp | 45 +-- .../html/base/src/nsBlockReflowContext.cpp | 15 +- .../html/base/src/nsBlockReflowState.cpp | 3 +- .../layout/html/base/src/nsContainerFrame.cpp | 23 +- mozilla/layout/html/base/src/nsFrame.cpp | 58 ++-- .../layout/html/base/src/nsFrameManager.cpp | 244 +--------------- mozilla/layout/html/base/src/nsPresShell.cpp | 16 +- .../layout/html/document/src/nsFrameFrame.cpp | 5 +- .../html/style/src/nsCSSFrameConstructor.cpp | 35 +-- .../layout/html/table/src/nsTableFrame.cpp | 26 +- .../mathml/base/src/nsMathMLmtableFrame.cpp | 13 +- mozilla/layout/xul/base/src/nsBox.cpp | 3 +- 30 files changed, 702 insertions(+), 483 deletions(-) create mode 100644 mozilla/content/shared/public/nsPropertyTable.h create mode 100644 mozilla/content/shared/src/nsPropertyTable.cpp diff --git a/mozilla/content/base/public/nsContentErrors.h b/mozilla/content/base/public/nsContentErrors.h index 5c458649e0f..77982c289fc 100644 --- a/mozilla/content/base/public/nsContentErrors.h +++ b/mozilla/content/base/public/nsContentErrors.h @@ -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___ diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index 3809e82be0d..1673acaa0f0 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -43,6 +43,7 @@ #include "nsEvent.h" #include "nsAString.h" #include "nsContentErrors.h" +#include "nsPropertyTable.h" // Forward declarations class nsIAtom; @@ -560,6 +561,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 diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 75a1b72fffc..3add9074265 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -52,6 +52,7 @@ #include "nsReadableUtils.h" #include "nsCRT.h" #include "mozFlushType.h" +#include "nsPropertyTable.h" class nsIAtom; class nsIContent; @@ -607,6 +608,8 @@ public: PRBool aDocumentDefaultType, nsIContent** aResult) = 0; + nsPropertyTable* PropertyTable() { return &mPropertyTable; } + protected: nsString mDocumentTitle; nsCOMPtr mDocumentURI; @@ -633,6 +636,9 @@ protected: nsCOMPtr mBindingManager; nsNodeInfoManager* mNodeInfoManager; // [STRONG] + // Table of element properties for this document. + nsPropertyTable mPropertyTable; + // True if BIDI is enabled. PRBool mBidiEnabled; diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 30c3b700146..7db7cc705d8 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1735,6 +1735,10 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, } } + if (mDocument && HasProperties()) { + mDocument->PropertyTable()->DeleteAllPropertiesFor(this); + } + nsIContent::SetDocument(aDocument, aDeep, aCompileEventHandlers); } @@ -3622,3 +3626,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); +} diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 74526dfcd32..6efe5770198 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -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 \ @@ -398,6 +401,14 @@ public: virtual PRBool IsContentOfType(PRUint32 aFlags) const; virtual nsresult GetListenerManager(nsIEventListenerManager** aResult); virtual already_AddRefed 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; @@ -735,6 +746,13 @@ protected: return NS_REINTERPRET_CAST(nsIContent *, mParentPtrBits); } + 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 diff --git a/mozilla/content/shared/public/Makefile.in b/mozilla/content/shared/public/Makefile.in index ee3c2c0bfd6..892f1d66d52 100644 --- a/mozilla/content/shared/public/Makefile.in +++ b/mozilla/content/shared/public/Makefile.in @@ -68,6 +68,7 @@ nsHTMLValue.h \ nsImageMapUtils.h \ nsLayoutAtomList.h \ nsLayoutAtoms.h \ +nsPropertyTable.h \ nsRuleNode.h \ nsRuleWalker.h \ nsStyleContext.h \ diff --git a/mozilla/content/shared/public/nsFrameManager.h b/mozilla/content/shared/public/nsFrameManager.h index fd74a76bdba..4a84f634898 100644 --- a/mozilla/content/shared/public/nsFrameManager.h +++ b/mozilla/content/shared/public/nsFrameManager.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: *
  • 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(nsIPresContext* aPresContext); - NS_HIDDEN_(PropertyList*) GetPropertyListFor(nsIAtom* aPropertyName) const; - NS_HIDDEN_(void) RemoveAllPropertiesFor(nsIPresContext *aPresContext, - nsIFrame *aFrame); static NS_HIDDEN_(void) HandlePLEvent(CantRenderReplacedElementEvent* aEvent); diff --git a/mozilla/content/shared/public/nsFrameManagerBase.h b/mozilla/content/shared/public/nsFrameManagerBase.h index eccba380a6f..834ac770f4c 100644 --- a/mozilla/content/shared/public/nsFrameManagerBase.h +++ b/mozilla/content/shared/public/nsFrameManagerBase.h @@ -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; }; diff --git a/mozilla/content/shared/public/nsPropertyTable.h b/mozilla/content/shared/public/nsPropertyTable.h new file mode 100644 index 00000000000..96e4d1b1178 --- /dev/null +++ b/mozilla/content/shared/public/nsPropertyTable.h @@ -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 diff --git a/mozilla/content/shared/src/Makefile.in b/mozilla/content/shared/src/Makefile.in index 0525ea11326..a86a5cae45e 100644 --- a/mozilla/content/shared/src/Makefile.in +++ b/mozilla/content/shared/src/Makefile.in @@ -73,6 +73,7 @@ CPPSRCS = \ nsStyleCoord.cpp \ nsStyleStruct.cpp \ nsBidiUtils.cpp \ + nsPropertyTable.cpp \ $(NULL) ifdef MOZ_SVG diff --git a/mozilla/content/shared/src/nsPropertyTable.cpp b/mozilla/content/shared/src/nsPropertyTable.cpp new file mode 100644 index 00000000000..b0b18f6e16f --- /dev/null +++ b/mozilla/content/shared/src/nsPropertyTable.cpp @@ -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 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; +} diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index b266c204ac4..2a9a92679f8 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1586,6 +1586,10 @@ nsXULElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, nsCOMPtr nsDoc(do_QueryInterface(mDocument)); nsDoc->SetBoxObjectFor(this, nsnull); + + if (mSlots && mSlots->mHasProperties) { + mDocument->PropertyTable()->DeleteAllPropertiesFor(this); + } } // mControllers can own objects that are implemented @@ -2897,6 +2901,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) @@ -4019,8 +4072,8 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide) // nsXULElement::Slots::Slots() - : mLazyState(0) { + mLazyState = mHasProperties = 0; MOZ_COUNT_CTOR(nsXULElement::Slots); } diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 52fa5c9e2bc..aeda197ba6f 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -493,6 +493,14 @@ public: virtual PRBool IsContentOfType(PRUint32 aFlags) const; virtual already_AddRefed GetBaseURI() const; virtual nsresult GetListenerManager(nsIEventListenerManager** aResult); + 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); @@ -593,7 +601,8 @@ protected: nsRefPtr mDOMStyle; // [OWNER] nsRefPtr mAttributeMap; // [OWNER] nsRefPtr mChildNodes; // [OWNER] - PRUint32 mLazyState; + unsigned mLazyState : 3; + unsigned mHasProperties : 1; }; friend struct Slots; diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 00930ebd5f4..2ebb9c73dcf 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -89,13 +89,6 @@ struct nsRect; struct nsSize; struct nsMargin; -// Calback function used to destroy the value associated with a property. -typedef void -(*NSFramePropertyDtorFunc)(nsIPresContext* aPresContext, - nsIFrame* aFrame, - nsIAtom* aPropertyName, - void* aPropertyValue); - // IID for the nsIFrame interface // a6cf9050-15b3-11d2-932e-00805f8add32 #define NS_IFRAME_IID \ @@ -1211,13 +1204,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)) diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index a359678ecc7..979a8d3c863 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -46,6 +46,7 @@ #include "nsIPresShell.h" #include "nsRect.h" #include "nsIDeviceContext.h" +#include "nsPropertyTable.h" #ifdef IBMBIDI class nsBidiPresUtils; #endif // IBMBIDI @@ -500,6 +501,9 @@ public: */ NS_IMETHOD SysColorChanged() = 0; + /* Accessor for table of frame properties */ + nsPropertyTable* PropertyTable() { return &mPropertyTable; } + #ifdef MOZ_REFLOW_PERF NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0; NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0; @@ -524,6 +528,8 @@ protected: nsILinkHandler* mLinkHandler; // [WEAK] nsIAtom* mLangGroup; // [STRONG] + nsPropertyTable mPropertyTable; + nsLanguageSpecificTransformType mLanguageSpecificTransformType; PRInt32 mFontScaler; nscoord mMinimumFontSize; diff --git a/mozilla/layout/base/public/nsLayoutErrors.h b/mozilla/layout/base/public/nsLayoutErrors.h index 68ef2e6f4fb..924e3f77e2c 100644 --- a/mozilla/layout/base/public/nsLayoutErrors.h +++ b/mozilla/layout/base/public/nsLayoutErrors.h @@ -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) diff --git a/mozilla/layout/base/src/nsBidiPresUtils.cpp b/mozilla/layout/base/src/nsBidiPresUtils.cpp index ffc12d7f206..7a3f51887d9 100644 --- a/mozilla/layout/base/src/nsBidiPresUtils.cpp +++ b/mozilla/layout/base/src/nsBidiPresUtils.cpp @@ -787,22 +787,21 @@ nsBidiPresUtils::RemoveBidiContinuation(nsIPresContext* 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) } diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 10784380932..50502de386c 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -68,6 +68,7 @@ #include "nsIDOMDocument.h" #include "nsAutoPtr.h" #include "nsEventStateManager.h" +#include "nsPropertyTable.h" #ifdef IBMBIDI #include "nsBidiPresUtils.h" #endif // IBMBIDI diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 5697bb6ab23..34c14598974 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -922,10 +922,9 @@ nsBlockFrame::Reflow(nsIPresContext* 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(); } @@ -4298,21 +4297,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(nsIPresContext* 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); + nsIPresContext *context = NS_STATIC_CAST(nsIPresContext*, aDtorData); + nsLineBox::DeleteLineList(context, *lines); delete lines; } } @@ -4326,9 +4326,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; } @@ -4343,15 +4344,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(nsIPresContext* 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); @@ -4364,7 +4365,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; } @@ -4381,15 +4382,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(nsIPresContext* aPresContext, - nsIFrame* aFrame, +DestroyOverflowPlaceholders(void* aFrame, nsIAtom* aPropertyName, - void* aPropertyValue) + void* aPropertyValue, + void* aDtorData) { nsFrameList* overflowPlace = NS_STATIC_CAST(nsFrameList*, aPropertyValue); delete overflowPlace; @@ -4403,7 +4404,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; } @@ -5721,7 +5722,7 @@ void nsBlockFrame::ClearLineCursor() { return; } - RemoveProperty(nsLayoutAtoms::lineCursorProperty); + UnsetProperty(nsLayoutAtoms::lineCursorProperty); RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR); } diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp index 552edcc947a..2d31d59730e 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp @@ -292,8 +292,8 @@ ComputeShrinkwrapMargins(const nsStyleMargin* aStyleMargin, nscoord aWidth, } static void -nsPointDtor(nsIPresContext *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); } } diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index bfaac62bfe4..a9b56860f42 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -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; diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 5d869b7cbf4..19a88cb76f7 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -1153,27 +1153,24 @@ nsIFrame* nsContainerFrame::GetOverflowFrames(nsIPresContext* 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(nsIPresContext* 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(nsIPresContext*, aDtorData)); } } @@ -1181,12 +1178,12 @@ nsresult nsContainerFrame::SetOverflowFrames(nsIPresContext* 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; } diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 71aab630f01..068a8a7a836 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -2307,8 +2307,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"); @@ -2328,8 +2327,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 @@ -4247,10 +4245,10 @@ nsFrame::GetAccessible(nsIAccessible** aAccessible) // Destructor function for the overflow area property static void -DestroyRectFunc(nsIPresContext* aPresContext, - nsIFrame* aFrame, +DestroyRectFunc(void* aFrame, nsIAtom* aPropertyName, - void* aPropertyValue) + void* aPropertyValue, + void* aDtorData) { delete (nsRect*)aPropertyValue; } @@ -4262,11 +4260,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 @@ -4274,9 +4268,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; } @@ -4309,8 +4302,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; } @@ -4376,8 +4368,7 @@ GetIBSpecialSibling(nsIPresContext* 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"); @@ -4583,19 +4574,20 @@ nsFrame::IsMouseCaptured(nsIPresContext* 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* @@ -4604,11 +4596,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* diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index be6dceeea6e..c5455fa0eb4 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -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 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(nsIPresContext* aPresContext, - const nsIFrame* aFrame); - - // Destroy all remaining properties (without removing them) - NS_HIDDEN_(void) Destroy(nsIPresContext* aPresContext); -}; - - //---------------------------------------------------------------------- nsFrameManager::nsFrameManager() @@ -335,9 +308,7 @@ nsFrameManager::Destroy() nsCOMPtr presContext; mPresShell->GetPresContext(getter_AddRefs(presContext)); - // 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 @@ -356,7 +327,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. @@ -738,10 +708,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; } @@ -762,8 +730,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); } @@ -781,12 +748,6 @@ nsFrameManager::NotifyDestroyingFrame(nsIFrame* aFrame) // Dequeue and destroy and posted events for this frame DequeuePostedEventFor(aFrame); - // Remove all properties associated with the frame - nsCOMPtr presContext; - mPresShell->GetPresContext(getter_AddRefs(presContext)); - - RemoveAllPropertiesFor(presContext, aFrame); - #ifdef DEBUG if (mPrimaryFrameMap.ops) { PrimaryFrameMapEntry *entry = NS_STATIC_CAST(PrimaryFrameMapEntry*, @@ -1708,8 +1669,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; @@ -1885,143 +1846,6 @@ CompareKeys(void* key1, void* key2) return key1 == key2; } -void -nsFrameManager::DestroyPropertyList(nsIPresContext* 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(nsIPresContext* 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) { - nsCOMPtr presContext; - mPresShell->GetPresContext(getter_AddRefs(presContext)); - propertyList->mDtorFunc(presContext, 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) { - nsCOMPtr presContext; - mPresShell->GetPresContext(getter_AddRefs(presContext)); - - if (propertyList->RemovePropertyForFrame(presContext, aFrame)) - return NS_OK; - } - - return NS_IFRAME_MGR_PROP_NOT_THERE; -} - //---------------------------------------------------------------------- MOZ_DECL_CTOR_COUNTER(UndisplayedMap) @@ -2169,59 +1993,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); - nsIPresContext *presContext = NS_STATIC_CAST(nsIPresContext*, 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(nsIPresContext* aPresContext) -{ - // Enumerate any remaining frame/value pairs and destroy the value object - if (mDtorFunc) - PL_DHashTableEnumerate(&mFrameValueMap, DestroyPropertyEnumerator, - aPresContext); -} - -PRBool -nsFrameManagerBase::PropertyList::RemovePropertyForFrame(nsIPresContext* 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; -} diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index c015b49fb47..a6152e52c9e 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -6767,20 +6767,12 @@ CompareTrees(nsIPresContext* 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)) || diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index ae44a3eed2e..4953065f403 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -242,10 +242,7 @@ nsSubDocumentFrame::Init(nsIPresContext* aPresContext, nsCOMPtr 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; } diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 6a0c3364698..cf1d7a3caf5 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -380,9 +380,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); } @@ -434,9 +432,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); } } @@ -567,10 +564,8 @@ MarkIBSpecialPrevSibling(nsIPresContext* aPresContext, nsIFrame *aAnonymousFrame, nsIFrame *aSpecialParent) { - aFrameManager->SetFrameProperty(aAnonymousFrame, - nsLayoutAtoms::IBSplitSpecialPrevSibling, - aSpecialParent, - nsnull); + aAnonymousFrame->SetProperty(nsLayoutAtoms::IBSplitSpecialPrevSibling, + aSpecialParent, nsnull); } // ----------------------------------------------------------- @@ -4738,9 +4733,7 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsIPresShell* aPresShell, // there is no reasonable way to get the value there. // so we store it as a frame property. nsCOMPtr contentParentAtom = do_GetAtom("contentParent"); - aState.mFrameManager->SetFrameProperty(newFrame, - contentParentAtom, - aParentFrame, nsnull); + newFrame->SetProperty(contentParentAtom, aParentFrame, nsnull); } } } @@ -9961,8 +9954,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 @@ -9971,8 +9962,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); } } @@ -9987,12 +9978,9 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList, if (frame) { nsresult res; - void* dummy = - frameManager->GetFrameProperty(frame, - nsLayoutAtoms::changeListProperty, 0, - &res); + void* dummy = frame->GetProperty(nsLayoutAtoms::changeListProperty); - if (NS_IFRAME_MGR_PROP_NOT_THERE == res) + if (NS_PROPTABLE_PROP_NOT_THERE == res) continue; } @@ -10028,8 +10016,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); } } diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 63436782fcf..f06d3f8d489 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -7375,30 +7375,30 @@ PRBool nsTableFrame::ColIsSpannedInto(PRInt32 aColIndex) // Destructor function for nscoord properties static void -DestroyCoordFunc(nsIPresContext* aPresContext, - nsIFrame* aFrame, +DestroyCoordFunc(void* aFrame, nsIAtom* aPropertyName, - void* aPropertyValue) + void* aPropertyValue, + void* aDtorData) { delete (nscoord*)aPropertyValue; } // Destructor function point properties static void -DestroyPointFunc(nsIPresContext* 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(nsIPresContext* aPresContext, - nsIFrame* aFrame, +DestroyBCPropertyDataFunc(void* aFrame, nsIAtom* aPropertyName, - void* aPropertyValue) + void* aPropertyValue, + void* aDtorData) { delete (BCPropertyData*)aPropertyValue; } @@ -7409,16 +7409,14 @@ nsTableFrame::GetProperty(nsIPresContext* 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(nsIPresContext* aPresContext, } if (!value) return nsnull; - frameManager->SetFrameProperty(aFrame, aPropertyName, value, dtorFunc); + aFrame->SetProperty(aPropertyName, value, dtorFunc); return value; } diff --git a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 99b87da07ec..5baae4e8599 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -116,10 +116,10 @@ struct nsValueList // The code doesn't include hooks for AttributeChanged() notifications. static void -DestroyValueListFunc(nsIPresContext* 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(nsIPresContext* 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(nsIPresContext* 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); } } } diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index 772b91578b4..406815c6f1a 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -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); }