зеркало из https://github.com/mozilla/gecko-dev.git
Checking in John Keiser's <jkeiser@iname.com> fix for *tons* of form submission and <select> related bugs, see tracking bug 34297 for details. r=rods@netscape.com, sr=jst@netscape.com
This commit is contained in:
Родитель
8af0a7449a
Коммит
6d64ded4f2
|
@ -5,5 +5,7 @@ nsIBodySuper.h
|
|||
nsIForm.h
|
||||
nsIFormControl.h
|
||||
nsILink.h
|
||||
nsIOptionElement.h
|
||||
nsISelectElement.h
|
||||
nsIScriptElement.h
|
||||
nsITextControlElement.h
|
||||
|
|
|
@ -33,6 +33,8 @@ EXPORTS = \
|
|||
nsIFormControl.h \
|
||||
nsIForm.h \
|
||||
nsILink.h \
|
||||
nsIOptionElement.h \
|
||||
nsITextControlElement.h \
|
||||
nsISelectElement.h \
|
||||
nsIScriptElement.h \
|
||||
$(NULL)
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
EXPORTS=nsIFormControl.h nsIForm.h nsILink.h \
|
||||
nsISelectElement.h nsIScriptElement.h nsIBodySuper.h
|
||||
EXPORTS=nsIFormControl.h nsIForm.h nsILink.h nsIOptionElement.h \
|
||||
nsISelectElement.h nsIScriptElement.h nsIBodySuper.h \
|
||||
nsITextControlElement.h
|
||||
|
||||
MODULE=content
|
||||
|
||||
|
|
|
@ -134,9 +134,6 @@ public:
|
|||
|
||||
NS_IMETHOD IndexOfControl(nsIFormControl* aControl, PRInt32* aIndex) = 0;
|
||||
|
||||
#ifdef DEBUG // XXX Does this even need to be here?
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsIForm_h___ */
|
||||
|
|
|
@ -40,6 +40,11 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIPresContext;
|
||||
class nsIPresState;
|
||||
class nsIContent;
|
||||
class nsString;
|
||||
class nsIFormProcessor;
|
||||
|
||||
#define NS_FORM_BROWSE 0
|
||||
#define NS_FORM_BUTTON_BUTTON 1
|
||||
|
@ -72,38 +77,60 @@ class nsIDOMHTMLFormElement;
|
|||
|
||||
|
||||
/**
|
||||
* Interface which all form controls (e.g. buttons, checkboxes, text,
|
||||
* radio buttons, select, etc) implement in addition to their dom specific interface.
|
||||
**/
|
||||
class nsIFormControl : public nsISupports {
|
||||
* Interface which all form controls (e.g. buttons, checkboxes, text,
|
||||
* radio buttons, select, etc) implement in addition to their dom specific
|
||||
* interface.
|
||||
*/
|
||||
class nsIFormControl : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IFORMCONTROL_IID; return iid; }
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMCONTROL_IID)
|
||||
|
||||
/**
|
||||
* Get the form for this form control.
|
||||
* @param aForm the form to get
|
||||
* @return NS_OK
|
||||
*/
|
||||
* Get the form for this form control.
|
||||
* @param aForm the form to get
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm) = 0;
|
||||
|
||||
/**
|
||||
* Set the form for this form control.
|
||||
* @param aForm the form
|
||||
* @return NS_OK
|
||||
*/
|
||||
* Set the form for this form control.
|
||||
* @param aForm the form
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
|
||||
PRBool aRemoveFromForm = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Get the type of this control
|
||||
* @param aType the type to be returned
|
||||
* @return NS_OK
|
||||
*/
|
||||
* Get the type of this control
|
||||
* @param aType the type to be returned
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_IMETHOD GetType(PRInt32* aType) = 0;
|
||||
|
||||
NS_IMETHOD Init() = 0;
|
||||
NS_IMETHOD Reset() = 0;
|
||||
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval) = 0;
|
||||
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval) = 0;
|
||||
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames) = 0;
|
||||
|
||||
/**
|
||||
* Save to presentation state
|
||||
*/
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState) = 0;
|
||||
|
||||
/**
|
||||
* Restore from presentation state
|
||||
*/
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIFormControl_h___ */
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
class nsIDOMHTMLOptionElement;
|
||||
class nsIPresContext;
|
||||
class nsIPresState;
|
||||
|
||||
/**
|
||||
* This interface is used to notify a SELECT when OPTION
|
||||
|
@ -59,6 +61,21 @@ public:
|
|||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISELECTELEMENT_IID)
|
||||
|
||||
/**
|
||||
* To be called when stuff is added under a child of
|
||||
* the select--but *before* they are actually added.
|
||||
*/
|
||||
NS_IMETHOD WillAddOptions(nsIContent* aOptions,
|
||||
nsIContent* aParent,
|
||||
PRInt32 aContentIndex) = 0;
|
||||
|
||||
/**
|
||||
* To be called when stuff is removed under a child of
|
||||
* the select--but *before* they are actually removed.
|
||||
*/
|
||||
NS_IMETHOD WillRemoveOptions(nsIContent* aParent,
|
||||
PRInt32 aContentIndex) = 0;
|
||||
|
||||
/**
|
||||
* An OPTION element has been added to the SELECT's
|
||||
* subtree.
|
||||
|
@ -86,13 +103,42 @@ public:
|
|||
/**
|
||||
* Returns whether we're the option is selected
|
||||
*/
|
||||
NS_IMETHOD IsOptionSelected(nsIDOMHTMLOptionElement* anOption, PRBool * aIsSelected) = 0;
|
||||
NS_IMETHOD IsOptionSelected(nsIDOMHTMLOptionElement* anOption,
|
||||
PRBool* aIsSelected) = 0;
|
||||
|
||||
/**
|
||||
* Sets an option selected or delselected
|
||||
*/
|
||||
NS_IMETHOD SetOptionSelected(nsIDOMHTMLOptionElement* anOption, PRBool aIsSelected) = 0;
|
||||
NS_IMETHOD SetOptionSelected(nsIDOMHTMLOptionElement* anOption,
|
||||
PRBool aIsSelected) = 0;
|
||||
|
||||
/**
|
||||
* Checks whether an option is disabled (even if it's part of an optgroup)
|
||||
*/
|
||||
NS_IMETHOD IsOptionDisabled(PRInt32 aIndex, PRBool* aIsDisabled) = 0;
|
||||
|
||||
/**
|
||||
* Sets multiple options (or just sets startIndex if select is single)
|
||||
*/
|
||||
NS_IMETHOD SetOptionsSelectedByIndex(PRInt32 aStartIndex,
|
||||
PRInt32 aEndIndex,
|
||||
PRBool aIsSelected,
|
||||
PRBool aClearAll,
|
||||
PRBool aSetDisabled,
|
||||
PRBool* aChangedSomething) = 0;
|
||||
|
||||
/**
|
||||
* Called when an option is disabled
|
||||
*/
|
||||
NS_IMETHOD OnOptionDisabled(nsIDOMHTMLOptionElement* anOption) = 0;
|
||||
|
||||
/**
|
||||
* Called to save/restore to/from pres. state
|
||||
*/
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState) = 0;
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState) = 0;
|
||||
};
|
||||
|
||||
#endif // nsISelectElement_h___
|
||||
|
|
|
@ -49,6 +49,10 @@ REQUIRES = xpcom \
|
|||
editor \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
mimetype \
|
||||
exthandler \
|
||||
unicharutil \
|
||||
uconv \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -56,6 +60,7 @@ CPPSRCS = \
|
|||
nsGenericHTMLElement.cpp \
|
||||
nsGenericDOMHTMLCollection.cpp \
|
||||
GenericElementCollection.cpp \
|
||||
nsFormSubmitter.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
nsHTMLAreaElement.cpp \
|
||||
|
|
|
@ -44,6 +44,10 @@ REQUIRES = xpcom \
|
|||
layout \
|
||||
gfx \
|
||||
content_xul \
|
||||
mimetype \
|
||||
exthandler \
|
||||
unicharutil \
|
||||
uconv \
|
||||
$(NULL)
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
!if defined(XP_NEW_SELECTION)
|
||||
|
@ -61,6 +65,7 @@ CPPSRCS= \
|
|||
nsGenericHTMLElement.cpp \
|
||||
nsGenericDOMHTMLCollection.cpp \
|
||||
GenericElementCollection.cpp \
|
||||
nsFormSubmitter.cpp \
|
||||
nsHTMLAnchorElement.cpp \
|
||||
nsHTMLAppletElement.cpp \
|
||||
nsHTMLAreaElement.cpp \
|
||||
|
@ -122,6 +127,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsGenericHTMLElement.obj \
|
||||
.\$(OBJDIR)\nsGenericDOMHTMLCollection.obj \
|
||||
.\$(OBJDIR)\GenericElementCollection.obj \
|
||||
.\$(OBJDIR)\nsFormSubmitter.obj \
|
||||
.\$(OBJDIR)\nsHTMLAnchorElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAppletElement.obj \
|
||||
.\$(OBJDIR)\nsHTMLAreaElement.obj \
|
||||
|
|
|
@ -61,6 +61,9 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID,
|
|||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsRange.h"
|
||||
|
@ -85,6 +88,9 @@ static NS_DEFINE_CID(kUBidiUtilCID, NS_UNICHARBIDIUTIL_CID);
|
|||
// JBK moved from nsFormFrame - bug 34297
|
||||
// submission
|
||||
|
||||
PRBool nsFormSubmitter::gFirstFormSubmitted = PR_FALSE;
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::CompareNodes(nsIDOMNode* a, nsIDOMNode* b, PRInt32* retval)
|
||||
{
|
||||
|
@ -128,6 +134,7 @@ nsFormSubmitter::CompareNodes(nsIDOMNode* a, nsIDOMNode* b, PRInt32* retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::OnSubmit(nsIForm* form,
|
||||
nsIPresContext* aPresContext,
|
||||
|
@ -187,8 +194,8 @@ nsFormSubmitter::OnSubmit(nsIForm* form,
|
|||
do_GetService(kFormProcessorCID, &rv);
|
||||
|
||||
PRInt32 method, enctype;
|
||||
form->FullyGetMethod(method);
|
||||
form->FullyGetEnctype(enctype);
|
||||
FullyGetMethod(form, &method);
|
||||
FullyGetEnctype(form, &enctype);
|
||||
|
||||
PRBool isURLEncoded = (NS_FORM_ENCTYPE_MULTIPART != enctype);
|
||||
|
||||
|
@ -221,7 +228,10 @@ nsFormSubmitter::OnSubmit(nsIForm* form,
|
|||
nsCOMPtr<nsILinkHandler> handler;
|
||||
if (NS_OK == aPresContext->GetLinkHandler(getter_AddRefs(handler))) {
|
||||
nsAutoString href;
|
||||
form->FullyGetAction(href);
|
||||
nsCOMPtr<nsIDOMHTMLFormElement> formDOMElement = do_QueryInterface(form);
|
||||
if (formDOMElement) {
|
||||
formDOMElement->GetAction(href);
|
||||
}
|
||||
|
||||
// Get the document.
|
||||
// We'll need it now to form the URL we're submitting to.
|
||||
|
@ -300,7 +310,9 @@ nsFormSubmitter::OnSubmit(nsIForm* form,
|
|||
}
|
||||
|
||||
nsAutoString target;
|
||||
form->FullyGetTarget(target);
|
||||
if (formDOMElement) {
|
||||
formDOMElement->GetTarget(target);
|
||||
}
|
||||
|
||||
// Add the URI encoded form values to the URI
|
||||
// Get the scheme of the URI.
|
||||
|
@ -345,40 +357,48 @@ nsFormSubmitter::OnSubmit(nsIForm* form,
|
|||
rv = NS_MakeAbsoluteURI(absURLSpec, href, docURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// If this is the first form, bring alive the first form submit
|
||||
// category observers
|
||||
if (!gFirstFormSubmitted) {
|
||||
gFirstFormSubmitted = PR_TRUE;
|
||||
NS_CreateServicesFromCategory(NS_FIRST_FORMSUBMIT_CATEGORY,
|
||||
nsnull,
|
||||
NS_FIRST_FORMSUBMIT_CATEGORY);
|
||||
}
|
||||
|
||||
// Notify observers that the form is being submitted.
|
||||
rv = NS_OK;
|
||||
nsCOMPtr<nsIObserverService> service =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString theTopic = NS_ConvertASCIItoUCS2(NS_FORMSUBMIT_SUBJECT);
|
||||
nsCOMPtr<nsIEnumerator> theEnum;
|
||||
rv = service->EnumerateObserverList(theTopic.get(),
|
||||
getter_AddRefs(theEnum));
|
||||
nsCOMPtr<nsISimpleEnumerator> theEnum;
|
||||
rv = service->EnumerateObservers(NS_FORMSUBMIT_SUBJECT,
|
||||
getter_AddRefs(theEnum));
|
||||
if (NS_SUCCEEDED(rv) && theEnum) {
|
||||
nsCOMPtr<nsISupports> inst;
|
||||
// XXX What is cancelSubmit doing anyway?
|
||||
PRBool cancelSubmit = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(globalObject);
|
||||
|
||||
for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) {
|
||||
nsresult gotObserver = NS_OK;
|
||||
gotObserver = theEnum->CurrentItem(getter_AddRefs(inst));
|
||||
if (NS_SUCCEEDED(gotObserver) && inst) {
|
||||
nsCOMPtr<nsIFormSubmitObserver> formSubmitObserver(
|
||||
do_QueryInterface(inst, &rv));
|
||||
if (NS_SUCCEEDED(rv) && formSubmitObserver) {
|
||||
nsCOMPtr<nsGenericElement> formElement = do_QueryInterface(form);
|
||||
if (formElement) {
|
||||
nsresult notifyStatus = formSubmitObserver->Notify(formElement,
|
||||
window,
|
||||
actionURL,
|
||||
&cancelSubmit);
|
||||
if (NS_FAILED(notifyStatus)) { // assert/warn if we get here?
|
||||
return notifyStatus;
|
||||
}
|
||||
PRBool loop = PR_TRUE;
|
||||
while (NS_SUCCEEDED(theEnum->HasMoreElements(&loop)) && loop) {
|
||||
theEnum->GetNext(getter_AddRefs(inst));
|
||||
|
||||
nsCOMPtr<nsIFormSubmitObserver> formSubmitObserver(
|
||||
do_QueryInterface(inst, &rv));
|
||||
if (formSubmitObserver) {
|
||||
nsCOMPtr<nsGenericElement> formElement = do_QueryInterface(form);
|
||||
if (formElement) {
|
||||
nsresult notifyStatus = formSubmitObserver->Notify(formElement,
|
||||
window,
|
||||
actionURL,
|
||||
&cancelSubmit);
|
||||
if (NS_FAILED(notifyStatus)) { // assert/warn if we get here?
|
||||
return notifyStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,6 +467,7 @@ nsFormSubmitter::OnSubmit(nsIForm* form,
|
|||
// JBK moved from nsFormFrame - bug 34297
|
||||
// Process form stuff without worrying about FILE elements
|
||||
#define CRLF "\015\012"
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::ProcessAsURLEncoded(nsIForm* form,
|
||||
nsIPresContext* aPresContext,
|
||||
|
@ -572,6 +593,7 @@ nsFormSubmitter::ProcessAsURLEncoded(nsIForm* form,
|
|||
return rv;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::ProcessAsMultipart(nsIForm* form,
|
||||
nsIPresContext* aPresContext,
|
||||
|
@ -1075,6 +1097,7 @@ nsFormSubmitter::ProcessAsMultipart(nsIForm* form,
|
|||
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
// static
|
||||
void
|
||||
nsFormSubmitter::GetSubmitCharset(nsIForm* form,
|
||||
nsAString& oCharset,
|
||||
|
@ -1160,6 +1183,7 @@ nsFormSubmitter::GetSubmitCharset(nsIForm* form,
|
|||
}
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::GetEncoder(nsIForm* form,
|
||||
nsIPresContext* aPresContext,
|
||||
|
@ -1180,6 +1204,8 @@ nsFormSubmitter::GetEncoder(nsIForm* form,
|
|||
(nsISupports**)&ccm);
|
||||
if (NS_SUCCEEDED(rv) && ccm) {
|
||||
nsString charset(aCharset);
|
||||
if (charset.Equals(NS_LITERAL_STRING("ISO-8859-1")))
|
||||
charset.Assign(NS_LITERAL_STRING("windows-1252"));
|
||||
rv = ccm->GetUnicodeEncoder(&charset, encoder);
|
||||
nsServiceManager::ReleaseService( kCharsetConverterManagerCID, ccm);
|
||||
if (encoder) {
|
||||
|
@ -1196,6 +1222,7 @@ nsFormSubmitter::GetEncoder(nsIForm* form,
|
|||
}
|
||||
|
||||
// XXX i18n helper routines
|
||||
// static
|
||||
nsString*
|
||||
nsFormSubmitter::URLEncode(const nsAString& aString,
|
||||
nsIUnicodeEncoder* encoder,
|
||||
|
@ -1235,6 +1262,7 @@ nsFormSubmitter::URLEncode(const nsAString& aString,
|
|||
}
|
||||
|
||||
// XXX i18n helper routines
|
||||
// static
|
||||
char*
|
||||
nsFormSubmitter::UnicodeToNewBytes(const PRUnichar* aSrc,
|
||||
PRUint32 aLen,
|
||||
|
@ -1321,6 +1349,7 @@ nsFormSubmitter::UnicodeToNewBytes(const PRUnichar* aSrc,
|
|||
}
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::GetPlatformEncoder(nsIUnicodeEncoder** encoder)
|
||||
{
|
||||
|
@ -1364,6 +1393,7 @@ nsFormSubmitter::GetPlatformEncoder(nsIUnicodeEncoder** encoder)
|
|||
|
||||
|
||||
// return the filename without the leading directories (Unix basename)
|
||||
// static
|
||||
PRUint32
|
||||
nsFormSubmitter::GetFileNameWithinPath(nsString& aPathName)
|
||||
{
|
||||
|
@ -1385,6 +1415,7 @@ nsFormSubmitter::GetFileNameWithinPath(nsString& aPathName)
|
|||
}
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::GetContentType(char* aPathName, char** aContentType)
|
||||
{
|
||||
|
@ -1418,3 +1449,39 @@ nsFormSubmitter::GetContentType(char* aPathName, char** aContentType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::GetEnumAttr(nsIForm* form, nsIAtom* atom, PRInt32* aValue)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLContent> content = do_QueryInterface(form);
|
||||
if (content) {
|
||||
nsHTMLValue value;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE ==
|
||||
content->GetHTMLAttribute(atom, value)) {
|
||||
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
||||
(*aValue) = value.GetIntValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
// Get the Method, with proper defaults (for submit/reset)
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::FullyGetMethod(nsIForm* form, PRInt32* aMethod)
|
||||
{
|
||||
(*aMethod) = NS_FORM_METHOD_GET;
|
||||
return GetEnumAttr(form, nsHTMLAtoms::method, aMethod);
|
||||
}
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
// Get the Enctype, with proper defaults (for submit/reset)
|
||||
// static
|
||||
nsresult
|
||||
nsFormSubmitter::FullyGetEnctype(nsIForm* form, PRInt32* aEnctype)
|
||||
{
|
||||
(*aEnctype) = NS_FORM_ENCTYPE_URLENCODED;
|
||||
return GetEnumAttr(form, nsHTMLAtoms::enctype, aEnctype);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ class nsIPresContext;
|
|||
class nsIUnicodeEncoder;
|
||||
class nsIDOMNode;
|
||||
class nsAString;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIAtom;
|
||||
|
||||
class nsFormSubmitter {
|
||||
|
||||
|
@ -91,6 +93,10 @@ protected:
|
|||
static PRUint32 GetFileNameWithinPath(nsString& aPathName);
|
||||
static nsresult GetContentType(char* aPathName, char** aContentType);
|
||||
|
||||
static nsresult GetEnumAttr(nsIForm* form, nsIAtom* atom, PRInt32* aValue);
|
||||
static nsresult FullyGetMethod(nsIForm* form, PRInt32* aMethod);
|
||||
static nsresult FullyGetEnctype(nsIForm* form, PRInt32* aEnctype);
|
||||
|
||||
// Detection of first form to notify observers
|
||||
static PRBool gFirstFormSubmitted;
|
||||
};
|
||||
|
|
|
@ -2594,7 +2594,7 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
|||
fputs(NS_LossyConvertUCS2toASCII(buf).get(), out);
|
||||
NS_RELEASE(tag);
|
||||
}
|
||||
fprintf(out, "@%p", this);
|
||||
fprintf(out, "@%p", (void*)this);
|
||||
|
||||
ListAttributes(out);
|
||||
|
||||
|
@ -2864,7 +2864,8 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsAReadableString&
|
|||
{
|
||||
nsAutoString tmp(aString);
|
||||
tmp.CompressWhitespace(PR_TRUE, PR_TRUE);
|
||||
PRInt32 ec, val = tmp.ToInteger(&ec);
|
||||
PRInt32 ec, val = tmp.ToInteger(&ec);
|
||||
|
||||
if (NS_OK == ec) {
|
||||
if (val < 0) val = 0;
|
||||
if (tmp.Length() && tmp.RFindChar('%') >= 0) {/* XXX not 100% compatible with ebina's code */
|
||||
|
@ -3092,39 +3093,45 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue,
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// XXX This creates a dependency between content and frames
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetPrimaryFrame(nsIHTMLContent* aContent,
|
||||
nsIFormControlFrame *&aFormControlFrame,
|
||||
PRBool aFlushNotifications)
|
||||
PRBool aFlushContent,
|
||||
PRBool aFlushReflows)
|
||||
{
|
||||
nsIDocument* doc = nsnull;
|
||||
nsresult res = NS_NOINTERFACE;
|
||||
// Get the document
|
||||
if (NS_OK == aContent->GetDocument(doc)) {
|
||||
if (nsnull != doc) {
|
||||
if (aFlushNotifications) {
|
||||
// Cause a flushing of notifications, so we get
|
||||
// up-to-date presentation information
|
||||
doc->FlushPendingNotifications();
|
||||
}
|
||||
aFormControlFrame = nsnull;
|
||||
|
||||
// Get presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
if (nsnull != presShell) {
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
if (nsnull != frame) {
|
||||
res = frame->QueryInterface(NS_GET_IID(nsIFormControlFrame),
|
||||
(void**)&aFormControlFrame);
|
||||
}
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
// Get the document
|
||||
aContent->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
if (aFlushReflows) {
|
||||
// Cause a flushing of notifications, so we get
|
||||
// up-to-date presentation information
|
||||
doc->FlushPendingNotifications(PR_TRUE);
|
||||
} else if (aFlushContent) {
|
||||
// Cause a flushing of notifications, so we get
|
||||
// up-to-date presentation information
|
||||
doc->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
|
||||
// Get presentation shell 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
|
||||
if (presShell) {
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(aContent, &frame);
|
||||
|
||||
if (frame) {
|
||||
CallQueryInterface(frame, &aFormControlFrame);
|
||||
}
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -349,7 +349,7 @@ public:
|
|||
//XXX These three create a dependency between content and frames
|
||||
static nsresult GetPrimaryFrame(nsIHTMLContent* aContent,
|
||||
nsIFormControlFrame *&aFormControlFrame,
|
||||
PRBool aFlushNotifications=PR_TRUE);
|
||||
PRBool aFlushContent, PRBool aFlushReflows);
|
||||
static nsresult GetPrimaryPresState(nsIHTMLContent* aContent,
|
||||
nsIPresState** aPresState);
|
||||
static nsresult GetPresContext(nsIHTMLContent* aContent,
|
||||
|
@ -533,6 +533,14 @@ public:
|
|||
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
|
||||
PRBool aRemoveFromForm = PR_TRUE);
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD SetParent(nsIContent *aParent);
|
||||
|
@ -575,6 +583,14 @@ public:
|
|||
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm,
|
||||
PRBool aRemoveFromForm = PR_TRUE);
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD SetParent(nsIContent *aParent);
|
||||
|
|
|
@ -87,6 +87,13 @@ public:
|
|||
|
||||
// overrided nsIFormControl method
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames);
|
||||
|
||||
// nsIContent overrides...
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
|
@ -112,6 +119,12 @@ public:
|
|||
|
||||
protected:
|
||||
PRInt8 mType;
|
||||
|
||||
private:
|
||||
// The analogue of defaultValue in the DOM for input and textarea
|
||||
nsresult SetDefaultValue(const nsAReadableString& aDefaultValue);
|
||||
nsresult GetDefaultValue(nsAWritableString& aDefaultValue);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -289,12 +302,14 @@ nsHTMLButtonElement::SetFocus(nsIPresContext* aPresContext)
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
formControlFrame->ScrollIntoView(aPresContext);
|
||||
}
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -306,8 +321,9 @@ nsHTMLButtonElement::RemoveFocus(nsIPresContext* aPresContext)
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
|
@ -398,13 +414,13 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv) && formControlFrame)
|
||||
{
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsIFrame* formFrame = nsnull;
|
||||
if (NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame),
|
||||
(void **)&formFrame)) && formFrame)
|
||||
{
|
||||
CallQueryInterface(formControlFrame, &formFrame);
|
||||
|
||||
if (formFrame) {
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface,
|
||||
(const nsStyleStruct *&)uiStyle);
|
||||
|
@ -454,8 +470,8 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
{
|
||||
// Tell the frame about the click
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
if (formControlFrame) {
|
||||
formControlFrame->MouseClicked(aPresContext);
|
||||
}
|
||||
}
|
||||
|
@ -537,3 +553,76 @@ nsHTMLButtonElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::GetDefaultValue(nsAWritableString& aDefaultValue)
|
||||
{
|
||||
return GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::SetDefaultValue(const nsAReadableString& aDefaultValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_HTML, nsHTMLAtoms::value, aDefaultValue, PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::Reset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
if (aSubmitElement != this) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if it's disabled, it won't submit
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (disabled) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If there is no name, it won't submit
|
||||
nsAutoString val;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, val);
|
||||
*_retval = rv != NS_CONTENT_ATTR_NOT_THERE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLButtonElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// We'll of course use the name of the control for the submit
|
||||
nsAutoString name;
|
||||
nsresult rv = GetName(name);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString value;
|
||||
rv = GetValue(value);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aNames[0] = name;
|
||||
aValues[0] = value;
|
||||
aNumValues = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -74,8 +74,14 @@ public:
|
|||
|
||||
// nsIFormControl
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
#ifdef DEBUG
|
||||
// nsIContent
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
};
|
||||
|
@ -195,3 +201,34 @@ nsHTMLFieldSetElement::SizeOf(nsISizeOfHandler* aSizer,
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHTMLFieldSetElement::Reset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFieldSetElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFieldSetElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLFieldSetElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "nsIForm.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIFormManager.h"
|
||||
#include "nsFormSubmitter.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMNSHTMLFormElement.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
@ -52,7 +53,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
|
@ -62,6 +63,7 @@
|
|||
#include "nsHashtable.h"
|
||||
#include "nsContentList.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIFormSubmitObserver.h"
|
||||
|
||||
static const int NS_FORM_CONTROL_LIST_HASHTABLE_SIZE = 16;
|
||||
|
||||
|
@ -126,6 +128,8 @@ protected:
|
|||
nsresult DoSubmitOrReset(nsIPresContext* aPresContext,
|
||||
nsEvent* aEvent,
|
||||
PRInt32 aMessage);
|
||||
|
||||
NS_IMETHOD OnReset(nsIPresContext* aPresContext);
|
||||
nsresult RemoveSelfAsWebProgressListener();
|
||||
|
||||
nsFormControlList* mControls;
|
||||
|
@ -187,6 +191,7 @@ protected:
|
|||
nsSupportsHashtable mNameLookupTable;
|
||||
};
|
||||
|
||||
|
||||
static PRBool
|
||||
IsNamedFormControl(nsIFormControl* aFormControl)
|
||||
{
|
||||
|
@ -355,7 +360,27 @@ NS_IMPL_STRING_ATTR(nsHTMLFormElement, AcceptCharset, acceptcharset)
|
|||
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Action, action)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Enctype, enctype)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Method, method)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLFormElement, Target, target)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormElement::GetTarget(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
nsresult rv = nsGenericHTMLContainerElement::GetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::target,
|
||||
aValue);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
rv = GetBaseTarget(aValue);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormElement::SetTarget(const nsAString& aValue)
|
||||
{
|
||||
return nsGenericHTMLContainerElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::target,
|
||||
aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormElement::Submit()
|
||||
|
@ -500,42 +525,47 @@ nsHTMLFormElement::DoSubmitOrReset(nsIPresContext* aPresContext,
|
|||
doc->FlushPendingNotifications();
|
||||
}
|
||||
|
||||
// Get the form manager
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
NS_ENSURE_TRUE(shell, NS_OK);
|
||||
|
||||
nsIFrame* frame = nsnull;
|
||||
shell->GetPrimaryFrameFor(this, &frame);
|
||||
NS_ENSURE_TRUE(frame, NS_OK);
|
||||
|
||||
nsIFormManager* formMan = nsnull;
|
||||
frame->QueryInterface(NS_GET_IID(nsIFormManager), (void**)&formMan);
|
||||
NS_ENSURE_TRUE(formMan, NS_OK);
|
||||
// JBK Don't get form frames anymore - bug 34297
|
||||
|
||||
// Submit or Reset the form
|
||||
nsresult rv = NS_OK;
|
||||
if (NS_FORM_RESET == aMessage) {
|
||||
rv = formMan->OnReset(aPresContext);
|
||||
rv = OnReset(aPresContext);
|
||||
}
|
||||
else if (NS_FORM_SUBMIT == aMessage) {
|
||||
nsIFrame *originatingFrame = nsnull;
|
||||
nsIContent *originatingElement = nsnull;
|
||||
|
||||
// Get the originating frame (failure is non-fatal)
|
||||
if (aEvent) {
|
||||
if (NS_FORM_EVENT == aEvent->eventStructType) {
|
||||
nsIContent *originator = ((nsFormEvent *)aEvent)->originator;
|
||||
if (originator) {
|
||||
shell->GetPrimaryFrameFor(originator, &originatingFrame);
|
||||
}
|
||||
originatingElement = ((nsFormEvent *)aEvent)->originator;
|
||||
}
|
||||
}
|
||||
|
||||
rv = formMan->OnSubmit(aPresContext, originatingFrame);
|
||||
// Pass the form originator
|
||||
rv = nsFormSubmitter::OnSubmit(this, aPresContext, originatingElement);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// JBK moved from nsFormFrame - bug 34297
|
||||
NS_IMETHODIMP
|
||||
nsHTMLFormElement::OnReset(nsIPresContext* aPresContext)
|
||||
{
|
||||
// JBK walk the elements[] array instead of form frame controls - bug 34297
|
||||
PRUint32 numElements;
|
||||
GetElementCount(&numElements);
|
||||
for (PRUint32 elementX = 0; (elementX < numElements); elementX++) {
|
||||
nsCOMPtr<nsIFormControl> controlNode;
|
||||
GetElementAt(elementX, getter_AddRefs(controlNode));
|
||||
if (controlNode) {
|
||||
controlNode->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIForm
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -761,8 +791,6 @@ nsFormControlList::GetNamedObject(const nsAReadableString& aName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get the hash entry
|
||||
nsStringKey key(aName);
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsIDOMNSHTMLInputElement.h"
|
||||
#include "nsITextControlElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIEditorController.h"
|
||||
#include "nsIFocusController.h"
|
||||
|
@ -79,6 +80,9 @@
|
|||
#include "nsICheckboxControlFrame.h"
|
||||
#include "nsIRadioControlFrame.h"
|
||||
#include "nsIFormManager.h"
|
||||
#include "nsIImageControlFrame.h"
|
||||
#include "nsLinebreakConverter.h" //to strip out carriage returns
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -94,7 +98,8 @@ typedef nsIGfxTextControlFrame2 textControlPlace;
|
|||
|
||||
class nsHTMLInputElement : public nsGenericHTMLLeafFormElement,
|
||||
public nsIDOMHTMLInputElement,
|
||||
public nsIDOMNSHTMLInputElement
|
||||
public nsIDOMNSHTMLInputElement,
|
||||
public nsITextControlElement
|
||||
{
|
||||
public:
|
||||
nsHTMLInputElement();
|
||||
|
@ -107,88 +112,7 @@ public:
|
|||
NS_FORWARD_NSIDOMNODE_NO_CLONENODE(nsGenericHTMLLeafFormElement::)
|
||||
|
||||
// nsIDOMElement
|
||||
// can't use the macro here because input type=text needs to notify up to
|
||||
// frame system on SetAttribute("value");
|
||||
NS_IMETHOD GetTagName(nsAWritableString& aTagName) {
|
||||
return nsGenericHTMLLeafFormElement::GetTagName(aTagName);
|
||||
}
|
||||
NS_IMETHOD GetAttribute(const nsAReadableString& aName,
|
||||
nsAWritableString& aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetAttribute(aName, aReturn);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(const nsAReadableString& aName,
|
||||
const nsAReadableString& aValue) {
|
||||
nsAutoString valueAttribute;
|
||||
nsHTMLAtoms::value->ToString(valueAttribute);
|
||||
if (PR_TRUE==valueAttribute.Equals(aName)) {
|
||||
SetValue(aValue);
|
||||
// Don't return here, need to set the attribute in the content model too.
|
||||
}
|
||||
return nsGenericHTMLLeafFormElement::SetAttribute(aName, aValue);
|
||||
}
|
||||
NS_IMETHOD RemoveAttribute(const nsAReadableString& aName) {
|
||||
return nsGenericHTMLLeafFormElement::RemoveAttribute(aName);
|
||||
}
|
||||
NS_IMETHOD GetAttributeNode(const nsAReadableString& aName,
|
||||
nsIDOMAttr** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetAttributeNode(aName, aReturn);
|
||||
}
|
||||
NS_IMETHOD SetAttributeNode(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::SetAttributeNode(aNewAttr, aReturn);
|
||||
}
|
||||
NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* aOldAttr, nsIDOMAttr** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::RemoveAttributeNode(aOldAttr,
|
||||
aReturn);
|
||||
}
|
||||
NS_IMETHOD GetElementsByTagName(const nsAReadableString& aTagname,
|
||||
nsIDOMNodeList** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetElementsByTagName(aTagname,
|
||||
aReturn);
|
||||
}
|
||||
NS_IMETHOD GetAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
nsAWritableString& aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetAttributeNS(aNamespaceURI,
|
||||
aLocalName, aReturn);
|
||||
}
|
||||
NS_IMETHOD SetAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aQualifiedName,
|
||||
const nsAReadableString& aValue) {
|
||||
return nsGenericHTMLLeafFormElement::SetAttributeNS(aNamespaceURI,
|
||||
aQualifiedName,
|
||||
aValue);
|
||||
}
|
||||
NS_IMETHOD RemoveAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName) {
|
||||
return nsGenericHTMLLeafFormElement::RemoveAttributeNS(aNamespaceURI,
|
||||
aLocalName);
|
||||
}
|
||||
NS_IMETHOD GetAttributeNodeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
nsIDOMAttr** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetAttributeNodeNS(aNamespaceURI,
|
||||
aLocalName,
|
||||
aReturn);
|
||||
}
|
||||
NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* aNewAttr, nsIDOMAttr** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::SetAttributeNodeNS(aNewAttr, aReturn);
|
||||
}
|
||||
NS_IMETHOD GetElementsByTagNameNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
nsIDOMNodeList** aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::GetElementsByTagNameNS(aNamespaceURI,
|
||||
aLocalName,
|
||||
aReturn);
|
||||
}
|
||||
NS_IMETHOD HasAttribute(const nsAReadableString& aName, PRBool* aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::HasAttribute(aName, aReturn);
|
||||
}
|
||||
NS_IMETHOD HasAttributeNS(const nsAReadableString& aNamespaceURI,
|
||||
const nsAReadableString& aLocalName,
|
||||
PRBool* aReturn) {
|
||||
return nsGenericHTMLLeafFormElement::HasAttributeNS(aNamespaceURI,
|
||||
aLocalName, aReturn);
|
||||
}
|
||||
NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLLeafFormElement::)
|
||||
|
||||
// nsIDOMHTMLElement
|
||||
NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLLeafFormElement::)
|
||||
|
@ -201,7 +125,17 @@ public:
|
|||
|
||||
// Overriden nsIFormControl methods
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames);
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD SetFocus(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext);
|
||||
|
||||
|
@ -221,10 +155,16 @@ public:
|
|||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
// nsITextControlElement
|
||||
NS_IMETHOD GetValueInternal(nsAWritableString& str);
|
||||
NS_IMETHOD SetValueInternal(nsAReadableString& str);
|
||||
|
||||
protected:
|
||||
// Helper method
|
||||
void SetPresStateChecked(nsIHTMLContent * aHTMLContent,
|
||||
PRBool aValue);
|
||||
NS_IMETHOD SetValueSecure(const nsAReadableString& aValue,
|
||||
PRBool aCheckSecurity);
|
||||
|
||||
nsresult GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSelectionEnd);
|
||||
nsresult MouseClickForAltText(nsIPresContext* aPresContext);
|
||||
|
@ -250,6 +190,7 @@ protected:
|
|||
PRInt8 mType;
|
||||
PRPackedBool mSkipFocusEvent;
|
||||
PRPackedBool mHandlingClick;
|
||||
char* mValue;
|
||||
};
|
||||
|
||||
// construction, destruction
|
||||
|
@ -286,12 +227,17 @@ nsHTMLInputElement::nsHTMLInputElement()
|
|||
mType = NS_FORM_INPUT_TEXT; // default value
|
||||
mSkipFocusEvent = PR_FALSE;
|
||||
mHandlingClick = PR_FALSE;
|
||||
mValue = nsnull;
|
||||
}
|
||||
|
||||
nsHTMLInputElement::~nsHTMLInputElement()
|
||||
{
|
||||
// Null out form's pointer to us - no ref counting here!
|
||||
SetForm(nsnull);
|
||||
|
||||
if (mValue) {
|
||||
nsMemory::Free(mValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -306,6 +252,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLInputElement,
|
|||
nsGenericHTMLLeafFormElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLInputElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLInputElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITextControlElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLInputElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
|
@ -433,6 +380,24 @@ nsHTMLInputElement::SetType(const nsAReadableString& aValue)
|
|||
PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::GetValueInternal(nsAWritableString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
if (!mValue) {
|
||||
GetDefaultValue(aValue);
|
||||
|
||||
mValue = ToNewUTF8String(aValue);
|
||||
if (!mValue) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
} else {
|
||||
aValue = NS_ConvertUTF8toUCS2(mValue);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::GetValue(nsAWritableString& aValue)
|
||||
{
|
||||
|
@ -441,20 +406,12 @@ nsHTMLInputElement::GetValue(nsAWritableString& aValue)
|
|||
if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type ||
|
||||
NS_FORM_INPUT_FILE == type) {
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
if (NS_SUCCEEDED(GetPrimaryFrame(this, formControlFrame))) {
|
||||
if (formControlFrame) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Retrieve the presentation state instead.
|
||||
nsCOMPtr<nsIPresState> presState;
|
||||
GetPrimaryPresState(this, getter_AddRefs(presState));
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
// Obtain the value property from the presentation state.
|
||||
if (presState) {
|
||||
presState->GetStateProperty(NS_LITERAL_STRING("value"), aValue);
|
||||
}
|
||||
if (formControlFrame) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
|
||||
} else {
|
||||
GetValueInternal(aValue);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -475,27 +432,44 @@ nsHTMLInputElement::GetValue(nsAWritableString& aValue)
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SetValueInternal(nsAReadableString& aValue)
|
||||
{
|
||||
if (mValue) {
|
||||
nsMemory::Free(mValue);
|
||||
}
|
||||
|
||||
mValue = ToNewUTF8String(aValue);
|
||||
|
||||
return mValue ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SetValue(const nsAReadableString& aValue)
|
||||
{
|
||||
return SetValueSecure(aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SetValueSecure(const nsAReadableString& aValue,
|
||||
PRBool aCheckSecurity)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type ||
|
||||
NS_FORM_INPUT_FILE == type) {
|
||||
if (NS_FORM_INPUT_FILE == type) {
|
||||
nsresult result;
|
||||
if (aCheckSecurity && NS_FORM_INPUT_FILE == type) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool enabled;
|
||||
|
||||
result = securityManager->IsCapabilityEnabled("UniversalFileRead",
|
||||
&enabled);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
rv = securityManager->IsCapabilityEnabled("UniversalFileRead", &enabled);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
|
@ -506,24 +480,14 @@ nsHTMLInputElement::SetValue(const nsAReadableString& aValue)
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(GetPrimaryFrame(this, formControlFrame))) {
|
||||
if (formControlFrame ) {
|
||||
nsIPresContext* presContext;
|
||||
GetPresContext(this, &presContext);
|
||||
formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue);
|
||||
NS_IF_RELEASE(presContext);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Retrieve the presentation state instead.
|
||||
nsCOMPtr<nsIPresState> presState;
|
||||
GetPrimaryPresState(this, getter_AddRefs(presState));
|
||||
|
||||
// Obtain the value property from the presentation state.
|
||||
if (presState) {
|
||||
presState->SetStateProperty(NS_LITERAL_STRING("value"), aValue);
|
||||
}
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
GetPresContext(this, getter_AddRefs(presContext));
|
||||
formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue);
|
||||
} else {
|
||||
SetValueInternal(aValue);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -539,10 +503,11 @@ nsHTMLInputElement::GetChecked(PRBool* aValue)
|
|||
{
|
||||
nsAutoString value; value.AssignWithConversion("0");
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
if (NS_SUCCEEDED(GetPrimaryFrame(this, formControlFrame))) {
|
||||
if (formControlFrame) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::checked, value);
|
||||
}
|
||||
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::checked, value);
|
||||
}
|
||||
else {
|
||||
// Retrieve the presentation state instead.
|
||||
|
@ -594,7 +559,9 @@ nsHTMLInputElement::SetChecked(PRBool aValue)
|
|||
GetPresContext(this, getter_AddRefs(presContext));
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
if (NS_SUCCEEDED(GetPrimaryFrame(this, formControlFrame))) {
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
// the value is being toggled
|
||||
nsAutoString val; val.AssignWithConversion(aValue ? "1" : "0");
|
||||
|
||||
|
@ -715,7 +682,7 @@ nsHTMLInputElement::SetFocus(nsIPresContext* aPresContext)
|
|||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
|
@ -736,8 +703,7 @@ nsHTMLInputElement::RemoveFocus(nsIPresContext* aPresContext)
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_FALSE, PR_FALSE);
|
||||
|
@ -823,8 +789,9 @@ nsHTMLInputElement::Select()
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
|
||||
// Now Select all the text!
|
||||
|
@ -840,7 +807,7 @@ void
|
|||
nsHTMLInputElement::SelectAll(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetProperty(aPresContext, nsHTMLAtoms::select,
|
||||
|
@ -972,21 +939,20 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// This pointer is only valid until
|
||||
// nsGenericHTMLLeafFormElement::HandleDOMEvent
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
rv = GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
nsIFrame* formFrame = nsnull;
|
||||
if (formControlFrame) {
|
||||
nsIFrame* formFrame = nsnull;
|
||||
CallQueryInterface(formControlFrame, &formFrame);
|
||||
if (formFrame) {
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface,
|
||||
(const nsStyleStruct *&)uiStyle);
|
||||
|
||||
if (formControlFrame &&
|
||||
NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame),
|
||||
(void **)&formFrame)) &&
|
||||
formFrame) {
|
||||
const nsStyleUserInterface* uiStyle;
|
||||
formFrame->GetStyleData(eStyleStruct_UserInterface,
|
||||
(const nsStyleStruct *&)uiStyle);
|
||||
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED) {
|
||||
return NS_OK;
|
||||
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE ||
|
||||
uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1082,10 +1048,11 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// Get the currently selected button from the radio group
|
||||
// we get access to that via the nsIRadioControlFrame interface
|
||||
// because the current grouping is kept in the frame.
|
||||
nsIRadioControlFrame * rb = nsnull;
|
||||
if (formControlFrame != nsnull) {
|
||||
nsresult resv = formControlFrame->QueryInterface(NS_GET_IID(nsIRadioControlFrame), (void**)&rb);
|
||||
if (NS_SUCCEEDED(resv) && rb) {
|
||||
if (formControlFrame) {
|
||||
nsIRadioControlFrame * rb = nsnull;
|
||||
CallQueryInterface(formControlFrame, &rb);
|
||||
|
||||
if (rb) {
|
||||
rb->GetRadioGroupSelectedContent(getter_AddRefs(selectedRadiobtn));
|
||||
}
|
||||
}
|
||||
|
@ -1106,17 +1073,17 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
// Try script event handlers first if its not a focus/blur event
|
||||
//we dont want the doc to get these
|
||||
nsresult ret = nsGenericHTMLLeafFormElement::HandleDOMEvent(aPresContext,
|
||||
aEvent,
|
||||
aDOMEvent,
|
||||
aFlags,
|
||||
aEventStatus);
|
||||
|
||||
rv = nsGenericHTMLLeafFormElement::HandleDOMEvent(aPresContext,
|
||||
aEvent,
|
||||
aDOMEvent,
|
||||
aFlags,
|
||||
aEventStatus);
|
||||
// XXX Should we check if the event failed?
|
||||
// now check to see if the event was "cancelled"
|
||||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus && checkWasSet &&
|
||||
(type == NS_FORM_INPUT_CHECKBOX || type == NS_FORM_INPUT_RADIO)) {
|
||||
if (nsEventStatus_eConsumeNoDefault == *aEventStatus && checkWasSet
|
||||
&& (type == NS_FORM_INPUT_CHECKBOX || type == NS_FORM_INPUT_RADIO)) {
|
||||
// if it was cancelled and a radio button, then set the old
|
||||
// selceted btn to TRUE. if it is a checkbox then set it to it's
|
||||
// selected btn to TRUE. if it is a checkbox then set it to its
|
||||
// original value
|
||||
if (selectedRadiobtn) {
|
||||
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(selectedRadiobtn));
|
||||
|
@ -1130,7 +1097,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
|
||||
// Bugscape 2369: Frame might have changed during event handler
|
||||
formControlFrame = nsnull;
|
||||
rv = nsGenericHTMLElement::GetPrimaryFrame(this, formControlFrame, PR_FALSE);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
// Finish the special file control processing...
|
||||
if (oldTarget) {
|
||||
|
@ -1548,7 +1515,7 @@ NS_IMETHODIMP
|
|||
nsHTMLInputElement::GetTextLength(PRInt32* aTextLength)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<textControlPlace>
|
||||
|
@ -1566,7 +1533,7 @@ nsHTMLInputElement::SetSelectionRange(PRInt32 aSelectionStart,
|
|||
PRInt32 aSelectionEnd)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<textControlPlace>
|
||||
|
@ -1592,7 +1559,7 @@ NS_IMETHODIMP
|
|||
nsHTMLInputElement::SetSelectionStart(PRInt32 aSelectionStart)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<textControlPlace>
|
||||
|
@ -1619,7 +1586,7 @@ NS_IMETHODIMP
|
|||
nsHTMLInputElement::SetSelectionEnd(PRInt32 aSelectionEnd)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<textControlPlace>
|
||||
|
@ -1637,7 +1604,7 @@ nsHTMLInputElement::GetSelectionRange(PRInt32* aSelectionStart,
|
|||
PRInt32* aSelectionEnd)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<textControlPlace>
|
||||
|
@ -1696,3 +1663,290 @@ nsHTMLInputElement::FireEventForAccessibility(nsIPresContext* aPresContext,
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHTMLInputElement::Reset()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
// Seems like a dumb idea to reset image.
|
||||
switch (type) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
{
|
||||
PRBool resetVal;
|
||||
GetDefaultChecked(&resetVal);
|
||||
rv = SetChecked(resetVal);
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
{
|
||||
nsAutoString resetVal;
|
||||
GetDefaultValue(resetVal);
|
||||
rv = SetValue(resetVal);
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_FILE:
|
||||
{
|
||||
// Resetting it to blank should not perform security check
|
||||
rv = SetValueSecure(NS_LITERAL_STRING(""), PR_FALSE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLInputElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
// if it's disabled, it won't submit
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (disabled) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
// if it dosn't have a name it we don't submit
|
||||
if (type != NS_FORM_INPUT_IMAGE) {
|
||||
nsAutoString val;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, val);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
{
|
||||
GetChecked(_retval);
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_FILE:
|
||||
{
|
||||
nsAutoString val;
|
||||
GetValue(val);
|
||||
*_retval = !val.IsEmpty();
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_RESET:
|
||||
case NS_FORM_INPUT_BUTTON:
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
case NS_FORM_INPUT_IMAGE:
|
||||
{
|
||||
*_retval = (this == aSubmitElement);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLInputElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
*_retval = type == NS_FORM_INPUT_IMAGE ? 2 : 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLInputElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
switch (type) {
|
||||
case NS_FORM_INPUT_CHECKBOX:
|
||||
case NS_FORM_INPUT_RADIO:
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
GetName(aNames[0]);
|
||||
GetValue(aValues[0]);
|
||||
aNumValues = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_HIDDEN:
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
GetName(aNames[0]);
|
||||
GetValue(aValues[0]);
|
||||
aNumValues = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_FILE:
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
GetName(aNames[0]);
|
||||
GetValue(aValues[0]);
|
||||
aNumValues = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_IMAGE:
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 2, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// Go to the frame to find out where it was clicked. This is the only
|
||||
// case where I can actually see using the frame, because you're talking
|
||||
// about a value--mouse click--that is rightfully the domain of the frame.
|
||||
//
|
||||
// If the frame isn't there or isn't an ImageControlFrame, then we're not
|
||||
// submitting these values no matter *how* nicely you ask.
|
||||
PRInt32 clickedX;
|
||||
PRInt32 clickedY;
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIImageControlFrame> imageControlFrame(
|
||||
do_QueryInterface(formControlFrame));
|
||||
if (imageControlFrame) {
|
||||
imageControlFrame->GetClickedX(&clickedX);
|
||||
imageControlFrame->GetClickedY(&clickedY);
|
||||
} else {
|
||||
aNumValues = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Convert the values to strings for submission
|
||||
char buf[20];
|
||||
sprintf(&buf[0], "%d", clickedX);
|
||||
aValues[0].AssignWithConversion(&buf[0]);
|
||||
sprintf(&buf[0], "%d", clickedY);
|
||||
aValues[1].AssignWithConversion(&buf[0]);
|
||||
|
||||
// Figure out the proper name of the x and y values
|
||||
nsAutoString name;
|
||||
rv = GetName(name);
|
||||
aNumValues = 2;
|
||||
if (!name.IsEmpty()) {
|
||||
aNames[0] = name;
|
||||
aNames[0].Append(NS_LITERAL_STRING(".x"));
|
||||
aNames[1] = name;
|
||||
aNames[1].Append(NS_LITERAL_STRING(".y"));
|
||||
} else {
|
||||
// If the Image Element has no name, simply return x and y
|
||||
// to Nav and IE compatability.
|
||||
aNames[0] = NS_LITERAL_STRING("x");
|
||||
aNames[1] = NS_LITERAL_STRING("y");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_RESET:
|
||||
case NS_FORM_INPUT_BUTTON:
|
||||
{
|
||||
aNumValues = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
case NS_FORM_INPUT_SUBMIT:
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
GetName(aNames[0]);
|
||||
GetValue(aValues[0]);
|
||||
aNumValues = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
switch (type) {
|
||||
// Never save passwords in session history
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
break;
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
case NS_FORM_INPUT_FILE:
|
||||
nsresult rv = GetPrimaryPresState(this, aState);
|
||||
if (*aState) {
|
||||
nsString value;
|
||||
GetValue(value);
|
||||
// XXX Should use nsAutoString above but ConvertStringLineBreaks
|
||||
// requires mOwnsBuffer!
|
||||
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
|
||||
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLInputElement::RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
switch (type) {
|
||||
// Never save passwords in session history
|
||||
case NS_FORM_INPUT_PASSWORD:
|
||||
break;
|
||||
case NS_FORM_INPUT_TEXT:
|
||||
case NS_FORM_INPUT_FILE:
|
||||
nsAutoString value;
|
||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
|
||||
SetValue(value);
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,15 @@ public:
|
|||
|
||||
// nsIFormControl
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
|
@ -372,8 +380,9 @@ nsHTMLLabelElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// Find out of this is a form element.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIFormControlFrame* control;
|
||||
nsresult gotFrame = GetPrimaryFrame(node, control);
|
||||
isFormElement = NS_SUCCEEDED(gotFrame) && control;
|
||||
GetPrimaryFrame(node, control, PR_TRUE, PR_FALSE);
|
||||
|
||||
isFormElement = control != nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,9 +408,9 @@ nsHTMLLabelElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
// Find out of this is a form element.
|
||||
nsIFormControlFrame* control;
|
||||
|
||||
nsresult gotFrame = GetPrimaryFrame(node, control);
|
||||
GetPrimaryFrame(node, control, PR_TRUE, PR_FALSE);
|
||||
|
||||
isFormElement = NS_SUCCEEDED(gotFrame) && control;
|
||||
isFormElement = control != nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -432,3 +441,34 @@ nsHTMLLabelElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHTMLLabelElement::Reset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLabelElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLabelElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLabelElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,15 @@ public:
|
|||
|
||||
// nsIFormControl
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAReadableString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
|
@ -238,3 +246,34 @@ nsHTMLLegendElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsHTMLLegendElement::Reset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLegendElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLegendElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLLegendElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include "nsIFrame.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
|
||||
|
||||
class nsHTMLOptGroupElement : public nsGenericHTMLContainerElement,
|
||||
|
@ -71,12 +73,25 @@ public:
|
|||
// nsIDOMHTMLOptGroupElement
|
||||
NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument);
|
||||
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
|
||||
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent, PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus);
|
||||
#ifdef DEBUG
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
nsresult GetSelect(nsISelectElement **aSelectElement);
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -175,9 +190,9 @@ nsHTMLOptGroupElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
nsIFrame* formFrame = nsnull;
|
||||
if (formControlFrame &&
|
||||
NS_SUCCEEDED(formControlFrame->QueryInterface(NS_GET_IID(nsIFrame),
|
||||
(void **)&formFrame)) &&
|
||||
|
@ -208,3 +223,94 @@ nsHTMLOptGroupElement::SizeOf(nsISizeOfHandler* aSizer,
|
|||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Get the select content element that contains this option
|
||||
nsresult
|
||||
nsHTMLOptGroupElement::GetSelect(nsISelectElement **aSelectElement)
|
||||
{
|
||||
*aSelectElement = nsnull;
|
||||
// Get the containing element (Either a select or an optGroup)
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
nsCOMPtr<nsIContent> prevParent;
|
||||
GetParent(*getter_AddRefs(parent));
|
||||
while (parent) {
|
||||
CallQueryInterface(parent, aSelectElement);
|
||||
if (*aSelectElement) {
|
||||
break;
|
||||
}
|
||||
prevParent = parent;
|
||||
prevParent->GetParent(*getter_AddRefs(parent));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::AppendChildTo(nsIContent* aKid, PRBool aNotify,
|
||||
PRBool aDeepSetDocument)
|
||||
{
|
||||
// Since we're appending, the relevant option index to add after is found
|
||||
// *after* this optgroup.
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
PRInt32 count;
|
||||
ChildCount(count);
|
||||
sel->WillAddOptions(aKid, this, count);
|
||||
}
|
||||
|
||||
// Actually perform the append
|
||||
return nsGenericHTMLContainerElement::AppendChildTo(aKid,
|
||||
aNotify,
|
||||
aDeepSetDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
sel->WillAddOptions(aKid, this, aIndex);
|
||||
}
|
||||
|
||||
return nsGenericHTMLContainerElement::InsertChildAt(aKid,
|
||||
aIndex,
|
||||
aNotify,
|
||||
aDeepSetDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex,
|
||||
PRBool aNotify, PRBool aDeepSetDocument)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
sel->WillRemoveOptions(this, aIndex);
|
||||
sel->WillAddOptions(aKid, this, aIndex);
|
||||
}
|
||||
|
||||
return nsGenericHTMLContainerElement::ReplaceChildAt(aKid,
|
||||
aIndex,
|
||||
aNotify,
|
||||
aDeepSetDocument);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptGroupElement::RemoveChildAt(PRInt32 aIndex, PRBool aNotify)
|
||||
{
|
||||
nsCOMPtr<nsISelectElement> sel;
|
||||
GetSelect(getter_AddRefs(sel));
|
||||
if (sel) {
|
||||
sel->WillRemoveOptions(this, aIndex);
|
||||
}
|
||||
|
||||
nsresult rv = nsGenericHTMLContainerElement::RemoveChildAt(aIndex,
|
||||
aNotify);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIOptionElement.h"
|
||||
#include "nsIDOMHTMLOptGroupElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
|
@ -56,7 +57,6 @@
|
|||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
|
||||
// Notify/query select frame for selected state
|
||||
|
@ -67,11 +67,13 @@
|
|||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
|
||||
|
||||
class nsHTMLOptionElement : public nsGenericHTMLContainerElement,
|
||||
public nsIDOMHTMLOptionElement,
|
||||
public nsIJSNativeInitializer
|
||||
public nsIJSNativeInitializer,
|
||||
public nsIOptionElement
|
||||
{
|
||||
public:
|
||||
nsHTMLOptionElement();
|
||||
|
@ -105,15 +107,22 @@ public:
|
|||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
#endif
|
||||
|
||||
// nsIOptionElement
|
||||
NS_IMETHOD GetSelectedInternal(PRBool* aValue);
|
||||
NS_IMETHOD SetSelectedInternal(PRBool aValue, PRBool aNotify);
|
||||
NS_IMETHOD GetValueOrText(nsAString& aValue);
|
||||
|
||||
protected:
|
||||
// Get the primary frame associated with this content
|
||||
nsresult GetPrimaryFrame(nsIFormControlFrame *&aFormControlFrame,
|
||||
PRBool aFlushNotifications = PR_TRUE);
|
||||
PRBool aFlushContent, PRBool aFlushReflows);
|
||||
|
||||
// Get the select content element that contains this option, this
|
||||
// intentionally does not return nsresult, all we care about is if
|
||||
// there's a select associated with this option or not.
|
||||
void GetSelect(nsIDOMHTMLSelectElement *&aSelectElement);
|
||||
void GetSelect(nsIDOMHTMLSelectElement **aSelectElement);
|
||||
|
||||
PRBool mIsInitialized;
|
||||
};
|
||||
|
||||
nsresult
|
||||
|
@ -163,6 +172,7 @@ NS_NewHTMLOptionElement(nsIHTMLContent** aInstancePtrResult,
|
|||
|
||||
nsHTMLOptionElement::nsHTMLOptionElement()
|
||||
{
|
||||
mIsInitialized = PR_FALSE;
|
||||
}
|
||||
|
||||
nsHTMLOptionElement::~nsHTMLOptionElement()
|
||||
|
@ -181,6 +191,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLOptionElement,
|
|||
nsGenericHTMLContainerElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLOptionElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIJSNativeInitializer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIOptionElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLOptionElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
|
@ -220,7 +231,7 @@ nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
|||
*aForm = nsnull;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||
GetSelect(*getter_AddRefs(selectElement));
|
||||
GetSelect(getter_AddRefs(selectElement));
|
||||
|
||||
nsCOMPtr<nsIFormControl> selectControl(do_QueryInterface(selectElement));
|
||||
|
||||
|
@ -231,87 +242,95 @@ nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelectedInternal(PRBool* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = PR_FALSE;
|
||||
// If it's not initialized, initialize it.
|
||||
if (!mIsInitialized) {
|
||||
mIsInitialized = PR_TRUE;
|
||||
PRBool selected;
|
||||
GetDefaultSelected(&selected);
|
||||
// This does not need to be SetSelected (which sets selected in the select)
|
||||
// because we *will* be initialized when we are placed into a select. Plus
|
||||
// it seems like that's just inviting an infinite loop.
|
||||
SetSelectedInternal(selected, PR_TRUE);
|
||||
}
|
||||
nsAutoString tmpVal;
|
||||
nsresult rv = GetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
tmpVal);
|
||||
*aValue = !(NS_FAILED(rv) || NS_CONTENT_ATTR_NOT_THERE == rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
|
||||
// DO NOT flush pending reflows here
|
||||
GetPrimaryFrame(formControlFrame, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
PRInt32 indx;
|
||||
|
||||
GetIndex(&indx);
|
||||
|
||||
if (indx >= 0) {
|
||||
nsAutoString value;
|
||||
|
||||
value.AppendInt(indx, 10); // Save the index in base 10
|
||||
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::selected, value);
|
||||
|
||||
*aValue = value.EqualsWithConversion("1");
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetSelectedInternal(PRBool aValue, PRBool aNotify)
|
||||
{
|
||||
mIsInitialized = PR_TRUE;
|
||||
// This affects the display, but what the hey, it's a good place for it
|
||||
PRInt32 ind;
|
||||
GetIndex(&ind);
|
||||
if (aValue) {
|
||||
return SetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
NS_LITERAL_STRING(""),
|
||||
aNotify);
|
||||
} else {
|
||||
// Note: The select content obj maintains all the PresState
|
||||
// so defer to it to get the answer
|
||||
return UnsetAttr(kNameSpaceID_None,
|
||||
nsLayoutAtoms::optionSelectedPseudo,
|
||||
aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
GetParentNode(getter_AddRefs(parentNode));
|
||||
|
||||
nsCOMPtr<nsISelectElement> selectElement(do_QueryInterface(parentNode));
|
||||
|
||||
if (selectElement) {
|
||||
return selectElement->IsOptionSelected(this, aValue);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetValueOrText(nsAString& aValue)
|
||||
{
|
||||
nsHTMLValue value;
|
||||
nsresult rv = GetHTMLAttribute(nsHTMLAtoms::value, value);
|
||||
if (NS_CONTENT_ATTR_NOT_THERE == rv) {
|
||||
// XXX When an equivalent of CompressWhitespace exists for nsAString,
|
||||
// somebody please clean this up. The only reason I can think that we're
|
||||
// we're doing it anyway is because GetText() leaves whitespace around if
|
||||
// the text is all whitespace we apparently want to compress even that.
|
||||
nsAutoString getVal;
|
||||
rv = GetText(getVal);
|
||||
getVal.CompressWhitespace();
|
||||
aValue = getVal;
|
||||
} else {
|
||||
// Need to use GetValue to get the real value because it does extra
|
||||
// processing on the return value. (i.e it trims it.)
|
||||
rv = GetValue(aValue);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetSelected(PRBool* aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aValue);
|
||||
*aValue = PR_FALSE;
|
||||
|
||||
// If there is no select element, return the selected
|
||||
return GetSelectedInternal(aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetSelected(PRBool aValue)
|
||||
{
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
|
||||
// DO NOT flush pending reflows here
|
||||
nsresult result = GetPrimaryFrame(fcFrame, PR_FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(result) && fcFrame) {
|
||||
nsISelectControlFrame* selectFrame = nsnull;
|
||||
result = fcFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(void **) &selectFrame);
|
||||
|
||||
if (NS_SUCCEEDED(result) && (selectFrame)) {
|
||||
PRInt32 indx;
|
||||
|
||||
GetIndex(&indx);
|
||||
|
||||
if (indx >= 0) {
|
||||
// this will flush pending reflows
|
||||
return selectFrame->SetOptionSelected(indx, aValue);
|
||||
}
|
||||
}
|
||||
// Note: The select content obj maintains all the PresState
|
||||
// so defer to it to get the answer
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||
GetSelect(getter_AddRefs(selectElement));
|
||||
nsCOMPtr<nsISelectElement> selectInt(do_QueryInterface(selectElement));
|
||||
if (selectInt) {
|
||||
// This should end up calling SetSelectedInternal
|
||||
return selectInt->SetOptionSelected(this, aValue);
|
||||
} else {
|
||||
// Note: The select content obj maintains all the PresState
|
||||
// so defer to it to get the answer
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
result = NS_OK;
|
||||
|
||||
GetParentNode(getter_AddRefs(parentNode));
|
||||
|
||||
nsCOMPtr<nsISelectElement> selectElement(do_QueryInterface(parentNode));
|
||||
|
||||
if (selectElement) {
|
||||
return selectElement->SetOptionSelected(this, aValue);
|
||||
}
|
||||
return SetSelectedInternal(aValue, PR_TRUE);
|
||||
}
|
||||
|
||||
return result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//NS_IMPL_BOOL_ATTR(nsHTMLOptionElement, DefaultSelected, defaultselected)
|
||||
|
@ -319,39 +338,26 @@ nsHTMLOptionElement::SetSelected(PRBool aValue)
|
|||
//NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Label, label)
|
||||
NS_IMPL_STRING_ATTR(nsHTMLOptionElement, Value, value)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetDisabled(PRBool* aDisabled)
|
||||
{
|
||||
nsHTMLValue val;
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::GetDisabled(PRBool* aDisabled)
|
||||
{
|
||||
nsHTMLValue val;
|
||||
nsresult rv = GetHTMLAttribute(nsHTMLAtoms::disabled, val);
|
||||
*aDisabled = (NS_CONTENT_ATTR_NOT_THERE != rv);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetDisabled(PRBool aDisabled)
|
||||
{
|
||||
NS_IMETHODIMP
|
||||
nsHTMLOptionElement::SetDisabled(PRBool aDisabled)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
||||
|
||||
|
||||
if (aDisabled) {
|
||||
rv = SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult result = GetPrimaryFrame(fcFrame);
|
||||
if (NS_SUCCEEDED(result) && (nsnull != fcFrame)) {
|
||||
nsISelectControlFrame* selectFrame = nsnull;
|
||||
|
||||
result = fcFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(void **)&selectFrame);
|
||||
|
||||
if (NS_SUCCEEDED(result) && (nsnull != selectFrame)) {
|
||||
selectFrame->OptionDisabled(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rv = UnsetAttr(kNameSpaceID_HTML, nsHTMLAtoms::selected, PR_TRUE);
|
||||
rv = UnsetAttr(kNameSpaceID_HTML, nsHTMLAtoms::disabled, PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -372,19 +378,20 @@ nsHTMLOptionElement::SetLabel(const nsAReadableString& aValue)
|
|||
|
||||
result = nsGenericHTMLContainerElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::label,
|
||||
aValue, PR_TRUE);
|
||||
aValue, PR_TRUE);
|
||||
// XXX Why does this only happen to the combobox? and what about
|
||||
// when the text gets set and label is blank?
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
|
||||
result = GetPrimaryFrame(fcFrame);
|
||||
GetPrimaryFrame(fcFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(result) && (nsnull != fcFrame)) {
|
||||
if (fcFrame) {
|
||||
nsIComboboxControlFrame* selectFrame = nsnull;
|
||||
|
||||
result = fcFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),
|
||||
(void **) &selectFrame);
|
||||
CallQueryInterface(fcFrame, &selectFrame);
|
||||
|
||||
if (NS_SUCCEEDED(result) && selectFrame) {
|
||||
if (selectFrame) {
|
||||
selectFrame->UpdateSelection(PR_FALSE, PR_TRUE, 0);
|
||||
}
|
||||
}
|
||||
|
@ -416,11 +423,6 @@ nsHTMLOptionElement::SetDefaultSelected(PRBool aDefaultSelected)
|
|||
rv = UnsetAttr(kNameSpaceID_HTML, nsHTMLAtoms::selected, PR_TRUE);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// When setting DefaultSelected, we must also reset Selected (DOM Errata)
|
||||
rv = SetSelected(aDefaultSelected);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -434,7 +436,7 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
|
|||
// Get our containing select content object.
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||
|
||||
GetSelect(*getter_AddRefs(selectElement));
|
||||
GetSelect(getter_AddRefs(selectElement));
|
||||
|
||||
if (selectElement) {
|
||||
// Get the options from the select object.
|
||||
|
@ -600,15 +602,14 @@ nsHTMLOptionElement::SetText(const nsAReadableString& aText)
|
|||
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
result = GetPrimaryFrame(fcFrame);
|
||||
GetPrimaryFrame(fcFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (NS_SUCCEEDED(result) && fcFrame) {
|
||||
if (fcFrame) {
|
||||
nsIComboboxControlFrame* selectFrame = nsnull;
|
||||
|
||||
result = fcFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),
|
||||
(void **)&selectFrame);
|
||||
CallQueryInterface(fcFrame, &selectFrame);
|
||||
|
||||
if (NS_SUCCEEDED(result) && selectFrame) {
|
||||
if (selectFrame) {
|
||||
selectFrame->UpdateSelection(PR_FALSE, PR_TRUE, 0);
|
||||
}
|
||||
}
|
||||
|
@ -623,13 +624,14 @@ nsHTMLOptionElement::SetText(const nsAReadableString& aText)
|
|||
|
||||
nsresult
|
||||
nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
||||
PRBool aFlushNotifications)
|
||||
PRBool aFlushContent,
|
||||
PRBool aFlushReflows)
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement;
|
||||
|
||||
nsresult res = NS_ERROR_FAILURE; // This should be NS_OK;
|
||||
|
||||
GetSelect(*getter_AddRefs(selectElement));
|
||||
GetSelect(getter_AddRefs(selectElement));
|
||||
|
||||
if (selectElement) {
|
||||
nsCOMPtr<nsIHTMLContent> selectContent(do_QueryInterface(selectElement));
|
||||
|
@ -637,7 +639,8 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
|||
if (selectContent) {
|
||||
res = nsGenericHTMLElement::GetPrimaryFrame(selectContent,
|
||||
aIFormControlFrame,
|
||||
aFlushNotifications);
|
||||
aFlushContent,
|
||||
aFlushReflows);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,42 +649,21 @@ nsHTMLOptionElement::GetPrimaryFrame(nsIFormControlFrame *&aIFormControlFrame,
|
|||
|
||||
// Get the select content element that contains this option
|
||||
void
|
||||
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement *&aSelectElement)
|
||||
nsHTMLOptionElement::GetSelect(nsIDOMHTMLSelectElement **aSelectElement)
|
||||
{
|
||||
aSelectElement = nsnull;
|
||||
*aSelectElement = nsnull;
|
||||
|
||||
// Get the containing element (Either a select or an optGroup)
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
|
||||
GetParentNode(getter_AddRefs(parentNode));
|
||||
|
||||
if (parentNode) {
|
||||
nsresult res;
|
||||
res = parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||
(void**)&aSelectElement);
|
||||
|
||||
// If we are in an OptGroup we need to GetParentNode again (at least once)
|
||||
if (NS_FAILED(res)) {
|
||||
nsCOMPtr<nsIDOMHTMLOptGroupElement> optgroupElement;
|
||||
|
||||
while (parentNode) { // Be ready for nested OptGroups
|
||||
// Don't need the optgroupElement, just seeing if it IS one.
|
||||
optgroupElement = do_QueryInterface(parentNode);
|
||||
|
||||
if (optgroupElement) {
|
||||
nsIDOMNode* tmpNode = parentNode.get();
|
||||
|
||||
tmpNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
} else {
|
||||
break; // Break out if not a OptGroup (hopefully we have a select)
|
||||
}
|
||||
}
|
||||
|
||||
if (parentNode) {
|
||||
parentNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||
(void**)&aSelectElement);
|
||||
}
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
nsCOMPtr<nsIContent> prevParent;
|
||||
GetParent(*getter_AddRefs(parent));
|
||||
while (parent) {
|
||||
CallQueryInterface(parent, aSelectElement);
|
||||
if (*aSelectElement) {
|
||||
break;
|
||||
}
|
||||
prevParent = parent;
|
||||
prevParent->GetParent(*getter_AddRefs(parent));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,8 +728,8 @@ nsHTMLOptionElement::Initialize(JSContext* aContext,
|
|||
// The third (optional) parameter is the defaultSelected value
|
||||
JSBool defaultSelected;
|
||||
if ((JS_TRUE == JS_ValueToBoolean(aContext,
|
||||
argv[2],
|
||||
&defaultSelected)) &&
|
||||
argv[2],
|
||||
&defaultSelected)) &&
|
||||
(JS_TRUE == defaultSelected)) {
|
||||
nsHTMLValue empty(eHTMLUnit_Empty);
|
||||
|
||||
|
@ -758,10 +740,15 @@ nsHTMLOptionElement::Initialize(JSContext* aContext,
|
|||
}
|
||||
}
|
||||
|
||||
// XXX Since we don't store the selected state, we can't deal
|
||||
// with the fourth (optional) parameter that is meant to specify
|
||||
// whether the option element should be currently selected or
|
||||
// not. Does anyone depend on this behavior?
|
||||
// XXX This is *untested* behavior. Should work though.
|
||||
if (argc > 3) {
|
||||
JSBool selected;
|
||||
if (JS_TRUE == JS_ValueToBoolean(aContext,
|
||||
argv[3],
|
||||
&selected)) {
|
||||
return SetSelected(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -38,6 +38,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMNSHTMLTextAreaElement.h"
|
||||
#include "nsITextControlElement.h"
|
||||
#include "nsIControllers.h"
|
||||
#include "nsIEditorController.h"
|
||||
#include "nsContentCID.h"
|
||||
|
@ -65,14 +66,16 @@
|
|||
#include "nsIFormControlFrame.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsLinebreakConverter.h"
|
||||
#include "nsIPresState.h"
|
||||
|
||||
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
||||
|
||||
|
||||
class nsHTMLTextAreaElement : public nsGenericHTMLContainerFormElement,
|
||||
public nsIDOMHTMLTextAreaElement,
|
||||
public nsIDOMNSHTMLTextAreaElement
|
||||
public nsIDOMNSHTMLTextAreaElement,
|
||||
public nsITextControlElement
|
||||
{
|
||||
public:
|
||||
nsHTMLTextAreaElement();
|
||||
|
@ -98,7 +101,21 @@ public:
|
|||
|
||||
// nsIFormControl
|
||||
NS_IMETHOD GetType(PRInt32* aType);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD IsSuccessful(nsIContent* aSubmitElement, PRBool *_retval);
|
||||
NS_IMETHOD GetMaxNumValues(PRInt32 *_retval);
|
||||
NS_IMETHOD GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames);
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// nsITextControlElement
|
||||
NS_IMETHOD GetValueInternal(nsAWritableString& str);
|
||||
NS_IMETHOD SetValueInternal(nsAReadableString& str);
|
||||
|
||||
// nsIContent
|
||||
NS_IMETHOD StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsAReadableString& aValue,
|
||||
nsHTMLValue& aResult);
|
||||
|
@ -167,6 +184,7 @@ NS_HTML_CONTENT_INTERFACE_MAP_BEGIN(nsHTMLTextAreaElement,
|
|||
nsGenericHTMLContainerFormElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLTextAreaElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITextControlElement)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLTextAreaElement)
|
||||
NS_HTML_CONTENT_INTERFACE_MAP_END
|
||||
|
||||
|
@ -242,7 +260,7 @@ nsHTMLTextAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
|
@ -251,7 +269,7 @@ nsHTMLTextAreaElement::SetFocus(nsIPresContext* aPresContext)
|
|||
// select text when we receive focus.
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -263,7 +281,7 @@ nsHTMLTextAreaElement::RemoveFocus(nsIPresContext* aPresContext)
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_FALSE, PR_FALSE);
|
||||
|
@ -330,7 +348,7 @@ nsHTMLTextAreaElement::Select()
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetFocus(PR_TRUE, PR_TRUE);
|
||||
|
@ -347,15 +365,14 @@ NS_IMETHODIMP
|
|||
nsHTMLTextAreaElement::SelectAll(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
nsresult rv = GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->SetProperty(aPresContext, nsHTMLAtoms::select,
|
||||
nsAutoString());
|
||||
return NS_OK;
|
||||
nsString());
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTextAreaElement, AccessKey, accesskey)
|
||||
|
@ -375,31 +392,46 @@ nsHTMLTextAreaElement::GetType(nsAWritableString& aType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::GetValueInternal(nsAWritableString& aValue)
|
||||
{
|
||||
return nsGenericHTMLContainerFormElement::GetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::value,
|
||||
aValue);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::GetValue(nsAWritableString& aValue)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
formControlFrame->GetProperty(nsHTMLAtoms::value, aValue);
|
||||
|
||||
return NS_OK;
|
||||
} else {
|
||||
return GetValueInternal(aValue);
|
||||
}
|
||||
//XXX: Should this ASSERT instead of getting the default value here?
|
||||
return nsGenericHTMLContainerFormElement::GetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::value,
|
||||
aValue);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::SetValueInternal(nsAReadableString& aValue)
|
||||
{
|
||||
// Set the attribute in the DOM too, we call SetAttribute with aNotify
|
||||
// false so that we don't generate unnecessary reflows.
|
||||
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::value, aValue,
|
||||
PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::SetValue(const nsAReadableString& aValue)
|
||||
{
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
|
||||
GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_TRUE, PR_FALSE);
|
||||
|
||||
if (formControlFrame) {
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
|
@ -408,11 +440,8 @@ nsHTMLTextAreaElement::SetValue(const nsAReadableString& aValue)
|
|||
formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue);
|
||||
}
|
||||
|
||||
// Set the attribute in the DOM too, we call SetAttribute with aNotify
|
||||
// false so that we don't generate unnecessary reflows.
|
||||
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::value, aValue,
|
||||
PR_FALSE);
|
||||
// Always set the value internally, since it affects layout
|
||||
SetValueInternal(aValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -445,9 +474,7 @@ nsHTMLTextAreaElement::SetDefaultValue(const nsAReadableString& aDefaultValue)
|
|||
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::defaultvalue,
|
||||
defaultValue, PR_TRUE);
|
||||
nsGenericHTMLContainerFormElement::SetAttr(kNameSpaceID_HTML,
|
||||
nsHTMLAtoms::value,
|
||||
defaultValue, PR_TRUE);
|
||||
SetValue(defaultValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -537,7 +564,7 @@ nsHTMLTextAreaElement::HandleDOMEvent(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsIFormControlFrame* formControlFrame = nsnull;
|
||||
rv = GetPrimaryFrame(this, formControlFrame);
|
||||
GetPrimaryFrame(this, formControlFrame, PR_FALSE, PR_FALSE);
|
||||
nsIFrame* formFrame = nsnull;
|
||||
|
||||
if (formControlFrame &&
|
||||
|
@ -683,3 +710,100 @@ nsHTMLTextAreaElement::GetControllers(nsIControllers** aResult)
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsHTMLTextAreaElement::Reset()
|
||||
{
|
||||
nsAutoString resetVal;
|
||||
GetDefaultValue(resetVal);
|
||||
nsresult rv = SetValue(resetVal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTextAreaElement::IsSuccessful(nsIContent* aSubmitElement,
|
||||
PRBool *_retval)
|
||||
{
|
||||
// if it's disabled, it won't submit
|
||||
PRBool disabled;
|
||||
nsresult rv = GetDisabled(&disabled);
|
||||
if (disabled) {
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if it dosn't have a name it we don't submit
|
||||
nsAutoString val;
|
||||
rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, val);
|
||||
*_retval = rv != NS_CONTENT_ATTR_NOT_THERE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTextAreaElement::GetMaxNumValues(PRInt32 *_retval)
|
||||
{
|
||||
*_retval = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLTextAreaElement::GetNamesValues(PRInt32 aMaxNumValues,
|
||||
PRInt32& aNumValues,
|
||||
nsString* aValues,
|
||||
nsString* aNames)
|
||||
{
|
||||
NS_ENSURE_TRUE(aMaxNumValues >= 1, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// We'll of course use the name of the control for the submit
|
||||
nsAutoString name;
|
||||
nsresult rv = GetName(name);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString value;
|
||||
rv = GetValue(value);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aNames[0] = name;
|
||||
aValues[0] = value;
|
||||
aNumValues = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsresult rv = GetPrimaryPresState(this, aState);
|
||||
if (*aState) {
|
||||
nsString value;
|
||||
GetValue(value);
|
||||
// XXX Should use nsAutoString above but ConvertStringLineBreaks requires
|
||||
// mOwnsBuffer!
|
||||
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Converting linebreaks failed!");
|
||||
rv = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value save failed!");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTextAreaElement::RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsAutoString value;
|
||||
rv = aState->GetStateProperty(NS_LITERAL_STRING("value"), value);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "value restore failed!");
|
||||
SetValue(value);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -791,8 +791,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
|
|||
for (PRInt32 i = 0; i < ac; i++) {
|
||||
// Get upper-cased key
|
||||
const nsAReadableString& key = aNode.GetKeyAt(i);
|
||||
k.Truncate();
|
||||
k.Append(key);
|
||||
k.Assign(key);
|
||||
k.ToLowerCase();
|
||||
|
||||
nsIAtom* keyAtom = NS_NewAtom(k);
|
||||
|
@ -804,7 +803,7 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode,
|
|||
GetAttributeValueAt(aNode, i, v);
|
||||
|
||||
// Add attribute to content
|
||||
aContent->SetAttr(kNameSpaceID_HTML, keyAtom, v,aNotify);
|
||||
aContent->SetAttr(kNameSpaceID_HTML, keyAtom, v, aNotify);
|
||||
}
|
||||
NS_RELEASE(keyAtom);
|
||||
}
|
||||
|
@ -3779,7 +3778,8 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::WillProcessTokens(void) {
|
||||
HTMLContentSink::WillProcessTokens(void)
|
||||
{
|
||||
if (mFlags & NS_SINK_FLAG_CAN_INTERRUPT_PARSER) {
|
||||
mDelayTimerStart = PR_IntervalToMicroseconds(PR_IntervalNow());
|
||||
}
|
||||
|
@ -3787,18 +3787,20 @@ HTMLContentSink::WillProcessTokens(void) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::DidProcessTokens(void) {
|
||||
HTMLContentSink::DidProcessTokens(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::WillProcessAToken(void) {
|
||||
HTMLContentSink::WillProcessAToken(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::DidProcessAToken(void) {
|
||||
|
||||
HTMLContentSink::DidProcessAToken(void)
|
||||
{
|
||||
if (mFlags & NS_SINK_FLAG_CAN_INTERRUPT_PARSER) {
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
@ -3860,8 +3862,8 @@ PRInt32 newMaxTokenProcessingTime = GetMaxTokenProcessingTime();
|
|||
if ((currentTime - mDelayTimerStart) > NS_STATIC_CAST(PRUint32, GetMaxTokenProcessingTime())) {
|
||||
return NS_ERROR_HTMLPARSER_INTERRUPTED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,9 +73,9 @@
|
|||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIRadioControlFrame.h"
|
||||
#include "nsICheckboxControlFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsITextContent.h"
|
||||
|
@ -967,7 +967,7 @@ public:
|
|||
}
|
||||
|
||||
already_AddRefed<nsIContent> get() const {
|
||||
nsIContent* result;
|
||||
nsIContent* result = nsnull;
|
||||
if (mNodes) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
mNodes->Item(mIndex, getter_AddRefs(node));
|
||||
|
@ -1541,7 +1541,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell,
|
|||
rv = NS_NewFileControlFrame(aPresShell, &aFrame);
|
||||
}
|
||||
else if (val.EqualsIgnoreCase("hidden")) {
|
||||
rv = ConstructButtonControlFrame(aPresShell, aPresContext, aFrame);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else if (val.EqualsIgnoreCase("image")) {
|
||||
rv = NS_NewImageControlFrame(aPresShell, &aFrame);
|
||||
|
@ -3930,14 +3930,15 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (GetFormElementRenderingMode(aPresContext, eWidgetType_Button) == eWidgetRendering_Gfx)
|
||||
rv = NS_NewGfxButtonControlFrame(aPresShell, &aNewFrame);
|
||||
else
|
||||
if (GetFormElementRenderingMode(aPresContext, eWidgetType_Button)
|
||||
== eWidgetRendering_Gfx)
|
||||
rv = NS_NewGfxButtonControlFrame(aPresShell, &aNewFrame);
|
||||
else
|
||||
NS_ASSERTION(0, "We longer support native widgets");
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -3947,10 +3948,10 @@ nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShe
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame,
|
||||
nsIContent* aContent)
|
||||
nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
if (!aPresContext) { return NS_ERROR_NULL_POINTER;}
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -4236,20 +4237,10 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell,
|
|||
nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||
(void**)getter_AddRefs(selectElement));
|
||||
if (NS_SUCCEEDED(result) && selectElement) {
|
||||
PRUint32 numOptions = 0;
|
||||
result = selectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(result) && 0 == numOptions) {
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
scrolledFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, scrolledFrame, aContent,
|
||||
styleContext, nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
childItems.AddChild(generatedFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
AddDummyFrameToSelect(aPresContext, aPresShell, aState,
|
||||
scrollFrame, scrolledFrame, &childItems,
|
||||
aContent, selectElement);
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
@ -4511,7 +4502,8 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
|
|||
ProcessPseudoFrames(aPresContext, aState.mPseudoFrames, aFrameItems);
|
||||
}
|
||||
isReplaced = PR_TRUE;
|
||||
rv = CreateInputFrame(aPresShell, aPresContext, aContent, newFrame, aStyleContext);
|
||||
rv = CreateInputFrame(aPresShell, aPresContext,
|
||||
aContent, newFrame, aStyleContext);
|
||||
}
|
||||
else if (nsHTMLAtoms::textarea == aTag) {
|
||||
if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
|
||||
|
@ -5532,6 +5524,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
|
||||
|
||||
rv = NS_NewStackFrame(aPresShell, &newFrame);
|
||||
|
||||
if (IsScrollable(aPresContext, display)) {
|
||||
|
@ -8230,6 +8223,56 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell* aPresShell,
|
||||
nsFrameConstructorState& aState,
|
||||
nsIFrame* aListFrame,
|
||||
nsIFrame* aParentFrame,
|
||||
nsFrameItems* aChildItems,
|
||||
nsIContent* aContainer,
|
||||
nsIDOMHTMLSelectElement* aSelectElement)
|
||||
{
|
||||
PRUint32 numOptions = 0;
|
||||
nsresult rv = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(rv) && 0 == numOptions) {
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
CallQueryInterface(aListFrame, &listFrame);
|
||||
if (listFrame) {
|
||||
nsIFrame* dummyFrame;
|
||||
listFrame->GetDummyFrame(&dummyFrame);
|
||||
|
||||
if (!dummyFrame) {
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
aParentFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState,
|
||||
aParentFrame, aContainer,
|
||||
styleContext,
|
||||
nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
if (aChildItems) {
|
||||
aChildItems->AddChild(generatedFrame);
|
||||
} else {
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
if (frameManager) {
|
||||
frameManager->AppendFrames(aPresContext, *aPresShell,
|
||||
aParentFrame, nsnull, generatedFrame);
|
||||
}
|
||||
}
|
||||
|
||||
listFrame->SetDummyFrame(generatedFrame);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell * aPresShell,
|
||||
|
@ -8237,42 +8280,33 @@ nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
|||
nsIContent* aChild,
|
||||
nsIDOMHTMLSelectElement * aSelectElement)
|
||||
{
|
||||
//check to see if there is one item,
|
||||
// meaning we need to remove the dummy frame
|
||||
// Check to see if this is the first thing we have added to this frame.
|
||||
|
||||
PRUint32 numOptions = 0;
|
||||
nsresult result = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (0 == numOptions) {
|
||||
nsIFrame* parentFrame;
|
||||
nsIFrame* childFrame;
|
||||
// Get the childFrame for the added child (option)
|
||||
// then get the child's parent frame which should be an area frame
|
||||
aPresShell->GetPrimaryFrameFor(aChild, &childFrame);
|
||||
if (nsnull != childFrame) {
|
||||
childFrame->GetParent(&parentFrame);
|
||||
nsresult rv = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(rv) && numOptions > 0) {
|
||||
nsIFrame* frame;
|
||||
aPresShell->GetPrimaryFrameFor(aContainer, &frame);
|
||||
if (frame) {
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
CallQueryInterface(frame, &listFrame);
|
||||
|
||||
// Now loop through all the child looking fr the frame whose content
|
||||
// is equal to the select element's content
|
||||
// this is because when gernated content is created it stuff the parent content
|
||||
// pointer into the generated frame, so in this case it has the select content
|
||||
parentFrame->FirstChild(aPresContext, nsnull, &childFrame);
|
||||
nsCOMPtr<nsIContent> selectContent = do_QueryInterface(aSelectElement);
|
||||
while (nsnull != childFrame) {
|
||||
nsIContent * content;
|
||||
childFrame->GetContent(&content);
|
||||
|
||||
// Found the dummy frame so get the FrameManager and
|
||||
// delete/remove the dummy frame
|
||||
if (selectContent.get() == content) {
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
frameManager->RemoveFrame(aPresContext, *aPresShell, parentFrame, nsnull, childFrame);
|
||||
NS_IF_RELEASE(content);
|
||||
return NS_OK;
|
||||
}
|
||||
if (listFrame) {
|
||||
nsIFrame* dummyFrame;
|
||||
listFrame->GetDummyFrame(&dummyFrame);
|
||||
|
||||
NS_IF_RELEASE(content);
|
||||
childFrame->GetNextSibling(&childFrame);
|
||||
if (dummyFrame) {
|
||||
listFrame->SetDummyFrame(nsnull);
|
||||
|
||||
// get the child's parent frame (which ought to be the list frame)
|
||||
nsIFrame* parentFrame;
|
||||
dummyFrame->GetParent(&parentFrame);
|
||||
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
frameManager->RemoveFrame(aPresContext, *aPresShell,
|
||||
parentFrame, nsnull, dummyFrame);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9024,37 +9058,27 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
|
|||
// When the last item is removed from a select,
|
||||
// we need to add a pseudo frame so select gets sized as the best it can
|
||||
// so here we see if it is a select and then we get the number of options
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
if (aContainer && childFrame) {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = do_QueryInterface(aContainer);
|
||||
if (selectElement) {
|
||||
PRUint32 numOptions = 0;
|
||||
result = selectElement->GetLength(&numOptions);
|
||||
nsIFrame * selectFrame; // XXX temp needed only native controls
|
||||
shell->GetPrimaryFrameFor(aContainer, &selectFrame);// XXX temp needed only native controls
|
||||
// XXX temp needed only native controls
|
||||
nsIFrame* selectFrame;
|
||||
// XXX temp needed only native controls
|
||||
shell->GetPrimaryFrameFor(aContainer, &selectFrame);
|
||||
|
||||
// For "select" add the pseudo frame after the last item is deleted
|
||||
nsIFrame* parentFrame = nsnull;
|
||||
childFrame->GetParent(&parentFrame);
|
||||
if (parentFrame == selectFrame) { // XXX temp needed only native controls
|
||||
if (parentFrame == selectFrame) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(result) && shell && parentFrame && 1 == numOptions) {
|
||||
|
||||
nsIStyleContext* styleContext = nsnull;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
nsFrameConstructorState state(aPresContext, nsnull, nsnull, nsnull, nsnull);
|
||||
|
||||
//shell->GetPrimaryFrameFor(aContainer, &contentFrame);
|
||||
parentFrame->GetStyleContext(&styleContext);
|
||||
if (CreateGeneratedContentFrame(shell, aPresContext, state, parentFrame, aContainer,
|
||||
styleContext, nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
frameManager->AppendFrames(aPresContext, *shell, parentFrame, nsnull, generatedFrame);
|
||||
}
|
||||
NS_IF_RELEASE(styleContext);
|
||||
}
|
||||
if (shell && parentFrame) {
|
||||
nsFrameConstructorState state(aPresContext,
|
||||
nsnull, nsnull, nsnull, nsnull);
|
||||
AddDummyFrameToSelect(aPresContext, shell, state,
|
||||
selectFrame, parentFrame, nsnull,
|
||||
aContainer, selectElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11271,7 +11295,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
|
|||
if (insertionPoint) {
|
||||
// If the insertion point is a scrollable, then walk ``through''
|
||||
// it to get the scrolled frame.
|
||||
nsIScrollableFrame* scroll;
|
||||
nsIScrollableFrame* scroll = nsnull;
|
||||
CallQueryInterface(insertionPoint, &scroll);
|
||||
if (scroll)
|
||||
scroll->GetScrolledFrame(nsnull, insertionPoint);
|
||||
|
|
|
@ -611,11 +611,20 @@ protected:
|
|||
PRBool aParentIsBlock,
|
||||
nsTableCreator* aTableCreator = nsnull);
|
||||
|
||||
nsresult CreateInputFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext *aPresContext,
|
||||
nsIContent *aContent,
|
||||
nsIFrame *&aFrame,
|
||||
nsIStyleContext *aStyleContext);
|
||||
nsresult CreateInputFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame*& aFrame,
|
||||
nsIStyleContext* aStyleContext);
|
||||
|
||||
nsresult AddDummyFrameToSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell* aPresShell,
|
||||
nsFrameConstructorState& aState,
|
||||
nsIFrame* aListFrame,
|
||||
nsIFrame* aParentFrame,
|
||||
nsFrameItems* aChildItems,
|
||||
nsIContent* aContainer,
|
||||
nsIDOMHTMLSelectElement* aSelectElement);
|
||||
|
||||
nsresult RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell * aPresShell,
|
||||
|
|
|
@ -2203,7 +2203,7 @@ FrameManager::RestoreFrameStateFor(nsIPresContext* aPresContext, nsIFrame* aFram
|
|||
|
||||
nsCAutoString stateKey;
|
||||
rv = GenerateStateKey(content, aID, stateKey);
|
||||
if(NS_FAILED(rv) || stateKey.IsEmpty()) {
|
||||
if (NS_FAILED(rv) || stateKey.IsEmpty()) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2365,8 +2365,17 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
|
|||
|
||||
nsCOMPtr<nsIContent> formContent(do_QueryInterface(formElement));
|
||||
mHTMLForms->IndexOf(formContent, index, PR_FALSE);
|
||||
if (index <= -1) {
|
||||
mHTMLForms->IndexOf(formContent, index, PR_TRUE);
|
||||
}
|
||||
NS_ASSERTION(index > -1,
|
||||
"nsFrameManager::GenerateStateKey didn't find form index!");
|
||||
if (index <= -1) {
|
||||
PRUint32 formsLength;
|
||||
// Assume the form index is going to be added to the form content next
|
||||
mHTMLForms->GetLength(&formsLength, PR_FALSE);
|
||||
index = (PRInt32)formsLength;
|
||||
}
|
||||
if (index > -1) {
|
||||
KeyAppendInt(index, aKey);
|
||||
|
||||
|
|
|
@ -57,14 +57,12 @@
|
|||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -341,19 +339,19 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIComboboxControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIComboboxControlFrame*) this);
|
||||
*aInstancePtr = (void*)(nsIComboboxControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
||||
*aInstancePtr = (void*)(nsIFormControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
||||
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
|
||||
*aInstancePtr = (void*)(nsIAnonymousContentCreator*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
|
||||
*aInstancePtr = (void *)(nsISelectControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
||||
*aInstancePtr = (void *)(nsIStatefulFrame*)this;
|
||||
*aInstancePtr = (void*)(nsIStatefulFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIRollupListener))) {
|
||||
*aInstancePtr = (void*)(nsIRollupListener*)this;
|
||||
|
@ -411,94 +409,30 @@ nsComboboxControlFrame::Init(nsIPresContext* aPresContext,
|
|||
return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool
|
||||
nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
// If nothing is selected, and we have options, select item 0
|
||||
// This is a UI decision that goes against the HTML 4 spec.
|
||||
// See bugzilla bug 15841 for justification of this deviation.
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::MakeSureSomethingIsSelected(nsIPresContext* aPresContext)
|
||||
{
|
||||
REFLOW_DEBUG_MSG("CBX::MakeSureSomethingIsSelected\n");
|
||||
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if (NS_SUCCEEDED(rv) && fcFrame) {
|
||||
// If nothing selected, and there are options, default selection to item 0
|
||||
rv = mListControlFrame->GetSelectedIndex(&mSelectedIndex);
|
||||
if (NS_SUCCEEDED(rv) && (mSelectedIndex < 0)) {
|
||||
// Find out if there are any options in the list to select
|
||||
PRInt32 length = 0;
|
||||
mListControlFrame->GetNumberOfOptions(&length);
|
||||
if (length > 0) {
|
||||
// Set listbox selection to first item in the list box
|
||||
rv = fcFrame->SetProperty(aPresContext, nsHTMLAtoms::selectedindex, NS_ConvertASCIItoUCS2("0"));
|
||||
mSelectedIndex = 0;
|
||||
} else {
|
||||
UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // Needed to reflow when removing last option
|
||||
}
|
||||
}
|
||||
|
||||
// Don't NS_RELEASE fcFrame here as it isn't addRef'd in the QI (???)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Initialize the text string in the combobox using either the current
|
||||
// selection in the list box or the first item item in the list box.
|
||||
void
|
||||
nsComboboxControlFrame::InitTextStr(nsIPresContext* aPresContext, PRBool aUpdate)
|
||||
nsComboboxControlFrame::InitTextStr()
|
||||
{
|
||||
MakeSureSomethingIsSelected(aPresContext);
|
||||
|
||||
PRInt32 selectedIndex;
|
||||
mListControlFrame->GetSelectedIndex(&selectedIndex);
|
||||
// Update the selected text string
|
||||
mListControlFrame->GetSelectedItem(mTextStr);
|
||||
if (selectedIndex == -1) {
|
||||
mListControlFrame->GetOptionText(0, mTextStr);
|
||||
} else {
|
||||
mListControlFrame->GetOptionText(selectedIndex, mTextStr);
|
||||
}
|
||||
|
||||
// Update the display by setting the value attribute
|
||||
mDisplayContent->SetText(mTextStr.get(), mTextStr.Length(), aUpdate);
|
||||
// Update the display by setting the value attribute
|
||||
mDisplayContent->SetText(mTextStr.get(), mTextStr.Length(), PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
// Reset the combo box back to it original state.
|
||||
|
||||
void
|
||||
nsComboboxControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
if (mPresState) {
|
||||
nsIStatefulFrame* sFrame = nsnull;
|
||||
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
|
||||
(void**)&sFrame);
|
||||
if (NS_SUCCEEDED(res) && sFrame) {
|
||||
res = sFrame->RestoreState(mPresContext, mPresState);
|
||||
NS_RELEASE(sFrame);
|
||||
}
|
||||
mPresState = do_QueryInterface(nsnull);
|
||||
}
|
||||
|
||||
// Reset the dropdown list to its original state
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult result = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if ((NS_OK == result) && (nsnull != fcFrame)) {
|
||||
fcFrame->Reset(aPresContext);
|
||||
}
|
||||
|
||||
// Update the combobox using the text string returned from the dropdown list
|
||||
InitTextStr(aPresContext, PR_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
nsComboboxControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
Reset(aPresContext);
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
@ -1703,7 +1637,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Reflow the dropdown list to match the width of the display + button
|
||||
ReflowComboChildFrame(mDropdownFrame, aPresContext, dropdownDesiredSize, firstPassState, aStatus,
|
||||
aDesiredSize.width, NS_UNCONSTRAINEDSIZE);
|
||||
lcf->SetPassId(0); // reset it back
|
||||
lcf->SetPassId(0);
|
||||
}
|
||||
|
||||
#else // DO_NEW_REFLOW
|
||||
|
@ -1789,7 +1723,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
//--------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetName(nsString* aResult)
|
||||
nsComboboxControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -1809,44 +1743,6 @@ nsComboboxControlFrame::GetName(nsString* aResult)
|
|||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsComboboxControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*XXX-REMOVE
|
||||
PRBool
|
||||
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// use our name and the text widgets value
|
||||
aNames[0] = name;
|
||||
aValues[0] = mTextStr;
|
||||
aNumValues = 1;
|
||||
nsresult status = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
*/
|
||||
|
||||
PRBool
|
||||
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult result = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) {
|
||||
return fcFrame->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
const nsPoint& aPoint,
|
||||
|
@ -1933,18 +1829,9 @@ nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
|||
mDropdownFrame = aDropDownFrame;
|
||||
|
||||
if (NS_OK != mDropdownFrame->QueryInterface(NS_GET_IID(nsIListControlFrame), (void**)&mListControlFrame)) {
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The ListControlFrame was just created and added to the comboxbox
|
||||
// so provide it with a PresState so it can restore itself
|
||||
// when it does its first "Reset"
|
||||
if (mPresState) {
|
||||
mListControlFrame->SetPresState(mPresState);
|
||||
mPresState = do_QueryInterface(nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1991,9 +1878,10 @@ NS_IMETHODIMP
|
|||
nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex)
|
||||
{
|
||||
if (mListControlFrame) {
|
||||
// Check to see if the selection changed
|
||||
// Check to see if the selection changed
|
||||
if (mSelectedIndex != aNewIndex || aForceUpdate) {
|
||||
mListControlFrame->GetSelectedItem(mTextStr); // Update text box
|
||||
mListControlFrame->GetOptionText(aNewIndex, mTextStr);
|
||||
SelectionChanged();
|
||||
|
||||
// Fix for Bug 42661 (remove comment later)
|
||||
#ifdef DO_REFLOW_DEBUG
|
||||
|
@ -2002,9 +1890,7 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp
|
|||
delete [] str;
|
||||
#endif
|
||||
mSelectedIndex = aNewIndex;
|
||||
mListControlFrame->UpdateSelection(aDoDispatchEvent, aForceUpdate, mContent);
|
||||
} else {
|
||||
mSelectedIndex = aNewIndex;
|
||||
mListControlFrame->UpdateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2075,9 +1961,9 @@ nsComboboxControlFrame::SelectionChanged()
|
|||
rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||
ReflowDirtyChild(shell, (nsIFrame*) mDisplayFrame);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mPresContext->GetShell(getter_AddRefs(presShell));
|
||||
presShell->FlushPendingNotifications(PR_FALSE);
|
||||
// nsCOMPtr<nsIPresShell> presShell;
|
||||
// mPresContext->GetShell(getter_AddRefs(presShell));
|
||||
// presShell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -2136,19 +2022,6 @@ nsComboboxControlFrame::RemoveOption(nsIPresContext* aPresContext, PRInt32 aInde
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(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)
|
||||
{
|
||||
|
@ -2162,19 +2035,43 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
|||
return rv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Used by layout to determine if we have a fake option
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OptionDisabled(nsIContent * aContent)
|
||||
nsComboboxControlFrame::GetDummyFrame(nsIFrame** aFrame)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(void**)&listFrame);
|
||||
if (NS_SUCCEEDED(rv) && listFrame) {
|
||||
rv = listFrame->OptionDisabled(aContent);
|
||||
NS_RELEASE(listFrame);
|
||||
nsISelectControlFrame* listFrame;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->GetDummyFrame(aFrame);
|
||||
}
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SetDummyFrame(nsIFrame* aFrame)
|
||||
{
|
||||
nsISelectControlFrame* listFrame;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->SetDummyFrame(aFrame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// End nsISelectControlFrame
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -2511,7 +2408,7 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
|||
mPopupFrames.SetFrames(aChildList);
|
||||
} else {
|
||||
rv = nsAreaFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
||||
InitTextStr(aPresContext, PR_FALSE);
|
||||
InitTextStr();
|
||||
|
||||
nsIFrame * child = aChildList;
|
||||
while (child != nsnull) {
|
||||
|
@ -2575,40 +2472,6 @@ nsComboboxControlFrame::Rollup()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIStatefulFrame
|
||||
// XXX Do we need to implement this here? It is already implemented in
|
||||
// the ListControlFrame, our child...
|
||||
//----------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
||||
{
|
||||
if (!mListControlFrame) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// The ListControlFrame ignores requests to Save its state
|
||||
// when it is owned by a combobox
|
||||
// so we call the internal SaveState here
|
||||
return mListControlFrame->SaveStateInternal(aPresContext, aState);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
||||
{
|
||||
// The ListControlFrame ignores requests to Restore its state
|
||||
// when it is owned by a combobox
|
||||
// so we cache it here if the frame hasn't been created yet
|
||||
// or we call the internal RestoreState here
|
||||
if (!mListControlFrame) {
|
||||
mPresState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mListControlFrame->RestoreStateInternal(aPresContext, aState);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
|
@ -2706,3 +2569,55 @@ nsComboboxControlFrame::GetScrollableView(nsIScrollableView** aView)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// gets the content (an option) by index and then set it as
|
||||
// being selected or not selected
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected)
|
||||
{
|
||||
if (aSelected && !mDroppedDown) {
|
||||
mListControlFrame->GetOptionText(aIndex, mTextStr);
|
||||
SelectionChanged();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OnContentReset()
|
||||
{
|
||||
if (mListControlFrame) {
|
||||
nsCOMPtr<nsIFormControlFrame> formControl =
|
||||
do_QueryInterface(mListControlFrame);
|
||||
formControl->OnContentReset();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// nsIStatefulFrame
|
||||
//--------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
|
||||
if (stateful) {
|
||||
return stateful->SaveState(aPresContext, aState);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
|
||||
if (stateful) {
|
||||
return stateful->RestoreState(aPresContext, aState);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIRollupListener.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIScrollableViewProvider.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
|
||||
class nsFormFrame;
|
||||
class nsIView;
|
||||
|
@ -82,9 +82,9 @@ class nsComboboxControlFrame : public nsAreaFrame,
|
|||
public nsIComboboxControlFrame,
|
||||
public nsIAnonymousContentCreator,
|
||||
public nsISelectControlFrame,
|
||||
public nsIStatefulFrame,
|
||||
public nsIRollupListener,
|
||||
public nsIScrollableViewProvider
|
||||
public nsIScrollableViewProvider,
|
||||
public nsIStatefulFrame
|
||||
{
|
||||
public:
|
||||
friend nsresult NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlags);
|
||||
|
@ -144,19 +144,16 @@ public:
|
|||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void InitializeControl(nsIPresContext* aPresContext);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
||||
const nsFont*& aFont);
|
||||
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
||||
|
@ -192,15 +189,13 @@ public:
|
|||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
|
||||
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
|
||||
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent);
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext); // Default to option 0
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
|
||||
//nsIRollupListener
|
||||
// NS_DECL_NSIROLLUPLISTENER
|
||||
|
@ -219,6 +214,10 @@ public:
|
|||
// nsIScrollableViewProvider
|
||||
NS_IMETHOD GetScrollableView(nsIScrollableView** aView);
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD CreateDisplayFrame(nsIPresContext* aPresContext);
|
||||
|
||||
|
@ -249,7 +248,7 @@ protected:
|
|||
void ShowPopup(PRBool aShowPopup);
|
||||
void ShowList(nsIPresContext* aPresContext, PRBool aShowList);
|
||||
void SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nscoord aHeight);
|
||||
void InitTextStr(nsIPresContext* aPresContext, PRBool aUpdate);
|
||||
void InitTextStr();
|
||||
nsresult GetPrimaryComboFrame(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame** aFrame);
|
||||
NS_IMETHOD ToggleList(nsIPresContext* aPresContext);
|
||||
|
||||
|
@ -278,9 +277,6 @@ protected:
|
|||
nsIFrame* mTextFrame; // display area frame
|
||||
nsIListControlFrame * mListControlFrame; // ListControl Interface for the dropdown frame
|
||||
|
||||
|
||||
nsCOMPtr<nsIPresState> mPresState; // Need cache state when list is null
|
||||
|
||||
// Resize Reflow Optimization
|
||||
nsSize mCacheSize;
|
||||
nsSize mCachedMaxElementSize;
|
||||
|
|
|
@ -206,23 +206,6 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFileControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
void
|
||||
nsFileControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
if (mTextFrame) {
|
||||
mTextFrame->Reset(aPresContext);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::GetType(PRInt32* aType) const
|
||||
{
|
||||
|
@ -506,7 +489,7 @@ nsFileControlFrame::GetSkipSides() const
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::GetName(nsString* aResult)
|
||||
nsFileControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -527,34 +510,6 @@ nsFileControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
|
||||
|
||||
|
||||
PRInt32
|
||||
nsFileControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFileControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// use our name and the text widgets value
|
||||
aNames[0] = name;
|
||||
nsresult status = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(mTextFrame->GetProperty(nsHTMLAtoms::value, aValues[0]))) {
|
||||
aNumValues = 1;
|
||||
status = PR_TRUE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
|
@ -753,3 +708,9 @@ nsFileControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aSt
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
@ -107,14 +108,7 @@ public:
|
|||
PRInt32 aModType,
|
||||
PRInt32 aHint);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
|
|
@ -392,20 +392,6 @@ nsFormControlFrame::GetScrollbarWidth(float aPixToTwip)
|
|||
return NSIntPixelsToTwips(19, aPixToTwip); // XXX this is windows
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsFormControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFormControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsFormControlFrame::SetClickPoint(nscoord aX, nscoord aY)
|
||||
{
|
||||
|
@ -705,7 +691,7 @@ nsFormControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetName(nsString* aResult)
|
||||
nsFormControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -727,7 +713,7 @@ nsFormControlFrame::GetName(nsString* aResult)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetValue(nsString* aResult)
|
||||
nsFormControlFrame::GetValue(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -748,20 +734,6 @@ nsFormControlFrame::GetValue(nsString* aResult)
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsFormControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
|
||||
// Since JS Submit() calls are not linked to an element, aSubmitter is null.
|
||||
// Return success to allow the call to go through.
|
||||
if (aSubmitter == nsnull) return PR_TRUE;
|
||||
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsFormControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -822,11 +794,6 @@ nsFormControlFrame::GetStyleSize(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsFormControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetFormContent(nsIContent*& aContent) const
|
||||
{
|
||||
|
|
|
@ -150,11 +150,8 @@ public:
|
|||
virtual const nsIID& GetIID();
|
||||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetValue(nsString* aName);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetValue(nsAString* aName);
|
||||
|
||||
/**
|
||||
* Respond to a enter key being pressed
|
||||
|
@ -178,8 +175,6 @@ public:
|
|||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
virtual void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
|
||||
/**
|
||||
* Perform opertations before the widget associated with this frame has been
|
||||
|
|
|
@ -829,7 +829,7 @@ nsFormControlHelper::PaintCheckMark(nsIRenderingContext& aRenderingContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::GetName(nsIContent* aContent,nsString* aResult)
|
||||
nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (nsnull != aContent) {
|
||||
|
@ -851,7 +851,7 @@ nsFormControlHelper::GetName(nsIContent* aContent,nsString* aResult)
|
|||
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::GetValue(nsIContent* aContent, nsString* aResult)
|
||||
nsFormControlHelper::GetValue(nsIContent* aContent, nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (nsnull != aContent) {
|
||||
|
@ -1030,3 +1030,52 @@ void nsFormControlHelper::GetFormCompatibilityMode(nsIPresContext* aPresContext,
|
|||
aCompatMode = eCompatibility_Standard;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::Reset(nsIFrame* aFrame, nsIPresContext* aPresContext)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->Reset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::SaveContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->SaveState(aPresContext, aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::RestoreContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->RestoreState(aPresContext, aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class nsIView;
|
|||
//class nsIPresContext;
|
||||
class nsStyleCoord;
|
||||
class nsFormFrame;
|
||||
class nsIPresState;
|
||||
//class nsIStyleContext;
|
||||
|
||||
#define CSS_NOTSET -1
|
||||
|
@ -154,9 +155,16 @@ public:
|
|||
// Map platform line endings (CR, CRLF, LF) to DOM line endings (LF)
|
||||
static void PlatformToDOMLineBreaks(nsString &aString);
|
||||
|
||||
static nsresult GetValue(nsIContent* aContent, nsString* aResult);
|
||||
static nsresult GetName(nsIContent* aContent, nsString* aResult);
|
||||
static nsresult GetValue(nsIContent* aContent, nsAString* aResult);
|
||||
static nsresult GetName(nsIContent* aContent, nsAString* aResult);
|
||||
static nsresult GetInputElementValue(nsIContent* aContent, nsString* aText, PRBool aInitialValue);
|
||||
static nsresult Reset(nsIFrame* aFrame, nsIPresContext* aPresContext);
|
||||
static nsresult SaveContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState** aState);
|
||||
static nsresult RestoreContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState* aState);
|
||||
|
||||
/**
|
||||
* Utility to convert a string to a PRBool
|
||||
|
|
|
@ -66,63 +66,6 @@ nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
|||
mDefaultValueWasChanged = PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
PRBool successful = PR_TRUE;
|
||||
if ((NS_FORM_INPUT_HIDDEN == type) || (this == aSubmitter)) {
|
||||
// Can not use the nsHTMLButtonControlFrame::IsSuccessful because
|
||||
// it will fail it's test of (this==aSubmitter)
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
} else {
|
||||
successful = PR_FALSE;
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsGfxButtonControlFrame::GetMaxNumValues()
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if ((NS_FORM_INPUT_SUBMIT == type) || (NS_FORM_INPUT_HIDDEN == type)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
if (NS_FORM_INPUT_RESET == type) {
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
nsAutoString value;
|
||||
GetValue(&value);
|
||||
aValues[0] = value;
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
{
|
||||
|
@ -619,28 +562,6 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
#endif
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
// hidden inputs are zero width/height and are finished here
|
||||
if (NS_FORM_INPUT_HIDDEN == type) {
|
||||
aDesiredSize.width = aDesiredSize.height = aDesiredSize.ascent = aDesiredSize.descent = 0;
|
||||
if (aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
// just in case the hidden input is the target of an incremental reflow
|
||||
if (eReflowReason_Incremental == aReflowState.reason) {
|
||||
nsIFrame* targetFrame;
|
||||
aReflowState.reflowCommand->GetTarget(targetFrame);
|
||||
if (this == targetFrame) {
|
||||
nsIFrame* nextFrame;
|
||||
// Remove the next frame from the reflow path
|
||||
aReflowState.reflowCommand->GetNext(nextFrame);
|
||||
}
|
||||
}
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
||||
(kSuggestedNotSet != mSuggestedHeight)) {
|
||||
nsHTMLReflowState suggestedReflowState(aReflowState);
|
||||
|
|
|
@ -87,10 +87,6 @@ public:
|
|||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
#endif
|
||||
PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
|
||||
|
|
|
@ -285,12 +285,7 @@ void
|
|||
nsGfxCheckboxControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsFormControlFrame::InitializeControl(aPresContext);
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
nsresult result = GetDefaultCheckState(&checked);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
SetCheckboxState (aPresContext, checked ? eOn : eOff );
|
||||
}
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
@ -502,54 +497,6 @@ NS_IMETHODIMP nsGfxCheckboxControlFrame::GetProperty(nsIAtom* aName, nsAWritable
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
PRInt32
|
||||
nsGfxCheckboxControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
PRBool
|
||||
nsGfxCheckboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult nameResult = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != nameResult)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool result = PR_TRUE;
|
||||
CheckState state = GetCheckboxState();
|
||||
|
||||
nsAutoString value;
|
||||
nsresult valueResult = GetValue(&value);
|
||||
|
||||
if (eOn != state) {
|
||||
result = PR_FALSE;
|
||||
} else {
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != valueResult) {
|
||||
aValues[0].AssignWithConversion("on");
|
||||
} else {
|
||||
aValues[0] = value;
|
||||
}
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
void
|
||||
nsGfxCheckboxControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRBool checked;
|
||||
GetDefaultCheckState(&checked);
|
||||
SetCheckboxState (aPresContext, checked ? eOn : eOff );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
//
|
||||
|
@ -705,3 +652,9 @@ nsGfxCheckboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxCheckboxControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -106,10 +106,7 @@ public:
|
|||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
// nsIStatefulFrame
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
|
|
@ -246,46 +246,6 @@ nsGfxRadioControlFrame::GetRadioGroupSelectedContent(nsIContent ** aRadioBtn)
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool
|
||||
nsGfxRadioControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool state = GetRadioState();
|
||||
|
||||
if(PR_TRUE != state) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
result = GetValue(&value);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
aValues[0] = value;
|
||||
} else {
|
||||
aValues[0].AssignWithConversion("on");
|
||||
}
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void
|
||||
nsGfxRadioControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRBool checked = PR_TRUE;
|
||||
GetDefaultCheckState(&checked);
|
||||
SetCurrentCheckState(checked);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -385,13 +345,7 @@ void
|
|||
nsGfxRadioControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsFormControlFrame::InitializeControl(aPresContext);
|
||||
|
||||
// set the widget to the initial state
|
||||
PRBool checked = PR_FALSE;
|
||||
nsresult result = GetDefaultCheckState(&checked);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
SetRadioState(aPresContext, checked);
|
||||
}
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -474,3 +428,9 @@ nsGfxRadioControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -103,15 +103,10 @@ public:
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues() { return 1; }
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
|
|
|
@ -216,41 +216,6 @@ nsHTMLButtonControlFrame::GetDefaultLabel(nsString& aString)
|
|||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
nsHTMLButtonControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
nsAutoString value;
|
||||
nsresult valResult = GetValue(&value);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == valResult) {
|
||||
aValues[0] = value;
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetType(PRInt32* aType) const
|
||||
{
|
||||
|
@ -267,7 +232,7 @@ nsHTMLButtonControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetName(nsString* aResult)
|
||||
nsHTMLButtonControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -288,7 +253,7 @@ nsHTMLButtonControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetValue(nsString* aResult)
|
||||
nsHTMLButtonControlFrame::GetValue(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -308,21 +273,6 @@ nsHTMLButtonControlFrame::GetValue(nsString* aResult)
|
|||
return result;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
PRBool successful = PR_TRUE;
|
||||
if (this == (aSubmitter)) {
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
} else {
|
||||
successful = PR_FALSE;
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
|
@ -863,3 +813,8 @@ nsHTMLButtonControlFrame::AppendFrames(nsIPresContext* aPresContext,
|
|||
aFrameList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -129,16 +129,12 @@ public:
|
|||
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
||||
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetValue(nsString* aName);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetValue(nsAString* aName);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext*) {};
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
|
|
@ -120,11 +120,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsFont.h"
|
||||
class nsFormFrame;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const = 0;
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName) = 0;
|
||||
NS_IMETHOD GetName(nsAString* aName) = 0;
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE) = 0;
|
||||
|
||||
|
@ -71,15 +71,6 @@ public:
|
|||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
virtual void Reset(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter) = 0;
|
||||
|
||||
virtual PRInt32 GetMaxNumValues() = 0;
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames) = 0;
|
||||
|
||||
virtual void SetFormFrame(nsFormFrame* aFrame) = 0;
|
||||
|
||||
/**
|
||||
|
@ -140,7 +131,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Notification that the content has been reset
|
||||
*/
|
||||
NS_IMETHOD OnContentReset() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsFont.h"
|
||||
class nsFormFrame;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
class nsIPresState;
|
||||
|
||||
|
@ -66,10 +66,9 @@ public:
|
|||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame) = 0;
|
||||
|
||||
/**
|
||||
* Get the Selected Item's String
|
||||
*
|
||||
* Get the display string for an item
|
||||
*/
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr) = 0;
|
||||
NS_IMETHOD GetOptionText(PRInt32 aIndex, nsAString & aStr) = 0;
|
||||
|
||||
/**
|
||||
* Get the Selected Item's index
|
||||
|
@ -113,29 +112,13 @@ public:
|
|||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetPresState(nsIPresState * aState) = 0;
|
||||
NS_IMETHOD UpdateSelection() = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SaveStateInternal(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState) = 0;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RestoreStateInternal(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState) = 0;
|
||||
|
||||
/**
|
||||
* Return the the frame that the options will be inserted into
|
||||
*/
|
||||
|
|
|
@ -66,11 +66,6 @@ public:
|
|||
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index) = 0;
|
||||
|
||||
/**
|
||||
* Sets the select state of the option at index
|
||||
*/
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 index, PRBool value) = 0;
|
||||
|
||||
/**
|
||||
* Sets the select state of the option at index
|
||||
*/
|
||||
|
@ -82,16 +77,17 @@ public:
|
|||
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
|
||||
|
||||
/**
|
||||
* Notification that an option has been disabled
|
||||
* Notify the frame when an option is selected
|
||||
*/
|
||||
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0;
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected) = 0;
|
||||
|
||||
/**
|
||||
* This only applies to Comboboxes, no-op for ListBoxes
|
||||
* For the content model to tell if there's a dummy frame or not
|
||||
*/
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame) = 0;
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,7 +51,7 @@ class nsIGfxTextControlFrame2 : public nsISupports
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
|
||||
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIImageControlFrame.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsFormControlHelper.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
@ -78,7 +79,8 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|||
|
||||
#define nsImageControlFrameSuper nsImageFrame
|
||||
class nsImageControlFrame : public nsImageControlFrameSuper,
|
||||
public nsIFormControlFrame
|
||||
public nsIFormControlFrame,
|
||||
public nsIImageControlFrame
|
||||
{
|
||||
public:
|
||||
nsImageControlFrame();
|
||||
|
@ -122,18 +124,9 @@ public:
|
|||
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
|
||||
PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
|
||||
virtual void Reset(nsIPresContext*) {};
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
@ -156,6 +149,11 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
// nsIImageControlFrame
|
||||
NS_IMETHOD GetClickedX(PRInt32* aX);
|
||||
NS_IMETHOD GetClickedY(PRInt32* aY);
|
||||
|
||||
protected:
|
||||
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
|
||||
|
@ -225,6 +223,10 @@ nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIImageControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIImageControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -403,7 +405,7 @@ nsImageControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetName(nsString* aResult)
|
||||
nsImageControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
if (nsnull == aResult) {
|
||||
return NS_OK;
|
||||
|
@ -412,55 +414,6 @@ nsImageControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsImageControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
// Image control will only add it's value if it is clicked on.
|
||||
// XXX Is this right?
|
||||
return (this == (aSubmitter));
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsImageControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsImageControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
char buf[20];
|
||||
aNumValues = 2;
|
||||
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.x);
|
||||
aValues[0].AssignWithConversion(&buf[0]);
|
||||
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.y);
|
||||
aValues[1].AssignWithConversion(&buf[0]);
|
||||
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result && (name.Length() > 0)) {
|
||||
aNames[0] = name;
|
||||
aNames[0].AppendWithConversion(".x");
|
||||
aNames[1] = name;
|
||||
aNames[1].AppendWithConversion(".y");
|
||||
} else {
|
||||
// If the Image Element has no name, simply return x and y
|
||||
// to Nav and IE compatability.
|
||||
aNames[0].AssignWithConversion("x");
|
||||
aNames[1].AssignWithConversion("y");
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetCursor(nsIPresContext* aPresContext,
|
||||
nsPoint& aPoint,
|
||||
|
@ -553,3 +506,22 @@ NS_IMETHODIMP nsImageControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHei
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedX(PRInt32* aX)
|
||||
{
|
||||
*aX = mLastClickPoint.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedY(PRInt32* aY)
|
||||
{
|
||||
*aY = mLastClickPoint.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -55,10 +55,10 @@
|
|||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsCWeakReference.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
|
||||
class nsIDOMHTMLSelectElement;
|
||||
class nsIDOMHTMLCollection;
|
||||
|
@ -68,6 +68,7 @@ class nsIViewManager;
|
|||
class nsIPresContext;
|
||||
class nsVoidArray;
|
||||
class nsIScrollableView;
|
||||
class nsIStatefulFrame;
|
||||
|
||||
class nsListControlFrame;
|
||||
class nsSelectUpdateTimer;
|
||||
|
@ -229,22 +230,18 @@ public:
|
|||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
||||
const nsFont*& aFont);
|
||||
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
virtual void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext* aPresContext) { ResetList(aPresContext); }
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void SetFormFrame(nsFormFrame* aFrame);
|
||||
virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -266,7 +263,7 @@ public:
|
|||
// nsIListControlFrame
|
||||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
|
||||
NS_IMETHOD GetSelectedIndex(PRInt32* aIndex);
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr);
|
||||
NS_IMETHOD GetOptionText(PRInt32 aIndex, nsAString & aStr);
|
||||
NS_IMETHOD CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents);
|
||||
NS_IMETHOD GetMaximumSize(nsSize &aSize);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
@ -274,26 +271,21 @@ public:
|
|||
NS_IMETHOD SyncViewWithFrame(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD AboutToDropDown();
|
||||
NS_IMETHOD AboutToRollup();
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent);
|
||||
NS_IMETHOD SetPresState(nsIPresState * aState) { mPresState = aState; return NS_OK;}
|
||||
NS_IMETHOD UpdateSelection();
|
||||
NS_IMETHOD ComboboxUpdateSelection(PRBool aForceUpdate, PRBool aSendEvent);
|
||||
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) { mOverrideReflowOpt = aValue; return NS_OK; }
|
||||
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** aFrame);
|
||||
|
||||
NS_IMETHOD SaveStateInternal(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreStateInternal(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
|
||||
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
|
||||
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent);
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) { return NS_OK; }
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
|
||||
//nsIDOMEventListener
|
||||
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
||||
|
@ -313,98 +305,70 @@ public:
|
|||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
// Static Methods
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// Static Methods
|
||||
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
|
||||
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRInt32 aIndex);
|
||||
static PRBool GetOptionValue(nsIDOMHTMLCollection& aCollecton, PRInt32 aIndex, nsString& aValue);
|
||||
|
||||
// Weak Reference
|
||||
nsCWeakReferent *WeakReferent()
|
||||
{ return &mWeakReferent; }
|
||||
|
||||
// Helper
|
||||
// Helper
|
||||
void SetPassId(PRInt16 aId) { mPassId = aId; }
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD GetSelectedIndexFromDOM(PRInt32* aIndex); // from DOM
|
||||
NS_IMETHOD IsTargetOptionDisabled(PRBool &aIsDisabled);
|
||||
NS_IMETHOD IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||
PRBool IsClickingInCombobox(nsIDOMEvent* aMouseEvent);
|
||||
void AdjustIndexForDisabledOpt(PRInt32 &anNewIndex, PRInt32 &anOldIndex,
|
||||
PRBool &aDoSetNewIndex, PRBool &aWasDisabled,
|
||||
void AdjustIndexForDisabledOpt(PRInt32 aStartIndex, PRInt32 &anNewIndex,
|
||||
PRInt32 aNumOptions, PRInt32 aDoAdjustInc, PRInt32 aDoAdjustIncNext);
|
||||
virtual void ResetList(nsIPresContext* aPresContext, nsVoidArray * aInxList = nsnull);
|
||||
|
||||
// PresState Helper Methods
|
||||
nsresult GetPresStateAndValueArray(nsISupportsArray ** aSuppArray);
|
||||
nsresult SetOptionIntoPresState(nsISupportsArray * aSuppArray,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 anItemNum);
|
||||
nsresult SetSelectionInPresState(PRInt32 aIndex, PRBool aValue);
|
||||
nsresult RemoveOptionFromPresState(nsISupportsArray * aSuppArray,
|
||||
PRInt32 aIndex);
|
||||
|
||||
nsListControlFrame();
|
||||
virtual ~nsListControlFrame();
|
||||
|
||||
// nsScrollFrame overrides
|
||||
// Override the widget created for the list box so a Borderless top level widget is created
|
||||
// for drop-down lists.
|
||||
// nsScrollFrame overrides
|
||||
// Override the widget created for the list box so a Borderless top level
|
||||
// widget is created for drop-down lists.
|
||||
virtual nsresult CreateScrollingViewWidget(nsIView* aView, const nsStyleDisplay* aDisplay);
|
||||
virtual nsresult GetScrollingParentView(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParent,
|
||||
nsIView** aParentView);
|
||||
PRInt32 GetNumberOfOptions();
|
||||
|
||||
// Utility methods
|
||||
// Utility methods
|
||||
nsresult GetSizeAttribute(PRInt32 *aSize);
|
||||
PRInt32 GetNumberOfSelections();
|
||||
nsIContent* GetOptionFromContent(nsIContent *aContent);
|
||||
nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, PRInt32& aOldIndex, PRInt32& aCurIndex);
|
||||
PRInt32 GetSelectedIndexFromContent(nsIContent *aContent);
|
||||
nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, PRInt32& aCurIndex);
|
||||
nsIContent* GetOptionContent(PRInt32 aIndex);
|
||||
PRBool IsContentSelected(nsIContent* aContent);
|
||||
PRBool IsContentSelectedByIndex(PRInt32 aIndex);
|
||||
void SetContentSelected(PRInt32 aIndex,
|
||||
PRBool aSelected,
|
||||
PRBool aDoScrollTo = PR_TRUE,
|
||||
nsIPresShell * aPresShell = nsnull);
|
||||
void SetContentSelected(PRInt32 aIndex,
|
||||
nsIContent * aContent,
|
||||
PRBool aSelected,
|
||||
PRBool aDoScrollTo = PR_TRUE,
|
||||
nsIPresShell * aPresShell = nsnull);
|
||||
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
|
||||
nsresult Deselect();
|
||||
nsIFrame *GetOptionFromChild(nsIFrame* aParentFrame);
|
||||
PRBool IsAncestor(nsIView* aAncestor, nsIView* aChild);
|
||||
nsIView* GetViewFor(nsIWidget* aWidget);
|
||||
PRBool IsInDropDownMode();
|
||||
PRBool IsOptionElement(nsIContent* aContent);
|
||||
PRBool IsOptionElementFrame(nsIFrame *aFrame);
|
||||
nsIFrame *GetSelectableFrame(nsIFrame *aFrame);
|
||||
void DisplaySelected(nsIContent* aContent);
|
||||
void DisplayDeselected(nsIContent* aContent);
|
||||
void ForceRedraw(nsIPresContext* aPresContext);
|
||||
PRBool IsOptionGroup(nsIFrame* aFrame);
|
||||
void SingleSelection();
|
||||
void MultipleSelection(PRBool aIsShift, PRBool aIsControl);
|
||||
void SelectIndex(PRInt32 aIndex);
|
||||
void ToggleSelected(PRInt32 aIndex);
|
||||
void ClearSelection();
|
||||
void ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue);
|
||||
void SingleSelection(PRInt32 aSelectedIndex, PRBool aDoToggle);
|
||||
void ExtendedSelection(PRInt32 aStartIndex,
|
||||
PRInt32 aEndIndex,
|
||||
PRBool aClearAll);
|
||||
void PerformSelection(PRInt32 aSelectedIndex,
|
||||
PRBool aIsShift,
|
||||
PRBool aIsControl);
|
||||
void ResetSelectedItem();
|
||||
PRBool CheckIfAllFramesHere();
|
||||
|
||||
PRBool HasSameContent(nsIFrame* aFrame1, nsIFrame* aFrame2);
|
||||
void HandleListSelection(nsIDOMEvent * aDOMEvent);
|
||||
PRInt32 GetSelectedIndexFromFrame(nsIFrame *aHitFrame);
|
||||
PRInt32 GetIndexFromContent(nsIContent *aContent);
|
||||
void HandleListSelection(nsIDOMEvent * aDOMEvent, PRInt32 selectedIndex);
|
||||
PRBool IsLeftButton(nsIDOMEvent* aMouseEvent);
|
||||
|
||||
nsresult SetOptionsSelectedFromFrame(PRInt32 aStartIndex,
|
||||
PRInt32 aEndIndex,
|
||||
PRBool aValue,
|
||||
PRBool aClearAll);
|
||||
nsresult ToggleOptionSelectedFromFrame(PRInt32 aIndex);
|
||||
void GetScrollableView(nsIScrollableView*& aScrollableView);
|
||||
|
||||
// Timer Methods
|
||||
|
@ -413,16 +377,16 @@ protected:
|
|||
void ItemsHaveBeenRemoved(nsIPresContext * aPresContext);
|
||||
|
||||
// onChange detection
|
||||
nsresult SelectionChanged(nsIContent* aContent);
|
||||
nsresult SelectionChanged();
|
||||
|
||||
// Data Members
|
||||
nsFormFrame* mFormFrame;
|
||||
PRInt32 mSelectedIndex;
|
||||
PRInt32 mOldSelectedIndex;
|
||||
|
||||
PRInt32 mStartSelectionIndex;
|
||||
PRInt32 mEndSelectionIndex;
|
||||
PRBool mChangesNotNotified;
|
||||
|
||||
PRInt32 mSelectedIndexWhenPoppedDown;
|
||||
PRInt32 mStartExtendedIndex;
|
||||
PRInt32 mEndExtendedIndex;
|
||||
PRPackedBool mIsInitializedFromContent;
|
||||
nsIComboboxControlFrame *mComboboxFrame;
|
||||
PRPackedBool mButtonDown;
|
||||
nscoord mMaxWidth;
|
||||
|
@ -430,9 +394,6 @@ protected:
|
|||
PRPackedBool mIsCapturingMouseEvents;
|
||||
PRInt32 mNumDisplayRows;
|
||||
|
||||
nsVoidArray * mSelectionCache;
|
||||
PRInt32 mSelectionCacheLength;
|
||||
|
||||
PRBool mIsAllContentHere;
|
||||
PRPackedBool mIsAllFramesHere;
|
||||
PRPackedBool mHasBeenInitialized;
|
||||
|
@ -440,13 +401,8 @@ protected:
|
|||
|
||||
PRPackedBool mOverrideReflowOpt;
|
||||
|
||||
PRInt32 mDelayedIndexSetting;
|
||||
PRPackedBool mDelayedValueSetting;
|
||||
|
||||
nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context.
|
||||
|
||||
nsCOMPtr<nsIPresState> mPresState; // Need cache state when list is null
|
||||
|
||||
nsCOMPtr<nsIListEventListener> mEventListener; // ref counted
|
||||
nsCWeakReferent mWeakReferent; // so this obj can be used as a weak ptr
|
||||
|
||||
|
@ -459,6 +415,8 @@ protected:
|
|||
// Update timer
|
||||
nsSelectUpdateTimer * mUpdateTimer;
|
||||
|
||||
nsIFrame* mDummyFrame;
|
||||
|
||||
//Resize Reflow OpitmizationSize;
|
||||
nsSize mCacheSize;
|
||||
nsSize mCachedMaxElementSize;
|
||||
|
|
|
@ -2203,7 +2203,7 @@ FrameManager::RestoreFrameStateFor(nsIPresContext* aPresContext, nsIFrame* aFram
|
|||
|
||||
nsCAutoString stateKey;
|
||||
rv = GenerateStateKey(content, aID, stateKey);
|
||||
if(NS_FAILED(rv) || stateKey.IsEmpty()) {
|
||||
if (NS_FAILED(rv) || stateKey.IsEmpty()) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2365,8 +2365,17 @@ FrameManager::GenerateStateKey(nsIContent* aContent,
|
|||
|
||||
nsCOMPtr<nsIContent> formContent(do_QueryInterface(formElement));
|
||||
mHTMLForms->IndexOf(formContent, index, PR_FALSE);
|
||||
if (index <= -1) {
|
||||
mHTMLForms->IndexOf(formContent, index, PR_TRUE);
|
||||
}
|
||||
NS_ASSERTION(index > -1,
|
||||
"nsFrameManager::GenerateStateKey didn't find form index!");
|
||||
if (index <= -1) {
|
||||
PRUint32 formsLength;
|
||||
// Assume the form index is going to be added to the form content next
|
||||
mHTMLForms->GetLength(&formsLength, PR_FALSE);
|
||||
index = (PRInt32)formsLength;
|
||||
}
|
||||
if (index > -1) {
|
||||
KeyAppendInt(index, aKey);
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ optgroup:before {
|
|||
input[disabled],
|
||||
textarea[disabled],
|
||||
option[disabled],
|
||||
optgroup[disabled],
|
||||
select[disabled],
|
||||
select[disabled]:-moz-display-comboboxcontrol-frame {
|
||||
color: GrayText;
|
||||
|
|
|
@ -12,3 +12,4 @@ nsIFormProcessor.h
|
|||
nsISelectControlFrame.h
|
||||
nsIGfxTextControlFrame.h
|
||||
nsIFormManager.h
|
||||
nsIImageControlFrame.h
|
||||
|
|
|
@ -31,6 +31,7 @@ MODULE = layout
|
|||
EXPORTS = \
|
||||
nsIFormManager.h \
|
||||
nsIListControlFrame.h \
|
||||
nsIImageControlFrame.h \
|
||||
nsIComboboxControlFrame.h \
|
||||
nsIFormControlFrame.h \
|
||||
nsIRadioControlFrame.h \
|
||||
|
|
|
@ -23,6 +23,7 @@ DEPTH=..\..\..\..
|
|||
|
||||
EXPORTS=nsIFormManager.h \
|
||||
nsIListControlFrame.h \
|
||||
nsIImageControlFrame.h \
|
||||
nsIComboboxControlFrame.h \
|
||||
nsIRadioControlFrame.h \
|
||||
nsICheckboxControlFrame.h \
|
||||
|
@ -30,7 +31,7 @@ EXPORTS=nsIFormManager.h \
|
|||
nsIFormSubmitObserver.h \
|
||||
nsIFormProcessor.h \
|
||||
nsISelectControlFrame.h \
|
||||
nsIGfxTextControlFrame.h
|
||||
nsIGfxTextControlFrame.h
|
||||
|
||||
MODULE=layout
|
||||
|
||||
|
|
|
@ -120,11 +120,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetAbsoluteRect(nsRect* aRect) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsFont.h"
|
||||
class nsFormFrame;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const = 0;
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName) = 0;
|
||||
NS_IMETHOD GetName(nsAString* aName) = 0;
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE) = 0;
|
||||
|
||||
|
@ -71,15 +71,6 @@ public:
|
|||
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
virtual void Reset(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter) = 0;
|
||||
|
||||
virtual PRInt32 GetMaxNumValues() = 0;
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames) = 0;
|
||||
|
||||
virtual void SetFormFrame(nsFormFrame* aFrame) = 0;
|
||||
|
||||
/**
|
||||
|
@ -140,7 +131,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Notification that the content has been reset
|
||||
*/
|
||||
NS_IMETHOD OnContentReset() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -47,26 +47,13 @@ class nsIFrame;
|
|||
{ 0x80, 0x2d, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
|
||||
|
||||
|
||||
// XXX We can't get rid of this entirely yet ... layout is checking it.
|
||||
/**
|
||||
* Interface to provide submitting and resetting forms
|
||||
**/
|
||||
class nsIFormManager : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMMANAGER_IID)
|
||||
/**
|
||||
* Reset the values of all of this manager's controls back to their
|
||||
* initial values. This is in response to a reset button being pushed.
|
||||
*/
|
||||
NS_IMETHOD OnReset(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
/**
|
||||
* Submit the values of this manager's controls depending on its action,
|
||||
* method attributes. This in response to a submit button being clicked.
|
||||
* @param aPresContext the presentation context
|
||||
* @param aFrame the frame of the submit button
|
||||
* @param aSubmitter the control that caused the submit
|
||||
*/
|
||||
NS_IMETHOD OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class nsIGfxTextControlFrame2 : public nsISupports
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
|
||||
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "nsFont.h"
|
||||
class nsFormFrame;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
class nsAString;
|
||||
class nsIContent;
|
||||
class nsIPresState;
|
||||
|
||||
|
@ -66,10 +66,9 @@ public:
|
|||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame) = 0;
|
||||
|
||||
/**
|
||||
* Get the Selected Item's String
|
||||
*
|
||||
* Get the display string for an item
|
||||
*/
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr) = 0;
|
||||
NS_IMETHOD GetOptionText(PRInt32 aIndex, nsAString & aStr) = 0;
|
||||
|
||||
/**
|
||||
* Get the Selected Item's index
|
||||
|
@ -113,29 +112,13 @@ public:
|
|||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetPresState(nsIPresState * aState) = 0;
|
||||
NS_IMETHOD UpdateSelection() = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD SaveStateInternal(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState) = 0;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD RestoreStateInternal(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState) = 0;
|
||||
|
||||
/**
|
||||
* Return the the frame that the options will be inserted into
|
||||
*/
|
||||
|
|
|
@ -66,11 +66,6 @@ public:
|
|||
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index) = 0;
|
||||
|
||||
/**
|
||||
* Sets the select state of the option at index
|
||||
*/
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 index, PRBool value) = 0;
|
||||
|
||||
/**
|
||||
* Sets the select state of the option at index
|
||||
*/
|
||||
|
@ -82,16 +77,17 @@ public:
|
|||
NS_IMETHOD DoneAddingContent(PRBool aIsDone) = 0;
|
||||
|
||||
/**
|
||||
* Notification that an option has been disabled
|
||||
* Notify the frame when an option is selected
|
||||
*/
|
||||
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent) = 0;
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected) = 0;
|
||||
|
||||
/**
|
||||
* This only applies to Comboboxes, no-op for ListBoxes
|
||||
* For the content model to tell if there's a dummy frame or not
|
||||
*/
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) = 0;
|
||||
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame) = 0;
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,7 +51,7 @@ class nsIGfxTextControlFrame2 : public nsISupports
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IGFXTEXTCONTROLFRAME2_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0;
|
||||
|
||||
NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0;
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsGfxCheckboxControlFrame.obj \
|
||||
.\$(OBJDIR)\nsGfxRadioControlFrame.obj \
|
||||
.\$(OBJDIR)\nsIsIndexFrame.obj \
|
||||
.\$(OBJDIR)\nsRadioControlGroup.obj
|
||||
.\$(OBJDIR)\nsRadioControlGroup.obj
|
||||
|
||||
|
||||
LINCS= -I..\..\base\src \
|
||||
|
|
|
@ -57,14 +57,12 @@
|
|||
#include "nsIDOMNSHTMLOptionCollectn.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -341,19 +339,19 @@ nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIComboboxControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIComboboxControlFrame*) this);
|
||||
*aInstancePtr = (void*)(nsIComboboxControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
||||
*aInstancePtr = (void*)(nsIFormControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
||||
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
|
||||
*aInstancePtr = (void*)(nsIAnonymousContentCreator*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) {
|
||||
*aInstancePtr = (void *)(nsISelectControlFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
||||
*aInstancePtr = (void *)(nsIStatefulFrame*)this;
|
||||
*aInstancePtr = (void*)(nsIStatefulFrame*)this;
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIRollupListener))) {
|
||||
*aInstancePtr = (void*)(nsIRollupListener*)this;
|
||||
|
@ -411,94 +409,30 @@ nsComboboxControlFrame::Init(nsIPresContext* aPresContext,
|
|||
return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool
|
||||
nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
// If nothing is selected, and we have options, select item 0
|
||||
// This is a UI decision that goes against the HTML 4 spec.
|
||||
// See bugzilla bug 15841 for justification of this deviation.
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::MakeSureSomethingIsSelected(nsIPresContext* aPresContext)
|
||||
{
|
||||
REFLOW_DEBUG_MSG("CBX::MakeSureSomethingIsSelected\n");
|
||||
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if (NS_SUCCEEDED(rv) && fcFrame) {
|
||||
// If nothing selected, and there are options, default selection to item 0
|
||||
rv = mListControlFrame->GetSelectedIndex(&mSelectedIndex);
|
||||
if (NS_SUCCEEDED(rv) && (mSelectedIndex < 0)) {
|
||||
// Find out if there are any options in the list to select
|
||||
PRInt32 length = 0;
|
||||
mListControlFrame->GetNumberOfOptions(&length);
|
||||
if (length > 0) {
|
||||
// Set listbox selection to first item in the list box
|
||||
rv = fcFrame->SetProperty(aPresContext, nsHTMLAtoms::selectedindex, NS_ConvertASCIItoUCS2("0"));
|
||||
mSelectedIndex = 0;
|
||||
} else {
|
||||
UpdateSelection(PR_FALSE, PR_TRUE, mSelectedIndex); // Needed to reflow when removing last option
|
||||
}
|
||||
}
|
||||
|
||||
// Don't NS_RELEASE fcFrame here as it isn't addRef'd in the QI (???)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Initialize the text string in the combobox using either the current
|
||||
// selection in the list box or the first item item in the list box.
|
||||
void
|
||||
nsComboboxControlFrame::InitTextStr(nsIPresContext* aPresContext, PRBool aUpdate)
|
||||
nsComboboxControlFrame::InitTextStr()
|
||||
{
|
||||
MakeSureSomethingIsSelected(aPresContext);
|
||||
|
||||
PRInt32 selectedIndex;
|
||||
mListControlFrame->GetSelectedIndex(&selectedIndex);
|
||||
// Update the selected text string
|
||||
mListControlFrame->GetSelectedItem(mTextStr);
|
||||
if (selectedIndex == -1) {
|
||||
mListControlFrame->GetOptionText(0, mTextStr);
|
||||
} else {
|
||||
mListControlFrame->GetOptionText(selectedIndex, mTextStr);
|
||||
}
|
||||
|
||||
// Update the display by setting the value attribute
|
||||
mDisplayContent->SetText(mTextStr.get(), mTextStr.Length(), aUpdate);
|
||||
// Update the display by setting the value attribute
|
||||
mDisplayContent->SetText(mTextStr.get(), mTextStr.Length(), PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
||||
// Reset the combo box back to it original state.
|
||||
|
||||
void
|
||||
nsComboboxControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
if (mPresState) {
|
||||
nsIStatefulFrame* sFrame = nsnull;
|
||||
nsresult res = mListControlFrame->QueryInterface(NS_GET_IID(nsIStatefulFrame),
|
||||
(void**)&sFrame);
|
||||
if (NS_SUCCEEDED(res) && sFrame) {
|
||||
res = sFrame->RestoreState(mPresContext, mPresState);
|
||||
NS_RELEASE(sFrame);
|
||||
}
|
||||
mPresState = do_QueryInterface(nsnull);
|
||||
}
|
||||
|
||||
// Reset the dropdown list to its original state
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult result = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if ((NS_OK == result) && (nsnull != fcFrame)) {
|
||||
fcFrame->Reset(aPresContext);
|
||||
}
|
||||
|
||||
// Update the combobox using the text string returned from the dropdown list
|
||||
InitTextStr(aPresContext, PR_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
nsComboboxControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
Reset(aPresContext);
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
|
@ -1703,7 +1637,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Reflow the dropdown list to match the width of the display + button
|
||||
ReflowComboChildFrame(mDropdownFrame, aPresContext, dropdownDesiredSize, firstPassState, aStatus,
|
||||
aDesiredSize.width, NS_UNCONSTRAINEDSIZE);
|
||||
lcf->SetPassId(0); // reset it back
|
||||
lcf->SetPassId(0);
|
||||
}
|
||||
|
||||
#else // DO_NEW_REFLOW
|
||||
|
@ -1789,7 +1723,7 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
//--------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetName(nsString* aResult)
|
||||
nsComboboxControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -1809,44 +1743,6 @@ nsComboboxControlFrame::GetName(nsString* aResult)
|
|||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsComboboxControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*XXX-REMOVE
|
||||
PRBool
|
||||
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// use our name and the text widgets value
|
||||
aNames[0] = name;
|
||||
aValues[0] = mTextStr;
|
||||
aNumValues = 1;
|
||||
nsresult status = PR_TRUE;
|
||||
return status;
|
||||
}
|
||||
*/
|
||||
|
||||
PRBool
|
||||
nsComboboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsIFormControlFrame* fcFrame = nsnull;
|
||||
nsresult result = mDropdownFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame);
|
||||
if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) {
|
||||
return fcFrame->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||
const nsPoint& aPoint,
|
||||
|
@ -1933,18 +1829,9 @@ nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame)
|
|||
mDropdownFrame = aDropDownFrame;
|
||||
|
||||
if (NS_OK != mDropdownFrame->QueryInterface(NS_GET_IID(nsIListControlFrame), (void**)&mListControlFrame)) {
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The ListControlFrame was just created and added to the comboxbox
|
||||
// so provide it with a PresState so it can restore itself
|
||||
// when it does its first "Reset"
|
||||
if (mPresState) {
|
||||
mListControlFrame->SetPresState(mPresState);
|
||||
mPresState = do_QueryInterface(nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1991,9 +1878,10 @@ NS_IMETHODIMP
|
|||
nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, PRInt32 aNewIndex)
|
||||
{
|
||||
if (mListControlFrame) {
|
||||
// Check to see if the selection changed
|
||||
// Check to see if the selection changed
|
||||
if (mSelectedIndex != aNewIndex || aForceUpdate) {
|
||||
mListControlFrame->GetSelectedItem(mTextStr); // Update text box
|
||||
mListControlFrame->GetOptionText(aNewIndex, mTextStr);
|
||||
SelectionChanged();
|
||||
|
||||
// Fix for Bug 42661 (remove comment later)
|
||||
#ifdef DO_REFLOW_DEBUG
|
||||
|
@ -2002,9 +1890,7 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp
|
|||
delete [] str;
|
||||
#endif
|
||||
mSelectedIndex = aNewIndex;
|
||||
mListControlFrame->UpdateSelection(aDoDispatchEvent, aForceUpdate, mContent);
|
||||
} else {
|
||||
mSelectedIndex = aNewIndex;
|
||||
mListControlFrame->UpdateSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2075,9 +1961,9 @@ nsComboboxControlFrame::SelectionChanged()
|
|||
rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||
ReflowDirtyChild(shell, (nsIFrame*) mDisplayFrame);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mPresContext->GetShell(getter_AddRefs(presShell));
|
||||
presShell->FlushPendingNotifications(PR_FALSE);
|
||||
// nsCOMPtr<nsIPresShell> presShell;
|
||||
// mPresContext->GetShell(getter_AddRefs(presShell));
|
||||
// presShell->FlushPendingNotifications(PR_FALSE);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -2136,19 +2022,6 @@ nsComboboxControlFrame::RemoveOption(nsIPresContext* aPresContext, PRInt32 aInde
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SetOptionSelected(PRInt32 aIndex, PRBool aValue)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(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)
|
||||
{
|
||||
|
@ -2162,19 +2035,43 @@ nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue)
|
|||
return rv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Used by layout to determine if we have a fake option
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OptionDisabled(nsIContent * aContent)
|
||||
nsComboboxControlFrame::GetDummyFrame(nsIFrame** aFrame)
|
||||
{
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
nsresult rv = mDropdownFrame->QueryInterface(NS_GET_IID(nsISelectControlFrame),
|
||||
(void**)&listFrame);
|
||||
if (NS_SUCCEEDED(rv) && listFrame) {
|
||||
rv = listFrame->OptionDisabled(aContent);
|
||||
NS_RELEASE(listFrame);
|
||||
nsISelectControlFrame* listFrame;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->GetDummyFrame(aFrame);
|
||||
}
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SetDummyFrame(nsIFrame* aFrame)
|
||||
{
|
||||
nsISelectControlFrame* listFrame;
|
||||
NS_ASSERTION(mDropdownFrame, "No dropdown frame!");
|
||||
|
||||
CallQueryInterface(mDropdownFrame, &listFrame);
|
||||
NS_ASSERTION(listFrame, "No list frame!");
|
||||
|
||||
if (listFrame) {
|
||||
listFrame->SetDummyFrame(aFrame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// End nsISelectControlFrame
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -2511,7 +2408,7 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
|||
mPopupFrames.SetFrames(aChildList);
|
||||
} else {
|
||||
rv = nsAreaFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
||||
InitTextStr(aPresContext, PR_FALSE);
|
||||
InitTextStr();
|
||||
|
||||
nsIFrame * child = aChildList;
|
||||
while (child != nsnull) {
|
||||
|
@ -2575,40 +2472,6 @@ nsComboboxControlFrame::Rollup()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIStatefulFrame
|
||||
// XXX Do we need to implement this here? It is already implemented in
|
||||
// the ListControlFrame, our child...
|
||||
//----------------------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
||||
{
|
||||
if (!mListControlFrame) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// The ListControlFrame ignores requests to Save its state
|
||||
// when it is owned by a combobox
|
||||
// so we call the internal SaveState here
|
||||
return mListControlFrame->SaveStateInternal(aPresContext, aState);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
||||
{
|
||||
// The ListControlFrame ignores requests to Restore its state
|
||||
// when it is owned by a combobox
|
||||
// so we cache it here if the frame hasn't been created yet
|
||||
// or we call the internal RestoreState here
|
||||
if (!mListControlFrame) {
|
||||
mPresState = aState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mListControlFrame->RestoreStateInternal(aPresContext, aState);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsComboboxControlFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
|
@ -2706,3 +2569,55 @@ nsComboboxControlFrame::GetScrollableView(nsIScrollableView** aView)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// gets the content (an option) by index and then set it as
|
||||
// being selected or not selected
|
||||
//---------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected)
|
||||
{
|
||||
if (aSelected && !mDroppedDown) {
|
||||
mListControlFrame->GetOptionText(aIndex, mTextStr);
|
||||
SelectionChanged();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::OnContentReset()
|
||||
{
|
||||
if (mListControlFrame) {
|
||||
nsCOMPtr<nsIFormControlFrame> formControl =
|
||||
do_QueryInterface(mListControlFrame);
|
||||
formControl->OnContentReset();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// nsIStatefulFrame
|
||||
//--------------------------------------------------------
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::SaveState(nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
|
||||
if (stateful) {
|
||||
return stateful->SaveState(aPresContext, aState);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComboboxControlFrame::RestoreState(nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsCOMPtr<nsIStatefulFrame> stateful(do_QueryInterface(mListControlFrame));
|
||||
if (stateful) {
|
||||
return stateful->RestoreState(aPresContext, aState);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@
|
|||
#include "nsVoidArray.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIRollupListener.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsIScrollableViewProvider.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
|
||||
class nsFormFrame;
|
||||
class nsIView;
|
||||
|
@ -82,9 +82,9 @@ class nsComboboxControlFrame : public nsAreaFrame,
|
|||
public nsIComboboxControlFrame,
|
||||
public nsIAnonymousContentCreator,
|
||||
public nsISelectControlFrame,
|
||||
public nsIStatefulFrame,
|
||||
public nsIRollupListener,
|
||||
public nsIScrollableViewProvider
|
||||
public nsIScrollableViewProvider,
|
||||
public nsIStatefulFrame
|
||||
{
|
||||
public:
|
||||
friend nsresult NS_NewComboboxControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlags);
|
||||
|
@ -144,19 +144,16 @@ public:
|
|||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void InitializeControl(nsIPresContext* aPresContext);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
||||
const nsFont*& aFont);
|
||||
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
||||
|
@ -192,15 +189,13 @@ public:
|
|||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
|
||||
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
|
||||
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent);
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext); // Default to option 0
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
|
||||
//nsIRollupListener
|
||||
// NS_DECL_NSIROLLUPLISTENER
|
||||
|
@ -219,6 +214,10 @@ public:
|
|||
// nsIScrollableViewProvider
|
||||
NS_IMETHOD GetScrollableView(nsIScrollableView** aView);
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD CreateDisplayFrame(nsIPresContext* aPresContext);
|
||||
|
||||
|
@ -249,7 +248,7 @@ protected:
|
|||
void ShowPopup(PRBool aShowPopup);
|
||||
void ShowList(nsIPresContext* aPresContext, PRBool aShowList);
|
||||
void SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nscoord aHeight);
|
||||
void InitTextStr(nsIPresContext* aPresContext, PRBool aUpdate);
|
||||
void InitTextStr();
|
||||
nsresult GetPrimaryComboFrame(nsIPresContext* aPresContext, nsIContent* aContent, nsIFrame** aFrame);
|
||||
NS_IMETHOD ToggleList(nsIPresContext* aPresContext);
|
||||
|
||||
|
@ -278,9 +277,6 @@ protected:
|
|||
nsIFrame* mTextFrame; // display area frame
|
||||
nsIListControlFrame * mListControlFrame; // ListControl Interface for the dropdown frame
|
||||
|
||||
|
||||
nsCOMPtr<nsIPresState> mPresState; // Need cache state when list is null
|
||||
|
||||
// Resize Reflow Optimization
|
||||
nsSize mCacheSize;
|
||||
nsSize mCachedMaxElementSize;
|
||||
|
|
|
@ -206,23 +206,6 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFileControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
void
|
||||
nsFileControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
if (mTextFrame) {
|
||||
mTextFrame->Reset(aPresContext);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::GetType(PRInt32* aType) const
|
||||
{
|
||||
|
@ -506,7 +489,7 @@ nsFileControlFrame::GetSkipSides() const
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::GetName(nsString* aResult)
|
||||
nsFileControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -527,34 +510,6 @@ nsFileControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
|
||||
|
||||
|
||||
PRInt32
|
||||
nsFileControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFileControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
// use our name and the text widgets value
|
||||
aNames[0] = name;
|
||||
nsresult status = PR_FALSE;
|
||||
|
||||
if (NS_SUCCEEDED(mTextFrame->GetProperty(nsHTMLAtoms::value, aValues[0]))) {
|
||||
aNumValues = 1;
|
||||
status = PR_TRUE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||
nsIContent* aChild,
|
||||
|
@ -753,3 +708,9 @@ nsFileControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aSt
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
NS_IMETHOD Reflow(nsIPresContext* aCX,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
@ -107,14 +108,7 @@ public:
|
|||
PRInt32 aModType,
|
||||
PRInt32 aHint);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
|
|
@ -392,20 +392,6 @@ nsFormControlFrame::GetScrollbarWidth(float aPixToTwip)
|
|||
return NSIntPixelsToTwips(19, aPixToTwip); // XXX this is windows
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsFormControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsFormControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsFormControlFrame::SetClickPoint(nscoord aX, nscoord aY)
|
||||
{
|
||||
|
@ -705,7 +691,7 @@ nsFormControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetName(nsString* aResult)
|
||||
nsFormControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -727,7 +713,7 @@ nsFormControlFrame::GetName(nsString* aResult)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetValue(nsString* aResult)
|
||||
nsFormControlFrame::GetValue(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -748,20 +734,6 @@ nsFormControlFrame::GetValue(nsString* aResult)
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsFormControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
|
||||
// Since JS Submit() calls are not linked to an element, aSubmitter is null.
|
||||
// Return success to allow the call to go through.
|
||||
if (aSubmitter == nsnull) return PR_TRUE;
|
||||
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsFormControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -822,11 +794,6 @@ nsFormControlFrame::GetStyleSize(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsFormControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFormControlFrame::GetFormContent(nsIContent*& aContent) const
|
||||
{
|
||||
|
|
|
@ -150,11 +150,8 @@ public:
|
|||
virtual const nsIID& GetIID();
|
||||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetValue(nsString* aName);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetValue(nsAString* aName);
|
||||
|
||||
/**
|
||||
* Respond to a enter key being pressed
|
||||
|
@ -178,8 +175,6 @@ public:
|
|||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
virtual void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
|
||||
/**
|
||||
* Perform opertations before the widget associated with this frame has been
|
||||
|
|
|
@ -829,7 +829,7 @@ nsFormControlHelper::PaintCheckMark(nsIRenderingContext& aRenderingContext,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::GetName(nsIContent* aContent,nsString* aResult)
|
||||
nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (nsnull != aContent) {
|
||||
|
@ -851,7 +851,7 @@ nsFormControlHelper::GetName(nsIContent* aContent,nsString* aResult)
|
|||
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::GetValue(nsIContent* aContent, nsString* aResult)
|
||||
nsFormControlHelper::GetValue(nsIContent* aContent, nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (nsnull != aContent) {
|
||||
|
@ -1030,3 +1030,52 @@ void nsFormControlHelper::GetFormCompatibilityMode(nsIPresContext* aPresContext,
|
|||
aCompatMode = eCompatibility_Standard;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::Reset(nsIFrame* aFrame, nsIPresContext* aPresContext)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->Reset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::SaveContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState** aState)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->SaveState(aPresContext, aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFormControlHelper::RestoreContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState* aState)
|
||||
{
|
||||
nsCOMPtr<nsIContent> controlContent;
|
||||
aFrame->GetContent(getter_AddRefs(controlContent));
|
||||
|
||||
nsCOMPtr<nsIFormControl> control = do_QueryInterface(controlContent);
|
||||
if (control) {
|
||||
control->RestoreState(aPresContext, aState);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class nsIView;
|
|||
//class nsIPresContext;
|
||||
class nsStyleCoord;
|
||||
class nsFormFrame;
|
||||
class nsIPresState;
|
||||
//class nsIStyleContext;
|
||||
|
||||
#define CSS_NOTSET -1
|
||||
|
@ -154,9 +155,16 @@ public:
|
|||
// Map platform line endings (CR, CRLF, LF) to DOM line endings (LF)
|
||||
static void PlatformToDOMLineBreaks(nsString &aString);
|
||||
|
||||
static nsresult GetValue(nsIContent* aContent, nsString* aResult);
|
||||
static nsresult GetName(nsIContent* aContent, nsString* aResult);
|
||||
static nsresult GetValue(nsIContent* aContent, nsAString* aResult);
|
||||
static nsresult GetName(nsIContent* aContent, nsAString* aResult);
|
||||
static nsresult GetInputElementValue(nsIContent* aContent, nsString* aText, PRBool aInitialValue);
|
||||
static nsresult Reset(nsIFrame* aFrame, nsIPresContext* aPresContext);
|
||||
static nsresult SaveContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState** aState);
|
||||
static nsresult RestoreContentState(nsIFrame* aFrame,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIPresState* aState);
|
||||
|
||||
/**
|
||||
* Utility to convert a string to a PRBool
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -37,7 +37,6 @@
|
|||
#ifndef nsFormFrame_h___
|
||||
#define nsFormFrame_h___
|
||||
|
||||
#include "nsIFormManager.h"
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIFileSpec.h"
|
||||
|
@ -58,8 +57,7 @@ class nsFormFrame;
|
|||
class nsIUnicodeEncoder;
|
||||
class nsRadioControlGroup;
|
||||
|
||||
class nsFormFrame : public nsBlockFrame,
|
||||
public nsIFormManager
|
||||
class nsFormFrame : public nsBlockFrame
|
||||
{
|
||||
public:
|
||||
nsFormFrame();
|
||||
|
@ -72,12 +70,6 @@ public:
|
|||
nsIAtom* aListName,
|
||||
nsIFrame* aOldFrame);
|
||||
|
||||
// nsIFormManager
|
||||
|
||||
NS_IMETHOD OnReset(nsIPresContext* aPresContext);
|
||||
|
||||
NS_IMETHOD OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame);
|
||||
|
||||
// other methods
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
@ -92,23 +84,16 @@ public:
|
|||
void RemoveRadioControlFrame(nsIFormControlFrame * aFrame);
|
||||
nsresult GetRadioInfo(nsIFormControlFrame* aFrame, nsString& aName, nsRadioControlGroup *& aGroup);
|
||||
|
||||
NS_IMETHOD GetMethod(PRInt32* aMethod);
|
||||
NS_IMETHOD GetEnctype(PRInt32* aEnctype);
|
||||
NS_IMETHOD GetTarget(nsString* aTarget);
|
||||
NS_IMETHOD GetAction(nsString* aAction);
|
||||
|
||||
// Detection of first form to notify observers
|
||||
static PRBool gFirstFormSubmitted;
|
||||
// Detection of first password field to notify any password manager
|
||||
// style modules
|
||||
static PRBool gInitPasswordManager;
|
||||
|
||||
// static helper functions for nsIFormControls
|
||||
|
||||
static PRBool GetDisabled(nsIFrame* aChildFrame, nsIContent* aContent = 0);
|
||||
static PRBool GetReadonly(nsIFrame* aChildFrame, nsIContent* aContent = 0);
|
||||
static nsresult GetName(nsIFrame* aChildFrame, nsString& aName, nsIContent* aContent = 0);
|
||||
static nsresult GetValue(nsIFrame* aChildFrame, nsString& aValue, nsIContent* aContent = 0);
|
||||
static nsresult GetName(nsIFrame* aChildFrame,
|
||||
nsAString& aName,
|
||||
nsIContent* aContent = 0);
|
||||
static nsresult GetValue(nsIFrame* aChildFrame,
|
||||
nsAString& aValue,
|
||||
nsIContent* aContent = 0);
|
||||
static void StyleChangeReflow(nsIPresContext* aPresContext,
|
||||
nsIFrame* aFrame);
|
||||
static nsresult GetRadioGroupSelectedContent(nsGfxRadioControlFrame* aControl,
|
||||
|
@ -130,31 +115,10 @@ protected:
|
|||
nsRadioControlGroup * aGroup,
|
||||
nsGfxRadioControlFrame * aRadioToIgnore = nsnull);
|
||||
|
||||
nsresult ProcessValue(nsIFormProcessor& aFormProcessor, nsIFormControlFrame* aFrameControl, const nsString& aName, nsString& aNewValue);
|
||||
nsresult ProcessAsURLEncoded(nsIFormProcessor* aFormProcessor, PRBool aIsPost, nsString& aData, nsIFormControlFrame* aFrame);
|
||||
nsresult ProcessAsMultipart(nsIFormProcessor* aFormProcessor,
|
||||
nsIFile** aMultipartDataFile,
|
||||
nsIFormControlFrame* aFrame);
|
||||
PRUint32 GetFileNameWithinPath(nsString aPathName);
|
||||
nsresult GetContentType(char* aPathName, char** aContentType);
|
||||
|
||||
// i18n helper routines
|
||||
nsString* URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder);
|
||||
char* UnicodeToNewBytes(const PRUnichar* aSrc, PRUint32 aLen, nsIUnicodeEncoder* encoder);
|
||||
|
||||
NS_IMETHOD GetEncoder(nsIUnicodeEncoder** encoder);
|
||||
NS_IMETHOD GetPlatformEncoder(nsIUnicodeEncoder** encoder);
|
||||
void GetSubmitCharset(nsString& oCharset);
|
||||
|
||||
nsVoidArray mFormControls;
|
||||
nsVoidArray mRadioGroups;
|
||||
#ifdef IBMBIDI
|
||||
//ahmed
|
||||
nsAutoString mCharset; // The charset in use
|
||||
PRUint8 mTextDir; // The direction of the text
|
||||
PRUint8 mCtrlsModAtSubmit; // The text mode of the control (logical/visual)
|
||||
// Direction and text mode are set by Bidi Options in Preferences
|
||||
#endif
|
||||
|
||||
static PRBool gInitPasswordManager;
|
||||
};
|
||||
|
||||
#endif // nsFormFrame_h___
|
||||
|
|
|
@ -66,63 +66,6 @@ nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
|||
mDefaultValueWasChanged = PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
PRBool successful = PR_TRUE;
|
||||
if ((NS_FORM_INPUT_HIDDEN == type) || (this == aSubmitter)) {
|
||||
// Can not use the nsHTMLButtonControlFrame::IsSuccessful because
|
||||
// it will fail it's test of (this==aSubmitter)
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
} else {
|
||||
successful = PR_FALSE;
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsGfxButtonControlFrame::GetMaxNumValues()
|
||||
{
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if ((NS_FORM_INPUT_SUBMIT == type) || (NS_FORM_INPUT_HIDDEN == type)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGfxButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
|
||||
if (NS_FORM_INPUT_RESET == type) {
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
} else {
|
||||
nsAutoString value;
|
||||
GetValue(&value);
|
||||
aValues[0] = value;
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
||||
{
|
||||
|
@ -619,28 +562,6 @@ nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
#endif
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
// hidden inputs are zero width/height and are finished here
|
||||
if (NS_FORM_INPUT_HIDDEN == type) {
|
||||
aDesiredSize.width = aDesiredSize.height = aDesiredSize.ascent = aDesiredSize.descent = 0;
|
||||
if (aDesiredSize.maxElementSize) {
|
||||
aDesiredSize.maxElementSize->width = aDesiredSize.maxElementSize->height = 0;
|
||||
}
|
||||
// just in case the hidden input is the target of an incremental reflow
|
||||
if (eReflowReason_Incremental == aReflowState.reason) {
|
||||
nsIFrame* targetFrame;
|
||||
aReflowState.reflowCommand->GetTarget(targetFrame);
|
||||
if (this == targetFrame) {
|
||||
nsIFrame* nextFrame;
|
||||
// Remove the next frame from the reflow path
|
||||
aReflowState.reflowCommand->GetNext(nextFrame);
|
||||
}
|
||||
}
|
||||
aStatus = NS_FRAME_COMPLETE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
||||
(kSuggestedNotSet != mSuggestedHeight)) {
|
||||
nsHTMLReflowState suggestedReflowState(aReflowState);
|
||||
|
|
|
@ -87,10 +87,6 @@ public:
|
|||
#ifdef DEBUG
|
||||
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
||||
#endif
|
||||
PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
||||
|
||||
|
|
|
@ -285,12 +285,7 @@ void
|
|||
nsGfxCheckboxControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsFormControlFrame::InitializeControl(aPresContext);
|
||||
|
||||
PRBool checked = PR_FALSE;
|
||||
nsresult result = GetDefaultCheckState(&checked);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
SetCheckboxState (aPresContext, checked ? eOn : eOff );
|
||||
}
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
@ -502,54 +497,6 @@ NS_IMETHODIMP nsGfxCheckboxControlFrame::GetProperty(nsIAtom* aName, nsAWritable
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
PRInt32
|
||||
nsGfxCheckboxControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
PRBool
|
||||
nsGfxCheckboxControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult nameResult = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != nameResult)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool result = PR_TRUE;
|
||||
CheckState state = GetCheckboxState();
|
||||
|
||||
nsAutoString value;
|
||||
nsresult valueResult = GetValue(&value);
|
||||
|
||||
if (eOn != state) {
|
||||
result = PR_FALSE;
|
||||
} else {
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != valueResult) {
|
||||
aValues[0].AssignWithConversion("on");
|
||||
} else {
|
||||
aValues[0] = value;
|
||||
}
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
void
|
||||
nsGfxCheckboxControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRBool checked;
|
||||
GetDefaultCheckState(&checked);
|
||||
SetCheckboxState (aPresContext, checked ? eOn : eOff );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
//
|
||||
|
@ -705,3 +652,9 @@ nsGfxCheckboxControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxCheckboxControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -106,10 +106,7 @@ public:
|
|||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
// nsIStatefulFrame
|
||||
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
||||
|
|
|
@ -246,46 +246,6 @@ nsGfxRadioControlFrame::GetRadioGroupSelectedContent(nsIContent ** aRadioBtn)
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
PRBool
|
||||
nsGfxRadioControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool state = GetRadioState();
|
||||
|
||||
if(PR_TRUE != state) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsAutoString value;
|
||||
result = GetValue(&value);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
aValues[0] = value;
|
||||
} else {
|
||||
aValues[0].AssignWithConversion("on");
|
||||
}
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
void
|
||||
nsGfxRadioControlFrame::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
PRBool checked = PR_TRUE;
|
||||
GetDefaultCheckState(&checked);
|
||||
SetCurrentCheckState(checked);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
||||
nsGUIEvent* aEvent,
|
||||
|
@ -385,13 +345,7 @@ void
|
|||
nsGfxRadioControlFrame::InitializeControl(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsFormControlFrame::InitializeControl(aPresContext);
|
||||
|
||||
// set the widget to the initial state
|
||||
PRBool checked = PR_FALSE;
|
||||
nsresult result = GetDefaultCheckState(&checked);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
||||
SetRadioState(aPresContext, checked);
|
||||
}
|
||||
nsFormControlHelper::Reset(this, aPresContext);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -474,3 +428,9 @@ nsGfxRadioControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxRadioControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -103,15 +103,10 @@ public:
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues() { return 1; }
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "nsFormControlFrame.h" //for registering accesskeys
|
||||
#include "nsIDeviceContext.h" // to measure fonts
|
||||
#include "nsIPresState.h" //for saving state
|
||||
#include "nsLinebreakConverter.h" //to strip out carriage returns
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIAtom.h"
|
||||
|
@ -111,6 +110,7 @@
|
|||
#endif
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsITextControlElement.h"
|
||||
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsITransactionListener.h"
|
||||
|
@ -322,7 +322,7 @@ nsTextInputListener::KeyPress(nsIDOMEvent* aKeyEvent)
|
|||
nsIDOMKeyEvent::DOM_VK_ENTER==keyCode)
|
||||
{
|
||||
nsAutoString curValue;
|
||||
mFrame->GetText(&curValue,PR_FALSE);
|
||||
mFrame->GetText(&curValue);
|
||||
|
||||
// If the text control's contents have changed, fire
|
||||
// off an onChange().
|
||||
|
@ -428,7 +428,7 @@ nsTextInputListener::Focus(nsIDOMEvent* aEvent)
|
|||
editor->AddEditorObserver(this);
|
||||
}
|
||||
|
||||
nsresult rv = mFrame->GetText(&mFocusedValue, PR_FALSE);
|
||||
nsresult rv = mFrame->GetText(&mFocusedValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -448,7 +448,7 @@ nsTextInputListener::Blur (nsIDOMEvent* aEvent)
|
|||
editor->RemoveEditorObserver(this);
|
||||
|
||||
}
|
||||
mFrame->GetText(&blurValue,PR_FALSE);
|
||||
mFrame->GetText(&blurValue);
|
||||
if (!mFocusedValue.Equals(blurValue))//different fire onchange
|
||||
{
|
||||
mFocusedValue = blurValue;
|
||||
|
@ -1340,7 +1340,6 @@ NS_IMETHODIMP nsGfxTextControlFrame2::GetAccessible(nsIAccessible** aAccessible)
|
|||
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
||||
|
||||
if (accService) {
|
||||
nsIAccessible* acc = nsnull;
|
||||
return accService->CreateHTMLTextFieldAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
||||
}
|
||||
|
||||
|
@ -1370,8 +1369,14 @@ NS_IMETHODIMP
|
|||
nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext)
|
||||
{
|
||||
// notify the editor that we are going away
|
||||
if (mEditor)
|
||||
{
|
||||
if (mEditor) {
|
||||
nsAutoString value;
|
||||
GetTextControlFrameState(value);
|
||||
// Tell the content the final value
|
||||
nsCOMPtr<nsITextControlElement> control = do_QueryInterface(mContent);
|
||||
if (control) {
|
||||
control->SetValueInternal(value);
|
||||
}
|
||||
mEditor->PreDestroy();
|
||||
}
|
||||
|
||||
|
@ -1414,15 +1419,16 @@ nsGfxTextControlFrame2::Destroy(nsIPresContext* aPresContext)
|
|||
//unregister self from content
|
||||
mTextListener->SetFrame(nsnull);
|
||||
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
||||
if (mFormFrame) {
|
||||
if (mFormFrame)
|
||||
{
|
||||
mFormFrame->RemoveFormControlFrame(*this);
|
||||
mFormFrame = nsnull;
|
||||
mTextListener->SetFrame(nsnull);
|
||||
mTextListener->SetFrame(nsnull);
|
||||
}
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP;
|
||||
if (mTextListener)
|
||||
{
|
||||
if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP)
|
||||
nsCOMPtr<nsIDOMEventReceiver> erP = do_QueryInterface(mContent);
|
||||
if (erP)
|
||||
{
|
||||
erP->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMFocusListener *,mTextListener), NS_GET_IID(nsIDOMFocusListener));
|
||||
erP->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMKeyListener*,mTextListener), NS_GET_IID(nsIDOMKeyListener));
|
||||
|
@ -1834,8 +1840,8 @@ nsGfxTextControlFrame2::ReflowNavQuirks(nsIPresContext* aPresContext,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::CreateFrameFor(nsIPresContext* aPresContext,
|
||||
nsIContent * aContent,
|
||||
nsIFrame** aFrame)
|
||||
nsIContent * aContent,
|
||||
nsIFrame** aFrame)
|
||||
{
|
||||
aContent = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1856,27 +1862,28 @@ nsGfxTextControlFrame2::SetInitialValue()
|
|||
// during frame construction. This was causing other form controls
|
||||
// to display wrong values.
|
||||
|
||||
if (!mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Check if this method has been called already.
|
||||
// If so, just return early.
|
||||
|
||||
if (mUseEditor)
|
||||
return NS_OK;
|
||||
|
||||
// Get the default value for the textfield.
|
||||
// If the editor is not here, return failure.
|
||||
if (!mEditor)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Get the current value of the textfield.
|
||||
nsAutoString defaultValue;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mCachedState)
|
||||
// If we have a cached state, use that.
|
||||
if (mCachedState) {
|
||||
defaultValue = mCachedState->get();
|
||||
else
|
||||
rv = GetText(&defaultValue, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
} else {
|
||||
// The content will know to get the default value if it needs to.
|
||||
nsCOMPtr<nsITextControlElement> control = do_QueryInterface(mContent);
|
||||
if (control) {
|
||||
control->GetValueInternal(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a default value, insert it under the div we created
|
||||
// above, but be sure to use the editor so that '*' characters get
|
||||
|
@ -1885,11 +1892,10 @@ nsGfxTextControlFrame2::SetInitialValue()
|
|||
|
||||
mUseEditor = PR_TRUE;
|
||||
|
||||
if (defaultValue.Length() > 0)
|
||||
{
|
||||
if (!defaultValue.IsEmpty()) {
|
||||
PRUint32 editorFlags = 0;
|
||||
|
||||
rv = mEditor->GetFlags(&editorFlags);
|
||||
nsresult rv = mEditor->GetFlags(&editorFlags);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -2432,7 +2438,7 @@ nsGfxTextControlFrame2::GetSkipSides() const
|
|||
|
||||
//IMPLEMENTING NS_IFORMCONTROLFRAME
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::GetName(nsString* aResult)
|
||||
nsGfxTextControlFrame2::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult rv = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -2517,34 +2523,6 @@ void nsGfxTextControlFrame2::ScrollIntoView(nsIPresContext* aPresContext)
|
|||
|
||||
void nsGfxTextControlFrame2::MouseClicked(nsIPresContext* aPresContext){}
|
||||
|
||||
void nsGfxTextControlFrame2::Reset(nsIPresContext* aPresContext)
|
||||
{
|
||||
nsAutoString temp;
|
||||
GetText(&temp, PR_TRUE);
|
||||
SetTextControlFrameState(temp);
|
||||
}
|
||||
|
||||
PRInt32 nsGfxTextControlFrame2::GetMaxNumValues(){return 1;}/**/
|
||||
|
||||
PRBool nsGfxTextControlFrame2::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (!aValues || !aNames) { return PR_FALSE; }
|
||||
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_NOT_THERE == result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
|
||||
GetText(&(aValues[0]), PR_FALSE);
|
||||
// XXX: error checking
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsGfxTextControlFrame2::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -2572,16 +2550,6 @@ nsGfxTextControlFrame2::SetFormFrame(nsFormFrame* aFormFrame)
|
|||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
PRBool
|
||||
nsGfxTextControlFrame2::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
|
@ -2999,14 +2967,8 @@ nsGfxTextControlFrame2::AttributeChanged(nsIPresContext* aPresContext,
|
|||
|
||||
if (nsHTMLAtoms::value == aAttribute)
|
||||
{
|
||||
if (mEditor && mContent)
|
||||
{
|
||||
nsString value;
|
||||
mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::value, value);
|
||||
mEditor->EnableUndo(PR_FALSE); // wipe out undo info
|
||||
SetTextControlFrameState(value); // set new text value
|
||||
mEditor->EnableUndo(PR_TRUE); // fire up a new txn stack
|
||||
}
|
||||
// XXX If this should happen when value= attribute is set, shouldn't it
|
||||
// happen when .value is set too?
|
||||
if (aHint != NS_STYLE_HINT_REFLOW)
|
||||
nsFormFrame::StyleChangeReflow(aPresContext, this);
|
||||
}
|
||||
|
@ -3101,40 +3063,23 @@ nsGfxTextControlFrame2::AttributeChanged(nsIPresContext* aPresContext,
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::GetText(nsString* aText, PRBool aInitialValue)
|
||||
nsGfxTextControlFrame2::GetText(nsString* aText)
|
||||
{
|
||||
nsresult rv = NS_CONTENT_ATTR_NOT_THERE;
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type))
|
||||
{
|
||||
if (PR_TRUE==aInitialValue)
|
||||
{
|
||||
rv = nsFormControlHelper::GetInputElementValue(mContent, aText, aInitialValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetTextControlFrameState(*aText);
|
||||
}
|
||||
if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) {
|
||||
GetTextControlFrameState(*aText);
|
||||
RemoveNewlines(*aText);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsIDOMHTMLTextAreaElement* textArea = nsnull;
|
||||
rv = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLTextAreaElement), (void**)&textArea);
|
||||
if ((NS_OK == rv) && textArea) {
|
||||
if (PR_TRUE == aInitialValue) {
|
||||
rv = textArea->GetDefaultValue(*aText);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea = do_QueryInterface(mContent);
|
||||
if (textArea) {
|
||||
if (mEditor) {
|
||||
nsCOMPtr<nsIEditorIMESupport> imeSupport = do_QueryInterface(mEditor);
|
||||
if (imeSupport)
|
||||
imeSupport->ForceCompositionEnd();
|
||||
}
|
||||
else {
|
||||
if(mEditor) {
|
||||
nsCOMPtr<nsIEditorIMESupport> imeSupport = do_QueryInterface(mEditor);
|
||||
if(imeSupport)
|
||||
imeSupport->ForceCompositionEnd();
|
||||
}
|
||||
rv = textArea->GetValue(*aText);
|
||||
}
|
||||
NS_RELEASE(textArea);
|
||||
rv = textArea->GetValue(*aText);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -3193,10 +3138,6 @@ nsGfxTextControlFrame2::SubmitAttempt()
|
|||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (mFormFrame && mTextSelImpl && NS_FORM_TEXTAREA != type) {
|
||||
nsIContent *formContent = nsnull;
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
||||
nsWeakPtr &shell = mTextSelImpl->GetPresShell();
|
||||
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(shell);
|
||||
if (!presShell) return;
|
||||
|
@ -3332,7 +3273,7 @@ void nsGfxTextControlFrame2::GetTextControlFrameState(nsAWritableString& aValue)
|
|||
}
|
||||
else if (mCachedState)
|
||||
aValue.Assign(*mCachedState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// END IMPLEMENTING NS_IFORMCONTROLFRAME
|
||||
|
@ -3344,10 +3285,12 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsAReadableString& aValue
|
|||
{
|
||||
nsAutoString currentValue;
|
||||
GetTextControlFrameState(currentValue);
|
||||
if (PR_TRUE==IsSingleLineTextControl()) {
|
||||
if (IsSingleLineTextControl())
|
||||
{
|
||||
RemoveNewlines(currentValue);
|
||||
}
|
||||
if (PR_FALSE==currentValue.Equals(aValue)) // this is necessary to avoid infinite recursion
|
||||
// this is necessary to avoid infinite recursion
|
||||
if (!currentValue.Equals(aValue))
|
||||
{
|
||||
nsCOMPtr<nsISelection> domSel;
|
||||
nsCOMPtr<nsISelectionPrivate> selPriv;
|
||||
|
@ -3367,19 +3310,20 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsAReadableString& aValue
|
|||
|
||||
nsCOMPtr<nsIDOMDocument>domDoc;
|
||||
nsresult rv = mEditor->GetDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv)) return;
|
||||
if (!domDoc) return;
|
||||
if (NS_FAILED(rv)) return;
|
||||
if (!domDoc) return;
|
||||
mSelCon->SelectAll();
|
||||
nsCOMPtr<nsIPlaintextEditor> htmlEditor = do_QueryInterface(mEditor);
|
||||
if (!htmlEditor) return;
|
||||
if (!htmlEditor) return;
|
||||
|
||||
// get the flags, remove readonly and disabled, set the value, restore flags
|
||||
PRUint32 flags, savedFlags;
|
||||
mEditor->GetFlags(&savedFlags);
|
||||
flags = savedFlags;
|
||||
flags &= ~(nsIPlaintextEditor::eEditorDisabledMask);
|
||||
flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask);
|
||||
mEditor->SetFlags(flags);
|
||||
// get the flags, remove readonly and disabled, set the value,
|
||||
// restore flags
|
||||
PRUint32 flags, savedFlags;
|
||||
mEditor->GetFlags(&savedFlags);
|
||||
flags = savedFlags;
|
||||
flags &= ~(nsIPlaintextEditor::eEditorDisabledMask);
|
||||
flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask);
|
||||
mEditor->SetFlags(flags);
|
||||
if (currentValue.Length() < 1)
|
||||
mEditor->DeleteSelection(nsIEditor::eNone);
|
||||
else {
|
||||
|
@ -3519,51 +3463,13 @@ nsGfxTextControlFrame2::GetWidthInCharacters() const
|
|||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
|
||||
// Don't save state before we are initialized
|
||||
if (!mUseEditor && !mCachedState) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Never save passwords in session history
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
if (NS_FORM_INPUT_PASSWORD == type) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the value string
|
||||
nsString stateString;
|
||||
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// XXX Removed comparison between current and default state to
|
||||
// XXX temporarily fix bug 69365 (mail reply all looses addresses)
|
||||
|
||||
// XXX Should use nsAutoString above but ConvertStringLineBreaks requires mOwnsBuffer!
|
||||
res = nsLinebreakConverter::ConvertStringLineBreaks(stateString,
|
||||
nsLinebreakConverter::eLinebreakPlatform, nsLinebreakConverter::eLinebreakContent);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "Converting linebreaks failed!");
|
||||
|
||||
// Construct a pres state and store value in it.
|
||||
res = NS_NewPresState(aState);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
|
||||
return res;
|
||||
return nsFormControlHelper::SaveContentState(this, aPresContext, aState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aState);
|
||||
|
||||
// Set the value to the stored state.
|
||||
nsAutoString stateString;
|
||||
nsresult res = aState->GetStateProperty(NS_LITERAL_STRING("value"), stateString);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
return SetProperty(aPresContext, nsHTMLAtoms::value, stateString);
|
||||
return nsFormControlHelper::RestoreContentState(this, aPresContext, aState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3588,8 +3494,11 @@ nsGfxTextControlFrame2::GetScrollableView(nsIScrollableView** aView)
|
|||
PRBool
|
||||
nsGfxTextControlFrame2::IsScrollable() const
|
||||
{
|
||||
if (!IsSingleLineTextControl())
|
||||
return PR_TRUE;
|
||||
return PR_FALSE;
|
||||
return !IsSingleLineTextControl();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGfxTextControlFrame2::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -121,15 +121,10 @@ public:
|
|||
|
||||
//==== BEGIN NSIFORMCONTROLFRAME
|
||||
NS_IMETHOD GetType(PRInt32* aType) const; //*
|
||||
NS_IMETHOD GetName(nsString* aName);//*
|
||||
NS_IMETHOD GetName(nsAString* aName);//*
|
||||
virtual void SetFocus(PRBool aOn , PRBool aRepaint);
|
||||
virtual void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext* aPresContext);
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual PRInt32 GetMaxNumValues();/**/
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void SetFormFrame(nsFormFrame* aFrame);
|
||||
virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -145,6 +140,7 @@ public:
|
|||
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
|
||||
//==== END NSIFORMCONTROLFRAME
|
||||
|
@ -171,7 +167,7 @@ public:
|
|||
PRInt32 aModType,
|
||||
PRInt32 aHint);
|
||||
|
||||
NS_IMETHOD GetText(nsString* aText, PRBool aInitialValue);
|
||||
NS_IMETHOD GetText(nsString* aText);
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
|
|
|
@ -216,41 +216,6 @@ nsHTMLButtonControlFrame::GetDefaultLabel(nsString& aString)
|
|||
}
|
||||
|
||||
|
||||
PRInt32
|
||||
nsHTMLButtonControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRInt32 type;
|
||||
GetType(&type);
|
||||
nsAutoString value;
|
||||
nsresult valResult = GetValue(&value);
|
||||
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == valResult) {
|
||||
aValues[0] = value;
|
||||
aNames[0] = name;
|
||||
aNumValues = 1;
|
||||
return PR_TRUE;
|
||||
} else {
|
||||
aNumValues = 0;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetType(PRInt32* aType) const
|
||||
{
|
||||
|
@ -267,7 +232,7 @@ nsHTMLButtonControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetName(nsString* aResult)
|
||||
nsHTMLButtonControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -288,7 +253,7 @@ nsHTMLButtonControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::GetValue(nsString* aResult)
|
||||
nsHTMLButtonControlFrame::GetValue(nsAString* aResult)
|
||||
{
|
||||
nsresult result = NS_FORM_NOTOK;
|
||||
if (mContent) {
|
||||
|
@ -308,21 +273,6 @@ nsHTMLButtonControlFrame::GetValue(nsString* aResult)
|
|||
return result;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
PRBool successful = PR_TRUE;
|
||||
if (this == (aSubmitter)) {
|
||||
nsAutoString name;
|
||||
PRBool disabled = PR_FALSE;
|
||||
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
||||
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
||||
} else {
|
||||
successful = PR_FALSE;
|
||||
}
|
||||
return successful;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
||||
{
|
||||
|
@ -863,3 +813,8 @@ nsHTMLButtonControlFrame::AppendFrames(nsIPresContext* aPresContext,
|
|||
aFrameList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLButtonControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -129,16 +129,12 @@ public:
|
|||
virtual nsresult RequiresWidget(PRBool &aRequiresWidget);
|
||||
|
||||
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetValue(nsString* aName);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD GetValue(nsAString* aName);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext*) {};
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIImageControlFrame.h"
|
||||
#include "nsImageFrame.h"
|
||||
#include "nsFormControlHelper.h"
|
||||
#include "nsIFormControlFrame.h"
|
||||
|
@ -78,7 +79,8 @@ static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|||
|
||||
#define nsImageControlFrameSuper nsImageFrame
|
||||
class nsImageControlFrame : public nsImageControlFrameSuper,
|
||||
public nsIFormControlFrame
|
||||
public nsIFormControlFrame,
|
||||
public nsIImageControlFrame
|
||||
{
|
||||
public:
|
||||
nsImageControlFrame();
|
||||
|
@ -122,18 +124,9 @@ public:
|
|||
|
||||
virtual void SetFormFrame(nsFormFrame* aFormFrame) { mFormFrame = aFormFrame; }
|
||||
|
||||
PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
|
||||
virtual void Reset(nsIPresContext*) {};
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
|
||||
void SetFocus(PRBool aOn, PRBool aRepaint);
|
||||
void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
|
@ -156,6 +149,11 @@ public:
|
|||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
// nsIImageControlFrame
|
||||
NS_IMETHOD GetClickedX(PRInt32* aX);
|
||||
NS_IMETHOD GetClickedY(PRInt32* aY);
|
||||
|
||||
protected:
|
||||
void GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect); // XXX this implementation is a copy of nsHTMLButtonControlFrame
|
||||
|
@ -225,6 +223,10 @@ nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|||
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIImageControlFrame))) {
|
||||
*aInstancePtr = (void*) ((nsIImageControlFrame*) this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
@ -403,7 +405,7 @@ nsImageControlFrame::GetType(PRInt32* aType) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetName(nsString* aResult)
|
||||
nsImageControlFrame::GetName(nsAString* aResult)
|
||||
{
|
||||
if (nsnull == aResult) {
|
||||
return NS_OK;
|
||||
|
@ -412,55 +414,6 @@ nsImageControlFrame::GetName(nsString* aResult)
|
|||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsImageControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
||||
{
|
||||
// Image control will only add it's value if it is clicked on.
|
||||
// XXX Is this right?
|
||||
return (this == (aSubmitter));
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsImageControlFrame::GetMaxNumValues()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsImageControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames)
|
||||
{
|
||||
if (aMaxNumValues <= 0) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
char buf[20];
|
||||
aNumValues = 2;
|
||||
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.x);
|
||||
aValues[0].AssignWithConversion(&buf[0]);
|
||||
|
||||
sprintf(&buf[0], "%d", mLastClickPoint.y);
|
||||
aValues[1].AssignWithConversion(&buf[0]);
|
||||
|
||||
nsAutoString name;
|
||||
nsresult result = GetName(&name);
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE == result && (name.Length() > 0)) {
|
||||
aNames[0] = name;
|
||||
aNames[0].AppendWithConversion(".x");
|
||||
aNames[1] = name;
|
||||
aNames[1].AppendWithConversion(".y");
|
||||
} else {
|
||||
// If the Image Element has no name, simply return x and y
|
||||
// to Nav and IE compatability.
|
||||
aNames[0].AssignWithConversion("x");
|
||||
aNames[1].AssignWithConversion("y");
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetCursor(nsIPresContext* aPresContext,
|
||||
nsPoint& aPoint,
|
||||
|
@ -553,3 +506,22 @@ NS_IMETHODIMP nsImageControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHei
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::OnContentReset()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedX(PRInt32* aX)
|
||||
{
|
||||
*aX = mLastClickPoint.x;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageControlFrame::GetClickedY(PRInt32* aY)
|
||||
{
|
||||
*aY = mLastClickPoint.y;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -55,10 +55,10 @@
|
|||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMMouseMotionListener.h"
|
||||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
#include "nsIPresState.h"
|
||||
#include "nsCWeakReference.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIStatefulFrame.h"
|
||||
|
||||
class nsIDOMHTMLSelectElement;
|
||||
class nsIDOMHTMLCollection;
|
||||
|
@ -68,6 +68,7 @@ class nsIViewManager;
|
|||
class nsIPresContext;
|
||||
class nsVoidArray;
|
||||
class nsIScrollableView;
|
||||
class nsIStatefulFrame;
|
||||
|
||||
class nsListControlFrame;
|
||||
class nsSelectUpdateTimer;
|
||||
|
@ -229,22 +230,18 @@ public:
|
|||
|
||||
// nsIFormControlFrame
|
||||
NS_IMETHOD GetType(PRInt32* aType) const;
|
||||
NS_IMETHOD GetName(nsString* aName);
|
||||
NS_IMETHOD GetName(nsAString* aName);
|
||||
NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAReadableString& aValue);
|
||||
NS_IMETHOD GetProperty(nsIAtom* aName, nsAWritableString& aValue);
|
||||
NS_IMETHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
NS_IMETHOD GetFont(nsIPresContext* aPresContext,
|
||||
const nsFont*& aFont);
|
||||
NS_IMETHOD GetFormContent(nsIContent*& aContent) const;
|
||||
NS_IMETHOD OnContentReset();
|
||||
|
||||
virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE);
|
||||
virtual void ScrollIntoView(nsIPresContext* aPresContext);
|
||||
virtual void MouseClicked(nsIPresContext* aPresContext);
|
||||
virtual void Reset(nsIPresContext* aPresContext) { ResetList(aPresContext); }
|
||||
virtual PRBool IsSuccessful(nsIFormControlFrame* aSubmitter);
|
||||
virtual PRInt32 GetMaxNumValues();
|
||||
virtual PRBool GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
||||
nsString* aValues, nsString* aNames);
|
||||
virtual void SetFormFrame(nsFormFrame* aFrame);
|
||||
virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
||||
float aPixToTwip,
|
||||
|
@ -266,7 +263,7 @@ public:
|
|||
// nsIListControlFrame
|
||||
NS_IMETHOD SetComboboxFrame(nsIFrame* aComboboxFrame);
|
||||
NS_IMETHOD GetSelectedIndex(PRInt32* aIndex);
|
||||
NS_IMETHOD GetSelectedItem(nsString & aStr);
|
||||
NS_IMETHOD GetOptionText(PRInt32 aIndex, nsAString & aStr);
|
||||
NS_IMETHOD CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGrabMouseEvents);
|
||||
NS_IMETHOD GetMaximumSize(nsSize &aSize);
|
||||
NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight);
|
||||
|
@ -274,26 +271,21 @@ public:
|
|||
NS_IMETHOD SyncViewWithFrame(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD AboutToDropDown();
|
||||
NS_IMETHOD AboutToRollup();
|
||||
NS_IMETHOD UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUpdate, nsIContent* aContent);
|
||||
NS_IMETHOD SetPresState(nsIPresState * aState) { mPresState = aState; return NS_OK;}
|
||||
NS_IMETHOD UpdateSelection();
|
||||
NS_IMETHOD ComboboxUpdateSelection(PRBool aForceUpdate, PRBool aSendEvent);
|
||||
NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) { mOverrideReflowOpt = aValue; return NS_OK; }
|
||||
NS_IMETHOD GetOptionsContainer(nsIPresContext* aPresContext, nsIFrame** aFrame);
|
||||
|
||||
NS_IMETHOD SaveStateInternal(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreStateInternal(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// nsISelectControlFrame
|
||||
NS_IMETHOD AddOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD RemoveOption(nsIPresContext* aPresContext, PRInt32 index);
|
||||
NS_IMETHOD SetOptionSelected(PRInt32 aIndex, PRBool aValue);
|
||||
NS_IMETHOD GetOptionSelected(PRInt32 aIndex, PRBool* aValue);
|
||||
NS_IMETHOD DoneAddingContent(PRBool aIsDone);
|
||||
NS_IMETHOD OptionDisabled(nsIContent * aContent);
|
||||
NS_IMETHOD MakeSureSomethingIsSelected(nsIPresContext* aPresContext) { return NS_OK; }
|
||||
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
NS_IMETHOD OnOptionSelected(nsIPresContext* aPresContext,
|
||||
PRInt32 aIndex,
|
||||
PRBool aSelected);
|
||||
NS_IMETHOD GetDummyFrame(nsIFrame** aFrame);
|
||||
NS_IMETHOD SetDummyFrame(nsIFrame* aFrame);
|
||||
|
||||
//nsIDOMEventListener
|
||||
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
|
||||
|
@ -313,98 +305,70 @@ public:
|
|||
NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent) { return NS_OK; }
|
||||
NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
|
||||
|
||||
// Static Methods
|
||||
//nsIStatefulFrame
|
||||
NS_IMETHOD SaveState(nsIPresContext* aPresContext, nsIPresState** aState);
|
||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||
|
||||
// Static Methods
|
||||
static nsIDOMHTMLSelectElement* GetSelect(nsIContent * aContent);
|
||||
static nsIDOMHTMLCollection* GetOptions(nsIContent * aContent, nsIDOMHTMLSelectElement* aSelect = nsnull);
|
||||
static nsIDOMHTMLOptionElement* GetOption(nsIDOMHTMLCollection& aOptions, PRInt32 aIndex);
|
||||
static nsIContent* GetOptionAsContent(nsIDOMHTMLCollection* aCollection,PRInt32 aIndex);
|
||||
static PRBool GetOptionValue(nsIDOMHTMLCollection& aCollecton, PRInt32 aIndex, nsString& aValue);
|
||||
|
||||
// Weak Reference
|
||||
nsCWeakReferent *WeakReferent()
|
||||
{ return &mWeakReferent; }
|
||||
|
||||
// Helper
|
||||
// Helper
|
||||
void SetPassId(PRInt16 aId) { mPassId = aId; }
|
||||
|
||||
protected:
|
||||
|
||||
NS_IMETHOD GetSelectedIndexFromDOM(PRInt32* aIndex); // from DOM
|
||||
NS_IMETHOD IsTargetOptionDisabled(PRBool &aIsDisabled);
|
||||
NS_IMETHOD IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled);
|
||||
nsresult ScrollToFrame(nsIContent * aOptElement);
|
||||
nsresult ScrollToIndex(PRInt32 anIndex);
|
||||
PRBool IsClickingInCombobox(nsIDOMEvent* aMouseEvent);
|
||||
void AdjustIndexForDisabledOpt(PRInt32 &anNewIndex, PRInt32 &anOldIndex,
|
||||
PRBool &aDoSetNewIndex, PRBool &aWasDisabled,
|
||||
void AdjustIndexForDisabledOpt(PRInt32 aStartIndex, PRInt32 &anNewIndex,
|
||||
PRInt32 aNumOptions, PRInt32 aDoAdjustInc, PRInt32 aDoAdjustIncNext);
|
||||
virtual void ResetList(nsIPresContext* aPresContext, nsVoidArray * aInxList = nsnull);
|
||||
|
||||
// PresState Helper Methods
|
||||
nsresult GetPresStateAndValueArray(nsISupportsArray ** aSuppArray);
|
||||
nsresult SetOptionIntoPresState(nsISupportsArray * aSuppArray,
|
||||
PRInt32 aIndex,
|
||||
PRInt32 anItemNum);
|
||||
nsresult SetSelectionInPresState(PRInt32 aIndex, PRBool aValue);
|
||||
nsresult RemoveOptionFromPresState(nsISupportsArray * aSuppArray,
|
||||
PRInt32 aIndex);
|
||||
|
||||
nsListControlFrame();
|
||||
virtual ~nsListControlFrame();
|
||||
|
||||
// nsScrollFrame overrides
|
||||
// Override the widget created for the list box so a Borderless top level widget is created
|
||||
// for drop-down lists.
|
||||
// nsScrollFrame overrides
|
||||
// Override the widget created for the list box so a Borderless top level
|
||||
// widget is created for drop-down lists.
|
||||
virtual nsresult CreateScrollingViewWidget(nsIView* aView, const nsStyleDisplay* aDisplay);
|
||||
virtual nsresult GetScrollingParentView(nsIPresContext* aPresContext,
|
||||
nsIFrame* aParent,
|
||||
nsIView** aParentView);
|
||||
PRInt32 GetNumberOfOptions();
|
||||
|
||||
// Utility methods
|
||||
// Utility methods
|
||||
nsresult GetSizeAttribute(PRInt32 *aSize);
|
||||
PRInt32 GetNumberOfSelections();
|
||||
nsIContent* GetOptionFromContent(nsIContent *aContent);
|
||||
nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, PRInt32& aOldIndex, PRInt32& aCurIndex);
|
||||
PRInt32 GetSelectedIndexFromContent(nsIContent *aContent);
|
||||
nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, PRInt32& aCurIndex);
|
||||
nsIContent* GetOptionContent(PRInt32 aIndex);
|
||||
PRBool IsContentSelected(nsIContent* aContent);
|
||||
PRBool IsContentSelectedByIndex(PRInt32 aIndex);
|
||||
void SetContentSelected(PRInt32 aIndex,
|
||||
PRBool aSelected,
|
||||
PRBool aDoScrollTo = PR_TRUE,
|
||||
nsIPresShell * aPresShell = nsnull);
|
||||
void SetContentSelected(PRInt32 aIndex,
|
||||
nsIContent * aContent,
|
||||
PRBool aSelected,
|
||||
PRBool aDoScrollTo = PR_TRUE,
|
||||
nsIPresShell * aPresShell = nsnull);
|
||||
void GetViewOffset(nsIViewManager* aManager, nsIView* aView, nsPoint& aPoint);
|
||||
nsresult Deselect();
|
||||
nsIFrame *GetOptionFromChild(nsIFrame* aParentFrame);
|
||||
PRBool IsAncestor(nsIView* aAncestor, nsIView* aChild);
|
||||
nsIView* GetViewFor(nsIWidget* aWidget);
|
||||
PRBool IsInDropDownMode();
|
||||
PRBool IsOptionElement(nsIContent* aContent);
|
||||
PRBool IsOptionElementFrame(nsIFrame *aFrame);
|
||||
nsIFrame *GetSelectableFrame(nsIFrame *aFrame);
|
||||
void DisplaySelected(nsIContent* aContent);
|
||||
void DisplayDeselected(nsIContent* aContent);
|
||||
void ForceRedraw(nsIPresContext* aPresContext);
|
||||
PRBool IsOptionGroup(nsIFrame* aFrame);
|
||||
void SingleSelection();
|
||||
void MultipleSelection(PRBool aIsShift, PRBool aIsControl);
|
||||
void SelectIndex(PRInt32 aIndex);
|
||||
void ToggleSelected(PRInt32 aIndex);
|
||||
void ClearSelection();
|
||||
void ExtendedSelection(PRInt32 aStartIndex, PRInt32 aEndIndex, PRBool aDoInvert, PRBool aSetValue);
|
||||
void SingleSelection(PRInt32 aSelectedIndex, PRBool aDoToggle);
|
||||
void ExtendedSelection(PRInt32 aStartIndex,
|
||||
PRInt32 aEndIndex,
|
||||
PRBool aClearAll);
|
||||
void PerformSelection(PRInt32 aSelectedIndex,
|
||||
PRBool aIsShift,
|
||||
PRBool aIsControl);
|
||||
void ResetSelectedItem();
|
||||
PRBool CheckIfAllFramesHere();
|
||||
|
||||
PRBool HasSameContent(nsIFrame* aFrame1, nsIFrame* aFrame2);
|
||||
void HandleListSelection(nsIDOMEvent * aDOMEvent);
|
||||
PRInt32 GetSelectedIndexFromFrame(nsIFrame *aHitFrame);
|
||||
PRInt32 GetIndexFromContent(nsIContent *aContent);
|
||||
void HandleListSelection(nsIDOMEvent * aDOMEvent, PRInt32 selectedIndex);
|
||||
PRBool IsLeftButton(nsIDOMEvent* aMouseEvent);
|
||||
|
||||
nsresult SetOptionsSelectedFromFrame(PRInt32 aStartIndex,
|
||||
PRInt32 aEndIndex,
|
||||
PRBool aValue,
|
||||
PRBool aClearAll);
|
||||
nsresult ToggleOptionSelectedFromFrame(PRInt32 aIndex);
|
||||
void GetScrollableView(nsIScrollableView*& aScrollableView);
|
||||
|
||||
// Timer Methods
|
||||
|
@ -413,16 +377,16 @@ protected:
|
|||
void ItemsHaveBeenRemoved(nsIPresContext * aPresContext);
|
||||
|
||||
// onChange detection
|
||||
nsresult SelectionChanged(nsIContent* aContent);
|
||||
nsresult SelectionChanged();
|
||||
|
||||
// Data Members
|
||||
nsFormFrame* mFormFrame;
|
||||
PRInt32 mSelectedIndex;
|
||||
PRInt32 mOldSelectedIndex;
|
||||
|
||||
PRInt32 mStartSelectionIndex;
|
||||
PRInt32 mEndSelectionIndex;
|
||||
PRBool mChangesNotNotified;
|
||||
|
||||
PRInt32 mSelectedIndexWhenPoppedDown;
|
||||
PRInt32 mStartExtendedIndex;
|
||||
PRInt32 mEndExtendedIndex;
|
||||
PRPackedBool mIsInitializedFromContent;
|
||||
nsIComboboxControlFrame *mComboboxFrame;
|
||||
PRPackedBool mButtonDown;
|
||||
nscoord mMaxWidth;
|
||||
|
@ -430,9 +394,6 @@ protected:
|
|||
PRPackedBool mIsCapturingMouseEvents;
|
||||
PRInt32 mNumDisplayRows;
|
||||
|
||||
nsVoidArray * mSelectionCache;
|
||||
PRInt32 mSelectionCacheLength;
|
||||
|
||||
PRBool mIsAllContentHere;
|
||||
PRPackedBool mIsAllFramesHere;
|
||||
PRPackedBool mHasBeenInitialized;
|
||||
|
@ -440,13 +401,8 @@ protected:
|
|||
|
||||
PRPackedBool mOverrideReflowOpt;
|
||||
|
||||
PRInt32 mDelayedIndexSetting;
|
||||
PRPackedBool mDelayedValueSetting;
|
||||
|
||||
nsIPresContext* mPresContext; // XXX: Remove the need to cache the pres context.
|
||||
|
||||
nsCOMPtr<nsIPresState> mPresState; // Need cache state when list is null
|
||||
|
||||
nsCOMPtr<nsIListEventListener> mEventListener; // ref counted
|
||||
nsCWeakReferent mWeakReferent; // so this obj can be used as a weak ptr
|
||||
|
||||
|
@ -459,6 +415,8 @@ protected:
|
|||
// Update timer
|
||||
nsSelectUpdateTimer * mUpdateTimer;
|
||||
|
||||
nsIFrame* mDummyFrame;
|
||||
|
||||
//Resize Reflow OpitmizationSize;
|
||||
nsSize mCacheSize;
|
||||
nsSize mCachedMaxElementSize;
|
||||
|
|
|
@ -87,7 +87,7 @@ nsRadioControlGroup::SetCheckedRadio(nsGfxRadioControlFrame* aRadio)
|
|||
}
|
||||
|
||||
void
|
||||
nsRadioControlGroup::GetName(nsString& aNameResult) const
|
||||
nsRadioControlGroup::GetName(nsAString& aNameResult) const
|
||||
{
|
||||
aNameResult = mName;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
nsGfxRadioControlFrame* GetCheckedRadio();
|
||||
void SetCheckedRadio(nsGfxRadioControlFrame* aRadio);
|
||||
void GetName(nsString& aNameResult) const;
|
||||
void GetName(nsAString& aNameResult) const;
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
|
|
|
@ -73,9 +73,9 @@
|
|||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIComboboxControlFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsISelectControlFrame.h"
|
||||
#include "nsIRadioControlFrame.h"
|
||||
#include "nsICheckboxControlFrame.h"
|
||||
#include "nsIListControlFrame.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsITextContent.h"
|
||||
|
@ -967,7 +967,7 @@ public:
|
|||
}
|
||||
|
||||
already_AddRefed<nsIContent> get() const {
|
||||
nsIContent* result;
|
||||
nsIContent* result = nsnull;
|
||||
if (mNodes) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
mNodes->Item(mIndex, getter_AddRefs(node));
|
||||
|
@ -1541,7 +1541,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell,
|
|||
rv = NS_NewFileControlFrame(aPresShell, &aFrame);
|
||||
}
|
||||
else if (val.EqualsIgnoreCase("hidden")) {
|
||||
rv = ConstructButtonControlFrame(aPresShell, aPresContext, aFrame);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else if (val.EqualsIgnoreCase("image")) {
|
||||
rv = NS_NewImageControlFrame(aPresShell, &aFrame);
|
||||
|
@ -3930,14 +3930,15 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIPresShell* aPresShell
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (GetFormElementRenderingMode(aPresContext, eWidgetType_Button) == eWidgetRendering_Gfx)
|
||||
rv = NS_NewGfxButtonControlFrame(aPresShell, &aNewFrame);
|
||||
else
|
||||
if (GetFormElementRenderingMode(aPresContext, eWidgetType_Button)
|
||||
== eWidgetRendering_Gfx)
|
||||
rv = NS_NewGfxButtonControlFrame(aPresShell, &aNewFrame);
|
||||
else
|
||||
NS_ASSERTION(0, "We longer support native widgets");
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -3947,10 +3948,10 @@ nsCSSFrameConstructor::ConstructButtonControlFrame(nsIPresShell* aPresShe
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame,
|
||||
nsIContent* aContent)
|
||||
nsCSSFrameConstructor::ConstructTextControlFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIFrame*& aNewFrame,
|
||||
nsIContent* aContent)
|
||||
{
|
||||
if (!aPresContext) { return NS_ERROR_NULL_POINTER;}
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -4236,20 +4237,10 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell,
|
|||
nsresult result = aContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement),
|
||||
(void**)getter_AddRefs(selectElement));
|
||||
if (NS_SUCCEEDED(result) && selectElement) {
|
||||
PRUint32 numOptions = 0;
|
||||
result = selectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(result) && 0 == numOptions) {
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
scrolledFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState, scrolledFrame, aContent,
|
||||
styleContext, nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
childItems.AddChild(generatedFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
AddDummyFrameToSelect(aPresContext, aPresShell, aState,
|
||||
scrollFrame, scrolledFrame, &childItems,
|
||||
aContent, selectElement);
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
@ -4511,7 +4502,8 @@ nsCSSFrameConstructor::ConstructFrameByTag(nsIPresShell* aPresShell,
|
|||
ProcessPseudoFrames(aPresContext, aState.mPseudoFrames, aFrameItems);
|
||||
}
|
||||
isReplaced = PR_TRUE;
|
||||
rv = CreateInputFrame(aPresShell, aPresContext, aContent, newFrame, aStyleContext);
|
||||
rv = CreateInputFrame(aPresShell, aPresContext,
|
||||
aContent, newFrame, aStyleContext);
|
||||
}
|
||||
else if (nsHTMLAtoms::textarea == aTag) {
|
||||
if (!aState.mPseudoFrames.IsEmpty()) { // process pending pseudo frames
|
||||
|
@ -5532,6 +5524,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
|
|||
processChildren = PR_TRUE;
|
||||
isReplaced = PR_TRUE;
|
||||
|
||||
|
||||
rv = NS_NewStackFrame(aPresShell, &newFrame);
|
||||
|
||||
if (IsScrollable(aPresContext, display)) {
|
||||
|
@ -8230,6 +8223,56 @@ nsCSSFrameConstructor::ContentAppended(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::AddDummyFrameToSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell* aPresShell,
|
||||
nsFrameConstructorState& aState,
|
||||
nsIFrame* aListFrame,
|
||||
nsIFrame* aParentFrame,
|
||||
nsFrameItems* aChildItems,
|
||||
nsIContent* aContainer,
|
||||
nsIDOMHTMLSelectElement* aSelectElement)
|
||||
{
|
||||
PRUint32 numOptions = 0;
|
||||
nsresult rv = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(rv) && 0 == numOptions) {
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
CallQueryInterface(aListFrame, &listFrame);
|
||||
if (listFrame) {
|
||||
nsIFrame* dummyFrame;
|
||||
listFrame->GetDummyFrame(&dummyFrame);
|
||||
|
||||
if (!dummyFrame) {
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
aParentFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
if (CreateGeneratedContentFrame(aPresShell, aPresContext, aState,
|
||||
aParentFrame, aContainer,
|
||||
styleContext,
|
||||
nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
if (aChildItems) {
|
||||
aChildItems->AddChild(generatedFrame);
|
||||
} else {
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
if (frameManager) {
|
||||
frameManager->AppendFrames(aPresContext, *aPresShell,
|
||||
aParentFrame, nsnull, generatedFrame);
|
||||
}
|
||||
}
|
||||
|
||||
listFrame->SetDummyFrame(generatedFrame);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell * aPresShell,
|
||||
|
@ -8237,42 +8280,33 @@ nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
|||
nsIContent* aChild,
|
||||
nsIDOMHTMLSelectElement * aSelectElement)
|
||||
{
|
||||
//check to see if there is one item,
|
||||
// meaning we need to remove the dummy frame
|
||||
// Check to see if this is the first thing we have added to this frame.
|
||||
|
||||
PRUint32 numOptions = 0;
|
||||
nsresult result = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (0 == numOptions) {
|
||||
nsIFrame* parentFrame;
|
||||
nsIFrame* childFrame;
|
||||
// Get the childFrame for the added child (option)
|
||||
// then get the child's parent frame which should be an area frame
|
||||
aPresShell->GetPrimaryFrameFor(aChild, &childFrame);
|
||||
if (nsnull != childFrame) {
|
||||
childFrame->GetParent(&parentFrame);
|
||||
nsresult rv = aSelectElement->GetLength(&numOptions);
|
||||
if (NS_SUCCEEDED(rv) && numOptions > 0) {
|
||||
nsIFrame* frame;
|
||||
aPresShell->GetPrimaryFrameFor(aContainer, &frame);
|
||||
if (frame) {
|
||||
nsISelectControlFrame* listFrame = nsnull;
|
||||
CallQueryInterface(frame, &listFrame);
|
||||
|
||||
// Now loop through all the child looking fr the frame whose content
|
||||
// is equal to the select element's content
|
||||
// this is because when gernated content is created it stuff the parent content
|
||||
// pointer into the generated frame, so in this case it has the select content
|
||||
parentFrame->FirstChild(aPresContext, nsnull, &childFrame);
|
||||
nsCOMPtr<nsIContent> selectContent = do_QueryInterface(aSelectElement);
|
||||
while (nsnull != childFrame) {
|
||||
nsIContent * content;
|
||||
childFrame->GetContent(&content);
|
||||
|
||||
// Found the dummy frame so get the FrameManager and
|
||||
// delete/remove the dummy frame
|
||||
if (selectContent.get() == content) {
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
frameManager->RemoveFrame(aPresContext, *aPresShell, parentFrame, nsnull, childFrame);
|
||||
NS_IF_RELEASE(content);
|
||||
return NS_OK;
|
||||
}
|
||||
if (listFrame) {
|
||||
nsIFrame* dummyFrame;
|
||||
listFrame->GetDummyFrame(&dummyFrame);
|
||||
|
||||
NS_IF_RELEASE(content);
|
||||
childFrame->GetNextSibling(&childFrame);
|
||||
if (dummyFrame) {
|
||||
listFrame->SetDummyFrame(nsnull);
|
||||
|
||||
// get the child's parent frame (which ought to be the list frame)
|
||||
nsIFrame* parentFrame;
|
||||
dummyFrame->GetParent(&parentFrame);
|
||||
|
||||
nsCOMPtr<nsIFrameManager> frameManager;
|
||||
aPresShell->GetFrameManager(getter_AddRefs(frameManager));
|
||||
frameManager->RemoveFrame(aPresContext, *aPresShell,
|
||||
parentFrame, nsnull, dummyFrame);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9024,37 +9058,27 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
|
|||
// When the last item is removed from a select,
|
||||
// we need to add a pseudo frame so select gets sized as the best it can
|
||||
// so here we see if it is a select and then we get the number of options
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
if (aContainer && childFrame) {
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> selectElement = do_QueryInterface(aContainer);
|
||||
if (selectElement) {
|
||||
PRUint32 numOptions = 0;
|
||||
result = selectElement->GetLength(&numOptions);
|
||||
nsIFrame * selectFrame; // XXX temp needed only native controls
|
||||
shell->GetPrimaryFrameFor(aContainer, &selectFrame);// XXX temp needed only native controls
|
||||
// XXX temp needed only native controls
|
||||
nsIFrame* selectFrame;
|
||||
// XXX temp needed only native controls
|
||||
shell->GetPrimaryFrameFor(aContainer, &selectFrame);
|
||||
|
||||
// For "select" add the pseudo frame after the last item is deleted
|
||||
nsIFrame* parentFrame = nsnull;
|
||||
childFrame->GetParent(&parentFrame);
|
||||
if (parentFrame == selectFrame) { // XXX temp needed only native controls
|
||||
if (parentFrame == selectFrame) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(result) && shell && parentFrame && 1 == numOptions) {
|
||||
|
||||
nsIStyleContext* styleContext = nsnull;
|
||||
nsIFrame* generatedFrame = nsnull;
|
||||
nsFrameConstructorState state(aPresContext, nsnull, nsnull, nsnull, nsnull);
|
||||
|
||||
//shell->GetPrimaryFrameFor(aContainer, &contentFrame);
|
||||
parentFrame->GetStyleContext(&styleContext);
|
||||
if (CreateGeneratedContentFrame(shell, aPresContext, state, parentFrame, aContainer,
|
||||
styleContext, nsLayoutAtoms::dummyOptionPseudo,
|
||||
PR_FALSE, &generatedFrame)) {
|
||||
// Add the generated frame to the child list
|
||||
frameManager->AppendFrames(aPresContext, *shell, parentFrame, nsnull, generatedFrame);
|
||||
}
|
||||
NS_IF_RELEASE(styleContext);
|
||||
}
|
||||
if (shell && parentFrame) {
|
||||
nsFrameConstructorState state(aPresContext,
|
||||
nsnull, nsnull, nsnull, nsnull);
|
||||
AddDummyFrameToSelect(aPresContext, shell, state,
|
||||
selectFrame, parentFrame, nsnull,
|
||||
aContainer, selectElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11271,7 +11295,7 @@ nsCSSFrameConstructor::GetInsertionPoint(nsIPresShell* aPresShell,
|
|||
if (insertionPoint) {
|
||||
// If the insertion point is a scrollable, then walk ``through''
|
||||
// it to get the scrolled frame.
|
||||
nsIScrollableFrame* scroll;
|
||||
nsIScrollableFrame* scroll = nsnull;
|
||||
CallQueryInterface(insertionPoint, &scroll);
|
||||
if (scroll)
|
||||
scroll->GetScrolledFrame(nsnull, insertionPoint);
|
||||
|
|
|
@ -611,11 +611,20 @@ protected:
|
|||
PRBool aParentIsBlock,
|
||||
nsTableCreator* aTableCreator = nsnull);
|
||||
|
||||
nsresult CreateInputFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext *aPresContext,
|
||||
nsIContent *aContent,
|
||||
nsIFrame *&aFrame,
|
||||
nsIStyleContext *aStyleContext);
|
||||
nsresult CreateInputFrame(nsIPresShell* aPresShell,
|
||||
nsIPresContext* aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame*& aFrame,
|
||||
nsIStyleContext* aStyleContext);
|
||||
|
||||
nsresult AddDummyFrameToSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell* aPresShell,
|
||||
nsFrameConstructorState& aState,
|
||||
nsIFrame* aListFrame,
|
||||
nsIFrame* aParentFrame,
|
||||
nsFrameItems* aChildItems,
|
||||
nsIContent* aContainer,
|
||||
nsIDOMHTMLSelectElement* aSelectElement);
|
||||
|
||||
nsresult RemoveDummyFrameFromSelect(nsIPresContext* aPresContext,
|
||||
nsIPresShell * aPresShell,
|
||||
|
|
|
@ -216,6 +216,7 @@ optgroup:before {
|
|||
input[disabled],
|
||||
textarea[disabled],
|
||||
option[disabled],
|
||||
optgroup[disabled],
|
||||
select[disabled],
|
||||
select[disabled]:-moz-display-comboboxcontrol-frame {
|
||||
color: GrayText;
|
||||
|
|
Загрузка…
Ссылка в новой задаче