diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index b1dcccc145c..23d46131712 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -337,7 +337,9 @@ PRBool nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&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 diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 862a428160b..6c38339b622 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -181,7 +181,9 @@ PRBool nsFileControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } void diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 67077c83435..8dcd42c9ad0 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -762,10 +762,14 @@ 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 (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } NS_METHOD diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 5b3b4a44e6d..bf94eab0cf4 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -1399,3 +1399,21 @@ nsFormControlHelper::GetLocalizedString(char* aKey, nsString& oVal) return rv; } +// Return value of disabled attribute or PR_FALSE if none set +nsresult +nsFormControlHelper::GetDisabled(nsIContent* aContent, PRBool* oIsDisabled) +{ + nsCOMPtr formControl = do_QueryInterface(aContent); + nsHTMLValue value; + nsresult result = formControl->GetHTMLAttribute(nsHTMLAtoms::disabled, value); + if (NS_CONTENT_ATTR_HAS_VALUE == result) { + if (eHTMLUnit_Empty == value.GetUnit()) { + *oIsDisabled = PR_TRUE; + } else { + *oIsDisabled = PR_FALSE; + } + } else { + *oIsDisabled = PR_FALSE; + } + return NS_OK; +} diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index 840548fb740..8ea3b7c08c5 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -179,6 +179,8 @@ public: // Localization Helper static nsresult GetLocalizedString(char* aKey, nsString& oVal); + + static nsresult GetDisabled(nsIContent* aContent, PRBool* oIsDisabled); // //------------------------------------------------------------------------------------- // Utility methods for managing checkboxes and radiobuttons diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 148fc40767e..605b40eb6af 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -41,14 +41,18 @@ 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; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } else { - return PR_FALSE; + successful = PR_FALSE; } + return successful; } PRInt32 diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index 8e22916aad8..59f955b13cc 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -280,12 +280,16 @@ nsHTMLButtonControlFrame::GetValue(nsString* aResult) PRBool nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { + PRBool successful = PR_TRUE; if (this == (aSubmitter)) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } else { - return PR_FALSE; + successful = PR_FALSE; } + return successful; } PRBool diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 52726c1f189..bd6c193224a 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -1738,7 +1738,9 @@ PRBool nsListControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index b1dcccc145c..23d46131712 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -337,7 +337,9 @@ PRBool nsComboboxControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&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 diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 862a428160b..6c38339b622 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -181,7 +181,9 @@ PRBool nsFileControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } void diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 67077c83435..8dcd42c9ad0 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -762,10 +762,14 @@ 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 (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } NS_METHOD diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index 5b3b4a44e6d..bf94eab0cf4 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -1399,3 +1399,21 @@ nsFormControlHelper::GetLocalizedString(char* aKey, nsString& oVal) return rv; } +// Return value of disabled attribute or PR_FALSE if none set +nsresult +nsFormControlHelper::GetDisabled(nsIContent* aContent, PRBool* oIsDisabled) +{ + nsCOMPtr formControl = do_QueryInterface(aContent); + nsHTMLValue value; + nsresult result = formControl->GetHTMLAttribute(nsHTMLAtoms::disabled, value); + if (NS_CONTENT_ATTR_HAS_VALUE == result) { + if (eHTMLUnit_Empty == value.GetUnit()) { + *oIsDisabled = PR_TRUE; + } else { + *oIsDisabled = PR_FALSE; + } + } else { + *oIsDisabled = PR_FALSE; + } + return NS_OK; +} diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.h b/mozilla/layout/html/forms/src/nsFormControlHelper.h index 840548fb740..8ea3b7c08c5 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.h +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.h @@ -179,6 +179,8 @@ public: // Localization Helper static nsresult GetLocalizedString(char* aKey, nsString& oVal); + + static nsresult GetDisabled(nsIContent* aContent, PRBool* oIsDisabled); // //------------------------------------------------------------------------------------- // Utility methods for managing checkboxes and radiobuttons diff --git a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp index 148fc40767e..605b40eb6af 100644 --- a/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxButtonControlFrame.cpp @@ -41,14 +41,18 @@ 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; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } else { - return PR_FALSE; + successful = PR_FALSE; } + return successful; } PRInt32 diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index ce8718b5dc9..5bfad207873 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -2085,7 +2085,9 @@ PRBool nsGfxTextControlFrame2::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } NS_IMETHODIMP diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index 8e22916aad8..59f955b13cc 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -280,12 +280,16 @@ nsHTMLButtonControlFrame::GetValue(nsString* aResult) PRBool nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { + PRBool successful = PR_TRUE; if (this == (aSubmitter)) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); } else { - return PR_FALSE; + successful = PR_FALSE; } + return successful; } PRBool diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index 52726c1f189..bd6c193224a 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -1738,7 +1738,9 @@ PRBool nsListControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter) { nsAutoString name; - return (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); + PRBool disabled = PR_FALSE; + nsFormControlHelper::GetDisabled(mContent, &disabled); + return !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name)); }