зеркало из https://github.com/mozilla/pjs.git
Fix for Bug#128763
Implementation of SplashScreenObserver for BeOS Removed the nsNativeAppSupportBeOS class, as it was not doing anything, and was interfering with the ability for nsAppRunner to check if nsSplashScreenBeOS implemented the IObserver interface, which it now does. r=cls (seawood@netscape.com) a=asa (on behalf of drivers) for checin to trunk
This commit is contained in:
Родитель
fd47a2b589
Коммит
fd2a869a03
Двоичные данные
xpfe/bootstrap/apprunner-beos.rsrc
Двоичные данные
xpfe/bootstrap/apprunner-beos.rsrc
Двоичный файл не отображается.
|
@ -188,7 +188,7 @@ private:
|
||||||
appFileInfo.SetTo(&file) != B_OK ||
|
appFileInfo.SetTo(&file) != B_OK ||
|
||||||
appFileInfo.GetSignature(sig) != B_OK)
|
appFileInfo.GetSignature(sig) != B_OK)
|
||||||
{
|
{
|
||||||
return "application/x-vnd.mozilla.apprunner";
|
return "application/x-vnd.Mozilla";
|
||||||
}
|
}
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ PRBool NS_CanRun()
|
||||||
// then rely on nsINativeAppSupport and its use of
|
// then rely on nsINativeAppSupport and its use of
|
||||||
// nsISplashScreen will be removed.
|
// nsISplashScreen will be removed.
|
||||||
//
|
//
|
||||||
#if !defined( XP_PC ) && !defined( XP_BEOS ) && !defined(MOZ_WIDGET_GTK)
|
#if !defined( XP_PC ) && !defined(MOZ_WIDGET_GTK)
|
||||||
|
|
||||||
nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult )
|
nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult )
|
||||||
{
|
{
|
||||||
|
@ -1208,7 +1208,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
||||||
splashScreen->Hide();
|
splashScreen->Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release argument object.
|
// Release argument object.
|
||||||
NS_IF_RELEASE(nativeApp);
|
NS_IF_RELEASE(nativeApp);
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -37,248 +37,189 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
#include "nsNativeAppSupportBase.h"
|
#include "nsNativeAppSupportBase.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsICmdLineService.h"
|
#include "nsIObserver.h"
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsXPIDLString.h"
|
|
||||||
#include "nsIComponentManager.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
#include "nsIAppShellService.h"
|
|
||||||
#include "nsAppShellCIDs.h"
|
|
||||||
#include "nsIDOMWindowInternal.h"
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
#include <StringView.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
#include <Font.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define DEBUG_SPLASH 1
|
#define DEBUG_SPLASH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class nsSplashScreenBeOS : public nsISplashScreen {
|
class nsSplashScreenBeOS : public nsISplashScreen,
|
||||||
|
public nsIObserver {
|
||||||
public:
|
public:
|
||||||
nsSplashScreenBeOS();
|
nsSplashScreenBeOS();
|
||||||
~nsSplashScreenBeOS();
|
virtual ~nsSplashScreenBeOS();
|
||||||
|
|
||||||
NS_IMETHOD Show();
|
NS_DECL_ISUPPORTS
|
||||||
NS_IMETHOD Hide();
|
|
||||||
|
|
||||||
// nsISupports methods
|
NS_IMETHOD Show();
|
||||||
NS_IMETHOD_(nsrefcnt) AddRef() {
|
NS_IMETHOD Hide();
|
||||||
mRefCnt++;
|
|
||||||
return mRefCnt;
|
NS_DECL_NSIOBSERVER
|
||||||
}
|
|
||||||
NS_IMETHOD_(nsrefcnt) Release() {
|
|
||||||
--mRefCnt;
|
|
||||||
if ( !mRefCnt ) {
|
|
||||||
delete this;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return mRefCnt;
|
|
||||||
}
|
|
||||||
NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) {
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
if ( p ) {
|
|
||||||
*p = 0;
|
|
||||||
if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
|
|
||||||
nsISplashScreen *result = this;
|
|
||||||
*p = result;
|
|
||||||
NS_ADDREF( result );
|
|
||||||
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
|
|
||||||
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
|
|
||||||
*p = result;
|
|
||||||
NS_ADDREF( result );
|
|
||||||
} else {
|
|
||||||
rv = NS_NOINTERFACE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rv = NS_ERROR_NULL_POINTER;
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsresult LoadBitmap();
|
nsresult LoadBitmap();
|
||||||
|
|
||||||
nsrefcnt mRefCnt;
|
BWindow *window;
|
||||||
BWindow *window;
|
BBitmap *bitmap;
|
||||||
BBitmap *bitmap;
|
BStringView *textView;
|
||||||
}; // class nsSplashScreenBeOS
|
}; // class nsSplashScreenBeOS
|
||||||
|
|
||||||
class nsNativeAppSupportBeOS : public nsNativeAppSupportBase {
|
|
||||||
public:
|
|
||||||
// Overrides of base implementation.
|
|
||||||
NS_IMETHOD Start( PRBool *aResult );
|
|
||||||
NS_IMETHOD Stop( PRBool *aResult );
|
|
||||||
NS_IMETHOD Quit();
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsrefcnt mRefCnt;
|
|
||||||
}; // nsNativeAppSupportBeOS
|
|
||||||
|
|
||||||
nsSplashScreenBeOS::nsSplashScreenBeOS()
|
nsSplashScreenBeOS::nsSplashScreenBeOS()
|
||||||
: mRefCnt( 0 ) , window( NULL ) , bitmap( NULL ) {
|
: window( NULL ) , bitmap( NULL ), textView(NULL) {
|
||||||
|
NS_INIT_REFCNT();
|
||||||
#ifdef DEBUG_SPLASH
|
#ifdef DEBUG_SPLASH
|
||||||
puts("nsSplashScreenBeOS::nsSlpashScreenBeOS()");
|
puts("nsSplashScreenBeOS::nsSlpashScreenBeOS()");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSplashScreenBeOS::~nsSplashScreenBeOS() {
|
nsSplashScreenBeOS::~nsSplashScreenBeOS() {
|
||||||
#ifdef DEBUG_SPLASH
|
#ifdef DEBUG_SPLASH
|
||||||
puts("nsSplashScreenBeOS::~nsSlpashScreenBeOS()");
|
puts("nsSplashScreenBeOS::~nsSlpashScreenBeOS()");
|
||||||
#endif
|
#endif
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS2(nsSplashScreenBeOS, nsISplashScreen, nsIObserver);
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSplashScreenBeOS::Show() {
|
nsSplashScreenBeOS::Show() {
|
||||||
#ifdef DEBUG_SPLASH
|
#ifdef DEBUG_SPLASH
|
||||||
puts("nsSplashScreenBeOS::Show()");
|
puts("nsSplashScreenBeOS::Show()");
|
||||||
#endif
|
#endif
|
||||||
if (NULL == bitmap && NS_OK != LoadBitmap())
|
if (NULL == bitmap && NS_OK != LoadBitmap())
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
// Get the center position.
|
// Get the center position.
|
||||||
BScreen scr;
|
BScreen scr;
|
||||||
BRect scrRect = scr.Frame();
|
BRect scrRect = scr.Frame();
|
||||||
BRect bmpRect = bitmap->Bounds();
|
BRect bmpRect = bitmap->Bounds();
|
||||||
float winX = (scrRect.right - bmpRect.right) / 2;
|
float winX = (scrRect.right - bmpRect.right) / 2;
|
||||||
float winY = (scrRect.bottom - bmpRect.bottom) / 2;
|
float winY = (scrRect.bottom - bmpRect.bottom) / 2;
|
||||||
BRect winRect(winX, winY, winX + bmpRect.right, winY + bmpRect.bottom);
|
BRect winRect(winX, winY, winX + bmpRect.right, winY + bmpRect.bottom);
|
||||||
#ifdef DEBUG_SPLASH
|
#ifdef DEBUG_SPLASH
|
||||||
printf("SplashRect (%f, %f) - (%f, %f)\n", winRect.left, winRect.top,
|
printf("SplashRect (%f, %f) - (%f, %f)\n", winRect.left, winRect.top,
|
||||||
winRect.right, winRect.bottom);
|
winRect.right, winRect.bottom);
|
||||||
#endif
|
#endif
|
||||||
if (NULL == window) {
|
if (NULL == window) {
|
||||||
window = new BWindow(winRect,
|
window = new BWindow(winRect,
|
||||||
"mozilla splash",
|
"mozilla splash",
|
||||||
B_NO_BORDER_WINDOW_LOOK,
|
B_NO_BORDER_WINDOW_LOOK,
|
||||||
B_MODAL_APP_WINDOW_FEEL,
|
B_MODAL_APP_WINDOW_FEEL,
|
||||||
0);
|
0);
|
||||||
if (NULL == window)
|
if (NULL == window)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
BView *view = new BView(bmpRect, "splash view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
BView *view = new BView(bmpRect, "splash view", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
|
||||||
if (NULL != view) {
|
if (NULL != view) {
|
||||||
window->AddChild(view);
|
window->AddChild(view);
|
||||||
view->SetViewBitmap(bitmap);
|
view->SetViewBitmap(bitmap);
|
||||||
}
|
}
|
||||||
window->Show();
|
window->Show();
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSplashScreenBeOS::Hide() {
|
nsSplashScreenBeOS::Hide() {
|
||||||
#ifdef DEBUG_SPLASH
|
#ifdef DEBUG_SPLASH
|
||||||
puts("nsSplashScreenBeOS::Hide()");
|
puts("nsSplashScreenBeOS::Hide()");
|
||||||
#endif
|
#endif
|
||||||
if (NULL != window) {
|
if (NULL != window) {
|
||||||
if (window->Lock())
|
if (window->Lock())
|
||||||
window->Quit();
|
window->Quit();
|
||||||
window = NULL;
|
window = NULL;
|
||||||
}
|
}
|
||||||
if (NULL != bitmap) {
|
if (NULL != bitmap) {
|
||||||
delete bitmap;
|
delete bitmap;
|
||||||
bitmap = NULL;
|
bitmap = NULL;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsSplashScreenBeOS::Observe(nsISupports *aSubject,
|
||||||
|
const char *aTopic,
|
||||||
|
const PRUnichar *someData)
|
||||||
|
{
|
||||||
|
nsCAutoString statusString;
|
||||||
|
statusString.AssignWithConversion(someData);
|
||||||
|
if (textView == NULL) {
|
||||||
|
BRect textRect = bitmap->Bounds();
|
||||||
|
// Reduce the view size, and take into account the image frame
|
||||||
|
textRect.bottom -= 10;
|
||||||
|
textRect.left += 10;
|
||||||
|
textRect.right -= 10;
|
||||||
|
textRect.top = textRect.bottom - 20;
|
||||||
|
textView = new BStringView(textRect,
|
||||||
|
"splash text",
|
||||||
|
statusString.get(),
|
||||||
|
B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
|
||||||
|
textView->SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
|
textView->SetHighColor(255,255,255,0);
|
||||||
|
textView->SetLowColor(0,0,0,0);
|
||||||
|
if (textView != NULL) {
|
||||||
|
window->AddChild(textView);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (textView->LockLooper()) {
|
||||||
|
textView->SetText(statusString.get());
|
||||||
|
textView->UnlockLooper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsSplashScreenBeOS::LoadBitmap() {
|
nsSplashScreenBeOS::LoadBitmap() {
|
||||||
BResources *rsrc = be_app->AppResources();
|
BResources *rsrc = be_app->AppResources();
|
||||||
if (NULL == rsrc)
|
if (NULL == rsrc)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
size_t length;
|
size_t length;
|
||||||
const void *data = rsrc->LoadResource('BBMP', "MOZILLA:SPLASH", &length);
|
const void *data = rsrc->LoadResource('BBMP', "MOZILLA:SPLASH", &length);
|
||||||
if (NULL == data)
|
if (NULL == data)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
BMessage msg;
|
BMessage msg;
|
||||||
if (B_OK != msg.Unflatten((const char *)data))
|
if (B_OK != msg.Unflatten((const char *)data))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
BBitmap *bmp = new BBitmap(&msg);
|
BBitmap *bmp = new BBitmap(&msg);
|
||||||
if (NULL == bmp)
|
if (NULL == bmp)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
bitmap = new BBitmap(bmp, true);
|
bitmap = new BBitmap(bmp, true);
|
||||||
if (NULL == bitmap) {
|
if (NULL == bitmap) {
|
||||||
delete bmp;
|
delete bmp;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and return an instance of class nsNativeAppSupportBeOS.
|
|
||||||
nsresult
|
|
||||||
NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
|
|
||||||
if ( aResult ) {
|
|
||||||
*aResult = new nsNativeAppSupportBeOS();
|
|
||||||
if ( *aResult ) {
|
|
||||||
NS_ADDREF( *aResult );
|
|
||||||
} else {
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create instance of BeOS splash screen object.
|
// Create instance of BeOS splash screen object.
|
||||||
nsresult
|
nsresult
|
||||||
NS_CreateSplashScreen( nsISplashScreen **aResult ) {
|
NS_CreateSplashScreen( nsISplashScreen **aResult ) {
|
||||||
if ( aResult ) {
|
if ( aResult ) {
|
||||||
*aResult = new nsSplashScreenBeOS;
|
*aResult = new nsSplashScreenBeOS;
|
||||||
if ( *aResult ) {
|
if ( *aResult ) {
|
||||||
NS_ADDREF( *aResult );
|
NS_ADDREF( *aResult );
|
||||||
} else {
|
return NS_OK;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
} else {
|
||||||
}
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
} else {
|
}
|
||||||
return NS_ERROR_NULL_POINTER;
|
} else {
|
||||||
}
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
}
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsNativeAppSupportBeOS::Start( PRBool *aResult ) {
|
|
||||||
NS_ENSURE_ARG( aResult );
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
#ifdef DEBUG_SPLASH
|
|
||||||
puts("nsNativeAppSupportBeOS::Start()");
|
|
||||||
#endif
|
|
||||||
*aResult = PR_TRUE;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsNativeAppSupportBeOS::Stop( PRBool *aResult ) {
|
|
||||||
NS_ENSURE_ARG( aResult );
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
#ifdef DEBUG_SPLASH
|
|
||||||
puts("nsNativeAppSupportBeOS::Stop()");
|
|
||||||
#endif
|
|
||||||
*aResult = PR_TRUE;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsNativeAppSupportBeOS::Quit() {
|
|
||||||
#ifdef DEBUG_SPLASH
|
|
||||||
puts("nsNativeAppSupportBeOS::Quit()");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool NS_CanRun()
|
PRBool NS_CanRun()
|
||||||
{
|
{
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче