Bug 53966. Remove unnecessary view creation from nsImageControlFrame, and remove unused fields and functions from nsImageControlFrame/nsHTMLButtonControlFrame. r+sr=bzbarsky

This commit is contained in:
roc+%cs.cmu.edu 2004-02-28 15:01:38 +00:00
parent 96b60839a0
commit 87b13e8430
6 changed files with 0 additions and 286 deletions

View File

@ -58,10 +58,6 @@
#include "nsIHTMLContent.h"
#include "nsIWidget.h"
#include "nsIComponentManager.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsViewsCID.h"
#include "nsColor.h"
#include "nsIDocument.h"
#include "nsButtonFrameRenderer.h"
#include "nsFormControlFrame.h"
@ -76,11 +72,6 @@
#include "nsIAccessibilityService.h"
#endif
#if 0
// see nsHTMLButtonControlFrame::Reflow()
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#endif
nsresult
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
{
@ -100,9 +91,6 @@ nsHTMLButtonControlFrame::nsHTMLButtonControlFrame()
: nsHTMLContainerFrame()
{
mInline = PR_TRUE;
mPreviousCursor = eCursor_standard;
mTranslatedRect = nsRect(0,0,0,0);
mDidInit = PR_FALSE;
mCacheSize.width = -1;
mCacheSize.height = -1;
@ -280,21 +268,6 @@ nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
}
}
void
nsHTMLButtonControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
{
nsIView* view;
nsPoint viewOffset(0,0);
GetOffsetFromView(aPresContext, viewOffset, &view);
while (view) {
viewOffset += view->GetPosition();
view = view->GetParent();
}
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
@ -418,37 +391,6 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
}
#endif
// commenting this out for now. We need a view to do mouse grabbing but
// it doesn't really seem to work correctly. When you press the only event
// you can get after that is a release. You need mouse enter and exit.
// the view also breaks the outline code. For some reason you can not reset
// the clip rect to draw outside you bounds if you have a view. And you need to
// because the outline must be drawn outside of our bounds according to CSS. -EDV
// XXX If you do decide you need a view, then create it in the Init() function
// and not here...
#if 0
if (!mDidInit) {
// create our view, we need a view to grab the mouse
nsIView* view = GetView();
if (!view) {
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
nsIViewManager* viewMan = aPresContext->GetViewManager();
nsIFrame* parWithView = GetAncestorWithView();
nsIView* parView = parWithView->GetView();
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 500, 500);
result = view->Init(viewMan, boundBox, parView, nsnull);
viewMan->InsertChild(parView, view, 0);
SetView(view);
// set the opacity
viewMan->SetViewOpacity(view, GetStyleDisplay()->mOpacity);
}
mDidInit = PR_TRUE;
}
#endif
// Reflow the child
nsIFrame* firstKid = mFrames.FirstChild();
nsSize availSize(aReflowState.mComputedWidth, NS_INTRINSICSIZE);

View File

@ -186,13 +186,9 @@ protected:
const nsHTMLReflowState& aSuggestedReflowState);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect);
PRIntn GetSkipSides() const;
PRBool mInline;
nsCursor mPreviousCursor;
nsRect mTranslatedRect;
PRBool mDidInit;
nsButtonFrameRenderer mRenderer;
//Resize Reflow OpitmizationSize;

View File

@ -47,11 +47,8 @@
#include "nsStyleContext.h"
#include "nsLeafFrame.h"
#include "nsCSSRendering.h"
#include "nsIViewManager.h"
#include "nsISupports.h"
#include "nsHTMLAtoms.h"
#include "nsIView.h"
#include "nsViewsCID.h"
#include "nsIDeviceContext.h"
#include "nsIFontMetrics.h"
#include "nsIImage.h"
@ -65,17 +62,6 @@
#include "nsIAccessibilityService.h"
#endif
//Enumeration of possible mouse states used to detect mouse clicks
/*enum nsMouseState {
eMouseNone,
eMouseEnter,
eMouseExit,
eMouseDown,
eMouseUp
};
*/
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#define nsImageControlFrameSuper nsImageFrame
class nsImageControlFrame : public nsImageControlFrameSuper,
public nsIFormControlFrame,
@ -88,12 +74,6 @@ public:
NS_IMETHOD Destroy(nsIPresContext *aPresContext);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -153,26 +133,16 @@ public:
NS_IMETHOD GetClickedY(PRInt32* aY);
protected:
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
nsMouseState mLastMouseState;
nsPoint mLastClickPoint;
nsCursor mPreviousCursor;
nsRect mTranslatedRect;
PRBool mGotFocus;
};
nsImageControlFrame::nsImageControlFrame()
{
mLastMouseState = eMouseNone;
mLastClickPoint = nsPoint(0,0);
mPreviousCursor = eCursor_standard;
mTranslatedRect = nsRect(0,0,0,0);
mGotFocus = PR_FALSE;
}
nsImageControlFrame::~nsImageControlFrame()
@ -253,42 +223,6 @@ nsImageControlFrame::GetType() const
return nsLayoutAtoms::imageControlFrame;
}
NS_IMETHODIMP
nsImageControlFrame::Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
// call our base class
nsresult rv = nsImageControlFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
// create our view, we need a view to grab the mouse
if (!HasView()) {
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
nsIViewManager* viewMan = aPresContext->GetViewManager();
nsIFrame* parWithView = GetAncestorWithView();
nsIView *parView = parWithView->GetView();
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
nsContainerFrame::SyncFrameViewProperties(aPresContext, this, aContext, view);
// this gets reset during reflow anyway
// viewMan->SetViewContentTransparency(view, PR_TRUE);
// XXX put the view last in document order until we know how to do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(view);
}
return rv;
}
NS_METHOD
nsImageControlFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -336,7 +270,6 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x, t2p);
mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y, t2p);
mGotFocus = PR_TRUE;
break;
}
}
@ -347,7 +280,6 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
void
nsImageControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
mGotFocus = aOn;
/*if (aRepaint) {
nsRect rect(0, 0, mRect.width, mRect.height);
Invalidate(rect, PR_TRUE);
@ -366,19 +298,6 @@ nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
}
}
void
nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
{
nsIView* view;
nsPoint viewOffset(0,0);
GetOffsetFromView(aPresContext, viewOffset, &view);
while (view) {
viewOffset += view->GetPosition();
view = view->GetParent();
}
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
}
NS_IMETHODIMP_(PRInt32)
nsImageControlFrame::GetFormControlType() const
{

View File

@ -58,10 +58,6 @@
#include "nsIHTMLContent.h"
#include "nsIWidget.h"
#include "nsIComponentManager.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsViewsCID.h"
#include "nsColor.h"
#include "nsIDocument.h"
#include "nsButtonFrameRenderer.h"
#include "nsFormControlFrame.h"
@ -76,11 +72,6 @@
#include "nsIAccessibilityService.h"
#endif
#if 0
// see nsHTMLButtonControlFrame::Reflow()
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#endif
nsresult
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
{
@ -100,9 +91,6 @@ nsHTMLButtonControlFrame::nsHTMLButtonControlFrame()
: nsHTMLContainerFrame()
{
mInline = PR_TRUE;
mPreviousCursor = eCursor_standard;
mTranslatedRect = nsRect(0,0,0,0);
mDidInit = PR_FALSE;
mCacheSize.width = -1;
mCacheSize.height = -1;
@ -280,21 +268,6 @@ nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
}
}
void
nsHTMLButtonControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
{
nsIView* view;
nsPoint viewOffset(0,0);
GetOffsetFromView(aPresContext, viewOffset, &view);
while (view) {
viewOffset += view->GetPosition();
view = view->GetParent();
}
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
nsGUIEvent* aEvent,
@ -418,37 +391,6 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
}
#endif
// commenting this out for now. We need a view to do mouse grabbing but
// it doesn't really seem to work correctly. When you press the only event
// you can get after that is a release. You need mouse enter and exit.
// the view also breaks the outline code. For some reason you can not reset
// the clip rect to draw outside you bounds if you have a view. And you need to
// because the outline must be drawn outside of our bounds according to CSS. -EDV
// XXX If you do decide you need a view, then create it in the Init() function
// and not here...
#if 0
if (!mDidInit) {
// create our view, we need a view to grab the mouse
nsIView* view = GetView();
if (!view) {
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
nsIViewManager* viewMan = aPresContext->GetViewManager();
nsIFrame* parWithView = GetAncestorWithView();
nsIView* parView = parWithView->GetView();
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 500, 500);
result = view->Init(viewMan, boundBox, parView, nsnull);
viewMan->InsertChild(parView, view, 0);
SetView(view);
// set the opacity
viewMan->SetViewOpacity(view, GetStyleDisplay()->mOpacity);
}
mDidInit = PR_TRUE;
}
#endif
// Reflow the child
nsIFrame* firstKid = mFrames.FirstChild();
nsSize availSize(aReflowState.mComputedWidth, NS_INTRINSICSIZE);

View File

@ -186,13 +186,9 @@ protected:
const nsHTMLReflowState& aSuggestedReflowState);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect);
PRIntn GetSkipSides() const;
PRBool mInline;
nsCursor mPreviousCursor;
nsRect mTranslatedRect;
PRBool mDidInit;
nsButtonFrameRenderer mRenderer;
//Resize Reflow OpitmizationSize;

View File

@ -47,11 +47,8 @@
#include "nsStyleContext.h"
#include "nsLeafFrame.h"
#include "nsCSSRendering.h"
#include "nsIViewManager.h"
#include "nsISupports.h"
#include "nsHTMLAtoms.h"
#include "nsIView.h"
#include "nsViewsCID.h"
#include "nsIDeviceContext.h"
#include "nsIFontMetrics.h"
#include "nsIImage.h"
@ -65,17 +62,6 @@
#include "nsIAccessibilityService.h"
#endif
//Enumeration of possible mouse states used to detect mouse clicks
/*enum nsMouseState {
eMouseNone,
eMouseEnter,
eMouseExit,
eMouseDown,
eMouseUp
};
*/
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
#define nsImageControlFrameSuper nsImageFrame
class nsImageControlFrame : public nsImageControlFrameSuper,
public nsIFormControlFrame,
@ -88,12 +74,6 @@ public:
NS_IMETHOD Destroy(nsIPresContext *aPresContext);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow);
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -153,26 +133,16 @@ public:
NS_IMETHOD GetClickedY(PRInt32* aY);
protected:
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
nsMouseState mLastMouseState;
nsPoint mLastClickPoint;
nsCursor mPreviousCursor;
nsRect mTranslatedRect;
PRBool mGotFocus;
};
nsImageControlFrame::nsImageControlFrame()
{
mLastMouseState = eMouseNone;
mLastClickPoint = nsPoint(0,0);
mPreviousCursor = eCursor_standard;
mTranslatedRect = nsRect(0,0,0,0);
mGotFocus = PR_FALSE;
}
nsImageControlFrame::~nsImageControlFrame()
@ -253,42 +223,6 @@ nsImageControlFrame::GetType() const
return nsLayoutAtoms::imageControlFrame;
}
NS_IMETHODIMP
nsImageControlFrame::Init(nsIPresContext* aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
// call our base class
nsresult rv = nsImageControlFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
// create our view, we need a view to grab the mouse
if (!HasView()) {
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
nsIViewManager* viewMan = aPresContext->GetViewManager();
nsIFrame* parWithView = GetAncestorWithView();
nsIView *parView = parWithView->GetView();
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
nsContainerFrame::SyncFrameViewProperties(aPresContext, this, aContext, view);
// this gets reset during reflow anyway
// viewMan->SetViewContentTransparency(view, PR_TRUE);
// XXX put the view last in document order until we know how to do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(view);
}
return rv;
}
NS_METHOD
nsImageControlFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -336,7 +270,6 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
mLastClickPoint.x = NSTwipsToIntPixels(aEvent->point.x, t2p);
mLastClickPoint.y = NSTwipsToIntPixels(aEvent->point.y, t2p);
mGotFocus = PR_TRUE;
break;
}
}
@ -347,7 +280,6 @@ nsImageControlFrame::HandleEvent(nsIPresContext* aPresContext,
void
nsImageControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
mGotFocus = aOn;
/*if (aRepaint) {
nsRect rect(0, 0, mRect.width, mRect.height);
Invalidate(rect, PR_TRUE);
@ -366,19 +298,6 @@ nsImageControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
}
}
void
nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
{
nsIView* view;
nsPoint viewOffset(0,0);
GetOffsetFromView(aPresContext, viewOffset, &view);
while (view) {
viewOffset += view->GetPosition();
view = view->GetParent();
}
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
}
NS_IMETHODIMP_(PRInt32)
nsImageControlFrame::GetFormControlType() const
{