Fix dynamic change bugs by making HTMLColorRule immutable. b=99850 r+sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2003-02-22 19:15:46 +00:00
parent 651bd3b256
commit a5105c6ec7
2 changed files with 66 additions and 36 deletions

View File

@ -1154,13 +1154,18 @@ HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
{
if (!mLinkRule) {
mLinkRule = new HTMLColorRule(this);
if (!mLinkRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mLinkRule);
if (mLinkRule) {
if (mLinkRule->mColor == aColor)
return NS_OK;
mLinkRule->mSheet = nsnull;
NS_RELEASE(mLinkRule);
}
mLinkRule = new HTMLColorRule(this);
if (!mLinkRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mLinkRule);
mLinkRule->mColor = aColor;
return NS_OK;
}
@ -1169,13 +1174,18 @@ HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor)
{
if (!mActiveRule) {
mActiveRule = new HTMLColorRule(this);
if (!mActiveRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mActiveRule);
if (mActiveRule) {
if (mActiveRule->mColor == aColor)
return NS_OK;
mActiveRule->mSheet = nsnull;
NS_RELEASE(mActiveRule);
}
mActiveRule = new HTMLColorRule(this);
if (!mActiveRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mActiveRule);
mActiveRule->mColor = aColor;
return NS_OK;
}
@ -1183,13 +1193,18 @@ HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
{
if (!mVisitedRule) {
mVisitedRule = new HTMLColorRule(this);
if (!mVisitedRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mVisitedRule);
if (mVisitedRule) {
if (mVisitedRule->mColor == aColor)
return NS_OK;
mVisitedRule->mSheet = nsnull;
NS_RELEASE(mVisitedRule);
}
mVisitedRule = new HTMLColorRule(this);
if (!mVisitedRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mVisitedRule);
mVisitedRule->mColor = aColor;
return NS_OK;
}

View File

@ -1154,13 +1154,18 @@ HTMLStyleSheetImpl::GetVisitedLinkColor(nscolor& aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
{
if (!mLinkRule) {
mLinkRule = new HTMLColorRule(this);
if (!mLinkRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mLinkRule);
if (mLinkRule) {
if (mLinkRule->mColor == aColor)
return NS_OK;
mLinkRule->mSheet = nsnull;
NS_RELEASE(mLinkRule);
}
mLinkRule = new HTMLColorRule(this);
if (!mLinkRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mLinkRule);
mLinkRule->mColor = aColor;
return NS_OK;
}
@ -1169,13 +1174,18 @@ HTMLStyleSheetImpl::SetLinkColor(nscolor aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor)
{
if (!mActiveRule) {
mActiveRule = new HTMLColorRule(this);
if (!mActiveRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mActiveRule);
if (mActiveRule) {
if (mActiveRule->mColor == aColor)
return NS_OK;
mActiveRule->mSheet = nsnull;
NS_RELEASE(mActiveRule);
}
mActiveRule = new HTMLColorRule(this);
if (!mActiveRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mActiveRule);
mActiveRule->mColor = aColor;
return NS_OK;
}
@ -1183,13 +1193,18 @@ HTMLStyleSheetImpl::SetActiveLinkColor(nscolor aColor)
NS_IMETHODIMP
HTMLStyleSheetImpl::SetVisitedLinkColor(nscolor aColor)
{
if (!mVisitedRule) {
mVisitedRule = new HTMLColorRule(this);
if (!mVisitedRule) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(mVisitedRule);
if (mVisitedRule) {
if (mVisitedRule->mColor == aColor)
return NS_OK;
mVisitedRule->mSheet = nsnull;
NS_RELEASE(mVisitedRule);
}
mVisitedRule = new HTMLColorRule(this);
if (!mVisitedRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mVisitedRule);
mVisitedRule->mColor = aColor;
return NS_OK;
}