From 1788de88fc22ff773c113906f676158079cad94a Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Mon, 6 Dec 1999 22:59:43 +0000 Subject: [PATCH] removing unused variables (bloat) and using nsLayoutAtoms::optionSelectedPseudo instead of using a string and creating and deleting it each time. r=kmcclusk --- layout/forms/nsListControlFrame.cpp | 27 ++++++------------- layout/forms/nsListControlFrame.h | 7 ----- .../html/forms/src/nsGfxListControlFrame.cpp | 7 ----- layout/html/forms/src/nsGfxListControlFrame.h | 7 ----- layout/html/forms/src/nsListControlFrame.cpp | 27 ++++++------------- layout/html/forms/src/nsListControlFrame.h | 7 ----- 6 files changed, 16 insertions(+), 66 deletions(-) diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index c70df041fb85..744add09089b 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -51,6 +51,7 @@ #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" #include "nsILookAndFeel.h" +#include "nsLayoutAtoms.h" #include "nsISelectElement.h" @@ -72,7 +73,8 @@ const PRInt32 kNoSizeSpecified = -1; //XXX: This is temporary. It simulates psuedo states by using a attribute selector on // -moz-option-selected in the ua.css style sheet. This will not be needed when //The event state manager is functional. KMM -const char * kMozSelected = "-moz-option-selected"; +//const char * kMozSelected = "-moz-option-selected"; +// it is now using "nsLayoutAtoms::optionSelectedPseudo" //--------------------------------------------------------- nsresult @@ -93,18 +95,15 @@ NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) //--------------------------------------------------------- nsListControlFrame::nsListControlFrame() { - mHitFrame = nsnull; mSelectedIndex = kNothingSelected; mComboboxFrame = nsnull; mFormFrame = nsnull; mButtonDown = PR_FALSE; - mLastFrame = nsnull; mMaxWidth = 0; mMaxHeight = 0; mPresContext = nsnull; mEndExtendedIndex = kNothingSelected; mStartExtendedIndex = kNothingSelected; - mIgnoreMouseUp = PR_FALSE; mIsCapturingMouseEvents = PR_FALSE; mSelectionCache = nsnull; mSelectionCacheLength = -1; @@ -429,8 +428,6 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, padding.SizeTo(0, 0, 0, 0); } - mBorderOffsetY = border.top; - scrolledAreaWidth -= (border.left + border.right + padding.left + padding.right); scrolledAreaHeight -= (border.top + border.bottom); @@ -672,14 +669,12 @@ nsListControlFrame::DisplaySelected(nsIContent* aContent) // -moz-option-selected in the ua.css style sheet. This will not be needed when // The event state manager supports selected states. KMM - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); if (PR_TRUE == mIsAllFramesHere) { - aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE); + aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, "", PR_TRUE); //ForceRedraw(); } else { - aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_FALSE); + aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, "", PR_FALSE); } - NS_RELEASE(selectedAtom); } //--------------------------------------------------------- @@ -689,15 +684,12 @@ nsListControlFrame::DisplayDeselected(nsIContent* aContent) //XXX: This is temporary. It simulates psuedo states by using a attribute selector on // -moz-option-selected in the ua.css style sheet. This will not be needed when // The event state manager is functional. KMM - - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); if (PR_TRUE == mIsAllFramesHere) { - aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_TRUE); + aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_TRUE); //ForceRedraw(); } else { - aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_FALSE); + aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_FALSE); } - NS_RELEASE(selectedAtom); } @@ -1095,7 +1087,6 @@ nsListControlFrame::SetInitialChildList(nsIPresContext* aPresContext, mHasBeenInitialized = PR_FALSE; } } - mContentFrame = aChildList; nsresult rv = nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); // If all the content is here now check @@ -1365,10 +1356,8 @@ PRBool nsListControlFrame::IsContentSelected(nsIContent* aContent) { nsString value; - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); //nsIAtom * selectedAtom = NS_NewAtom("selected"); - nsresult result = aContent->GetAttribute(kNameSpaceID_None, selectedAtom, value); - NS_RELEASE(selectedAtom); + nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, value); return (NS_CONTENT_ATTR_NOT_THERE == result ? PR_FALSE : PR_TRUE); } diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 8bcbe7c8c85c..62af96706b4a 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -221,23 +221,18 @@ protected: nsresult SelectionChanged(nsIContent* aContent); // Data Members - nscoord mBorderOffsetY; nsFormFrame* mFormFrame; PRInt32 mSelectedIndex; PRInt32 mOldSelectedIndex; PRInt32 mSelectedIndexWhenPoppedDown; PRInt32 mStartExtendedIndex; PRInt32 mEndExtendedIndex; - nsIFrame* mHitFrame; PRBool mIsInitializedFromContent; - nsIFrame* mContentFrame; nsIComboboxControlFrame *mComboboxFrame; PRBool mButtonDown; - nsIFrame* mLastFrame; nscoord mMaxWidth; nscoord mMaxHeight; PRBool mIsCapturingMouseEvents; - PRBool mIgnoreMouseUp; PRBool* mSelectionCache; PRInt32 mSelectionCacheLength; @@ -245,8 +240,6 @@ protected: PRBool mIsAllFramesHere; PRBool mHasBeenInitialized; - nsIFrame * mMainChild; - nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context. // XXX temprary only until full system mouse capture works diff --git a/layout/html/forms/src/nsGfxListControlFrame.cpp b/layout/html/forms/src/nsGfxListControlFrame.cpp index 701048809225..e0e7b57bd074 100644 --- a/layout/html/forms/src/nsGfxListControlFrame.cpp +++ b/layout/html/forms/src/nsGfxListControlFrame.cpp @@ -95,18 +95,15 @@ NS_NewGfxListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) //--------------------------------------------------------- nsGfxListControlFrame::nsGfxListControlFrame() { - mHitFrame = nsnull; mSelectedIndex = kNothingSelected; mComboboxFrame = nsnull; mFormFrame = nsnull; mButtonDown = PR_FALSE; - mLastFrame = nsnull; mMaxWidth = 0; mMaxHeight = 0; mPresContext = nsnull; mEndExtendedIndex = kNothingSelected; mStartExtendedIndex = kNothingSelected; - mIgnoreMouseUp = PR_FALSE; mIsCapturingMouseEvents = PR_FALSE; mSelectionCache = nsnull; mSelectionCacheLength = -1; @@ -448,9 +445,6 @@ nsGfxListControlFrame::Reflow(nsIPresContext* aPresContext, padding.SizeTo(0, 0, 0, 0); } - mBorderOffsetY = border.top; - - // Now the scrolledAreaWidth and scrolledAreaHeight are exactly // wide and high enough to enclose their contents @@ -1121,7 +1115,6 @@ nsGfxListControlFrame::SetInitialChildList(nsIPresContext* aPresContext, } } - mContentFrame = aChildList; nsresult rv = nsHTMLContainerFrame::SetInitialChildList(aPresContext, aListName, aChildList); // If all the content is here now check diff --git a/layout/html/forms/src/nsGfxListControlFrame.h b/layout/html/forms/src/nsGfxListControlFrame.h index 559431881554..99b3c42375aa 100644 --- a/layout/html/forms/src/nsGfxListControlFrame.h +++ b/layout/html/forms/src/nsGfxListControlFrame.h @@ -222,23 +222,18 @@ protected: nsresult SelectionChanged(nsIContent* aContent); // Data Members - nscoord mBorderOffsetY; nsFormFrame* mFormFrame; PRInt32 mSelectedIndex; PRInt32 mOldSelectedIndex; PRInt32 mSelectedIndexWhenPoppedDown; PRInt32 mStartExtendedIndex; PRInt32 mEndExtendedIndex; - nsIFrame* mHitFrame; PRBool mIsInitializedFromContent; - nsIFrame* mContentFrame; nsIComboboxControlFrame *mComboboxFrame; PRBool mButtonDown; - nsIFrame* mLastFrame; nscoord mMaxWidth; nscoord mMaxHeight; PRBool mIsCapturingMouseEvents; - PRBool mIgnoreMouseUp; PRBool* mSelectionCache; PRInt32 mSelectionCacheLength; @@ -246,8 +241,6 @@ protected: PRBool mIsAllFramesHere; PRBool mHasBeenInitialized; - nsIFrame * mMainChild; - nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context. // XXX temprary only until full system mouse capture works diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index c70df041fb85..744add09089b 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -51,6 +51,7 @@ #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" #include "nsILookAndFeel.h" +#include "nsLayoutAtoms.h" #include "nsISelectElement.h" @@ -72,7 +73,8 @@ const PRInt32 kNoSizeSpecified = -1; //XXX: This is temporary. It simulates psuedo states by using a attribute selector on // -moz-option-selected in the ua.css style sheet. This will not be needed when //The event state manager is functional. KMM -const char * kMozSelected = "-moz-option-selected"; +//const char * kMozSelected = "-moz-option-selected"; +// it is now using "nsLayoutAtoms::optionSelectedPseudo" //--------------------------------------------------------- nsresult @@ -93,18 +95,15 @@ NS_NewListControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) //--------------------------------------------------------- nsListControlFrame::nsListControlFrame() { - mHitFrame = nsnull; mSelectedIndex = kNothingSelected; mComboboxFrame = nsnull; mFormFrame = nsnull; mButtonDown = PR_FALSE; - mLastFrame = nsnull; mMaxWidth = 0; mMaxHeight = 0; mPresContext = nsnull; mEndExtendedIndex = kNothingSelected; mStartExtendedIndex = kNothingSelected; - mIgnoreMouseUp = PR_FALSE; mIsCapturingMouseEvents = PR_FALSE; mSelectionCache = nsnull; mSelectionCacheLength = -1; @@ -429,8 +428,6 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, padding.SizeTo(0, 0, 0, 0); } - mBorderOffsetY = border.top; - scrolledAreaWidth -= (border.left + border.right + padding.left + padding.right); scrolledAreaHeight -= (border.top + border.bottom); @@ -672,14 +669,12 @@ nsListControlFrame::DisplaySelected(nsIContent* aContent) // -moz-option-selected in the ua.css style sheet. This will not be needed when // The event state manager supports selected states. KMM - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); if (PR_TRUE == mIsAllFramesHere) { - aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_TRUE); + aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, "", PR_TRUE); //ForceRedraw(); } else { - aContent->SetAttribute(kNameSpaceID_None, selectedAtom, "", PR_FALSE); + aContent->SetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, "", PR_FALSE); } - NS_RELEASE(selectedAtom); } //--------------------------------------------------------- @@ -689,15 +684,12 @@ nsListControlFrame::DisplayDeselected(nsIContent* aContent) //XXX: This is temporary. It simulates psuedo states by using a attribute selector on // -moz-option-selected in the ua.css style sheet. This will not be needed when // The event state manager is functional. KMM - - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); if (PR_TRUE == mIsAllFramesHere) { - aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_TRUE); + aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_TRUE); //ForceRedraw(); } else { - aContent->UnsetAttribute(kNameSpaceID_None, selectedAtom, PR_FALSE); + aContent->UnsetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, PR_FALSE); } - NS_RELEASE(selectedAtom); } @@ -1095,7 +1087,6 @@ nsListControlFrame::SetInitialChildList(nsIPresContext* aPresContext, mHasBeenInitialized = PR_FALSE; } } - mContentFrame = aChildList; nsresult rv = nsScrollFrame::SetInitialChildList(aPresContext, aListName, aChildList); // If all the content is here now check @@ -1365,10 +1356,8 @@ PRBool nsListControlFrame::IsContentSelected(nsIContent* aContent) { nsString value; - nsIAtom * selectedAtom = NS_NewAtom(kMozSelected); //nsIAtom * selectedAtom = NS_NewAtom("selected"); - nsresult result = aContent->GetAttribute(kNameSpaceID_None, selectedAtom, value); - NS_RELEASE(selectedAtom); + nsresult result = aContent->GetAttribute(kNameSpaceID_None, nsLayoutAtoms::optionSelectedPseudo, value); return (NS_CONTENT_ATTR_NOT_THERE == result ? PR_FALSE : PR_TRUE); } diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index 8bcbe7c8c85c..62af96706b4a 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -221,23 +221,18 @@ protected: nsresult SelectionChanged(nsIContent* aContent); // Data Members - nscoord mBorderOffsetY; nsFormFrame* mFormFrame; PRInt32 mSelectedIndex; PRInt32 mOldSelectedIndex; PRInt32 mSelectedIndexWhenPoppedDown; PRInt32 mStartExtendedIndex; PRInt32 mEndExtendedIndex; - nsIFrame* mHitFrame; PRBool mIsInitializedFromContent; - nsIFrame* mContentFrame; nsIComboboxControlFrame *mComboboxFrame; PRBool mButtonDown; - nsIFrame* mLastFrame; nscoord mMaxWidth; nscoord mMaxHeight; PRBool mIsCapturingMouseEvents; - PRBool mIgnoreMouseUp; PRBool* mSelectionCache; PRInt32 mSelectionCacheLength; @@ -245,8 +240,6 @@ protected: PRBool mIsAllFramesHere; PRBool mHasBeenInitialized; - nsIFrame * mMainChild; - nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context. // XXX temprary only until full system mouse capture works