Bug 346083, Crash [@ nsBoxObject::SetProperty], r+sr=bz

git-svn-id: svn://10.0.0.236/trunk@205033 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
Olli.Pettay%helsinki.fi 2006-07-28 06:28:27 +00:00
parent 872ffd95ea
commit 06eae5daea
2 changed files with 15 additions and 6 deletions

View File

@ -76,6 +76,7 @@ nsPresState::GetStateProperty(const nsAString& aName, nsAString& aResult)
supportsStr->GetData(data);
CopyUTF8toUTF16(data, aResult);
aResult.SetIsVoid(data.IsVoid());
rv = NS_STATE_PROPERTY_EXISTS;
}
@ -88,8 +89,9 @@ nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue)
// Add to hashtable
nsCOMPtr<nsISupportsCString> supportsStr(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
supportsStr->SetData(NS_ConvertUTF16toUTF8(aValue));
NS_ConvertUTF16toUTF8 data(aValue);
data.SetIsVoid(aValue.IsVoid());
supportsStr->SetData(data);
mPropertyTable.Put(aName, supportsStr);
return NS_OK;

View File

@ -395,18 +395,25 @@ nsBoxObject::GetProperty(const PRUnichar* aPropertyName, PRUnichar** aResult)
nsresult rv = mPresState->GetStateProperty(propertyName, result);
if (NS_FAILED(rv))
return rv;
*aResult = ToNewUnicode(result);
*aResult = result.IsVoid() ? nsnull : ToNewUnicode(result);
return NS_OK;
}
NS_IMETHODIMP
nsBoxObject::SetProperty(const PRUnichar* aPropertyName, const PRUnichar* aPropertyValue)
{
if (!mPresState)
NS_ENSURE_ARG(aPropertyName && *aPropertyName);
if (!mPresState) {
NS_NewPresState(getter_Transfers(mPresState));
NS_ENSURE_TRUE(mPresState, NS_ERROR_OUT_OF_MEMORY);
}
nsDependentString propertyName(aPropertyName);
nsDependentString propertyValue(aPropertyValue);
nsDependentString propertyValue;
if (aPropertyValue) {
propertyValue.Rebind(aPropertyValue);
} else {
propertyValue.SetIsVoid(PR_TRUE);
}
return mPresState->SetStateProperty(propertyName, propertyValue);
}