diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 4545e36b5c49..648c92a6a9b3 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -2899,8 +2899,7 @@ nsEventStateManager::ChangeFocus(nsIContent* aFocusContent, PRInt32 aFocusedWith mCurrentFocus && mCurrentFocus->IsContentOfType(nsIContent::eHTML_FORM_CONTROL)) { nsCOMPtr formControl(do_QueryInterface(mCurrentFocus)); - PRInt32 controlType; - formControl->GetType(&controlType); + PRInt32 controlType = formControl->GetType(); if (controlType == NS_FORM_INPUT_TEXT || controlType == NS_FORM_INPUT_PASSWORD) { nsCOMPtr inputElement = diff --git a/content/html/content/public/nsIFormControl.h b/content/html/content/public/nsIFormControl.h index 6a532d1a75c6..71498efc635b 100644 --- a/content/html/content/public/nsIFormControl.h +++ b/content/html/content/public/nsIFormControl.h @@ -103,9 +103,9 @@ public: /** * Get the type of this control as an int (see NS_FORM_* above) - * @param aType the type to be returned [OUT] + * @return the type of this control */ - NS_IMETHOD GetType(PRInt32* aType) = 0; + NS_IMETHOD_(PRInt32) GetType() = 0; /** * Reset this form control (as it should be when the user clicks the Reset diff --git a/content/html/content/src/nsFormSubmission.cpp b/content/html/content/src/nsFormSubmission.cpp index 0f4dc8b10a25..ab0fae0ea4ef 100644 --- a/content/html/content/src/nsFormSubmission.cpp +++ b/content/html/content/src/nsFormSubmission.cpp @@ -329,9 +329,7 @@ nsFSURLEncoded::AddNameValuePair(nsIDOMHTMLElement* aSource, // if (!mWarnedFileControl) { nsCOMPtr formControl = do_QueryInterface(aSource); - PRInt32 type; - formControl->GetType(&type); - if (type == NS_FORM_INPUT_FILE) { + if (formControl->GetType() == NS_FORM_INPUT_FILE) { nsCOMPtr content = do_QueryInterface(aSource); SendJSWarning(content, NS_LITERAL_STRING("ForgotFileEnctypeWarning")); mWarnedFileControl = PR_TRUE; @@ -1460,9 +1458,7 @@ nsFormSubmission::ProcessValue(nsIDOMHTMLElement* aSource, if (aName == NS_LITERAL_STRING("_charset_")) { nsCOMPtr formControl = do_QueryInterface(aSource); if (formControl) { - PRInt32 type; - formControl->GetType(&type); - if (type == NS_FORM_INPUT_HIDDEN) { + if (formControl->GetType() == NS_FORM_INPUT_HIDDEN) { return new nsString(mCharset); } } diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index e1ba34bf7446..763cbf45dd00 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -88,7 +88,7 @@ public: NS_DECL_NSIDOMNSHTMLBUTTONELEMENT // overrided nsIFormControl method - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return mType; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -635,14 +635,6 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext* aPresContext, return ret; } -NS_IMETHODIMP -nsHTMLButtonElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "Null pointer bad!"); - *aType = mType; - return NS_OK; -} - #ifdef DEBUG NS_IMETHODIMP nsHTMLButtonElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp index 000f15c3ea8e..7be8f2ef1f4b 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -72,7 +72,7 @@ public: NS_DECL_NSIDOMHTMLFIELDSETELEMENT // nsIFormControl - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_FIELDSET; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -174,15 +174,6 @@ nsHTMLFieldSetElement::GetForm(nsIDOMHTMLFormElement** aForm) // nsIFormControl -NS_IMETHODIMP -nsHTMLFieldSetElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "Null pointer bad"); - *aType = NS_FORM_FIELDSET; - return NS_OK; -} - - #ifdef DEBUG NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 489d2a0fb4f2..73512db4b479 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -394,15 +394,11 @@ private: static PRBool ShouldBeInElements(nsIFormControl* aFormControl) { - PRInt32 type; - - aFormControl->GetType(&type); - // For backwards compatibility (with 4.x and IE) we must not add // elements to the list of form controls in a // form. - switch (type) { + switch (aFormControl->GetType()) { case NS_FORM_BUTTON_BUTTON : case NS_FORM_BUTTON_RESET : case NS_FORM_BUTTON_SUBMIT : @@ -1246,8 +1242,7 @@ nsHTMLFormElement::AddElement(nsIFormControl* aChild) // // Notify the radio button it's been added to a group // - PRInt32 type; - aChild->GetType(&type); + PRInt32 type = aChild->GetType(); if (type == NS_FORM_INPUT_RADIO) { nsCOMPtr radio = do_QueryInterface(aChild); nsresult rv = radio->AddedToRadioGroup(); @@ -1287,9 +1282,7 @@ nsHTMLFormElement::RemoveElement(nsIFormControl* aChild) // // Remove it from the radio group if it's a radio button // - PRInt32 type; - aChild->GetType(&type); - if (type == NS_FORM_INPUT_RADIO) { + if (aChild->GetType() == NS_FORM_INPUT_RADIO) { nsCOMPtr radio = do_QueryInterface(aChild); nsresult rv = radio->WillRemoveFromRadioGroup(); NS_ENSURE_SUCCESS(rv, rv); @@ -1508,9 +1501,7 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName, GetElementCount(&len); for (PRUint32 i=0; iGetType(&type); - if (type == NS_FORM_INPUT_RADIO) { + if (control->GetType() == NS_FORM_INPUT_RADIO) { nsCOMPtr controlContent(do_QueryInterface(control)); if (controlContent) { // @@ -1542,9 +1533,7 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName, // nsCOMPtr formControl(do_QueryInterface(item)); if (formControl) { - PRInt32 type; - formControl->GetType(&type); - if (type == NS_FORM_INPUT_RADIO) { + if (formControl->GetType() == NS_FORM_INPUT_RADIO) { aVisitor->Visit(formControl, &stopIterating); } } else { @@ -1557,9 +1546,7 @@ nsHTMLFormElement::WalkRadioGroup(const nsAString& aName, nodeList->Item(i, getter_AddRefs(node)); nsCOMPtr formControl(do_QueryInterface(node)); if (formControl) { - PRInt32 type; - formControl->GetType(&type); - if (type == NS_FORM_INPUT_RADIO) { + if (formControl->GetType() == NS_FORM_INPUT_RADIO) { aVisitor->Visit(formControl, &stopIterating); if (stopIterating) { break; diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index ab97856e0163..558e07db8ff7 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -162,7 +162,7 @@ public: NS_DECL_NSIPHONETIC // Overriden nsIFormControl methods - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return mType; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -664,11 +664,8 @@ nsHTMLInputElement::SetType(const nsAString& aValue) NS_IMETHODIMP nsHTMLInputElement::GetValue(nsAString& aValue) { - PRInt32 type; - GetType(&type); - - if (type == NS_FORM_INPUT_TEXT || type == NS_FORM_INPUT_PASSWORD || - type == NS_FORM_INPUT_FILE) { + if (mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_PASSWORD || + mType == NS_FORM_INPUT_FILE) { // No need to flush here, if there's no frame created for this // input yet, there won't be a value in it (that we don't already // have) even if we force it to be created @@ -704,7 +701,7 @@ nsHTMLInputElement::GetValue(nsAString& aValue) nsresult rv = GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue); if (rv == NS_CONTENT_ATTR_NOT_THERE && - (type == NS_FORM_INPUT_RADIO || type == NS_FORM_INPUT_CHECKBOX)) { + (mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_CHECKBOX)) { // The default value of a radio or checkbox input is "on". aValue.Assign(NS_LITERAL_STRING("on")); @@ -889,9 +886,7 @@ nsHTMLInputElement::SetChecked(PRBool aChecked) // // Set checked // - PRInt32 type; - GetType(&type); - if (type == NS_FORM_INPUT_RADIO) { + if (mType == NS_FORM_INPUT_RADIO) { // // For radio button, we need to do some extra fun stuff // @@ -989,19 +984,16 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked) return NS_OK; } - PRInt32 type; - GetType(&type); - nsCOMPtr presContext; GetPresContext(this, getter_AddRefs(presContext)); - if (type == NS_FORM_INPUT_CHECKBOX) { + if (mType == NS_FORM_INPUT_CHECKBOX) { nsICheckboxControlFrame* checkboxFrame = nsnull; CallQueryInterface(frame, &checkboxFrame); if (checkboxFrame) { checkboxFrame->OnChecked(presContext, aChecked); } - } else if (type == NS_FORM_INPUT_RADIO) { + } else if (mType == NS_FORM_INPUT_RADIO) { nsIRadioControlFrame* radioFrame = nsnull; CallQueryInterface(frame, &radioFrame); if (radioFrame) { @@ -1150,12 +1142,7 @@ nsHTMLInputElement::Select() return rv; } - // see what type of input we are. Only select for texts and passwords - PRInt32 type; - GetType(&type); - - if (NS_FORM_INPUT_PASSWORD == type || - NS_FORM_INPUT_TEXT == type) { + if (mType == NS_FORM_INPUT_PASSWORD || mType == NS_FORM_INPUT_TEXT) { // XXX Bug? We have to give the input focus before contents can be // selected @@ -1250,13 +1237,9 @@ nsHTMLInputElement::Click() // see what type of input we are. Only click button, checkbox, radio, // reset, submit, & image - PRInt32 type; - GetType(&type); - if (NS_FORM_INPUT_BUTTON == type || - NS_FORM_INPUT_CHECKBOX == type || - NS_FORM_INPUT_RADIO == type || - NS_FORM_INPUT_RESET == type || - NS_FORM_INPUT_SUBMIT == type) { + if (mType == NS_FORM_INPUT_BUTTON || mType == NS_FORM_INPUT_CHECKBOX || + mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_RESET || + mType == NS_FORM_INPUT_SUBMIT) { nsCOMPtr doc; // Strong rv = GetDocument(*getter_AddRefs(doc)); @@ -1673,8 +1656,7 @@ nsHTMLInputElement::HandleDOMEvent(nsIPresContext* aPresContext, currentControl = do_QueryInterface(currentControlSupports); if (currentControl) { - PRInt32 type; - currentControl->GetType(&type); + PRInt32 type = currentControl->GetType(); if (!submitControl && (type == NS_FORM_INPUT_SUBMIT || type == NS_FORM_BUTTON_SUBMIT || @@ -2060,14 +2042,6 @@ nsHTMLInputElement::GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapR // nsIFormControl -NS_IMETHODIMP -nsHTMLInputElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "aType must not be null!"); - *aType = mType; - return NS_OK; -} - #ifdef DEBUG NS_IMETHODIMP nsHTMLInputElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const @@ -2086,11 +2060,8 @@ nsHTMLInputElement::GetControllers(nsIControllers** aResult) { NS_ENSURE_ARG_POINTER(aResult); - PRInt32 type; - GetType(&type); - //XXX: what about type "file"? - if (NS_FORM_INPUT_TEXT == type || NS_FORM_INPUT_PASSWORD == type) + if (mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_PASSWORD) { if (!mControllers) { @@ -2278,12 +2249,10 @@ nsresult nsHTMLInputElement::Reset() { nsresult rv = NS_OK; - PRInt32 type; - GetType(&type); nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); - switch (type) { + switch (mType) { case NS_FORM_INPUT_CHECKBOX: case NS_FORM_INPUT_RADIO: { @@ -2340,19 +2309,10 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, return rv; } - // - // Get the type (many ops depend on the type) - // - PRInt32 type; - rv = GetType(&type); - if (NS_FAILED(rv)) { - return rv; - } - // // For type=reset, and type=button, we just never submit, period. // - if (type == NS_FORM_INPUT_RESET || type == NS_FORM_INPUT_BUTTON) { + if (mType == NS_FORM_INPUT_RESET || mType == NS_FORM_INPUT_BUTTON) { return rv; } @@ -2360,7 +2320,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // For type=image and type=button, we only submit if we were the button // pressed // - if ((type == NS_FORM_INPUT_SUBMIT || type == NS_FORM_INPUT_IMAGE) + if ((mType == NS_FORM_INPUT_SUBMIT || mType == NS_FORM_INPUT_IMAGE) && aSubmitElement != this) { return rv; } @@ -2368,7 +2328,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // // For type=radio and type=checkbox, we only submit if checked=true // - if (type == NS_FORM_INPUT_RADIO || type == NS_FORM_INPUT_CHECKBOX) { + if (mType == NS_FORM_INPUT_RADIO || mType == NS_FORM_INPUT_CHECKBOX) { PRBool checked; rv = GetChecked(&checked); if (NS_FAILED(rv) || !checked) { @@ -2389,7 +2349,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // // Submit .x, .y for input type=image // - if (type == NS_FORM_INPUT_IMAGE) { + if (mType == NS_FORM_INPUT_IMAGE) { // 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. @@ -2448,7 +2408,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // // Submit file if it's input type=file and this encoding method accepts files // - if (type == NS_FORM_INPUT_FILE) { + if (mType == NS_FORM_INPUT_FILE) { // // Open the file // @@ -2550,7 +2510,7 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission, // Submit // (for type=image, only submit if value is non-null) - if (type != NS_FORM_INPUT_IMAGE || !value.IsEmpty()) { + if (mType != NS_FORM_INPUT_IMAGE || !value.IsEmpty()) { rv = aFormSubmission->AddNameValuePair(this, name, value); } @@ -2563,11 +2523,8 @@ nsHTMLInputElement::SaveState() { nsresult rv = NS_OK; - PRInt32 type; - GetType(&type); - nsCOMPtr state; - switch (type) { + switch (mType) { case NS_FORM_INPUT_CHECKBOX: case NS_FORM_INPUT_RADIO: { @@ -2578,7 +2535,7 @@ nsHTMLInputElement::SaveState() // Only save if checked != defaultChecked (bug 62713) // (always save if it's a radio button so that the checked // state of all radio buttons is restored) - if (type == NS_FORM_INPUT_RADIO || checked != defaultChecked) { + if (mType == NS_FORM_INPUT_RADIO || checked != defaultChecked) { rv = GetPrimaryPresState(this, getter_AddRefs(state)); if (state) { if (checked) { @@ -2669,10 +2626,7 @@ nsHTMLInputElement::RestoreState(nsIPresState* aState) { nsresult rv = NS_OK; - PRInt32 type; - GetType(&type); - - switch (type) { + switch (mType) { case NS_FORM_INPUT_CHECKBOX: case NS_FORM_INPUT_RADIO: { diff --git a/content/html/content/src/nsHTMLLabelElement.cpp b/content/html/content/src/nsHTMLLabelElement.cpp index 0f1729a40d66..f99cdb8bc9ce 100644 --- a/content/html/content/src/nsHTMLLabelElement.cpp +++ b/content/html/content/src/nsHTMLLabelElement.cpp @@ -170,7 +170,7 @@ public: NS_DECL_NSIDOMHTMLLABELELEMENT // nsIFormControl - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_LABEL; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -288,17 +288,6 @@ nsHTMLLabelElement::GetForm(nsIDOMHTMLFormElement** aForm) } -// nsIFormControl - -NS_IMETHODIMP -nsHTMLLabelElement::GetType(PRInt32* aType) -{ - *aType = NS_FORM_LABEL; - - return NS_OK; -} - - NS_IMPL_STRING_ATTR(nsHTMLLabelElement, AccessKey, accesskey) //NS_IMPL_STRING_ATTR(nsHTMLLabelElement, HtmlFor, _for) diff --git a/content/html/content/src/nsHTMLLegendElement.cpp b/content/html/content/src/nsHTMLLegendElement.cpp index 455b3e0b863a..a184c3971b1e 100644 --- a/content/html/content/src/nsHTMLLegendElement.cpp +++ b/content/html/content/src/nsHTMLLegendElement.cpp @@ -72,7 +72,7 @@ public: NS_DECL_NSIDOMHTMLLEGENDELEMENT // nsIFormControl - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_LEGEND; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -172,16 +172,6 @@ nsHTMLLegendElement::GetForm(nsIDOMHTMLFormElement** aForm) return nsGenericHTMLContainerFormElement::GetForm(aForm); } -// nsIFormControl - -NS_IMETHODIMP -nsHTMLLegendElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "Null pointer bad!"); - *aType = NS_FORM_LEGEND; - return NS_OK; -} - NS_IMPL_STRING_ATTR(nsHTMLLegendElement, AccessKey, accesskey) NS_IMPL_STRING_ATTR(nsHTMLLegendElement, Align, align) diff --git a/content/html/content/src/nsHTMLObjectElement.cpp b/content/html/content/src/nsHTMLObjectElement.cpp index 200e6aabf192..23c35bbb94ea 100644 --- a/content/html/content/src/nsHTMLObjectElement.cpp +++ b/content/html/content/src/nsHTMLObjectElement.cpp @@ -70,7 +70,7 @@ public: NS_DECL_NSIDOMHTMLOBJECTELEMENT // Overriden nsIFormControl methods - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_OBJECT; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -174,14 +174,6 @@ nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) // nsIFormControl -NS_IMETHODIMP -nsHTMLObjectElement::GetType(PRInt32* aType) -{ - NS_PRECONDITION(aType, "aType must not be null!"); - *aType = NS_FORM_OBJECT; - return NS_OK; -} - NS_IMETHODIMP nsHTMLObjectElement::Reset() { diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index b53d5d42d745..040f5f9c80ba 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -243,7 +243,7 @@ public: NS_IMETHOD RemoveFocus(nsIPresContext* aPresContext); // Overriden nsIFormControl methods - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_SELECT; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -1941,14 +1941,6 @@ nsHTMLSelectElement::HandleDOMEvent(nsIPresContext* aPresContext, // nsIFormControl -NS_IMETHODIMP -nsHTMLSelectElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "Null pointer bad!"); - *aType = NS_FORM_SELECT; - return NS_OK; -} - NS_IMETHODIMP nsHTMLSelectElement::SaveState() { diff --git a/content/html/content/src/nsHTMLSharedObjectElement.cpp b/content/html/content/src/nsHTMLSharedObjectElement.cpp index 200e6aabf192..23c35bbb94ea 100644 --- a/content/html/content/src/nsHTMLSharedObjectElement.cpp +++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp @@ -70,7 +70,7 @@ public: NS_DECL_NSIDOMHTMLOBJECTELEMENT // Overriden nsIFormControl methods - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_OBJECT; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -174,14 +174,6 @@ nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement** aForm) // nsIFormControl -NS_IMETHODIMP -nsHTMLObjectElement::GetType(PRInt32* aType) -{ - NS_PRECONDITION(aType, "aType must not be null!"); - *aType = NS_FORM_OBJECT; - return NS_OK; -} - NS_IMETHODIMP nsHTMLObjectElement::Reset() { diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 6b784bbab54a..0ce5b1b1a7ec 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -108,7 +108,7 @@ public: NS_DECL_NSITEXTAREAELEMENT // nsIFormControl - NS_IMETHOD GetType(PRInt32* aType); + NS_IMETHOD_(PRInt32) GetType() { return NS_FORM_TEXTAREA; } NS_IMETHOD Reset(); NS_IMETHOD SubmitNamesValues(nsIFormSubmission* aFormSubmission, nsIContent* aSubmitElement); @@ -772,15 +772,6 @@ nsHTMLTextAreaElement::DoneAddingChildren() return NS_OK; } -// nsIFormControl - -NS_IMETHODIMP -nsHTMLTextAreaElement::GetType(PRInt32* aType) -{ - NS_ASSERTION(aType, "Null pointer bad!"); - *aType = NS_FORM_TEXTAREA; - return NS_OK; -} nsresult nsHTMLTextAreaElement::GetInnerHTML(nsAString& aInnerHTML) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8ac13372f34e..18a84f674bc9 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1672,9 +1672,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell, nsCOMPtr control = do_QueryInterface(aContent); NS_ASSERTION(control, "input is not an nsIFormControl!"); - PRInt32 type; - control->GetType(&type); - switch (type) { + switch (control->GetType()) { case NS_FORM_INPUT_SUBMIT: case NS_FORM_INPUT_RESET: case NS_FORM_INPUT_BUTTON: diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 11e4f45afd15..0e4356f50b3b 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -2286,9 +2286,7 @@ FrameManager::GenerateStateKey(nsIContent* aContent, if (control && mHTMLFormControls && mHTMLForms) { // Append the control type - PRInt32 type; - control->GetType(&type); - KeyAppendInt(type, aKey); + KeyAppendInt(control->GetType(), aKey); // If in a form, add form name / index of form / index in form PRInt32 index = -1; diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index f34900dbd0ee..c4736be57197 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -428,11 +428,10 @@ nsComboboxControlFrame::InitializeControl(nsIPresContext* aPresContext) } //-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsComboboxControlFrame::GetType() const { - *aType = NS_FORM_SELECT; - return NS_OK; + return NS_FORM_SELECT; } //-------------------------------------------------------------- @@ -2423,17 +2422,15 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext, InitTextStr(); nsIFrame * child = aChildList; - while (child != nsnull) { + while (child) { nsIFormControlFrame* fcFrame = nsnull; - rv = child->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame); - if (NS_FAILED(rv) && fcFrame == nsnull) { + CallQueryInterface(child, &fcFrame); + if (fcFrame) { + if (fcFrame->GetType() == NS_FORM_INPUT_BUTTON) { + mButtonFrame = child; + } + } else { mDisplayFrame = child; - } else if (fcFrame != nsnull) { - PRInt32 type; - fcFrame->GetType(&type); - if (type == NS_FORM_INPUT_BUTTON) { - mButtonFrame = child; - } } child->GetNextSibling(&child); } diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 6c833a738ef2..6f64f3541b15 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -145,7 +145,7 @@ public: // nsIFormControlFrame NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); void SetFocus(PRBool aOn, PRBool aRepaint); diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index c23726b08ff8..92ee07dc3fd4 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -194,11 +194,10 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); } -NS_IMETHODIMP -nsFileControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsFileControlFrame::GetType() const { - *aType = NS_FORM_INPUT_FILE; - return NS_OK; + return NS_FORM_INPUT_FILE; } diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 007ef943473c..719844b3e2b6 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -103,7 +103,7 @@ public: PRInt32 aHint); NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); diff --git a/layout/forms/nsFormControlFrame.cpp b/layout/forms/nsFormControlFrame.cpp index 328f96d09e67..c8d01c80f222 100644 --- a/layout/forms/nsFormControlFrame.cpp +++ b/layout/forms/nsFormControlFrame.cpp @@ -709,10 +709,10 @@ nsFormControlFrame::GetSizeFromContent(PRInt32* aSize) const return result; } -NS_IMETHODIMP -nsFormControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsFormControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } NS_IMETHODIMP diff --git a/layout/forms/nsFormControlFrame.h b/layout/forms/nsFormControlFrame.h index 92ba316c0fbe..761fa75d4527 100644 --- a/layout/forms/nsFormControlFrame.h +++ b/layout/forms/nsFormControlFrame.h @@ -153,7 +153,7 @@ public: */ virtual const nsIID& GetIID(); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD GetValue(nsAString* aName); diff --git a/layout/forms/nsFormControlHelper.cpp b/layout/forms/nsFormControlHelper.cpp index b34f1aa3e5ce..a81911af4533 100644 --- a/layout/forms/nsFormControlHelper.cpp +++ b/layout/forms/nsFormControlHelper.cpp @@ -442,15 +442,11 @@ nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult) return rv; } -nsresult -nsFormControlHelper::GetType(nsIContent* aContent, PRInt32* aType) +PRInt32 +nsFormControlHelper::GetType(nsIContent* aContent) { - NS_PRECONDITION(aType, "Null pointer bad!"); nsCOMPtr formControl(do_QueryInterface(aContent)); - if (!formControl) - return NS_ERROR_FAILURE; - - return formControl->GetType(aType); + return formControl->GetType(); } nsresult diff --git a/layout/forms/nsFormControlHelper.h b/layout/forms/nsFormControlHelper.h index 7a4e38c173ee..9b97d801213f 100644 --- a/layout/forms/nsFormControlHelper.h +++ b/layout/forms/nsFormControlHelper.h @@ -136,7 +136,7 @@ public: * @return NS_CONTENT_ATTR_NOT_THERE if the type attribute is undefined * @return NS_ERROR_FAILURE if aContent is null or is not HTML content */ - static nsresult GetType(nsIContent* aContent, PRInt32* aType); + static PRInt32 GetType(nsIContent* aContent); /** * Get the value of the form control (if it's just living in an attr) * @param aContent the content to get the name of diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index c11e1aa50d42..865694d659d9 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -320,8 +320,7 @@ nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString) { const char * propname = nsFormControlHelper::GetHTMLPropertiesFileName(); nsresult rv = NS_OK; - PRInt32 type; - GetType(&type); + PRInt32 type = GetType(); if (type == NS_FORM_INPUT_RESET) { rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Reset").get(), aString); } diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index f201af5bb61c..24f89e7d28c5 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -206,10 +206,10 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessibl #endif -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsHTMLButtonControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } NS_IMETHODIMP diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index 6ca5e2690606..42522b49f38a 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -128,7 +128,7 @@ public: virtual nsresult RequiresWidget(PRBool &aRequiresWidget); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD GetValue(nsAString* aName); virtual void MouseClicked(nsIPresContext* aPresContext); diff --git a/layout/forms/nsIFormControlFrame.h b/layout/forms/nsIFormControlFrame.h index 63246e71ee2f..5c116d8dc75a 100644 --- a/layout/forms/nsIFormControlFrame.h +++ b/layout/forms/nsIFormControlFrame.h @@ -61,7 +61,7 @@ class nsIFormControlFrame : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMCONTROLFRAME_IID) - NS_IMETHOD GetType(PRInt32* aType) const = 0; + NS_IMETHOD_(PRInt32) GetType() const = 0; NS_IMETHOD GetName(nsAString* aName) = 0; diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index 4d1d0f8e6f7c..e9aa0d5e4a2a 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -121,7 +121,7 @@ public: virtual void MouseClicked(nsIPresContext* aPresContext); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); @@ -392,11 +392,10 @@ nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRe aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height); } -NS_IMETHODIMP -nsImageControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsImageControlFrame::GetType() const { - *aType = NS_FORM_INPUT_IMAGE; - return NS_OK; + return NS_FORM_INPUT_IMAGE; } NS_IMETHODIMP diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 2ce8ca45b950..0b432716990f 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1929,11 +1929,10 @@ nsListControlFrame::GetSkipSides() const } //--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsListControlFrame::GetType() const { - *aType = NS_FORM_SELECT; - return NS_OK; + return NS_FORM_SELECT; } diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 5af52a335144..dc162d346ae2 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -229,7 +229,7 @@ public: #endif // nsIFormControlFrame - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 6e4893470918..3baf44908f04 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1313,12 +1313,8 @@ nsTextControlFrame::GetFrameType(nsIAtom** aType) const // XXX: wouldn't it be nice to get this from the style context! PRBool nsTextControlFrame::IsSingleLineTextControl() const { - PRInt32 type; - GetType(&type); - if ((NS_FORM_INPUT_TEXT==type) || (NS_FORM_INPUT_PASSWORD==type)) { - return PR_TRUE; - } - return PR_FALSE; + PRInt32 type = GetType(); + return (type == NS_FORM_INPUT_TEXT) || (type == NS_FORM_INPUT_PASSWORD); } PRBool nsTextControlFrame::IsTextArea() const @@ -1344,12 +1340,7 @@ PRBool nsTextControlFrame::IsPlainTextControl() const PRBool nsTextControlFrame::IsPasswordTextControl() const { - PRInt32 type; - GetType(&type); - if (NS_FORM_INPUT_PASSWORD==type) { - return PR_TRUE; - } - return PR_FALSE; + return GetType() == NS_FORM_INPUT_PASSWORD; } @@ -2101,10 +2092,10 @@ nsTextControlFrame::GetName(nsAString* aResult) return nsFormControlHelper::GetName(mContent, aResult); } -NS_IMETHODIMP -nsTextControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsTextControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } void nsTextControlFrame::SetFocus(PRBool aOn , PRBool aRepaint){} @@ -3001,9 +2992,7 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext, first->SetFrameState(state); //we must turn off scrollbars for singleline text controls - PRInt32 type; - GetType(&type); - if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) + if (IsSingleLineTextControl()) { nsIScrollableFrame *scrollableFrame = nsnull; if (first) diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index dae04edd6e93..c06e09903230 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -130,7 +130,7 @@ public: nsIFrame* aChildList); //==== BEGIN NSIFORMCONTROLFRAME - NS_IMETHOD GetType(PRInt32* aType) const; //* + NS_IMETHOD_(PRInt32) GetType() const; //* NS_IMETHOD GetName(nsAString* aName);//* virtual void SetFocus(PRBool aOn , PRBool aRepaint); virtual void ScrollIntoView(nsIPresContext* aPresContext); diff --git a/layout/html/base/src/nsFrameManager.cpp b/layout/html/base/src/nsFrameManager.cpp index 11e4f45afd15..0e4356f50b3b 100644 --- a/layout/html/base/src/nsFrameManager.cpp +++ b/layout/html/base/src/nsFrameManager.cpp @@ -2286,9 +2286,7 @@ FrameManager::GenerateStateKey(nsIContent* aContent, if (control && mHTMLFormControls && mHTMLForms) { // Append the control type - PRInt32 type; - control->GetType(&type); - KeyAppendInt(type, aKey); + KeyAppendInt(control->GetType(), aKey); // If in a form, add form name / index of form / index in form PRInt32 index = -1; diff --git a/layout/html/forms/public/nsIFormControlFrame.h b/layout/html/forms/public/nsIFormControlFrame.h index 63246e71ee2f..5c116d8dc75a 100644 --- a/layout/html/forms/public/nsIFormControlFrame.h +++ b/layout/html/forms/public/nsIFormControlFrame.h @@ -61,7 +61,7 @@ class nsIFormControlFrame : public nsISupports { public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFORMCONTROLFRAME_IID) - NS_IMETHOD GetType(PRInt32* aType) const = 0; + NS_IMETHOD_(PRInt32) GetType() const = 0; NS_IMETHOD GetName(nsAString* aName) = 0; diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index f34900dbd0ee..c4736be57197 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -428,11 +428,10 @@ nsComboboxControlFrame::InitializeControl(nsIPresContext* aPresContext) } //-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsComboboxControlFrame::GetType() const { - *aType = NS_FORM_SELECT; - return NS_OK; + return NS_FORM_SELECT; } //-------------------------------------------------------------- @@ -2423,17 +2422,15 @@ nsComboboxControlFrame::SetInitialChildList(nsIPresContext* aPresContext, InitTextStr(); nsIFrame * child = aChildList; - while (child != nsnull) { + while (child) { nsIFormControlFrame* fcFrame = nsnull; - rv = child->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame); - if (NS_FAILED(rv) && fcFrame == nsnull) { + CallQueryInterface(child, &fcFrame); + if (fcFrame) { + if (fcFrame->GetType() == NS_FORM_INPUT_BUTTON) { + mButtonFrame = child; + } + } else { mDisplayFrame = child; - } else if (fcFrame != nsnull) { - PRInt32 type; - fcFrame->GetType(&type); - if (type == NS_FORM_INPUT_BUTTON) { - mButtonFrame = child; - } } child->GetNextSibling(&child); } diff --git a/layout/html/forms/src/nsComboboxControlFrame.h b/layout/html/forms/src/nsComboboxControlFrame.h index 6c833a738ef2..6f64f3541b15 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.h +++ b/layout/html/forms/src/nsComboboxControlFrame.h @@ -145,7 +145,7 @@ public: // nsIFormControlFrame NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); void SetFocus(PRBool aOn, PRBool aRepaint); diff --git a/layout/html/forms/src/nsFileControlFrame.cpp b/layout/html/forms/src/nsFileControlFrame.cpp index c23726b08ff8..92ee07dc3fd4 100644 --- a/layout/html/forms/src/nsFileControlFrame.cpp +++ b/layout/html/forms/src/nsFileControlFrame.cpp @@ -194,11 +194,10 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); } -NS_IMETHODIMP -nsFileControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsFileControlFrame::GetType() const { - *aType = NS_FORM_INPUT_FILE; - return NS_OK; + return NS_FORM_INPUT_FILE; } diff --git a/layout/html/forms/src/nsFileControlFrame.h b/layout/html/forms/src/nsFileControlFrame.h index 007ef943473c..719844b3e2b6 100644 --- a/layout/html/forms/src/nsFileControlFrame.h +++ b/layout/html/forms/src/nsFileControlFrame.h @@ -103,7 +103,7 @@ public: PRInt32 aHint); NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); diff --git a/layout/html/forms/src/nsFormControlFrame.cpp b/layout/html/forms/src/nsFormControlFrame.cpp index 328f96d09e67..c8d01c80f222 100644 --- a/layout/html/forms/src/nsFormControlFrame.cpp +++ b/layout/html/forms/src/nsFormControlFrame.cpp @@ -709,10 +709,10 @@ nsFormControlFrame::GetSizeFromContent(PRInt32* aSize) const return result; } -NS_IMETHODIMP -nsFormControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsFormControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } NS_IMETHODIMP diff --git a/layout/html/forms/src/nsFormControlFrame.h b/layout/html/forms/src/nsFormControlFrame.h index 92ba316c0fbe..761fa75d4527 100644 --- a/layout/html/forms/src/nsFormControlFrame.h +++ b/layout/html/forms/src/nsFormControlFrame.h @@ -153,7 +153,7 @@ public: */ virtual const nsIID& GetIID(); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD GetValue(nsAString* aName); diff --git a/layout/html/forms/src/nsFormControlHelper.cpp b/layout/html/forms/src/nsFormControlHelper.cpp index b34f1aa3e5ce..a81911af4533 100644 --- a/layout/html/forms/src/nsFormControlHelper.cpp +++ b/layout/html/forms/src/nsFormControlHelper.cpp @@ -442,15 +442,11 @@ nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult) return rv; } -nsresult -nsFormControlHelper::GetType(nsIContent* aContent, PRInt32* aType) +PRInt32 +nsFormControlHelper::GetType(nsIContent* aContent) { - NS_PRECONDITION(aType, "Null pointer bad!"); nsCOMPtr formControl(do_QueryInterface(aContent)); - if (!formControl) - return NS_ERROR_FAILURE; - - return formControl->GetType(aType); + return formControl->GetType(); } nsresult diff --git a/layout/html/forms/src/nsFormControlHelper.h b/layout/html/forms/src/nsFormControlHelper.h index 7a4e38c173ee..9b97d801213f 100644 --- a/layout/html/forms/src/nsFormControlHelper.h +++ b/layout/html/forms/src/nsFormControlHelper.h @@ -136,7 +136,7 @@ public: * @return NS_CONTENT_ATTR_NOT_THERE if the type attribute is undefined * @return NS_ERROR_FAILURE if aContent is null or is not HTML content */ - static nsresult GetType(nsIContent* aContent, PRInt32* aType); + static PRInt32 GetType(nsIContent* aContent); /** * Get the value of the form control (if it's just living in an attr) * @param aContent the content to get the name of diff --git a/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/layout/html/forms/src/nsGfxButtonControlFrame.cpp index c11e1aa50d42..865694d659d9 100644 --- a/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -320,8 +320,7 @@ nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString) { const char * propname = nsFormControlHelper::GetHTMLPropertiesFileName(); nsresult rv = NS_OK; - PRInt32 type; - GetType(&type); + PRInt32 type = GetType(); if (type == NS_FORM_INPUT_RESET) { rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Reset").get(), aString); } diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index f201af5bb61c..24f89e7d28c5 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -206,10 +206,10 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessibl #endif -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsHTMLButtonControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } NS_IMETHODIMP diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.h b/layout/html/forms/src/nsHTMLButtonControlFrame.h index 6ca5e2690606..42522b49f38a 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.h +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.h @@ -128,7 +128,7 @@ public: virtual nsresult RequiresWidget(PRBool &aRequiresWidget); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD GetValue(nsAString* aName); virtual void MouseClicked(nsIPresContext* aPresContext); diff --git a/layout/html/forms/src/nsImageControlFrame.cpp b/layout/html/forms/src/nsImageControlFrame.cpp index 4d1d0f8e6f7c..e9aa0d5e4a2a 100644 --- a/layout/html/forms/src/nsImageControlFrame.cpp +++ b/layout/html/forms/src/nsImageControlFrame.cpp @@ -121,7 +121,7 @@ public: virtual void MouseClicked(nsIPresContext* aPresContext); - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); @@ -392,11 +392,10 @@ nsImageControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRe aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height); } -NS_IMETHODIMP -nsImageControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsImageControlFrame::GetType() const { - *aType = NS_FORM_INPUT_IMAGE; - return NS_OK; + return NS_FORM_INPUT_IMAGE; } NS_IMETHODIMP diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 2ce8ca45b950..0b432716990f 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -1929,11 +1929,10 @@ nsListControlFrame::GetSkipSides() const } //--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsListControlFrame::GetType() const { - *aType = NS_FORM_SELECT; - return NS_OK; + return NS_FORM_SELECT; } diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index 5af52a335144..dc162d346ae2 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -229,7 +229,7 @@ public: #endif // nsIFormControlFrame - NS_IMETHOD GetType(PRInt32* aType) const; + NS_IMETHOD_(PRInt32) GetType() const; NS_IMETHOD GetName(nsAString* aName); NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); diff --git a/layout/html/forms/src/nsTextControlFrame.cpp b/layout/html/forms/src/nsTextControlFrame.cpp index 6e4893470918..3baf44908f04 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -1313,12 +1313,8 @@ nsTextControlFrame::GetFrameType(nsIAtom** aType) const // XXX: wouldn't it be nice to get this from the style context! PRBool nsTextControlFrame::IsSingleLineTextControl() const { - PRInt32 type; - GetType(&type); - if ((NS_FORM_INPUT_TEXT==type) || (NS_FORM_INPUT_PASSWORD==type)) { - return PR_TRUE; - } - return PR_FALSE; + PRInt32 type = GetType(); + return (type == NS_FORM_INPUT_TEXT) || (type == NS_FORM_INPUT_PASSWORD); } PRBool nsTextControlFrame::IsTextArea() const @@ -1344,12 +1340,7 @@ PRBool nsTextControlFrame::IsPlainTextControl() const PRBool nsTextControlFrame::IsPasswordTextControl() const { - PRInt32 type; - GetType(&type); - if (NS_FORM_INPUT_PASSWORD==type) { - return PR_TRUE; - } - return PR_FALSE; + return GetType() == NS_FORM_INPUT_PASSWORD; } @@ -2101,10 +2092,10 @@ nsTextControlFrame::GetName(nsAString* aResult) return nsFormControlHelper::GetName(mContent, aResult); } -NS_IMETHODIMP -nsTextControlFrame::GetType(PRInt32* aType) const +NS_IMETHODIMP_(PRInt32) +nsTextControlFrame::GetType() const { - return nsFormControlHelper::GetType(mContent, aType); + return nsFormControlHelper::GetType(mContent); } void nsTextControlFrame::SetFocus(PRBool aOn , PRBool aRepaint){} @@ -3001,9 +2992,7 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext, first->SetFrameState(state); //we must turn off scrollbars for singleline text controls - PRInt32 type; - GetType(&type); - if ((NS_FORM_INPUT_TEXT == type) || (NS_FORM_INPUT_PASSWORD == type)) + if (IsSingleLineTextControl()) { nsIScrollableFrame *scrollableFrame = nsnull; if (first) diff --git a/layout/html/forms/src/nsTextControlFrame.h b/layout/html/forms/src/nsTextControlFrame.h index dae04edd6e93..c06e09903230 100644 --- a/layout/html/forms/src/nsTextControlFrame.h +++ b/layout/html/forms/src/nsTextControlFrame.h @@ -130,7 +130,7 @@ public: nsIFrame* aChildList); //==== BEGIN NSIFORMCONTROLFRAME - NS_IMETHOD GetType(PRInt32* aType) const; //* + NS_IMETHOD_(PRInt32) GetType() const; //* NS_IMETHOD GetName(nsAString* aName);//* virtual void SetFocus(PRBool aOn , PRBool aRepaint); virtual void ScrollIntoView(nsIPresContext* aPresContext); diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 8ac13372f34e..18a84f674bc9 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -1672,9 +1672,7 @@ nsCSSFrameConstructor::CreateInputFrame(nsIPresShell *aPresShell, nsCOMPtr control = do_QueryInterface(aContent); NS_ASSERTION(control, "input is not an nsIFormControl!"); - PRInt32 type; - control->GetType(&type); - switch (type) { + switch (control->GetType()) { case NS_FORM_INPUT_SUBMIT: case NS_FORM_INPUT_RESET: case NS_FORM_INPUT_BUTTON: