Commented out the MACRO for for settting and getting the disabled attribute

I implemented them fully so I code set the "disabled" pseudo-class properly
This commit is contained in:
rods%netscape.com 1999-01-27 04:13:44 +00:00
parent 4ce26fdce3
commit afa1a733ff
2 changed files with 58 additions and 4 deletions

View File

@ -216,7 +216,32 @@ nsHTMLButtonElement::GetType(nsString& aType)
}
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
//NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
NS_IMETHODIMP
nsHTMLButtonElement::GetDisabled(PRBool* aValue)
{
nsHTMLValue val;
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::disabled, val);
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLButtonElement::SetDisabled(PRBool aValue)
{
nsHTMLValue empty(eHTMLUnit_Empty);
if (aValue) {
nsresult status = mInner.SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "DISABLED", PR_TRUE);
return status;
}
else {
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "", PR_TRUE);
return NS_OK;
}
}
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Name, name)
NS_IMPL_INT_ATTR(nsHTMLButtonElement, TabIndex, tabindex)
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Value, value)
@ -334,11 +359,13 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
if (activeLink == this) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString href, target;
nsAutoString href, target, disabled;
nsIURL* baseURL = nsnull;
GetBaseURL(baseURL);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, disabled);
if (target.Length() == 0) {
GetBaseTarget(target);
}

View File

@ -216,7 +216,32 @@ nsHTMLButtonElement::GetType(nsString& aType)
}
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, AccessKey, accesskey)
NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
//NS_IMPL_BOOL_ATTR(nsHTMLButtonElement, Disabled, disabled)
NS_IMETHODIMP
nsHTMLButtonElement::GetDisabled(PRBool* aValue)
{
nsHTMLValue val;
nsresult rv = mInner.GetHTMLAttribute(nsHTMLAtoms::disabled, val);
*aValue = NS_CONTENT_ATTR_NOT_THERE != rv;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLButtonElement::SetDisabled(PRBool aValue)
{
nsHTMLValue empty(eHTMLUnit_Empty);
if (aValue) {
nsresult status = mInner.SetHTMLAttribute(nsHTMLAtoms::disabled, empty, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "DISABLED", PR_TRUE);
return status;
}
else {
mInner.UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, PR_TRUE);
mInner.SetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::kClass, "", PR_TRUE);
return NS_OK;
}
}
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Name, name)
NS_IMPL_INT_ATTR(nsHTMLButtonElement, TabIndex, tabindex)
NS_IMPL_STRING_ATTR(nsHTMLButtonElement, Value, value)
@ -334,11 +359,13 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
if (activeLink == this) {
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
nsAutoString href, target;
nsAutoString href, target, disabled;
nsIURL* baseURL = nsnull;
GetBaseURL(baseURL);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::disabled, disabled);
if (target.Length() == 0) {
GetBaseTarget(target);
}