Bug 225984 DRefTool analysis for beos files

r=roc sr=roc
This commit is contained in:
timeless%mozdev.org 2003-11-17 20:43:48 +00:00
Родитель 037f8aab54
Коммит 368aea7260
5 изменённых файлов: 95 добавлений и 77 удалений

Просмотреть файл

@ -134,6 +134,8 @@ NS_IMETHODIMP nsFontMetricsBeOS::Init(const nsFont& aFont, nsIAtom* aLangGroup,
PRInt16 face = 0; PRInt16 face = 0;
mFont = new nsFont(aFont); mFont = new nsFont(aFont);
if (!mFont)
return NS_ERROR_OUT_OF_MEMORY;
float app2dev, app2twip; float app2dev, app2twip;
aContext->GetAppUnitsToDevUnits(app2dev); aContext->GetAppUnitsToDevUnits(app2dev);

Просмотреть файл

@ -81,7 +81,7 @@ nsRenderingContextBeOS::~nsRenderingContextBeOS() {
mStateCache = nsnull; mStateCache = nsnull;
} }
if (mTranMatrix) delete mTranMatrix; delete mTranMatrix;
NS_IF_RELEASE(mOffscreenSurface); NS_IF_RELEASE(mOffscreenSurface);
NS_IF_RELEASE(mFontMetrics); NS_IF_RELEASE(mFontMetrics);
NS_IF_RELEASE(mContext); NS_IF_RELEASE(mContext);
@ -113,11 +113,14 @@ NS_IMETHODIMP nsRenderingContextBeOS::Init(nsIDeviceContext *aContext, nsDrawing
} }
NS_IMETHODIMP nsRenderingContextBeOS::CommonInit() { NS_IMETHODIMP nsRenderingContextBeOS::CommonInit() {
mContext->GetDevUnitsToAppUnits(mP2T); if (!mTranMatrix)
float app2dev; return NS_ERROR_OUT_OF_MEMORY;
mContext->GetAppUnitsToDevUnits(app2dev);
mTranMatrix->AddScale(app2dev, app2dev); mContext->GetDevUnitsToAppUnits(mP2T);
return NS_OK; float app2dev;
mContext->GetAppUnitsToDevUnits(app2dev);
mTranMatrix->AddScale(app2dev, app2dev);
return NS_OK;
} }
// We like PRUnichar rendering, hopefully it's not slowing us too much // We like PRUnichar rendering, hopefully it's not slowing us too much
@ -167,28 +170,40 @@ NS_IMETHODIMP nsRenderingContextBeOS::GetDeviceContext(nsIDeviceContext *&aConte
// Get a new GS // Get a new GS
NS_IMETHODIMP nsRenderingContextBeOS::PushState() { NS_IMETHODIMP nsRenderingContextBeOS::PushState() {
#ifdef USE_GS_POOL #ifdef USE_GS_POOL
nsGraphicsState *state = nsGraphicsStatePool::GetNewGS(); nsGraphicsState *state = nsGraphicsStatePool::GetNewGS();
#else #else
nsGraphicsState *state = new nsGraphicsState; nsGraphicsState *state = new nsGraphicsState;
#endif #endif
// Push into this state object, add to vector
if (!state) return NS_ERROR_OUT_OF_MEMORY;
// Push into this state object, add to vector nsTransform2D *tranMatrix;
if (!state) return NS_ERROR_FAILURE; if (nsnull == mTranMatrix)
tranMatrix = new nsTransform2D();
state->mMatrix = mTranMatrix; else
if (nsnull == mTranMatrix) mTranMatrix = new nsTransform2D(); tranMatrix = new nsTransform2D(mTranMatrix);
else mTranMatrix = new nsTransform2D(mTranMatrix);
if (!tranMatrix) {
// Set state to mClipRegion. SetClip{Rect,Region}() will do copy-on-write stuff #ifdef USE_GS_POOL
state->mClipRegion = mClipRegion; nsGraphicsStatePool::ReleaseGS(state);
#else
NS_IF_ADDREF(mFontMetrics); delete state;
state->mFontMetrics = mFontMetrics; #endif
state->mColor = mCurrentColor; return NS_ERROR_OUT_OF_MEMORY;
state->mLineStyle = mCurrentLineStyle; }
state->mMatrix = mTranMatrix;
mStateCache->AppendElement(state); mTranMatrix = tranMatrix;
return NS_OK;
// Set state to mClipRegion. SetClip{Rect,Region}() will do copy-on-write stuff
state->mClipRegion = mClipRegion;
NS_IF_ADDREF(mFontMetrics);
state->mFontMetrics = mFontMetrics;
state->mColor = mCurrentColor;
state->mLineStyle = mCurrentLineStyle;
mStateCache->AppendElement(state);
return NS_OK;
} }
NS_IMETHODIMP nsRenderingContextBeOS::PopState(PRBool &aClipEmpty) { NS_IMETHODIMP nsRenderingContextBeOS::PopState(PRBool &aClipEmpty) {
@ -201,7 +216,7 @@ NS_IMETHODIMP nsRenderingContextBeOS::PopState(PRBool &aClipEmpty) {
// Assign all local attributes from the state object just popped // Assign all local attributes from the state object just popped
if (state->mMatrix) { if (state->mMatrix) {
if (mTranMatrix) delete mTranMatrix; delete mTranMatrix;
mTranMatrix = state->mMatrix; mTranMatrix = state->mMatrix;
} }

Просмотреть файл

@ -432,12 +432,12 @@ void nsAppShell::RetrieveAllEvents(bool blockable)
while(true) while(true)
{ {
EventItem *newitem = new EventItem; EventItem *newitem = new EventItem;
if ( !newitem ) break;
newitem->code = 0; newitem->code = 0;
newitem->ifdata.data = nsnull; newitem->ifdata.data = nsnull;
newitem->ifdata.sync = 0; newitem->ifdata.sync = 0;
if ( !newitem ) break;
// only block on read_port when // only block on read_port when
// blockable == true // blockable == true
// and // and

Просмотреть файл

@ -1247,31 +1247,31 @@ nsIFontMetrics* nsWindow::GetFont(void)
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsWindow::SetFont(const nsFont &aFont) NS_METHOD nsWindow::SetFont(const nsFont &aFont)
{ {
// Cache Font for owner draw // Cache Font for owner draw
if (mFont == nsnull) { if (mFont == nsnull) {
mFont = new nsFont(aFont); if (!(mFont = new nsFont(aFont)))
} else { return NS_ERROR_OUT_OF_MEMORY;
*mFont = aFont; } else {
} *mFont = aFont;
}
// Bail out if there is no context // Bail out if there is no context
if (nsnull == mContext) { if (nsnull == mContext) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsIFontMetrics* metrics; nsCOMPtr<nsIFontMetrics> metrics;
mContext->GetMetricsFor(aFont, metrics); mContext->GetMetricsFor(aFont, getter_AddRefs(metrics));
nsFontHandle fontHandle; nsFontHandle fontHandle;
metrics->GetFontHandle(fontHandle); metrics->GetFontHandle(fontHandle);
BFont *font = (BFont*)fontHandle; BFont *font = (BFont*)fontHandle;
if(font && mView && mView->LockLooper()) if(font && mView && mView->LockLooper())
{ {
mView->SetFont(font, B_FONT_ALL); mView->SetFont(font, B_FONT_ALL);
mView->UnlockLooper(); mView->UnlockLooper();
} }
NS_RELEASE(metrics);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -148,33 +148,34 @@ nsSplashScreenBeOS::Observe(nsISupports *aSubject,
const char *aTopic, const char *aTopic,
const PRUnichar *someData) const PRUnichar *someData)
{ {
if (!bitmap) return NS_OK; if (!bitmap) return NS_OK;
nsCAutoString statusString; nsCAutoString statusString;
statusString.AssignWithConversion(someData); statusString.AssignWithConversion(someData);
if (textView == NULL) { if (textView == NULL) {
BRect textRect = bitmap->Bounds(); BRect textRect = bitmap->Bounds();
// Reduce the view size, and take into account the image frame textView = new BStringView(textRect,
textRect.bottom -= 10; "splash text",
textRect.left += 10; statusString.get(),
textRect.right -= 10; B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
textRect.top = textRect.bottom - 20; if (textView) {
textView = new BStringView(textRect, // Reduce the view size, and take into account the image frame
"splash text", textRect.bottom -= 10;
statusString.get(), textRect.left += 10;
B_FOLLOW_LEFT | B_FOLLOW_V_CENTER); textRect.right -= 10;
textView->SetViewColor(B_TRANSPARENT_COLOR); textRect.top = textRect.bottom - 20;
textView->SetHighColor(255,255,255,0);
textView->SetLowColor(0,0,0,0); textView->SetViewColor(B_TRANSPARENT_COLOR);
if (textView != NULL) { textView->SetHighColor(255,255,255,0);
window->AddChild(textView); textView->SetLowColor(0,0,0,0);
} window->AddChild(textView);
} else { }
if (textView->LockLooper()) { } else {
textView->SetText(statusString.get()); if (textView->LockLooper()) {
textView->UnlockLooper(); textView->SetText(statusString.get());
} textView->UnlockLooper();
} }
return NS_OK; }
return NS_OK;
} }
nsresult nsresult