Backing things out until I can get Solaris bustage figured out.

This commit is contained in:
pollmann%netscape.com 1999-09-14 20:42:26 +00:00
Родитель a874b261ad
Коммит 7de8a23562
26 изменённых файлов: 143 добавлений и 1074 удалений

Просмотреть файл

@ -38,14 +38,11 @@
#include "nsIDeviceContext.h"
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsIEventStateManager.h"
// Get onChange to target Select not Option
#include "nsIDOMNode.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsArray.h"
#include "nsISelectControlFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
static NS_DEFINE_IID(kIComboboxControlFrameIID, NS_ICOMBOBOXCONTROLFRAME_IID);
@ -151,15 +148,11 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
*aInstancePtr = (void *)(nsISelectControlFrame*)this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void *)(nsIStatefulFrame*)this;
NS_ADDREF_THIS();
} else if (aIID.Equals(nsCOMTypeInfo<nsISelectControlFrame>::GetIID())) {
*aInstancePtr = (void *)((nsISelectControlFrame*)this);
return NS_OK;
}
return nsAreaFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1049,16 +1042,16 @@ nsComboboxControlFrame::SelectionChanged(PRBool aDoDispatchEvent)
nsIDOMNode* node = nsnull;
res = mContent->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_SUCCEEDED(res) && node) {
nsIPrivateDOMEvent* pDOMEvent = nsnull;
nsIPrivateDOMEvent* pDOMEvent = nsnull;
res = DOMEvent->QueryInterface(kIPrivateDOMEventIID, (void**)&pDOMEvent);
if (NS_SUCCEEDED(res) && pDOMEvent) {
pDOMEvent->SetTarget(node);
NS_RELEASE(pDOMEvent);
NS_RELEASE(pDOMEvent);
// Have the content handle the event.
mContent->HandleDOMEvent(*mPresContext, &event, &DOMEvent, NS_EVENT_FLAG_BUBBLE, status);
}
NS_RELEASE(node);
NS_RELEASE(node);
}
NS_RELEASE(DOMEvent);
}
@ -1084,11 +1077,10 @@ nsComboboxControlFrame::AddOption(PRInt32 aIndex)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->AddOption(aIndex);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->AddOption(aIndex);
}
return rv;
}
@ -1099,11 +1091,10 @@ nsComboboxControlFrame::RemoveOption(PRInt32 aIndex)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->RemoveOption(aIndex);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->RemoveOption(aIndex);
}
return rv;
}
@ -1113,25 +1104,10 @@ nsComboboxControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->SetOptionSelected(aIndex, aValue);
NS_RELEASE(listFrame);
}
return rv;
}
NS_IMETHODIMP
nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->GetOptionSelected(aIndex, aValue);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->SetOptionSelected(aIndex, aValue);
}
return rv;
}
@ -1392,42 +1368,4 @@ nsComboboxControlFrame::Blur(nsIDOMEvent* aEvent)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
// XXX Do we need to implement this here? It is already implemented in
// the ListControlFrame, our child...
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eSelectType;
return NS_OK;
}
NS_IMETHODIMP
nsComboboxControlFrame::SaveState(nsISupports** aState)
{
if (!mListControlFrame) return NS_ERROR_UNEXPECTED;
nsIStatefulFrame* sFrame = nsnull;
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
(void**)&sFrame);
if (NS_SUCCEEDED(res) && sFrame) {
res = sFrame->SaveState(aState);
NS_RELEASE(sFrame);
}
return res;
}
NS_IMETHODIMP
nsComboboxControlFrame::RestoreState(nsISupports* aState)
{
if (!mListControlFrame) return NS_ERROR_UNEXPECTED;
nsIStatefulFrame* sFrame = nsnull;
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
(void**)&sFrame);
if (NS_SUCCEEDED(res) && sFrame) {
res = sFrame->RestoreState(aState);
NS_RELEASE(sFrame);
}
return res;
}

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsVoidArray.h"
#include "nsIAnonymousContentCreator.h"
#include "nsISelectControlFrame.h"
#include "nsIStatefulFrame.h"
class nsButtonControlFrame;
class nsTextControlFrame;
@ -50,8 +49,8 @@ class nsComboboxControlFrame : public nsAreaFrame,
public nsIDOMMouseListener,
public nsIDOMFocusListener,
public nsIAnonymousContentCreator,
public nsISelectControlFrame,
public nsIStatefulFrame
public nsISelectControlFrame
{
public:
nsComboboxControlFrame();
@ -141,7 +140,6 @@ public:
NS_IMETHOD AddOption(PRInt32 index);
NS_IMETHOD RemoveOption(PRInt32 index);
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
//nsIDOMEventListener
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
@ -156,11 +154,6 @@ public:
virtual nsresult Focus(nsIDOMEvent* aEvent);
virtual nsresult Blur(nsIDOMEvent* aEvent);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
// nsHTMLContainerFrame

Просмотреть файл

@ -45,9 +45,7 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
@ -78,16 +76,11 @@ nsFileControlFrame::nsFileControlFrame():
{
//Shrink the area around it's contents
SetFlags(NS_BLOCK_SHRINK_WRAP);
mCachedState = nsnull;
}
nsFileControlFrame::~nsFileControlFrame()
{
NS_IF_RELEASE(mTextContent);
if (mCachedState) {
delete mCachedState;
mCachedState = nsnull;
}
}
NS_IMETHODIMP
@ -128,28 +121,25 @@ nsFileControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(kIFormControlFrameIID)) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
} else if (aIID.Equals(kIDOMMouseListenerIID)) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
} else if (aIID.Equals(kIDOMMouseListenerIID)) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}
@ -270,12 +260,6 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext,
// add ourself as an nsIFormControlFrame
nsFormFrame::AddFormControlFrame(aPresContext, *this);
mTextFrame = GetTextControlFrame(this);
if (!mTextFrame) return NS_ERROR_UNEXPECTED;
if (mCachedState) {
mTextFrame->SetProperty(nsHTMLAtoms::value, *mCachedState);
delete mCachedState;
mCachedState = nsnull;
}
}
return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
@ -307,7 +291,7 @@ nsFileControlFrame::GetTextControlFrame(nsIFrame* aStart)
nsIFrame* childFrame = nsnull;
aStart->FirstChild(nsnull, &childFrame);
while (childFrame) {
while (nsnull != childFrame) {
// see if the child is a text control
nsCOMPtr<nsIContent> content;
childFrame->GetContent(getter_AddRefs(content));
@ -324,7 +308,7 @@ nsFileControlFrame::GetTextControlFrame(nsIFrame* aStart)
// if not continue looking
nsTextControlFrame* frame = GetTextControlFrame(childFrame);
if (frame)
if (frame != nsnull)
return frame;
nsresult rv = childFrame->GetNextSibling(&childFrame);
@ -502,50 +486,3 @@ nsFileControlFrame::Paint(nsIPresContext& aPresContext,
{
return nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsFileControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eFileType;
return NS_OK;
}
NS_IMETHODIMP
nsFileControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsAutoString string;
nsresult res = mTextFrame->GetProperty(nsHTMLAtoms::value, string);
if (NS_SUCCEEDED(res)) {
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
}
*aState = (nsISupports*)value;
return res;
}
NS_IMETHODIMP
nsFileControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
// Don't poke mTextFrame, it's not there yet.
mCachedState = new nsString(chars);
if (!mCachedState) res = NS_ERROR_OUT_OF_MEMORY;
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -23,7 +23,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
class nsButtonControlFrame;
class nsTextControlFrame;
@ -34,8 +33,7 @@ class nsIHTMLContent;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
@ -146,11 +144,6 @@ public:
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
nsIWidget* GetWindowTemp(nsIView *aView); // XXX temporary
@ -159,7 +152,6 @@ protected:
nsTextControlFrame* mTextFrame;
nsFormFrame* mFormFrame;
nsIHTMLContent* mTextContent;
nsString* mCachedState;
private:
nsTextControlFrame* GetTextControlFrame(nsIFrame* aStart);

Просмотреть файл

@ -52,8 +52,6 @@ public:
*/
NS_IMETHOD SetOptionSelected(PRInt32 index, PRBool value) = 0;
NS_IMETHOD GetOptionSelected(PRInt32 index, PRBool* value) = 0;
};
#endif

Просмотреть файл

@ -37,13 +37,10 @@
#include "nsIReflowCommand.h"
#include "nsIPresShell.h"
#include "nsHTMLParts.h"
#include "nsIDOMEventReceiver.h"
#include "nsIEventStateManager.h"
#include "nsIDOMUIEvent.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
@ -153,11 +150,6 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1645,15 +1637,6 @@ nsListControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
return NS_OK;
}
//---------------------------------------------------------
// Determine if the specified item in the listbox is selected.
NS_IMETHODIMP
nsListControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
{
*aValue = IsContentSelectedByIndex(aIndex);
return NS_OK;
}
//----------------------------------------------------------------------
// End nsISelectControlFrame
//----------------------------------------------------------------------
@ -2162,78 +2145,3 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eSelectType;
return NS_OK;
}
NS_IMETHODIMP
nsListControlFrame::SaveState(nsISupports** aState)
{
nsISupportsArray* value = nsnull;
nsresult res = NS_NewISupportsArray(&value);
if (NS_SUCCEEDED(res) && value) {
PRInt32 j=0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
PRInt32 i;
for (i=0; i<length; i++) {
PRBool selected = PR_FALSE;
res = GetOptionSelected(i, &selected);
if (NS_SUCCEEDED(res) && selected) {
nsISupportsPRInt32* thisVal = nsnull;
res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID,
nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)&thisVal);
if (NS_SUCCEEDED(res) && thisVal) {
res = thisVal->SetData(i);
if (NS_SUCCEEDED(res)) {
PRBool okay = value->InsertElementAt((nsISupports *)thisVal, j++);
if (!okay) res = NS_ERROR_OUT_OF_MEMORY; // Most likely cause;
}
if (!NS_SUCCEEDED(res)) NS_RELEASE(thisVal);
}
}
if (!NS_SUCCEEDED(res)) break;
}
if (i<length)
NS_RELEASE(value);
}
*aState = (nsISupports*)value; // Set to null if not successful
return res;
}
NS_IMETHODIMP
nsListControlFrame::RestoreState(nsISupports* aState)
{
nsISupportsArray* value = (nsISupportsArray *)aState;
nsresult res = NS_ERROR_NULL_POINTER;
if (value) {
res = Deselect();
if (NS_SUCCEEDED(res)) {
PRUint32 count = 0;
res = value->Count(&count);
if (NS_SUCCEEDED(res)) {
nsISupportsPRInt32* thisVal = nsnull;
PRInt32 j=0;
for (PRUint32 i=0; i<count; i++) {
thisVal = (nsISupportsPRInt32*) value->ElementAt(i);
if (thisVal) {
res = thisVal->GetData(&j);
if (NS_SUCCEEDED(res)) {
res = SetOptionSelected(j, PR_TRUE);
}
} else {
res = NS_ERROR_UNEXPECTED;
}
if (!NS_SUCCEEDED(res)) break;
}
}
}
}
return res;
}

Просмотреть файл

@ -26,7 +26,6 @@
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -45,8 +44,7 @@ class nsListControlFrame : public nsScrollFrame,
public nsIDOMMouseListener,
public nsIDOMMouseMotionListener,
public nsIDOMKeyListener,
public nsISelectControlFrame,
public nsIStatefulFrame
public nsISelectControlFrame
{
public:
friend nsresult NS_NewListControlFrame(nsIFrame** aNewFrame);
@ -122,12 +120,6 @@ public:
NS_IMETHOD AddOption(PRInt32 index);
NS_IMETHOD RemoveOption(PRInt32 index);
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
//nsIDOMEventListener
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);

Просмотреть файл

@ -45,9 +45,6 @@
#include "nsIFontMetrics.h"
#include "nsILookAndFeel.h"
#include "nsIComponentManager.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID);
@ -70,21 +67,6 @@ nsTextControlFrame::~nsTextControlFrame()
{
}
nsresult
nsTextControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);
}
nscoord
nsTextControlFrame::GetVerticalBorderWidth(float aPixToTwip) const
{
@ -373,49 +355,3 @@ nsTextControlFrame::GetWrapProperty(nsString &aOutValue)
}
return result;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsTextControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eTextType;
return NS_OK;
}
NS_IMETHODIMP
nsTextControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsAutoString string;
nsresult res = GetProperty(nsHTMLAtoms::value, string);
if (NS_SUCCEEDED(res)) {
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
}
*aState = (nsISupports*)value;
return res;
}
NS_IMETHODIMP
nsTextControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
nsAutoString string(chars);
res = SetProperty(nsHTMLAtoms::value, string);
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -20,14 +20,11 @@
#define nsTextControlFrame_h___
#include "nsNativeFormControlFrame.h"
#include "nsIStatefulFrame.h"
class nsIContent;
class nsIFrame;
class nsIPresContext;
class nsTextControlFrame : public nsNativeFormControlFrame,
public nsIStatefulFrame
class nsTextControlFrame : public nsNativeFormControlFrame
{
/* ---------- methods implemented by base class ---------- */
public:
@ -37,8 +34,6 @@ public:
virtual const nsIID& GetCID();
virtual const nsIID& GetIID();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameName(nsString& aResult) const;
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
@ -58,11 +53,6 @@ public:
* returns NS_CONTENT_ATTR_NOT_THERE if the property does not exist for this
*/
NS_IMETHOD GetWrapProperty(nsString &aOutValue);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
@ -77,9 +67,6 @@ protected:
PRInt32 GetDefaultColumnWidth() const { return (PRInt32)(20); } // this was DEFAULT_PIXEL_WIDTH
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
/* ---------- abstract methods derived class must implement ---------- */

Просмотреть файл

@ -52,8 +52,6 @@ public:
*/
NS_IMETHOD SetOptionSelected(PRInt32 index, PRBool value) = 0;
NS_IMETHOD GetOptionSelected(PRInt32 index, PRBool* value) = 0;
};
#endif

Просмотреть файл

@ -25,28 +25,8 @@
#include "nsCOMPtr.h"
#include "nsINameSpaceManager.h"
#include "nsFormFrame.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
//----------------------------------------------------------------------
// nsISupports
//----------------------------------------------------------------------
NS_IMETHODIMP
nsCheckboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
if ( !aInstancePtr )
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);
}
//
// GetTristateAtom [static]
//
@ -396,45 +376,3 @@ nsCheckboxControlFrame :: SwitchModesWithEmergencyBrake ( PRBool inIsNowTristate
mIsTristate = inIsNowTristate;
} // SwitchModesWithEmergencyBrake
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP nsCheckboxControlFrame::GetStateType(StateType* aStateType)
{
*aStateType=eCheckboxType;
return NS_OK;
}
NS_IMETHODIMP nsCheckboxControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsresult res = NS_OK;
nsAutoString string;
GetCheckboxControlFrameState(string);
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
*aState = (nsISupports*)value;
return res;
}
NS_IMETHODIMP nsCheckboxControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
nsAutoString string(chars);
SetCheckboxControlFrameState(string);
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -19,7 +19,6 @@
#define nsCheckboxControlFrame_h___
#include "nsNativeFormControlFrame.h"
#include "nsIStatefulFrame.h"
//
// nsCheckboxControlFrame
@ -41,9 +40,7 @@
// become checked since "mixed" doesn't exist on normal checkboxes.
//
class nsCheckboxControlFrame : public nsNativeFormControlFrame,
public nsIStatefulFrame
{
class nsCheckboxControlFrame : public nsNativeFormControlFrame {
private:
typedef nsNativeFormControlFrame Inherited;
@ -87,15 +84,9 @@ public:
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
// this should be protected, but VC6 is lame.
// this should be protected, but VC6 is lame.
enum CheckState { eOff, eOn, eMixed } ;
// nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
protected:
// native/gfx implementations need to implement needs.
@ -123,9 +114,6 @@ protected:
static nsIAtom* GetTristateAtom() ;
static nsIAtom* GetTristateValueAtom() ;
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
}; // class nsCheckboxControlFrame
#endif

Просмотреть файл

@ -38,14 +38,11 @@
#include "nsIDeviceContext.h"
#include "nsIView.h"
#include "nsIScrollableView.h"
#include "nsIEventStateManager.h"
// Get onChange to target Select not Option
#include "nsIDOMNode.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsArray.h"
#include "nsISelectControlFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
static NS_DEFINE_IID(kIComboboxControlFrameIID, NS_ICOMBOBOXCONTROLFRAME_IID);
@ -151,15 +148,11 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
*aInstancePtr = (void *)(nsISelectControlFrame*)this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void *)(nsIStatefulFrame*)this;
NS_ADDREF_THIS();
} else if (aIID.Equals(nsCOMTypeInfo<nsISelectControlFrame>::GetIID())) {
*aInstancePtr = (void *)((nsISelectControlFrame*)this);
return NS_OK;
}
return nsAreaFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1049,16 +1042,16 @@ nsComboboxControlFrame::SelectionChanged(PRBool aDoDispatchEvent)
nsIDOMNode* node = nsnull;
res = mContent->QueryInterface(kIDOMNodeIID, (void**)&node);
if (NS_SUCCEEDED(res) && node) {
nsIPrivateDOMEvent* pDOMEvent = nsnull;
nsIPrivateDOMEvent* pDOMEvent = nsnull;
res = DOMEvent->QueryInterface(kIPrivateDOMEventIID, (void**)&pDOMEvent);
if (NS_SUCCEEDED(res) && pDOMEvent) {
pDOMEvent->SetTarget(node);
NS_RELEASE(pDOMEvent);
NS_RELEASE(pDOMEvent);
// Have the content handle the event.
mContent->HandleDOMEvent(*mPresContext, &event, &DOMEvent, NS_EVENT_FLAG_BUBBLE, status);
}
NS_RELEASE(node);
NS_RELEASE(node);
}
NS_RELEASE(DOMEvent);
}
@ -1084,11 +1077,10 @@ nsComboboxControlFrame::AddOption(PRInt32 aIndex)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->AddOption(aIndex);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->AddOption(aIndex);
}
return rv;
}
@ -1099,11 +1091,10 @@ nsComboboxControlFrame::RemoveOption(PRInt32 aIndex)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->RemoveOption(aIndex);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->RemoveOption(aIndex);
}
return rv;
}
@ -1113,25 +1104,10 @@ nsComboboxControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
nsresult rv = dropdownFrame->QueryInterface(nsCOMTypeInfo<nsISelectControlFrame>::GetIID(),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->SetOptionSelected(aIndex, aValue);
NS_RELEASE(listFrame);
}
return rv;
}
NS_IMETHODIMP
nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
{
nsISelectControlFrame* listFrame = nsnull;
nsIFrame* dropdownFrame = GetDropdownFrame();
nsresult rv = dropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
(void**)&listFrame);
if (NS_SUCCEEDED(rv) && listFrame) {
rv = listFrame->GetOptionSelected(aIndex, aValue);
NS_RELEASE(listFrame);
if (NS_SUCCEEDED(rv) && nsnull != listFrame) {
return listFrame->SetOptionSelected(aIndex, aValue);
}
return rv;
}
@ -1392,42 +1368,4 @@ nsComboboxControlFrame::Blur(nsIDOMEvent* aEvent)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
// XXX Do we need to implement this here? It is already implemented in
// the ListControlFrame, our child...
//----------------------------------------------------------------------
NS_IMETHODIMP
nsComboboxControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eSelectType;
return NS_OK;
}
NS_IMETHODIMP
nsComboboxControlFrame::SaveState(nsISupports** aState)
{
if (!mListControlFrame) return NS_ERROR_UNEXPECTED;
nsIStatefulFrame* sFrame = nsnull;
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
(void**)&sFrame);
if (NS_SUCCEEDED(res) && sFrame) {
res = sFrame->SaveState(aState);
NS_RELEASE(sFrame);
}
return res;
}
NS_IMETHODIMP
nsComboboxControlFrame::RestoreState(nsISupports* aState)
{
if (!mListControlFrame) return NS_ERROR_UNEXPECTED;
nsIStatefulFrame* sFrame = nsnull;
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
(void**)&sFrame);
if (NS_SUCCEEDED(res) && sFrame) {
res = sFrame->RestoreState(aState);
NS_RELEASE(sFrame);
}
return res;
}

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsVoidArray.h"
#include "nsIAnonymousContentCreator.h"
#include "nsISelectControlFrame.h"
#include "nsIStatefulFrame.h"
class nsButtonControlFrame;
class nsTextControlFrame;
@ -50,8 +49,8 @@ class nsComboboxControlFrame : public nsAreaFrame,
public nsIDOMMouseListener,
public nsIDOMFocusListener,
public nsIAnonymousContentCreator,
public nsISelectControlFrame,
public nsIStatefulFrame
public nsISelectControlFrame
{
public:
nsComboboxControlFrame();
@ -141,7 +140,6 @@ public:
NS_IMETHOD AddOption(PRInt32 index);
NS_IMETHOD RemoveOption(PRInt32 index);
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
//nsIDOMEventListener
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);
@ -156,11 +154,6 @@ public:
virtual nsresult Focus(nsIDOMEvent* aEvent);
virtual nsresult Blur(nsIDOMEvent* aEvent);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
// nsHTMLContainerFrame

Просмотреть файл

@ -45,9 +45,7 @@
#include "nsIDOMMouseListener.h"
#include "nsIPresShell.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
@ -78,16 +76,11 @@ nsFileControlFrame::nsFileControlFrame():
{
//Shrink the area around it's contents
SetFlags(NS_BLOCK_SHRINK_WRAP);
mCachedState = nsnull;
}
nsFileControlFrame::~nsFileControlFrame()
{
NS_IF_RELEASE(mTextContent);
if (mCachedState) {
delete mCachedState;
mCachedState = nsnull;
}
}
NS_IMETHODIMP
@ -128,28 +121,25 @@ nsFileControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
return NS_OK;
}
NS_IMETHODIMP
nsresult
nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(kIAnonymousContentCreatorIID)) {
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(kIFormControlFrameIID)) {
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
return NS_OK;
} else if (aIID.Equals(kIDOMMouseListenerIID)) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
} else if (aIID.Equals(kIDOMMouseListenerIID)) {
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
}
@ -270,12 +260,6 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext,
// add ourself as an nsIFormControlFrame
nsFormFrame::AddFormControlFrame(aPresContext, *this);
mTextFrame = GetTextControlFrame(this);
if (!mTextFrame) return NS_ERROR_UNEXPECTED;
if (mCachedState) {
mTextFrame->SetProperty(nsHTMLAtoms::value, *mCachedState);
delete mCachedState;
mCachedState = nsnull;
}
}
return nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
@ -307,7 +291,7 @@ nsFileControlFrame::GetTextControlFrame(nsIFrame* aStart)
nsIFrame* childFrame = nsnull;
aStart->FirstChild(nsnull, &childFrame);
while (childFrame) {
while (nsnull != childFrame) {
// see if the child is a text control
nsCOMPtr<nsIContent> content;
childFrame->GetContent(getter_AddRefs(content));
@ -324,7 +308,7 @@ nsFileControlFrame::GetTextControlFrame(nsIFrame* aStart)
// if not continue looking
nsTextControlFrame* frame = GetTextControlFrame(childFrame);
if (frame)
if (frame != nsnull)
return frame;
nsresult rv = childFrame->GetNextSibling(&childFrame);
@ -502,50 +486,3 @@ nsFileControlFrame::Paint(nsIPresContext& aPresContext,
{
return nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsFileControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eFileType;
return NS_OK;
}
NS_IMETHODIMP
nsFileControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsAutoString string;
nsresult res = mTextFrame->GetProperty(nsHTMLAtoms::value, string);
if (NS_SUCCEEDED(res)) {
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
}
*aState = (nsISupports*)value;
return res;
}
NS_IMETHODIMP
nsFileControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
// Don't poke mTextFrame, it's not there yet.
mCachedState = new nsString(chars);
if (!mCachedState) res = NS_ERROR_OUT_OF_MEMORY;
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -23,7 +23,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIStatefulFrame.h"
class nsButtonControlFrame;
class nsTextControlFrame;
@ -34,8 +33,7 @@ class nsIHTMLContent;
class nsFileControlFrame : public nsAreaFrame,
public nsIFormControlFrame,
public nsIDOMMouseListener,
public nsIAnonymousContentCreator,
public nsIStatefulFrame
public nsIAnonymousContentCreator
{
public:
@ -146,11 +144,6 @@ public:
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
nsIWidget* GetWindowTemp(nsIView *aView); // XXX temporary
@ -159,7 +152,6 @@ protected:
nsTextControlFrame* mTextFrame;
nsFormFrame* mFormFrame;
nsIHTMLContent* mTextContent;
nsString* mCachedState;
private:
nsTextControlFrame* GetTextControlFrame(nsIFrame* aStart);

Просмотреть файл

@ -37,13 +37,10 @@
#include "nsIReflowCommand.h"
#include "nsIPresShell.h"
#include "nsHTMLParts.h"
#include "nsIDOMEventReceiver.h"
#include "nsIEventStateManager.h"
#include "nsIDOMUIEvent.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
static NS_DEFINE_IID(kIDOMMouseMotionListenerIID, NS_IDOMMOUSEMOTIONLISTENER_IID);
@ -153,11 +150,6 @@ nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsScrollFrame::QueryInterface(aIID, aInstancePtr);
}
@ -1645,15 +1637,6 @@ nsListControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
return NS_OK;
}
//---------------------------------------------------------
// Determine if the specified item in the listbox is selected.
NS_IMETHODIMP
nsListControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
{
*aValue = IsContentSelectedByIndex(aIndex);
return NS_OK;
}
//----------------------------------------------------------------------
// End nsISelectControlFrame
//----------------------------------------------------------------------
@ -2162,78 +2145,3 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent)
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsListControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eSelectType;
return NS_OK;
}
NS_IMETHODIMP
nsListControlFrame::SaveState(nsISupports** aState)
{
nsISupportsArray* value = nsnull;
nsresult res = NS_NewISupportsArray(&value);
if (NS_SUCCEEDED(res) && value) {
PRInt32 j=0;
PRInt32 length = 0;
GetNumberOfOptions(&length);
PRInt32 i;
for (i=0; i<length; i++) {
PRBool selected = PR_FALSE;
res = GetOptionSelected(i, &selected);
if (NS_SUCCEEDED(res) && selected) {
nsISupportsPRInt32* thisVal = nsnull;
res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID,
nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)&thisVal);
if (NS_SUCCEEDED(res) && thisVal) {
res = thisVal->SetData(i);
if (NS_SUCCEEDED(res)) {
PRBool okay = value->InsertElementAt((nsISupports *)thisVal, j++);
if (!okay) res = NS_ERROR_OUT_OF_MEMORY; // Most likely cause;
}
if (!NS_SUCCEEDED(res)) NS_RELEASE(thisVal);
}
}
if (!NS_SUCCEEDED(res)) break;
}
if (i<length)
NS_RELEASE(value);
}
*aState = (nsISupports*)value; // Set to null if not successful
return res;
}
NS_IMETHODIMP
nsListControlFrame::RestoreState(nsISupports* aState)
{
nsISupportsArray* value = (nsISupportsArray *)aState;
nsresult res = NS_ERROR_NULL_POINTER;
if (value) {
res = Deselect();
if (NS_SUCCEEDED(res)) {
PRUint32 count = 0;
res = value->Count(&count);
if (NS_SUCCEEDED(res)) {
nsISupportsPRInt32* thisVal = nsnull;
PRInt32 j=0;
for (PRUint32 i=0; i<count; i++) {
thisVal = (nsISupportsPRInt32*) value->ElementAt(i);
if (thisVal) {
res = thisVal->GetData(&j);
if (NS_SUCCEEDED(res)) {
res = SetOptionSelected(j, PR_TRUE);
}
} else {
res = NS_ERROR_UNEXPECTED;
}
if (!NS_SUCCEEDED(res)) break;
}
}
}
}
return res;
}

Просмотреть файл

@ -26,7 +26,6 @@
#include "nsIDOMMouseListener.h"
#include "nsIDOMMouseMotionListener.h"
#include "nsIDOMKeyListener.h"
#include "nsIStatefulFrame.h"
class nsIDOMHTMLSelectElement;
class nsIDOMHTMLCollection;
@ -45,8 +44,7 @@ class nsListControlFrame : public nsScrollFrame,
public nsIDOMMouseListener,
public nsIDOMMouseMotionListener,
public nsIDOMKeyListener,
public nsISelectControlFrame,
public nsIStatefulFrame
public nsISelectControlFrame
{
public:
friend nsresult NS_NewListControlFrame(nsIFrame** aNewFrame);
@ -122,12 +120,6 @@ public:
NS_IMETHOD AddOption(PRInt32 index);
NS_IMETHOD RemoveOption(PRInt32 index);
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
//nsIDOMEventListener
virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent);

Просмотреть файл

@ -298,7 +298,11 @@ NS_METHOD nsNativeFormControlFrame::HandleEvent(nsIPresContext& aPresContext,
break;
case NS_MOUSE_LEFT_BUTTON_DOWN:
mLastMouseState = eMouseDown;
if (NS_FORM_INPUT_IMAGE == type) {
mLastMouseState = eMouseDown;
} else {
mLastMouseState = (eMouseEnter == mLastMouseState) ? eMouseDown : eMouseNone;
}
break;
case NS_MOUSE_LEFT_BUTTON_UP:

Просмотреть файл

@ -50,10 +50,6 @@
#include "nsILookAndFeel.h"
#include "nsIComponentManager.h"
#include "nsISelectControlFrame.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsArray.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIDOMHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLOptionElementIID, NS_IDOMHTMLOPTIONELEMENT_IID);
@ -67,12 +63,12 @@ static NS_DEFINE_IID(kListCID, NS_LISTBOX_CID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
static NS_DEFINE_IID(kISelectControlFrameIID, NS_ISELECTCONTROLFRAME_IID);
class nsOption;
class nsNativeSelectControlFrame : public nsNativeFormControlFrame,
public nsISelectControlFrame,
public nsIStatefulFrame
public nsISelectControlFrame
{
private:
typedef nsNativeFormControlFrame Inherited;
@ -153,12 +149,6 @@ public:
NS_IMETHOD AddOption(PRInt32 aIndex);
NS_IMETHOD RemoveOption(PRInt32 aIndex);
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
PRInt32 mNumRows;
@ -169,7 +159,6 @@ protected:
PRBool GetOptionValue(nsIDOMHTMLCollection& aCollecton, PRUint32 aIndex, nsString& aValue);
PRInt32 GetSelectedIndex();
nsresult UpdateWidgetToCache(PRBool aDeselectFirst = PR_TRUE);
nsresult Deselect();
virtual void GetDesiredSize(nsIPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
@ -185,7 +174,6 @@ protected:
// GFX-rendered or not. This is used to detect changes in MouseClicked
PRInt32 mNumOptions;
PRBool* mOptionSelected;
PRBool mCachedState; // A flag meaning "Don't reset state on PostCreateWidget"
// Accessor methods for mOptionsSelected and mNumOptions
void GetOptionSelectedCache(PRInt32 index, PRBool* aValue);
@ -226,7 +214,6 @@ nsNativeSelectControlFrame::nsNativeSelectControlFrame()
mNumRows = 0;
mNumOptions = 0;
mOptionSelected = nsnull;
mCachedState = PR_FALSE;
}
// XXX is this the right way to clean up?
@ -242,16 +229,11 @@ nsNativeSelectControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePt
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
*aInstancePtr = (void*)(nsISelectControlFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
}
if (aIID.Equals(kISelectControlFrameIID)) {
*aInstancePtr = (void*) ((nsISelectControlFrame*) this);
return NS_OK;
}
return Inherited::QueryInterface(aIID, aInstancePtr);
}
@ -766,26 +748,21 @@ nsNativeSelectControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumV
void
nsNativeSelectControlFrame::Reset()
{
if (mCachedState) {
mCachedState = PR_FALSE;
} else {
// Reset selection to default
nsIDOMHTMLCollection* options = GetOptions();
if (!options) return; // XXX NS_ERROR_UNEXPECTED;
PRUint32 numOptions;
options->GetLength(&numOptions);
for (PRUint32 i = 0; i < numOptions; i++) {
nsIDOMHTMLOptionElement* option = GetOption(*options, i);
if (option) {
// Cache the state of each option locally
PRBool selected = PR_FALSE;
option->GetDefaultSelected(&selected);
SetOptionSelectedCache(i, selected);
NS_RELEASE(option);
}
// Reset selection to default
nsIDOMHTMLCollection* options = GetOptions();
if (!options) return; // XXX NS_ERROR_UNEXPECTED;
PRUint32 numOptions;
options->GetLength(&numOptions);
for (PRUint32 i = 0; i < numOptions; i++) {
nsIDOMHTMLOptionElement* option = GetOption(*options, i);
if (option) {
// Cache the state of each option locally
PRBool selected = PR_FALSE;
option->GetDefaultSelected(&selected);
SetOptionSelectedCache(i, selected);
}
NS_RELEASE(options);
}
NS_RELEASE(options);
UpdateWidgetToCache();
}
@ -1216,7 +1193,7 @@ void nsNativeSelectControlFrame::GetOptionSelectedWidget(PRInt32 indx, PRBool* a
void nsNativeSelectControlFrame::SetOptionSelectedCache(PRInt32 indx, PRBool aValue)
{
if (nsnull != mOptionSelected) {
if ((-1 < indx) && (mNumOptions >= indx)) {
if (mNumOptions >= indx) {
mOptionSelected[indx] = aValue;
}
}
@ -1248,10 +1225,9 @@ NS_IMETHODIMP nsNativeSelectControlFrame::SetProperty(nsIAtom* aName, const nsSt
return NS_ERROR_INVALID_ARG; // Couldn't convert to integer
// Update local cache of selected values
nsresult res = Deselect();
if (NS_SUCCEEDED(res)) {
SetOptionSelectedCache(selectedIndex, PR_TRUE); // Select selectedIndex
}
for (PRInt32 i=0; i < mNumOptions; i++) // Deselect all options
SetOptionSelectedCache(i, PR_FALSE);
SetOptionSelectedCache(selectedIndex, PR_TRUE); // Select selectedIndex
// Update widget
UpdateWidgetToCache();
@ -1291,12 +1267,7 @@ NS_IMETHODIMP nsNativeSelectControlFrame::AddOption(PRInt32 aIndex)
// Get the correct selected value and text of the option
nsIDOMHTMLOptionElement* option = GetOption(*options, i);
if (option) {
option->GetDefaultSelected(&selected);
NS_RELEASE(option);
} else {
selected = PR_FALSE; // XXX failure case.
}
option->GetDefaultSelected(&selected);
mOptionSelected[j]=selected;
j++;
}
@ -1371,12 +1342,7 @@ NS_IMETHODIMP nsNativeSelectControlFrame::RemoveOption(PRInt32 aIndex)
// Get the default (XXXincorrect) selected value and text of the option
nsIDOMHTMLOptionElement* option = GetOption(*options, i);
if (option) {
option->GetDefaultSelected(&selected); // Should be sel, not defsel :(
NS_RELEASE(option);
} else {
selected = PR_FALSE; // XXX failure case
}
option->GetDefaultSelected(&selected); // Should be sel, not defsel :(
mOptionSelected[i]=selected;
}
}
@ -1398,38 +1364,38 @@ NS_IMETHODIMP nsNativeSelectControlFrame::GetProperty(nsIAtom* aName, nsString&
PRInt32 error = 0;
PRBool selected = PR_FALSE;
PRInt32 indx = aValue.ToInteger(&error, 10); // Get index from aValue
// if (error == 0)
// GetOptionSelectedWidget(indx, &selected);
GetOptionSelectedCache(indx, &selected);
nsFormControlHelper::GetBoolString(selected, aValue);
// For selectedIndex, get the value from the widget
} else if (nsHTMLAtoms::selectedindex == aName) {
PRInt32 selectedIndex = -1;
if (mWidget) {
PRBool multiple;
GetMultiple(&multiple);
if (!multiple) {
nsIListWidget* listWidget;
nsresult result = mWidget->QueryInterface(kListWidgetIID, (void **) &listWidget);
if ((NS_OK == result) && (nsnull != listWidget)) {
selectedIndex = listWidget->GetSelectedIndex();
NS_RELEASE(listWidget);
}
} else {
// Listboxes don't do GetSelectedIndex on windows. Use GetSelectedIndices
nsIListBox* listBox;
nsresult result = mWidget->QueryInterface(kListBoxIID, (void **) &listBox);
if ((NS_OK == result) && (nsnull != listBox)) {
PRUint32 numSelected = listBox->GetSelectedCount();
PRInt32* selOptions = nsnull;
if (numSelected > 0) {
// Could we set numSelected to 1 here? (memory, speed optimization)
selOptions = new PRInt32[numSelected];
listBox->GetSelectedIndices(selOptions, numSelected);
selectedIndex = selOptions[0];
delete[] selOptions;
}
NS_RELEASE(listBox);
PRBool multiple;
GetMultiple(&multiple);
if (!multiple) {
nsIListWidget* listWidget;
nsresult result = mWidget->QueryInterface(kListWidgetIID, (void **) &listWidget);
if ((NS_OK == result) && (nsnull != listWidget)) {
selectedIndex = listWidget->GetSelectedIndex();
NS_RELEASE(listWidget);
}
} else {
// Listboxes don't do GetSelectedIndex on windows. Use GetSelectedIndices
nsIListBox* listBox;
nsresult result = mWidget->QueryInterface(kListBoxIID, (void **) &listBox);
if ((NS_OK == result) && (nsnull != listBox)) {
PRUint32 numSelected = listBox->GetSelectedCount();
PRInt32* selOptions = nsnull;
if (numSelected > 0) {
// Could we set numSelected to 1 here? (memory, speed optimization)
selOptions = new PRInt32[numSelected];
listBox->GetSelectedIndices(selOptions, numSelected);
selectedIndex = selOptions[0];
delete[] selOptions;
}
NS_RELEASE(listBox);
}
}
aValue.Append(selectedIndex, 10);
@ -1443,6 +1409,8 @@ NS_IMETHODIMP nsNativeSelectControlFrame::GetProperty(nsIAtom* aName, nsString&
NS_IMETHODIMP
nsNativeSelectControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
{
// Get Selected index out of Content model
PRInt32 selectedIndex = GetSelectedIndex();
PRBool multiple = PR_FALSE;
GetMultiple(&multiple);
@ -1450,38 +1418,18 @@ nsNativeSelectControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
SetOptionSelectedCache(aIndex, aValue);
} else {
if (aValue) {
// Get Selected index out of Content model
PRInt32 selectedIndex = GetSelectedIndex();
if (-1 < selectedIndex)
SetOptionSelectedCache(selectedIndex, PR_FALSE);
SetOptionSelectedCache(selectedIndex, PR_FALSE);
SetOptionSelectedCache(aIndex, PR_TRUE);
} else {
SetOptionSelectedCache(aIndex, PR_FALSE);
}
}
// Note that UpdateWidgetToCache may return NS_ERROR_UNEXPECTED if the
// widget is not created yet. We can safely ignore this as when Reset is
// called, it will update the widget to the cache's state.
UpdateWidgetToCache(!aValue); // Don't deselect all if adding selection
return NS_OK;
}
NS_IMETHODIMP
nsNativeSelectControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
{
// Determine if option is selected in local cache
GetOptionSelectedCache(aIndex, aValue);
return NS_OK;
return UpdateWidgetToCache(!aValue); // Don't deselect all if adding selection
}
nsresult
nsNativeSelectControlFrame::UpdateWidgetToCache(PRBool aDeselectFirst)
{
if (!mWidget) {
mCachedState = PR_TRUE; // Handle this update later when widget is created.
return NS_OK;
}
// Grab the list widget
nsIListWidget* listWidget;
nsresult result = mWidget->QueryInterface(kListWidgetIID, (void **) &listWidget);
@ -1521,86 +1469,3 @@ nsNativeSelectControlFrame::AppendFrames(nsIPresContext& aPresContext,
//NS_PRECONDITION(PR_FALSE, "not a container");
return NS_ERROR_UNEXPECTED;
}
nsresult
nsNativeSelectControlFrame::Deselect()
{
nsresult res = NS_OK;
for (PRInt32 i=0; (i<mNumOptions) && NS_SUCCEEDED(res); i++)
res = SetOptionSelected(i, PR_FALSE);
return res;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsNativeSelectControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eSelectType;
return NS_OK;
}
NS_IMETHODIMP
nsNativeSelectControlFrame::SaveState(nsISupports** aState)
{
nsISupportsArray* value = nsnull;
nsresult res = NS_NewISupportsArray(&value);
if (NS_SUCCEEDED(res) && value) {
PRInt32 j=0;
PRInt32 i;
for (i=0; i<mNumOptions; i++) {
PRBool selected = PR_FALSE;
res = GetOptionSelected(i, &selected);
if (NS_SUCCEEDED(res) && selected) {
nsISupportsPRInt32* thisVal = nsnull;
res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID,
nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)&thisVal);
if (NS_SUCCEEDED(res) && thisVal) {
res = thisVal->SetData(i);
if (NS_SUCCEEDED(res)) {
PRBool okay = value->InsertElementAt((nsISupports *)thisVal, j++);
if (!okay) res = NS_ERROR_OUT_OF_MEMORY; // Most likely cause;
}
if (!NS_SUCCEEDED(res)) NS_RELEASE(thisVal);
}
}
if (!NS_SUCCEEDED(res)) break;
}
if (i<mNumOptions)
NS_RELEASE(value);
}
*aState = (nsISupports*)value; // Set to null if not successful
return res;
}
NS_IMETHODIMP
nsNativeSelectControlFrame::RestoreState(nsISupports* aState)
{
nsISupportsArray* value = (nsISupportsArray *)aState;
nsresult res = NS_ERROR_NULL_POINTER;
if (value) {
res = Deselect();
if (NS_SUCCEEDED(res)) {
PRUint32 count = 0;
res = value->Count(&count);
if (NS_SUCCEEDED(res)) {
nsISupportsPRInt32* thisVal = nsnull;
PRInt32 j=0;
for (PRUint32 k=0; k<count; k++) {
thisVal = (nsISupportsPRInt32*) value->ElementAt(k);
if (thisVal) {
res = thisVal->GetData(&j);
if (NS_SUCCEEDED(res)) {
res = SetOptionSelected(j, PR_TRUE);
}
} else {
res = NS_ERROR_UNEXPECTED;
}
if (!NS_SUCCEEDED(res)) break;
}
}
}
}
return res;
}

Просмотреть файл

@ -71,19 +71,6 @@ NS_NewNativeTextControlFrame(nsIFrame** aNewFrame)
return NS_OK;
}
nsNativeTextControlFrame::nsNativeTextControlFrame()
: mCachedState(nsnull)
{
}
nsNativeTextControlFrame::~nsNativeTextControlFrame()
{
if (mCachedState) {
delete mCachedState;
mCachedState = nsnull;
}
}
void
nsNativeTextControlFrame::EnterPressed(nsIPresContext& aPresContext)
{
@ -257,12 +244,7 @@ nsNativeTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
nsITextAreaWidget* textArea = nsnull;
nsITextWidget* text = nsnull;
if (NS_OK == mWidget->QueryInterface(kITextWidgetIID,(void**)&text)) {
if (mCachedState) {
value = *mCachedState;
delete mCachedState;
mCachedState = nsnull;
} else
GetText(&value, PR_TRUE);
GetText(&value, PR_TRUE);
text->SetText(value, ignore);
PRInt32 maxLength;
nsresult result = GetMaxLength(&maxLength);
@ -271,12 +253,7 @@ nsNativeTextControlFrame::PostCreateWidget(nsIPresContext* aPresContext,
}
NS_RELEASE(text);
} else if (NS_OK == mWidget->QueryInterface(kITextAreaWidgetIID,(void**)&textArea)) {
if (mCachedState) {
value = *mCachedState;
delete mCachedState;
mCachedState = nsnull;
} else
GetText(&value, PR_TRUE);
GetText(&value, PR_TRUE);
textArea->SetText(value, ignore);
NS_RELEASE(textArea);
}
@ -562,9 +539,7 @@ void nsNativeTextControlFrame::SetTextControlFrameState(const nsString& aValue)
textArea->SetText(aValue,size);
NS_RELEASE(textArea);
}
} else {
mCachedState = new nsString(aValue);
}
}
}
NS_IMETHODIMP nsNativeTextControlFrame::SetProperty(nsIAtom* aName, const nsString& aValue)

Просмотреть файл

@ -30,10 +30,7 @@ private:
typedef nsNativeFormControlFrame Inherited;
public:
nsNativeTextControlFrame();
virtual ~nsNativeTextControlFrame();
// nsIFormControlFrame
// nsIFormControlFrame
NS_IMETHOD SetProperty(nsIAtom* aName, const nsString& aValue);
NS_IMETHOD GetProperty(nsIAtom* aName, nsString& aValue);
@ -78,8 +75,6 @@ public:
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
protected:
nsString* mCachedState;
};
#endif

Просмотреть файл

@ -25,12 +25,11 @@
#include "nsFormFrame.h"
#include "nsINameSpaceManager.h"
#include "nsFormFrame.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIRadioControlFrameIID, NS_IRADIOCONTROLFRAME_IID);
nsresult
nsRadioControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
@ -42,11 +41,6 @@ nsRadioControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
*aInstancePtr = (void*) ((nsIRadioControlFrame*) this);
return NS_OK;
}
if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*) ((nsIStatefulFrame*) this);
NS_ADDREF_THIS();
return NS_OK;
}
return Inherited::QueryInterface(aIID, aInstancePtr);
}
@ -258,48 +252,3 @@ nsresult nsRadioControlFrame::RequiresWidget(PRBool& aRequiresWidget)
aRequiresWidget = PR_FALSE;
return NS_OK;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsRadioControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eRadioType;
return NS_OK;
}
NS_IMETHODIMP
nsRadioControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsresult res = NS_OK;
nsAutoString string;
GetRadioControlFrameState(string);
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
*aState = (nsISupports*)value;
return NS_OK;
}
NS_IMETHODIMP
nsRadioControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
nsAutoString string(chars);
SetRadioControlFrameState(string);
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -23,14 +23,11 @@
#include "nsNativeFormControlFrame.h"
#include "nsVoidArray.h"
#include "nsString.h"
#include "nsIStatefulFrame.h"
class nsIAtom;
// nsRadioControlFrame
class nsRadioControlFrame : public nsNativeFormControlFrame,
public nsIRadioControlFrame,
public nsIStatefulFrame
class nsRadioControlFrame : public nsNativeFormControlFrame, public nsIRadioControlFrame
{
private:
typedef nsNativeFormControlFrame Inherited;
@ -74,17 +71,13 @@ public:
// Expect this code to repackaged and moved to a new location in the future.
//
NS_IMETHOD HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
///XXX: End o the temporary methods
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
// Utility methods for implementing SetProperty/GetProperty

Просмотреть файл

@ -45,9 +45,6 @@
#include "nsIFontMetrics.h"
#include "nsILookAndFeel.h"
#include "nsIComponentManager.h"
#include "nsIStatefulFrame.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
static NS_DEFINE_IID(kTextCID, NS_TEXTFIELD_CID);
@ -70,21 +67,6 @@ nsTextControlFrame::~nsTextControlFrame()
{
}
nsresult
nsTextControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
NS_ADDREF_THIS();
return NS_OK;
}
return nsFormControlFrame::QueryInterface(aIID, aInstancePtr);
}
nscoord
nsTextControlFrame::GetVerticalBorderWidth(float aPixToTwip) const
{
@ -373,49 +355,3 @@ nsTextControlFrame::GetWrapProperty(nsString &aOutValue)
}
return result;
}
//----------------------------------------------------------------------
// nsIStatefulFrame
//----------------------------------------------------------------------
NS_IMETHODIMP
nsTextControlFrame::GetStateType(StateType* aStateType)
{
*aStateType = eTextType;
return NS_OK;
}
NS_IMETHODIMP
nsTextControlFrame::SaveState(nsISupports** aState)
{
nsISupportsString* value = nsnull;
nsAutoString string;
nsresult res = GetProperty(nsHTMLAtoms::value, string);
if (NS_SUCCEEDED(res)) {
char* chars = string.ToNewCString();
if (chars) {
res = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_PROGID, nsnull,
NS_GET_IID(nsISupportsString), (void**)&value);
if (NS_SUCCEEDED(res) && value) {
value->SetData(chars);
}
nsCRT::free(chars);
} else {
res = NS_ERROR_OUT_OF_MEMORY;
}
}
*aState = (nsISupports*)value;
return res;
}
NS_IMETHODIMP
nsTextControlFrame::RestoreState(nsISupports* aState)
{
char* chars = nsnull;
nsresult res = ((nsISupportsString*)aState)->GetData(&chars);
if (NS_SUCCEEDED(res) && chars) {
nsAutoString string(chars);
res = SetProperty(nsHTMLAtoms::value, string);
nsCRT::free(chars);
}
return res;
}

Просмотреть файл

@ -20,14 +20,11 @@
#define nsTextControlFrame_h___
#include "nsNativeFormControlFrame.h"
#include "nsIStatefulFrame.h"
class nsIContent;
class nsIFrame;
class nsIPresContext;
class nsTextControlFrame : public nsNativeFormControlFrame,
public nsIStatefulFrame
class nsTextControlFrame : public nsNativeFormControlFrame
{
/* ---------- methods implemented by base class ---------- */
public:
@ -37,8 +34,6 @@ public:
virtual const nsIID& GetCID();
virtual const nsIID& GetIID();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD GetFrameName(nsString& aResult) const;
virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const;
@ -58,11 +53,6 @@ public:
* returns NS_CONTENT_ATTR_NOT_THERE if the property does not exist for this
*/
NS_IMETHOD GetWrapProperty(nsString &aOutValue);
//nsIStatefulFrame
NS_IMETHOD GetStateType(StateType* aStateType);
NS_IMETHOD SaveState(nsISupports** aState);
NS_IMETHOD RestoreState(nsISupports* aState);
protected:
@ -77,9 +67,6 @@ protected:
PRInt32 GetDefaultColumnWidth() const { return (PRInt32)(20); } // this was DEFAULT_PIXEL_WIDTH
private:
NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
/* ---------- abstract methods derived class must implement ---------- */