mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 488771. Stop nsIsIndexFrame from inheriting from nsISupports. r=roc
--HG-- extra : rebase_source : 75ec78edbb8c169dc9cf7d4f959865002b884512
This commit is contained in:
parent
2237f423ac
commit
aef27e1db9
@ -101,7 +101,9 @@ nsIsIndexFrame::Destroy()
|
||||
{
|
||||
// remove ourself as a listener of the text control (bug 40533)
|
||||
if (mInputContent) {
|
||||
mInputContent->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
|
||||
if (mListener) {
|
||||
mInputContent->RemoveEventListenerByIID(mListener, NS_GET_IID(nsIDOMKeyListener));
|
||||
}
|
||||
nsContentUtils::DestroyAnonymousContent(&mInputContent);
|
||||
}
|
||||
nsContentUtils::DestroyAnonymousContent(&mTextContent);
|
||||
@ -226,7 +228,8 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Register as an event listener to submit on Enter press
|
||||
mInputContent->AddEventListenerByIID(this, NS_GET_IID(nsIDOMKeyListener));
|
||||
mListener = new nsIsIndexFrame::KeyListener(this);
|
||||
mInputContent->AddEventListenerByIID(mListener, NS_GET_IID(nsIDOMKeyListener));
|
||||
|
||||
// Create an hr
|
||||
NS_NewHTMLElement(getter_AddRefs(mPostHr), hrInfo, PR_FALSE);
|
||||
@ -241,23 +244,9 @@ NS_QUERYFRAME_HEAD(nsIsIndexFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsIStatefulFrame)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
||||
|
||||
// Frames are not refcounted, no need to AddRef
|
||||
NS_IMETHODIMP
|
||||
nsIsIndexFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_PRECONDITION(aInstancePtr, "null out param");
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) {
|
||||
*aInstancePtr = static_cast<nsIDOMKeyListener*>(this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMEventListener))) {
|
||||
*aInstancePtr = static_cast<nsIDOMEventListener*>(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS2(nsIsIndexFrame::KeyListener,
|
||||
nsIDOMKeyListener,
|
||||
nsIDOMEventListener)
|
||||
|
||||
nscoord
|
||||
nsIsIndexFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
|
||||
@ -291,8 +280,14 @@ nsIsIndexFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsIsIndexFrame::KeyListener::KeyPress(nsIDOMEvent* aEvent)
|
||||
{
|
||||
mOwner->KeyPress(aEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsIsIndexFrame::KeyPress(nsIDOMEvent* aEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aEvent);
|
||||
@ -307,8 +302,6 @@ nsIsIndexFrame::KeyPress(nsIDOMEvent* aEvent)
|
||||
aEvent->PreventDefault(); // XXX Needed?
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -50,7 +50,6 @@ typedef nsTextControlFrame nsNewFrame;
|
||||
|
||||
class nsIsIndexFrame : public nsBlockFrame,
|
||||
public nsIAnonymousContentCreator,
|
||||
public nsIDOMKeyListener,
|
||||
public nsIStatefulFrame
|
||||
{
|
||||
public:
|
||||
@ -59,34 +58,30 @@ public:
|
||||
|
||||
virtual void Destroy();
|
||||
|
||||
/**
|
||||
* Processes a key pressed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
private:
|
||||
void KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
/**
|
||||
* Processes a key release event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*/
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
class KeyListener : public nsIDOMKeyListener
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* Processes a key typed event
|
||||
* @param aKeyEvent @see nsIDOMEvent.h
|
||||
* @returns whether the event was consumed or ignored. @see nsresult
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent); // we only care when a key is pressed
|
||||
KeyListener(nsIsIndexFrame* aOwner) : mOwner(aOwner) { };
|
||||
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent); // we only care when a key is pressed
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
nsIsIndexFrame* mOwner;
|
||||
};
|
||||
|
||||
public:
|
||||
NS_DECL_QUERYFRAME
|
||||
NS_DECL_FRAMEARENA_HELPERS
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
// nsIFormControlFrame
|
||||
virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
|
||||
|
||||
@ -104,8 +99,6 @@ public:
|
||||
// nsIAnonymousContentCreator
|
||||
virtual nsresult CreateAnonymousContent(nsTArray<nsIContent*>& aElements);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD OnSubmit(nsPresContext* aPresContext);
|
||||
|
||||
//nsIStatefulFrame
|
||||
@ -131,8 +124,7 @@ private:
|
||||
char* UnicodeToNewBytes(const PRUnichar* aSrc, PRUint32 aLen, nsIUnicodeEncoder* encoder);
|
||||
void URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, nsString& oString);
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
|
||||
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
|
||||
nsCOMPtr<KeyListener> mListener;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user