From 3437ee229a66c6cc062ef4b554fcd52734f8e5fb Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Thu, 27 Jan 2005 22:52:53 +0000 Subject: [PATCH] Remove nsIPresState (bug 279699). r+sr=roc. git-svn-id: svn://10.0.0.236/trunk@168423 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/public/nsIFormControl.h | 8 +- .../html/content/public/nsISelectElement.idl | 1 - .../html/content/src/nsGenericHTMLElement.cpp | 16 +- .../html/content/src/nsGenericHTMLElement.h | 6 +- .../html/content/src/nsHTMLInputElement.cpp | 14 +- .../html/content/src/nsHTMLObjectElement.cpp | 4 +- .../html/content/src/nsHTMLSelectElement.cpp | 10 +- .../content/src/nsHTMLSharedObjectElement.cpp | 4 +- .../content/src/nsHTMLTextAreaElement.cpp | 10 +- mozilla/layout/base/Makefile.in | 2 +- mozilla/layout/base/nsFrameManager.cpp | 18 +- mozilla/layout/base/nsILayoutHistoryState.h | 64 +++++- mozilla/layout/base/nsIPresState.h | 39 ---- mozilla/layout/base/nsLayoutErrors.h | 2 +- mozilla/layout/base/nsLayoutHistoryState.cpp | 101 ++++------ mozilla/layout/base/nsPresState.cpp | 183 ++++++------------ mozilla/layout/base/nsPresState.h | 71 +++++++ mozilla/layout/build/nsLayoutCID.h | 4 - mozilla/layout/build/nsLayoutModule.cpp | 13 -- .../layout/forms/nsComboboxControlFrame.cpp | 6 +- mozilla/layout/forms/nsComboboxControlFrame.h | 6 +- mozilla/layout/forms/nsFileControlFrame.cpp | 1 - mozilla/layout/forms/nsFileControlFrame.h | 1 - mozilla/layout/forms/nsFormControlHelper.h | 1 - .../layout/forms/nsGfxButtonControlFrame.cpp | 2 - .../layout/forms/nsGfxButtonControlFrame.h | 2 - .../forms/nsGfxCheckboxControlFrame.cpp | 1 - .../layout/forms/nsGfxRadioControlFrame.cpp | 1 - mozilla/layout/forms/nsIListControlFrame.h | 1 - mozilla/layout/forms/nsIsIndexFrame.cpp | 6 +- mozilla/layout/forms/nsIsIndexFrame.h | 5 +- mozilla/layout/forms/nsListControlFrame.h | 1 - mozilla/layout/forms/nsTextControlFrame.cpp | 1 - mozilla/layout/forms/nsTextControlFrame.h | 1 - mozilla/layout/generic/nsGfxScrollFrame.cpp | 14 +- mozilla/layout/generic/nsGfxScrollFrame.h | 18 +- mozilla/layout/generic/nsIStatefulFrame.h | 12 +- mozilla/layout/xul/base/src/nsBoxObject.cpp | 4 +- mozilla/layout/xul/base/src/nsBoxObject.h | 5 +- .../layout/xul/base/src/nsScrollBoxFrame.cpp | 1 - 40 files changed, 308 insertions(+), 352 deletions(-) delete mode 100644 mozilla/layout/base/nsIPresState.h create mode 100755 mozilla/layout/base/nsPresState.h diff --git a/mozilla/content/html/content/public/nsIFormControl.h b/mozilla/content/html/content/public/nsIFormControl.h index 5e6b5b85103..c2042199ad5 100644 --- a/mozilla/content/html/content/public/nsIFormControl.h +++ b/mozilla/content/html/content/public/nsIFormControl.h @@ -40,7 +40,7 @@ #include "nsISupports.h" class nsIDOMHTMLFormElement; class nsPresContext; -class nsIPresState; +class nsPresState; class nsIContent; class nsString; class nsIFormProcessor; @@ -69,8 +69,8 @@ class nsIFormSubmission; #define NS_FORM_OBJECT 21 #define NS_IFORMCONTROL_IID \ -{ 0x282ff440, 0xcd7e, 0x11d1, \ - {0x89, 0xad, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } +{ 0xfcf27549, 0xbd77, 0x455a, \ + {0x8c, 0x3e, 0xbb, 0x20, 0xc5, 0xaf, 0x7b, 0x86} } /** @@ -138,7 +138,7 @@ public: * @return PR_TRUE if the form control was a checkbox and its * checked state was restored, PR_FALSE otherwise. */ - virtual PRBool RestoreState(nsIPresState* aState) = 0; + virtual PRBool RestoreState(nsPresState* aState) = 0; virtual PRBool AllowDrop() = 0; }; diff --git a/mozilla/content/html/content/public/nsISelectElement.idl b/mozilla/content/html/content/public/nsISelectElement.idl index 22a750a1cbf..1b34e181669 100644 --- a/mozilla/content/html/content/public/nsISelectElement.idl +++ b/mozilla/content/html/content/public/nsISelectElement.idl @@ -40,7 +40,6 @@ interface nsIContent; interface nsIDOMHTMLOptionElement; interface nsPresContext; -interface nsIPresState; /** * This interface is used to notify a SELECT when OPTION diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index fff0f00513e..b5cf875eba8 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -88,7 +88,7 @@ #include "nsIScriptContext.h" #include "nsRuleData.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsILayoutHistoryState.h" #include "nsHTMLParts.h" @@ -139,7 +139,6 @@ #include "nsCOMArray.h" #include "nsNodeInfoManager.h" -static NS_DEFINE_CID(kPresStateCID, NS_PRESSTATE_CID); // XXX todo: add in missing out-of-memory checks //---------------------------------------------------------------------- @@ -2253,9 +2252,9 @@ nsGenericHTMLElement::GetFormControlFrameFor(nsIContent* aContent, return nsnull; } -nsresult +/* static */ nsresult nsGenericHTMLElement::GetPrimaryPresState(nsGenericHTMLElement* aContent, - nsIPresState** aPresState) + nsPresState** aPresState) { NS_ENSURE_ARG_POINTER(aPresState); *aPresState = nsnull; @@ -2270,7 +2269,7 @@ nsGenericHTMLElement::GetPrimaryPresState(nsGenericHTMLElement* aContent, // Get the pres state for this key, if it doesn't exist, create one result = history->GetState(key, aPresState); if (!*aPresState) { - result = CallCreateInstance(kPresStateCID, aPresState); + result = NS_NewPresState(aPresState); if (NS_SUCCEEDED(result)) { result = history->AddState(key, *aPresState); } @@ -2338,12 +2337,13 @@ nsGenericHTMLElement::RestoreFormControlState(nsGenericHTMLElement* aContent, return PR_FALSE; } - nsCOMPtr state; + nsPresState *state; // Get the pres state for this key - rv = history->GetState(key, getter_AddRefs(state)); + rv = history->GetState(key, &state); if (state) { + PRBool result = aControl->RestoreState(state); history->RemoveState(key); - return aControl->RestoreState(state); + return result; } return PR_FALSE; diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 59d3fbecd4b..9bd97823f08 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -59,7 +59,7 @@ class nsIDOMCSSStyleDeclaration; class nsIURI; class nsIFormControlFrame; class nsIForm; -class nsIPresState; +class nsPresState; class nsIScrollableView; class nsILayoutHistoryState; struct nsRect; @@ -545,7 +545,7 @@ public: * @param aPresState the presentation state (out param) */ static nsresult GetPrimaryPresState(nsGenericHTMLElement* aContent, - nsIPresState** aPresState); + nsPresState** aPresState); /** * Get the layout history object *and* generate the key for a particular * piece of content. @@ -818,7 +818,7 @@ public: { return NS_OK; } - virtual PRBool RestoreState(nsIPresState* aState) + virtual PRBool RestoreState(nsPresState* aState) { return PR_FALSE; } diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 500a233b1de..6960be60fa7 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -73,7 +73,7 @@ #include "nsIEditor.h" #include "nsGUIEvent.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsLayoutErrors.h" #include "nsIDOMEvent.h" #include "nsIDOMNSEvent.h" @@ -169,7 +169,7 @@ public: NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); NS_IMETHOD SaveState(); - virtual PRBool RestoreState(nsIPresState* aState); + virtual PRBool RestoreState(nsPresState* aState); virtual PRBool AllowDrop(); // nsIContent @@ -2338,7 +2338,7 @@ nsHTMLInputElement::SaveState() { nsresult rv = NS_OK; - nsCOMPtr state; + nsPresState *state = nsnull; switch (mType) { case NS_FORM_INPUT_CHECKBOX: case NS_FORM_INPUT_RADIO: @@ -2351,7 +2351,7 @@ nsHTMLInputElement::SaveState() // (always save if it's a radio button so that the checked // state of all radio buttons is restored) if (mType == NS_FORM_INPUT_RADIO || checked != defaultChecked) { - rv = GetPrimaryPresState(this, getter_AddRefs(state)); + rv = GetPrimaryPresState(this, &state); if (state) { if (checked) { rv = state->SetStateProperty(NS_LITERAL_STRING("checked"), @@ -2374,7 +2374,7 @@ nsHTMLInputElement::SaveState() case NS_FORM_INPUT_HIDDEN: { if (GET_BOOLBIT(mBitField, BF_VALUE_CHANGED)) { - rv = GetPrimaryPresState(this, getter_AddRefs(state)); + rv = GetPrimaryPresState(this, &state); if (state) { nsAutoString value; GetValue(value); @@ -2392,7 +2392,7 @@ nsHTMLInputElement::SaveState() } if (GET_BOOLBIT(mBitField, BF_DISABLED_CHANGED)) { - rv |= GetPrimaryPresState(this, getter_AddRefs(state)); + rv |= GetPrimaryPresState(this, &state); if (state) { PRBool disabled; GetDisabled(&disabled); @@ -2452,7 +2452,7 @@ nsHTMLInputElement::DoneCreatingElement() } PRBool -nsHTMLInputElement::RestoreState(nsIPresState* aState) +nsHTMLInputElement::RestoreState(nsPresState* aState) { PRBool restoredCheckedState = PR_FALSE; diff --git a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp index f338e76d681..6464a260852 100644 --- a/mozilla/content/html/content/src/nsHTMLObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLObjectElement.cpp @@ -79,7 +79,7 @@ public: NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); NS_IMETHOD SaveState(); - virtual PRBool RestoreState(nsIPresState* aState); + virtual PRBool RestoreState(nsPresState* aState); virtual void DoneAddingChildren(); virtual PRBool IsDoneAddingChildren(); @@ -180,7 +180,7 @@ nsHTMLObjectElement::SaveState() } PRBool -nsHTMLObjectElement::RestoreState(nsIPresState* aState) +nsHTMLObjectElement::RestoreState(nsPresState* aState) { return PR_FALSE; } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 26b5e71a5dd..1c4972a413c 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -67,7 +67,7 @@ // PresState #include "nsXPCOM.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsIComponentManager.h" #include "nsCheapSets.h" @@ -237,7 +237,7 @@ public: NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); NS_IMETHOD SaveState(); - virtual PRBool RestoreState(nsIPresState* aState); + virtual PRBool RestoreState(nsPresState* aState); // nsISelectElement NS_DECL_NSISELECTELEMENT @@ -1783,8 +1783,8 @@ nsHTMLSelectElement::SaveState() } } - nsCOMPtr presState; - nsresult rv = GetPrimaryPresState(this, getter_AddRefs(presState)); + nsPresState *presState = nsnull; + nsresult rv = GetPrimaryPresState(this, &presState); if (presState) { rv = presState->SetStatePropertyAsSupports(NS_LITERAL_STRING("selecteditems"), state); @@ -1797,7 +1797,7 @@ nsHTMLSelectElement::SaveState() } PRBool -nsHTMLSelectElement::RestoreState(nsIPresState* aState) +nsHTMLSelectElement::RestoreState(nsPresState* aState) { // Get the presentation state object to retrieve our stuff out of. nsCOMPtr state; diff --git a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp index e7363ecbc67..c62d7af55da 100644 --- a/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -80,7 +80,7 @@ public: NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); NS_IMETHOD SaveState(); - virtual PRBool RestoreState(nsIPresState* aState); + virtual PRBool RestoreState(nsPresState* aState); virtual PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, @@ -149,7 +149,7 @@ nsHTMLObjectElement::SaveState() } PRBool -nsHTMLObjectElement::RestoreState(nsIPresState* aState) +nsHTMLObjectElement::RestoreState(nsPresState* aState) { return PR_FALSE; } diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 5d5c65f7fb2..3efc7f4fbbc 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -63,7 +63,7 @@ #include "nsIPrivateDOMEvent.h" #include "nsGUIEvent.h" #include "nsLinebreakConverter.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsIDOMText.h" #include "nsReadableUtils.h" #include "nsITextContent.h" @@ -104,7 +104,7 @@ public: NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); NS_IMETHOD SaveState(); - virtual PRBool RestoreState(nsIPresState* aState); + virtual PRBool RestoreState(nsPresState* aState); // nsITextControlElemet NS_IMETHOD TakeTextFrameValue(const nsAString& aValue); @@ -817,8 +817,8 @@ nsHTMLTextAreaElement::SaveState() // Only save if value != defaultValue (bug 62713) if (mValueChanged) { - nsCOMPtr state; - rv = GetPrimaryPresState(this, getter_AddRefs(state)); + nsPresState *state = nsnull; + rv = GetPrimaryPresState(this, &state); if (state) { nsAutoString value; GetValueInternal(value, PR_TRUE); @@ -837,7 +837,7 @@ nsHTMLTextAreaElement::SaveState() } PRBool -nsHTMLTextAreaElement::RestoreState(nsIPresState* aState) +nsHTMLTextAreaElement::RestoreState(nsPresState* aState) { nsAutoString value; #ifdef DEBUG diff --git a/mozilla/layout/base/Makefile.in b/mozilla/layout/base/Makefile.in index 43cd8afaadf..921aef401e7 100644 --- a/mozilla/layout/base/Makefile.in +++ b/mozilla/layout/base/Makefile.in @@ -102,13 +102,13 @@ EXPORTS = \ nsILayoutHistoryState.h \ nsIPercentHeightObserver.h \ nsIPresShell.h \ - nsIPresState.h \ nsIReflowCallback.h \ nsLayoutAtomList.h \ nsLayoutAtoms.h \ nsLayoutErrors.h \ nsLayoutUtils.h \ nsPresContext.h \ + nsPresState.h \ nsStyleChangeList.h \ nsStyleConsts.h \ $(NULL) diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index 0096d62e519..4c68be4f748 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -66,7 +66,7 @@ #include "nsIStyleRule.h" #endif #include "nsILayoutHistoryState.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsIContent.h" #include "nsINameSpaceManager.h" #include "nsIXBLBinding.h" @@ -1717,9 +1717,9 @@ nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame, } // Capture the state, exit early if we get null (nothing to save) - nsCOMPtr frameState; - nsresult rv = NS_OK; - rv = statefulFrame->SaveState(GetPresContext(), getter_AddRefs(frameState)); + nsAutoPtr frameState; + nsresult rv = statefulFrame->SaveState(GetPresContext(), + getter_Transfers(frameState)); if (!frameState) { return; } @@ -1735,7 +1735,11 @@ nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame, } // Store the state - aState->AddState(stateKey, frameState); + rv = aState->AddState(stateKey, frameState); + if (NS_SUCCEEDED(rv)) { + // aState owns frameState now. + frameState.forget(); + } } void @@ -1796,8 +1800,8 @@ nsFrameManager::RestoreFrameStateFor(nsIFrame* aFrame, } // Get the state from the hash - nsCOMPtr frameState; - rv = aState->GetState(stateKey, getter_AddRefs(frameState)); + nsPresState *frameState; + rv = aState->GetState(stateKey, &frameState); if (!frameState) { return; } diff --git a/mozilla/layout/base/nsILayoutHistoryState.h b/mozilla/layout/base/nsILayoutHistoryState.h index 2f6e541b2a3..960c293b7d9 100644 --- a/mozilla/layout/base/nsILayoutHistoryState.h +++ b/mozilla/layout/base/nsILayoutHistoryState.h @@ -1,21 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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): + * Pierre Phaneuf + * + * 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 ***** */ + #ifndef _nsILayoutHistoryState_h #define _nsILayoutHistoryState_h #include "nsISupports.h" -#include "nsIPresState.h" +#include "nsStringFwd.h" -#define NS_ILAYOUTHISTORYSTATE_IID_STR "306c8ca0-5f0c-11d3-a9fb-000064657374" +class nsPresState; #define NS_ILAYOUTHISTORYSTATE_IID \ -{0x306c8ca0, 0x5f0c, 0x11d3, \ -{0xa9, 0xfb, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}} +{0xe6abfb7c, 0x6624, 0x4b4d, \ +{0x9d, 0xfe, 0xea, 0x62, 0xae, 0xfe, 0x03, 0x31}} class nsILayoutHistoryState : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILAYOUTHISTORYSTATE_IID) - NS_IMETHOD AddState(const nsCString& aKey, nsIPresState* aState) = 0; - NS_IMETHOD GetState(const nsCString& aKey, nsIPresState** aState) = 0; + /** + * Set |aState| as the state object for |aKey|. + * This _transfers_ownership_ of |aState| to the LayoutHistoryState. + * It will be freed when RemoveState() is called or when the + * LayoutHistoryState is destroyed. + */ + NS_IMETHOD AddState(const nsCString& aKey, nsPresState* aState) = 0; + + /** + * Look up the state object for |aKey|. + */ + NS_IMETHOD GetState(const nsCString& aKey, nsPresState** aState) = 0; + + /** + * Remove the state object for |aKey|. + */ NS_IMETHOD RemoveState(const nsCString& aKey) = 0; }; diff --git a/mozilla/layout/base/nsIPresState.h b/mozilla/layout/base/nsIPresState.h deleted file mode 100644 index 54469d522bf..00000000000 --- a/mozilla/layout/base/nsIPresState.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _nsIPresState_h -#define _nsIPresState_h - -#include "nsISupports.h" -#include "nsString.h" - -// {98DABCE1-C9D7-11d3-BF87-00105A1B0627} -#define NS_IPRESSTATE_IID \ -{ 0x98dabce1, 0xc9d7, 0x11d3, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } - -class nsIPresState : public nsISupports { -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESSTATE_IID) - - NS_IMETHOD GetStatePropertyAsSupports(const nsAString& aName, - nsISupports** aResult) = 0; - NS_IMETHOD SetStatePropertyAsSupports(const nsAString& aName, - nsISupports* aValue) = 0; - - /** - * Get the current value of a property. - * - * @param aName the name of the property. - * @param aResult the value (may legitimately be the empty string) [OUT] - * @throws NS_STATE_PROPERTY_NOT_THERE if the property is not set - * @throws NS_STATE_PROPERTY_EXISTS if the attribute exists (==NS_OK) - */ - NS_IMETHOD GetStateProperty(const nsAString& aName, - nsAString& aResult) = 0; - NS_IMETHOD SetStateProperty(const nsAString& aProperty, - const nsAString& aValue) = 0; - - NS_IMETHOD RemoveStateProperty(const nsAString& aName) = 0; -}; - -nsresult -NS_NewPresState(nsIPresState** aResult); - -#endif /* _nsIPresState_h */ diff --git a/mozilla/layout/base/nsLayoutErrors.h b/mozilla/layout/base/nsLayoutErrors.h index 924e3f77e2c..2129e222317 100644 --- a/mozilla/layout/base/nsLayoutErrors.h +++ b/mozilla/layout/base/nsLayoutErrors.h @@ -52,7 +52,7 @@ #define NS_ERROR_FRAME_REPLACED \ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LAYOUT, 4) -/** Error codes for nsIPresState::GetProperty() */ +/** Error codes for nsPresState::GetProperty() */ /** Returned if the property exists */ #define NS_STATE_PROPERTY_EXISTS NS_OK diff --git a/mozilla/layout/base/nsLayoutHistoryState.cpp b/mozilla/layout/base/nsLayoutHistoryState.cpp index d30a7368565..dad8867e659 100644 --- a/mozilla/layout/base/nsLayoutHistoryState.cpp +++ b/mozilla/layout/base/nsLayoutHistoryState.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -38,107 +38,76 @@ #include "nsILayoutHistoryState.h" #include "nsWeakReference.h" -#include "nsHashtable.h" +#include "nsClassHashtable.h" +#include "nsPresState.h" class nsLayoutHistoryState : public nsILayoutHistoryState, public nsSupportsWeakReference { public: - nsLayoutHistoryState(); - virtual ~nsLayoutHistoryState(); + NS_HIDDEN_(nsresult) Init(); NS_DECL_ISUPPORTS // nsILayoutHistoryState - NS_IMETHOD AddState(const nsCString& aKey, nsIPresState* aState); - NS_IMETHOD GetState(const nsCString& aKey, nsIPresState** aState); + NS_IMETHOD AddState(const nsCString& aKey, nsPresState* aState); + NS_IMETHOD GetState(const nsCString& aKey, nsPresState** aState); NS_IMETHOD RemoveState(const nsCString& aKey); private: - nsSupportsHashtable mStates; + ~nsLayoutHistoryState() {} + + nsClassHashtable mStates; }; nsresult NS_NewLayoutHistoryState(nsILayoutHistoryState** aState) { - NS_ENSURE_ARG_POINTER(aState); - if (! aState) - return NS_ERROR_NULL_POINTER; + nsLayoutHistoryState *state; - nsLayoutHistoryState *state = new nsLayoutHistoryState(); - if (!state) - return NS_ERROR_OUT_OF_MEMORY; + *aState = nsnull; + state = new nsLayoutHistoryState(); + if (!state) + return NS_ERROR_OUT_OF_MEMORY; - *aState = NS_STATIC_CAST(nsILayoutHistoryState *, state); - NS_ADDREF(*aState); + NS_ADDREF(state); + nsresult rv = state->Init(); + if (NS_SUCCEEDED(rv)) + *aState = state; + else + NS_RELEASE(state); - return NS_OK; -} - -nsLayoutHistoryState::nsLayoutHistoryState() -{ -} - -nsLayoutHistoryState::~nsLayoutHistoryState() -{ + return rv; } NS_IMPL_ISUPPORTS2(nsLayoutHistoryState, nsILayoutHistoryState, nsISupportsWeakReference) -NS_IMETHODIMP -nsLayoutHistoryState::AddState(const nsCString& aStateKey, - nsIPresState* aState) +nsresult +nsLayoutHistoryState::Init() { - nsCStringKey key(aStateKey); - - /* - * nsSupportsHashtable::Put() returns false when no object was - * replaced when inserting the new one, true if one was. - */ -#ifdef DEBUG_pollmann - PRBool replaced = -#endif - - mStates.Put (&key, aState); - -#ifdef DEBUG_pollmann - NS_ASSERTION(!replaced, - "nsLayoutHistoryState::AddState OOPS!. There was already a state in the hash table for the key\n"); -#endif - - return NS_OK; + return mStates.Init() ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -nsLayoutHistoryState::GetState(const nsCString& aKey, - nsIPresState** aState) +nsLayoutHistoryState::AddState(const nsCString& aStateKey, nsPresState* aState) { - nsresult rv = NS_OK; - nsCStringKey key(aKey); - nsISupports *state = nsnull; - state = mStates.Get(&key); - if (state) { - *aState = (nsIPresState *)state; - } - else { -#if 0 - printf("nsLayoutHistoryState::GetState, ERROR getting History state for the key\n"); -#endif - *aState = nsnull; - rv = NS_OK; - } - return rv; + return mStates.Put(aStateKey, aState) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; +} + +NS_IMETHODIMP +nsLayoutHistoryState::GetState(const nsCString& aKey, nsPresState** aState) +{ + mStates.Get(aKey, aState); + return NS_OK; } NS_IMETHODIMP nsLayoutHistoryState::RemoveState(const nsCString& aKey) { - nsresult rv = NS_OK; - nsCStringKey key(aKey); - mStates.Remove(&key); - return rv; + mStates.Remove(aKey); + return NS_OK; } diff --git a/mozilla/layout/base/nsPresState.cpp b/mozilla/layout/base/nsPresState.cpp index 776d2989c29..9dd7c776e64 100644 --- a/mozilla/layout/base/nsPresState.cpp +++ b/mozilla/layout/base/nsPresState.cpp @@ -36,169 +36,102 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" -#include "nsIPresState.h" -#include "nsHashtable.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" #include "nsLayoutErrors.h" - - - -class nsPresState: public nsIPresState -{ - NS_DECL_ISUPPORTS - - NS_IMETHOD GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aResult); - NS_IMETHOD SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aValue); - - NS_IMETHOD GetStateProperty(const nsAString& aProperty, nsAString& aResult); - NS_IMETHOD SetStateProperty(const nsAString& aProperty, const nsAString& aValue); - - NS_IMETHOD RemoveStateProperty(const nsAString& aProperty); - -public: - nsPresState(); - virtual ~nsPresState(); - -// Static members - -// Internal member functions -protected: - -// MEMBER VARIABLES -protected: - // A string table that holds property/value pairs. - nsSupportsHashtable* mPropertyTable; -}; - -// Static initialization - +#include "nsPresState.h" +#include "nsString.h" // Implementation ///////////////////////////////////////////////////////////////// -// Implement our nsISupports methods -NS_IMPL_ISUPPORTS1(nsPresState, nsIPresState) - -// Constructors/Destructors -nsPresState::nsPresState(void) -:mPropertyTable(nsnull) +nsresult +nsPresState::Init() { + return mPropertyTable.Init(8) ? NS_OK : NS_ERROR_FAILURE; } -nsPresState::~nsPresState(void) -{ - delete mPropertyTable; -} - -// nsIPresState Interface //////////////////////////////////////////////////////////////// - -NS_IMETHODIMP -nsPresState::GetStateProperty(const nsAString& aName, - nsAString& aResult) +nsresult +nsPresState::GetStateProperty(const nsAString& aName, nsAString& aResult) { nsresult rv = NS_STATE_PROPERTY_NOT_THERE; aResult.Truncate(); // Retrieve from hashtable. - if (mPropertyTable) { - const nsPromiseFlatString& flatString = PromiseFlatString(aName); - nsStringKey key(flatString); + nsISupports *data = mPropertyTable.GetWeak(aName); - nsCOMPtr supportsStr = - dont_AddRef(NS_STATIC_CAST(nsISupportsCString*, - mPropertyTable->Get(&key))); + // Strings are stored in the table as UTF-8, to save space. + // XXX minimize conversions here... - if (supportsStr) { - nsCAutoString data; - supportsStr->GetData(data); + nsCOMPtr supportsStr = do_QueryInterface(data); + if (supportsStr) { + nsCAutoString data; + supportsStr->GetData(data); - CopyUTF8toUTF16(data, aResult); - rv = NS_STATE_PROPERTY_EXISTS; - } + CopyUTF8toUTF16(data, aResult); + rv = NS_STATE_PROPERTY_EXISTS; } return rv; } -NS_IMETHODIMP +nsresult nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue) { - if (!mPropertyTable) { - mPropertyTable = new nsSupportsHashtable(8); - NS_ENSURE_TRUE(mPropertyTable, NS_ERROR_OUT_OF_MEMORY); - } - // Add to hashtable - const nsPromiseFlatString& flatString = PromiseFlatString(aName); - nsStringKey key(flatString); - nsCOMPtr supportsStr(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY); supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue)); - mPropertyTable->Put(&key, supportsStr); + mPropertyTable.Put(aName, supportsStr); return NS_OK; } -NS_IMETHODIMP -nsPresState::RemoveStateProperty(const nsAString& aName) -{ - if (!mPropertyTable) - return NS_OK; - - const nsPromiseFlatString& flatString = PromiseFlatString(aName); - nsStringKey key(flatString); - - mPropertyTable->Remove(&key); - return NS_OK; -} - -NS_IMETHODIMP -nsPresState::GetStatePropertyAsSupports(const nsAString& aName, nsISupports** aResult) -{ - // Retrieve from hashtable. - nsCOMPtr supp; - - if (mPropertyTable) { - const nsPromiseFlatString& flatString = PromiseFlatString(aName); - nsStringKey key(flatString); - supp = dont_AddRef(NS_STATIC_CAST(nsISupports*, mPropertyTable->Get(&key))); - } - - *aResult = supp; - NS_IF_ADDREF(*aResult); - return NS_OK; -} - -NS_IMETHODIMP -nsPresState::SetStatePropertyAsSupports(const nsAString& aName, nsISupports* aValue) -{ - if (!mPropertyTable) { - mPropertyTable = new nsSupportsHashtable(8); - NS_ENSURE_TRUE(mPropertyTable, NS_ERROR_OUT_OF_MEMORY); - } - - // Add to hashtable - const nsPromiseFlatString& flatString = PromiseFlatString(aName); - nsStringKey key(flatString); - - mPropertyTable->Put(&key, aValue); - return NS_OK; -} - -// Creation Routine /////////////////////////////////////////////////////////////////////// - nsresult -NS_NewPresState(nsIPresState** aResult) +nsPresState::RemoveStateProperty(const nsAString& aName) { - *aResult = new nsPresState; - if (!*aResult) - return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(*aResult); + mPropertyTable.Remove(aName); return NS_OK; } +nsresult +nsPresState::GetStatePropertyAsSupports(const nsAString& aName, + nsISupports** aResult) +{ + // Retrieve from hashtable. + mPropertyTable.Get(aName, aResult); + return NS_OK; +} + +nsresult +nsPresState::SetStatePropertyAsSupports(const nsAString& aName, + nsISupports* aValue) +{ + mPropertyTable.Put(aName, aValue); + return NS_OK; +} + + +nsresult +NS_NewPresState(nsPresState** aState) +{ + nsPresState *state; + + *aState = nsnull; + state = new nsPresState(); + if (!state) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult rv = state->Init(); + if (NS_SUCCEEDED(rv)) + *aState = state; + else + delete state; + + return rv; +} + + diff --git a/mozilla/layout/base/nsPresState.h b/mozilla/layout/base/nsPresState.h new file mode 100755 index 00000000000..ebc3c1f201c --- /dev/null +++ b/mozilla/layout/base/nsPresState.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 ***** */ + +#ifndef nsPresState_h_ +#define nsPresState_h_ + +#include "nsStringFwd.h" +#include "nsInterfaceHashtable.h" + +class nsPresState +{ +public: + NS_HIDDEN_(nsresult) Init(); + + NS_HIDDEN_(nsresult) GetStatePropertyAsSupports(const nsAString& aName, + nsISupports** aResult); + + NS_HIDDEN_(nsresult) SetStatePropertyAsSupports(const nsAString& aName, + nsISupports* aValue); + + NS_HIDDEN_(nsresult) GetStateProperty(const nsAString& aProperty, + nsAString& aResult); + + NS_HIDDEN_(nsresult) SetStateProperty(const nsAString& aProperty, + const nsAString& aValue); + + NS_HIDDEN_(nsresult) RemoveStateProperty(const nsAString& aProperty); + +// MEMBER VARIABLES +protected: + // A string table that holds property/value pairs. + nsInterfaceHashtable mPropertyTable; +}; + +NS_HIDDEN_(nsresult) NS_NewPresState(nsPresState **aState); + +#endif diff --git a/mozilla/layout/build/nsLayoutCID.h b/mozilla/layout/build/nsLayoutCID.h index 8d632178903..a8b566cd8a9 100644 --- a/mozilla/layout/build/nsLayoutCID.h +++ b/mozilla/layout/build/nsLayoutCID.h @@ -101,10 +101,6 @@ #define NS_PRESSHELL_CID \ { 0xe6fd9940, 0x899d, 0x11d2, { 0x8e, 0xae, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } } -// {A1FDE861-E802-11d4-9885-00C04FA0CF4B} -#define NS_PRESSTATE_CID \ -{ 0xa1fde861, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } - // {95F46161-D177-11d2-BF86-00105A1B0627} #define NS_HTML_CSS_STYLESHEET_CID \ { 0x95f46161, 0xd177, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index 5e86feeb3d9..b1eb1ed4438 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -460,7 +460,6 @@ nsresult NS_NewCanvasRenderingContext2D(nsICanvasRenderingContext2D** aResult); #endif nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); -nsresult NS_NewLayoutHistoryState(nsILayoutHistoryState** aResult); nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult); nsresult NS_NewSelectionImageService(nsISelectionImageService** aResult); @@ -520,9 +519,7 @@ MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLay #endif MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTraversal) -MAKE_CTOR(CreateNewLayoutHistoryState, nsILayoutHistoryState, NS_NewLayoutHistoryState) MAKE_CTOR(CreateNewPresShell, nsIPresShell, NS_NewPresShell) -MAKE_CTOR(CreateNewPresState, nsIPresState, NS_NewPresState) #ifdef MOZ_XUL MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject) MAKE_CTOR(CreateNewListBoxObject, nsIBoxObject, NS_NewListBoxObject) @@ -834,11 +831,6 @@ static const nsModuleComponentInfo gComponents[] = { nsnull, CreateNewFrameTraversal }, - { "Layout History State", - NS_LAYOUT_HISTORY_STATE_CID, - nsnull, - CreateNewLayoutHistoryState }, - { "selection image storage", NS_SELECTIONIMAGESERVICE_CID, nsnull, @@ -855,11 +847,6 @@ static const nsModuleComponentInfo gComponents[] = { nsnull, CreateNewPresShell }, - { "Presentation state", - NS_PRESSTATE_CID, - nsnull, - CreateNewPresState }, - // XXX end ick #ifdef MOZ_XUL diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 06646f0070c..4f1ec27ae44 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -54,7 +54,6 @@ #include "nsIDOMHTMLOptionElement.h" #include "nsIDOMNSHTMLOptionCollectn.h" #include "nsIPresShell.h" -#include "nsIPresState.h" #include "nsIDeviceContext.h" #include "nsIView.h" #include "nsIScrollableView.h" @@ -93,6 +92,7 @@ #include "nsIFontMetrics.h" #endif +class nsPresState; #define FIX_FOR_BUG_53259 @@ -2417,7 +2417,7 @@ nsComboboxControlFrame::OnContentReset() //-------------------------------------------------------- NS_IMETHODIMP nsComboboxControlFrame::SaveState(nsPresContext* aPresContext, - nsIPresState** aState) + nsPresState** aState) { nsCOMPtr stateful(do_QueryInterface(mListControlFrame)); NS_ASSERTION(stateful, "Couldn't cast list frame to stateful frame!!!"); @@ -2429,7 +2429,7 @@ nsComboboxControlFrame::SaveState(nsPresContext* aPresContext, NS_IMETHODIMP nsComboboxControlFrame::RestoreState(nsPresContext* aPresContext, - nsIPresState* aState) + nsPresState* aState) { if (!mListControlFrame) return NS_ERROR_FAILURE; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index a40272d9a8f..e41f14b6418 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -58,7 +58,7 @@ #include "nsIAnonymousContentCreator.h" #include "nsISelectControlFrame.h" #include "nsIRollupListener.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsCSSFrameConstructor.h" #include "nsITextContent.h" #include "nsIScrollableViewProvider.h" @@ -209,8 +209,8 @@ public: virtual nsIScrollableView* GetScrollableView(); //nsIStatefulFrame - NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState); - NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState); + NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState); + NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsPresState* aState); protected: diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index d6a11970b28..c53cfce48f3 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -43,7 +43,6 @@ #include "nsIAtom.h" #include "nsPresContext.h" #include "nsHTMLAtoms.h" -#include "nsIPresState.h" #include "nsWidgetsCID.h" #include "nsIComponentManager.h" #include "nsIView.h" diff --git a/mozilla/layout/forms/nsFileControlFrame.h b/mozilla/layout/forms/nsFileControlFrame.h index 19898ef0af7..b9d7a37fada 100644 --- a/mozilla/layout/forms/nsFileControlFrame.h +++ b/mozilla/layout/forms/nsFileControlFrame.h @@ -48,7 +48,6 @@ #include "nsFormControlHelper.h" typedef nsTextControlFrame nsNewFrame; -class nsIPresState; class nsISupportsArray; class nsFileControlFrame : public nsAreaFrame, diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index 36a4355e650..b3050e30d45 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -49,7 +49,6 @@ class nsIView; class nsPresContext; class nsStyleCoord; -class nsIPresState; class nsStyleContext; #define CSS_NOTSET -1 diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index f666bdd22f6..05734c45fcd 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -56,8 +56,6 @@ // MouseEvent suppression in PP #include "nsGUIEvent.h" -// Saving PresState -#include "nsIPresState.h" #include "nsNodeInfoManager.h" const nscoord kSuggestedNotSet = -1; diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.h b/mozilla/layout/forms/nsGfxButtonControlFrame.h index 120ad8e435b..86e82d589ff 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.h +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.h @@ -53,8 +53,6 @@ class nsIAccessible; // The label for button is specified through generated content // in the ua.css file. -class nsIPresState; - class nsGfxButtonControlFrame : public nsHTMLButtonControlFrame, public nsIAnonymousContentCreator { diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp index a5183b0d874..a9a0b75769f 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -43,7 +43,6 @@ #include "nsIContent.h" #include "nsIComponentManager.h" #include "nsHTMLAtoms.h" -#include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" #include "nsCSSRendering.h" diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp index 1362668aa1d..cfe9c4e5ade 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp @@ -44,7 +44,6 @@ #include "nsIComponentManager.h" #include "nsCOMPtr.h" #include "nsCSSRendering.h" -#include "nsIPresState.h" #include "nsIPresShell.h" #include "nsIDocument.h" #ifdef ACCESSIBILITY diff --git a/mozilla/layout/forms/nsIListControlFrame.h b/mozilla/layout/forms/nsIListControlFrame.h index b578ac896b6..9f0a461915e 100644 --- a/mozilla/layout/forms/nsIListControlFrame.h +++ b/mozilla/layout/forms/nsIListControlFrame.h @@ -43,7 +43,6 @@ class nsPresContext; class nsAString; class nsIContent; -class nsIPresState; // IID for the nsIListControlFrame class #define NS_ILISTCONTROLFRAME_IID \ diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index b8943e22036..2fe5d78dbe3 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -42,7 +42,7 @@ #include "nsIAtom.h" #include "nsPresContext.h" #include "nsHTMLAtoms.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsWidgetsCID.h" #include "nsIComponentManager.h" #include "nsIView.h" @@ -559,7 +559,7 @@ nsIsIndexFrame::URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, n // nsIStatefulFrame //---------------------------------------------------------------------- NS_IMETHODIMP -nsIsIndexFrame::SaveState(nsPresContext* aPresContext, nsIPresState** aState) +nsIsIndexFrame::SaveState(nsPresContext* aPresContext, nsPresState** aState) { NS_ENSURE_ARG_POINTER(aState); @@ -580,7 +580,7 @@ nsIsIndexFrame::SaveState(nsPresContext* aPresContext, nsIPresState** aState) } NS_IMETHODIMP -nsIsIndexFrame::RestoreState(nsPresContext* aPresContext, nsIPresState* aState) +nsIsIndexFrame::RestoreState(nsPresContext* aPresContext, nsPresState* aState) { NS_ENSURE_ARG_POINTER(aState); diff --git a/mozilla/layout/forms/nsIsIndexFrame.h b/mozilla/layout/forms/nsIsIndexFrame.h index 882e718bf88..b8f36f47e93 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.h +++ b/mozilla/layout/forms/nsIsIndexFrame.h @@ -49,7 +49,6 @@ #include "nsFormControlHelper.h" typedef nsTextControlFrame nsNewFrame; -class nsIPresState; class nsISupportsArray; class nsIsIndexFrame : public nsAreaFrame, @@ -130,8 +129,8 @@ public: NS_IMETHOD OnSubmit(nsPresContext* aPresContext); //nsIStatefulFrame - NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState); - NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState); + NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState); + NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsPresState* aState); protected: nsCOMPtr mTextContent; diff --git a/mozilla/layout/forms/nsListControlFrame.h b/mozilla/layout/forms/nsListControlFrame.h index e48b3926cf3..3bff18970f8 100644 --- a/mozilla/layout/forms/nsListControlFrame.h +++ b/mozilla/layout/forms/nsListControlFrame.h @@ -53,7 +53,6 @@ #include "nsIListControlFrame.h" #include "nsISelectControlFrame.h" #include "nsIDOMEventListener.h" -#include "nsIPresState.h" #include "nsIContent.h" #include "nsAutoPtr.h" diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 0d14e358551..0093892d947 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -67,7 +67,6 @@ #include "nsIScrollableFrame.h" //to turn off scroll bars #include "nsFormControlFrame.h" //for registering accesskeys #include "nsIDeviceContext.h" // to measure fonts -#include "nsIPresState.h" //for saving state #include "nsIContent.h" #include "nsIAtom.h" diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index a8b9701be65..7ef757dcccf 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -51,7 +51,6 @@ #include "nsIScrollableViewProvider.h" #include "nsIPhonetic.h" -class nsIPresState; class nsISupportsArray; class nsIEditor; class nsISelectionController; diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index b4eb3bb3ed0..560ba1dbb08 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -72,6 +72,8 @@ #include "nsContentCreatorFunctions.h" #include "nsISupportsPrimitives.h" #include "nsIPresShell.h" +#include "nsAutoPtr.h" +#include "nsPresState.h" #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif @@ -2176,7 +2178,7 @@ nsGfxScrollFrameInner::GetIntegerAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 return defaultValue; } -already_AddRefed +nsPresState* nsGfxScrollFrameInner::SaveState() { nsCOMPtr mediator; @@ -2202,8 +2204,8 @@ nsGfxScrollFrameInner::SaveState() } nsRect childRect = child->GetBounds(); - nsCOMPtr state; - nsresult rv = NS_NewPresState(getter_AddRefs(state)); + nsAutoPtr state; + nsresult rv = NS_NewPresState(getter_Transfers(state)); NS_ENSURE_SUCCESS(rv, nsnull); nsCOMPtr xoffset = do_CreateInstance(NS_SUPPORTS_PRINT32_CONTRACTID); @@ -2233,13 +2235,11 @@ nsGfxScrollFrameInner::SaveState() NS_ENSURE_SUCCESS(rv, nsnull); state->SetStatePropertyAsSupports(NS_LITERAL_STRING("height"), height); } - nsIPresState* result = state; - NS_ADDREF(result); - return result; + return state.forget(); } void -nsGfxScrollFrameInner::RestoreState(nsIPresState* aState) +nsGfxScrollFrameInner::RestoreState(nsPresState* aState) { nsCOMPtr xoffset; nsCOMPtr yoffset; diff --git a/mozilla/layout/generic/nsGfxScrollFrame.h b/mozilla/layout/generic/nsGfxScrollFrame.h index c4890c6aa87..33fc31bc374 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.h +++ b/mozilla/layout/generic/nsGfxScrollFrame.h @@ -42,7 +42,6 @@ #include "nsBoxFrame.h" #include "nsIScrollableFrame.h" #include "nsIScrollPositionListener.h" -#include "nsIPresState.h" #include "nsIStatefulFrame.h" class nsISupportsArray; @@ -53,6 +52,7 @@ class nsIContent; class nsIAtom; class nsIDocument; class nsIScrollFrameInternal; +class nsPresState; class nsGfxScrollFrameInner : public nsIScrollPositionListener { public: @@ -113,8 +113,8 @@ public: void ScrollToRestoredPosition(); - already_AddRefed SaveState(); - void RestoreState(nsIPresState* aState); + nsPresState* SaveState(); + void RestoreState(nsPresState* aState); nsIFrame* GetScrolledFrame() const { nsIFrame* childBox; @@ -254,12 +254,12 @@ public: virtual void CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType); // nsIStatefulFrame - NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState) { + NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState) { NS_ENSURE_ARG_POINTER(aState); - *aState = mInner.SaveState().get(); + *aState = mInner.SaveState(); return NS_OK; } - NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState) { + NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsPresState* aState) { NS_ENSURE_ARG_POINTER(aState); mInner.RestoreState(aState); return NS_OK; @@ -400,12 +400,12 @@ public: virtual void CurPosAttributeChanged(nsIContent* aChild, PRInt32 aModType); // nsIStatefulFrame - NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState) { + NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState) { NS_ENSURE_ARG_POINTER(aState); - *aState = mInner.SaveState().get(); + *aState = mInner.SaveState(); return NS_OK; } - NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState) { + NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsPresState* aState) { NS_ENSURE_ARG_POINTER(aState); mInner.RestoreState(aState); return NS_OK; diff --git a/mozilla/layout/generic/nsIStatefulFrame.h b/mozilla/layout/generic/nsIStatefulFrame.h index 2809f836461..c2fb6ea4806 100644 --- a/mozilla/layout/generic/nsIStatefulFrame.h +++ b/mozilla/layout/generic/nsIStatefulFrame.h @@ -4,13 +4,11 @@ #include "nsISupports.h" class nsPresContext; -class nsIPresState; - -#define NS_ISTATEFULFRAME_IID_STR "306c8ca0-5f0c-11d3-a9fb-000064657374" +class nsPresState; #define NS_ISTATEFULFRAME_IID \ -{0x306c8ca0, 0x5f0c, 0x11d3, \ -{0xa9, 0xfb, 0x00, 0x00, 0x64, 0x65, 0x73, 0x74}} +{0x26254ab7, 0xdea3, 0x4375, \ +{0xb0, 0x1d, 0xbd, 0x11, 0xa1, 0x4b, 0x54, 0xbc}} class nsIStatefulFrame : public nsISupports { public: @@ -24,8 +22,8 @@ class nsIStatefulFrame : public nsISupports { // offset NS_CONTENT_ID_COUNTER_BASE enum SpecialStateID {eNoID=0, eDocumentScrollState}; - NS_IMETHOD SaveState(nsPresContext* aPresContext, nsIPresState** aState) = 0; - NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsIPresState* aState) = 0; + NS_IMETHOD SaveState(nsPresContext* aPresContext, nsPresState** aState) = 0; + NS_IMETHOD RestoreState(nsPresContext* aPresContext, nsPresState* aState) = 0; }; #endif /* _nsIStatefulFrame_h */ diff --git a/mozilla/layout/xul/base/src/nsBoxObject.cpp b/mozilla/layout/xul/base/src/nsBoxObject.cpp index b7d6f1fd3c7..da18dcd62eb 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsBoxObject.cpp @@ -412,7 +412,7 @@ NS_IMETHODIMP nsBoxObject::SetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports* aValue) { if (!mPresState) - NS_NewPresState(getter_AddRefs(mPresState)); + NS_NewPresState(getter_Transfers(mPresState)); nsDependentString propertyName(aPropertyName); return mPresState->SetStatePropertyAsSupports(propertyName, aValue); @@ -439,7 +439,7 @@ NS_IMETHODIMP nsBoxObject::SetProperty(const PRUnichar* aPropertyName, const PRUnichar* aPropertyValue) { if (!mPresState) - NS_NewPresState(getter_AddRefs(mPresState)); + NS_NewPresState(getter_Transfers(mPresState)); nsDependentString propertyName(aPropertyName); nsDependentString propertyValue(aPropertyValue); diff --git a/mozilla/layout/xul/base/src/nsBoxObject.h b/mozilla/layout/xul/base/src/nsBoxObject.h index 5010984d97a..895d501c7fc 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.h +++ b/mozilla/layout/xul/base/src/nsBoxObject.h @@ -38,8 +38,9 @@ #include "nsCOMPtr.h" #include "nsIBoxObject.h" #include "nsPIBoxObject.h" -#include "nsIPresState.h" +#include "nsPresState.h" #include "nsPoint.h" +#include "nsAutoPtr.h" class nsIBoxLayoutManager; class nsIBoxPaintManager; @@ -73,7 +74,7 @@ protected: // MEMBER VARIABLES nsCOMPtr mLayoutManager; // [OWNER] nsCOMPtr mPaintManager; // [OWNER] - nsCOMPtr mPresState; // [OWNER] + nsAutoPtr mPresState; // [OWNER] nsIContent* mContent; // [WEAK] nsIPresShell* mPresShell; // [WEAK] diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp index 47513aab26b..13123657942 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -57,7 +57,6 @@ #include "nsGfxScrollFrame.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" -#include "nsIPresState.h" #include "nsButtonBoxFrame.h" #include "nsITimer.h" #include "nsRepeatService.h"