First Checked In.
git-svn-id: svn://10.0.0.236/trunk@48400 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
26278391ac
commit
f432271502
BIN
mozilla/lib/mac/embedding/powerplant/PowerPlant Appearance.mcp
Normal file
BIN
mozilla/lib/mac/embedding/powerplant/PowerPlant Appearance.mcp
Normal file
Binary file not shown.
BIN
mozilla/lib/mac/embedding/powerplant/resources/Appearance.ppob
Normal file
BIN
mozilla/lib/mac/embedding/powerplant/resources/Appearance.ppob
Normal file
Binary file not shown.
BIN
mozilla/lib/mac/embedding/powerplant/resources/Appearance.rsrc
Normal file
BIN
mozilla/lib/mac/embedding/powerplant/resources/Appearance.rsrc
Normal file
Binary file not shown.
Binary file not shown.
@ -0,0 +1,12 @@
|
||||
// ===========================================================================
|
||||
// Appearance_DebugHeaders.h ©1996-1998 Metrowerks Inc. All rights reserved.
|
||||
// ===========================================================================
|
||||
|
||||
// Use PowerPlant-specific Precompiled header
|
||||
|
||||
#if __POWERPC__
|
||||
#include "Appearance_DebugHeadersPPC++"
|
||||
|
||||
#else
|
||||
#include "Appearance_DebugHeaders68K++"
|
||||
#endif
|
||||
@ -0,0 +1,40 @@
|
||||
// ===============================================================================
|
||||
// Appearance_DebugHeaders.pch++ ©1995-1998 Metrowerks Inc. All rights reserved.
|
||||
// ===============================================================================
|
||||
//
|
||||
// Source for precompiled header for PowerPlant headers
|
||||
//
|
||||
// This file #includes most header files for the PowerPlant library,
|
||||
// as well as most of the Toolbox headers used by the PowerPlant library
|
||||
// with all debugging symbols defined.
|
||||
|
||||
|
||||
// This same file works for PowerPC and 68K. We check the target
|
||||
// at compile time and specify the appropriate output file name.
|
||||
|
||||
#if __POWERPC__
|
||||
#pragma precompile_target "Appearance_DebugHeadersPPC++"
|
||||
|
||||
#else
|
||||
#pragma precompile_target "Appearance_DebugHeaders68K++"
|
||||
#endif
|
||||
|
||||
#pragma once on
|
||||
|
||||
// Option for using PowerPlant namespace
|
||||
|
||||
#define PP_Uses_PowerPlant_Namespace 0 // off, don't use PowerPlant namespace
|
||||
|
||||
// establish some essential PowerPlant macros:
|
||||
|
||||
#define PP_StdDialogs_Option PP_StdDialogs_ClassicOnly // use classic standard dialog
|
||||
// implementation
|
||||
|
||||
#include <PP_DebugHeaders.cp>
|
||||
|
||||
|
||||
/* Read file of defines global to the Mac build */ //¥RAPTOR begin
|
||||
#include "DefinesMac.h"
|
||||
|
||||
/* Read build-wide defines (e.g. MOZILLA_CLIENT) */
|
||||
#include "DefinesMozilla.h" //¥RAPTOR end
|
||||
214
mozilla/lib/mac/embedding/powerplant/source/CAppearanceApp.cp
Normal file
214
mozilla/lib/mac/embedding/powerplant/source/CAppearanceApp.cp
Normal file
@ -0,0 +1,214 @@
|
||||
// ===========================================================================
|
||||
// CAppearanceApp.cp ©1994-1998 Metrowerks Inc. All rights reserved.
|
||||
// ===========================================================================
|
||||
// This file contains the starter code for an Appearance PowerPlant application
|
||||
|
||||
#include "CAppearanceApp.h"
|
||||
|
||||
#include <LGrowZone.h>
|
||||
#include <PP_Messages.h>
|
||||
#include <PP_Resources.h>
|
||||
#include <PPobClasses.h>
|
||||
#include <UDrawingState.h>
|
||||
#include <UMemoryMgr.h>
|
||||
#include <URegistrar.h>
|
||||
|
||||
#include <LWindow.h>
|
||||
#include <LCaption.h>
|
||||
|
||||
#include <UControlRegistry.h>
|
||||
#include <UGraphicUtils.h>
|
||||
#include <UEnvironment.h>
|
||||
|
||||
#include <Appearance.h>
|
||||
|
||||
#include "CWebShell.h" //¥RAPTOR begin
|
||||
#include "CBrowserWindow.h"
|
||||
#include "CUrlField.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include <TextServices.h>
|
||||
|
||||
extern "C" void NS_SetupRegistry(); //¥RAPTOR end
|
||||
|
||||
|
||||
|
||||
// put declarations for resource ids (ResIDTs) here
|
||||
|
||||
const PP_PowerPlant::ResIDT wind_SampleWindow = 128; // EXAMPLE, create a new window
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
// ¥ Main Program
|
||||
// ===========================================================================
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
SetDebugThrow_(PP_PowerPlant::debugAction_Alert); // Set Debugging options
|
||||
SetDebugSignal_(PP_PowerPlant::debugAction_Alert);
|
||||
|
||||
PP_PowerPlant::InitializeHeap(3); // Initialize Memory Manager
|
||||
// Parameter is number of Master Pointer
|
||||
// blocks to allocate
|
||||
|
||||
PP_PowerPlant::UQDGlobals::InitializeToolbox(&qd); // Initialize standard Toolbox managers
|
||||
|
||||
new PP_PowerPlant::LGrowZone(20000); // Install a GrowZone function to catch low memory situations.
|
||||
|
||||
|
||||
//¥RAPTOR begin
|
||||
// Initialize the Registry
|
||||
// Note: This can go away when Auto-Registration is implemented in all the Raptor DLLs.
|
||||
NS_SetupRegistry();
|
||||
nsIImageManager *manager;
|
||||
NS_NewImageManager(&manager);
|
||||
InitTSMAwareApplication();
|
||||
|
||||
nsresult rv;
|
||||
nsIEventQueueService* eventQService;
|
||||
|
||||
// Create the Event Queue for the UI thread...
|
||||
rv = nsServiceManager::GetService(NS_EVENTQUEUESERVICE_PROGID,
|
||||
NS_GET_IID(nsIEventQueueService),
|
||||
(nsISupports **)&eventQService);
|
||||
if (NS_OK != rv)
|
||||
NS_ASSERTION(PR_FALSE, "Could not obtain the event queue service");
|
||||
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
if (NS_OK != rv)
|
||||
NS_ASSERTION(PR_FALSE, "Could not create the event queue for the thread");
|
||||
//¥RAPTOR end
|
||||
|
||||
|
||||
|
||||
CAppearanceApp theApp; // create instance of your application
|
||||
theApp.Run();
|
||||
|
||||
|
||||
|
||||
if (nsnull != eventQService) { //¥RAPTOR begin
|
||||
nsServiceManager::ReleaseService(NS_EVENTQUEUESERVICE_PROGID, eventQService);
|
||||
eventQService = nsnull; //¥RAPTOR end
|
||||
}
|
||||
|
||||
::CloseTSMAwareApplication();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CAppearanceApp
|
||||
// ---------------------------------------------------------------------------
|
||||
// Constructor
|
||||
|
||||
CAppearanceApp::CAppearanceApp()
|
||||
{
|
||||
if ( PP_PowerPlant::UEnvironment::HasFeature( PP_PowerPlant::env_HasAppearance ) ) {
|
||||
::RegisterAppearanceClient();
|
||||
}
|
||||
|
||||
RegisterClass_(PP_PowerPlant::LWindow); // You must register each kind of
|
||||
RegisterClass_(PP_PowerPlant::LCaption); // PowerPlant classes that you use
|
||||
// in your PPob resource.
|
||||
|
||||
// Register the Appearance Manager/GA classes
|
||||
PP_PowerPlant::UControlRegistry::RegisterClasses();
|
||||
|
||||
RegisterClass_(CWebShell); //¥RAPTOR
|
||||
RegisterClass_(CBrowserWindow); //¥RAPTOR
|
||||
RegisterClass_(CUrlField); //¥RAPTOR
|
||||
|
||||
SetSleepTime(0); //¥RAPTOR
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ~CAppearanceApp
|
||||
// ---------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
|
||||
CAppearanceApp::~CAppearanceApp()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ StartUp
|
||||
// ---------------------------------------------------------------------------
|
||||
// This method lets you do something when the application starts up
|
||||
// without a document. For example, you could issue your own new command.
|
||||
|
||||
void
|
||||
CAppearanceApp::StartUp()
|
||||
{
|
||||
ObeyCommand(PP_PowerPlant::cmd_New, nil); // EXAMPLE, create a new window
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ObeyCommand
|
||||
// ---------------------------------------------------------------------------
|
||||
// This method lets the application respond to commands like Menu commands
|
||||
|
||||
Boolean
|
||||
CAppearanceApp::ObeyCommand(
|
||||
PP_PowerPlant::CommandT inCommand,
|
||||
void *ioParam)
|
||||
{
|
||||
Boolean cmdHandled = true;
|
||||
|
||||
switch (inCommand) {
|
||||
|
||||
// Handle command messages (defined in PP_Messages.h).
|
||||
case PP_PowerPlant::cmd_New:
|
||||
|
||||
PP_PowerPlant::LWindow *theWindow =
|
||||
PP_PowerPlant::LWindow::CreateWindow(wind_SampleBrowserWindow, this); //¥RAPTOR: was 'wind_SampleWindow'
|
||||
ThrowIfNil_(theWindow);
|
||||
|
||||
// LWindow is not initially visible in PPob resource
|
||||
theWindow->Show();
|
||||
break;
|
||||
|
||||
// Any that you don't handle, such as cmd_About and cmd_Quit,
|
||||
// will be passed up to LApplication
|
||||
default:
|
||||
cmdHandled = PP_PowerPlant::LApplication::ObeyCommand(inCommand, ioParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return cmdHandled;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FindCommandStatus
|
||||
// ---------------------------------------------------------------------------
|
||||
// This function enables menu commands.
|
||||
//
|
||||
|
||||
void
|
||||
CAppearanceApp::FindCommandStatus(
|
||||
PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled,
|
||||
Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark,
|
||||
Str255 outName)
|
||||
{
|
||||
|
||||
switch (inCommand) {
|
||||
|
||||
// Return menu item status according to command messages.
|
||||
case PP_PowerPlant::cmd_New:
|
||||
outEnabled = true;
|
||||
break;
|
||||
|
||||
// Any that you don't handle, such as cmd_About and cmd_Quit,
|
||||
// will be passed up to LApplication
|
||||
default:
|
||||
PP_PowerPlant::LApplication::FindCommandStatus(inCommand, outEnabled,
|
||||
outUsesMark, outMark, outName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
30
mozilla/lib/mac/embedding/powerplant/source/CAppearanceApp.h
Normal file
30
mozilla/lib/mac/embedding/powerplant/source/CAppearanceApp.h
Normal file
@ -0,0 +1,30 @@
|
||||
// ===========================================================================
|
||||
// CAppearanceApp.h ©1994-1998 Metrowerks Inc. All rights reserved.
|
||||
// ===========================================================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PP_Prefix.h>
|
||||
#include <LApplication.h>
|
||||
|
||||
|
||||
class CAppearanceApp : public PP_PowerPlant::LApplication {
|
||||
|
||||
public:
|
||||
CAppearanceApp(); // constructor registers PPobs
|
||||
virtual ~CAppearanceApp(); // stub destructor
|
||||
|
||||
|
||||
// this overriding method handles application commands
|
||||
virtual Boolean ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioParam);
|
||||
|
||||
|
||||
// this overriding method returns the status of menu items
|
||||
virtual void FindCommandStatus(PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled, Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark, Str255 outName);
|
||||
protected:
|
||||
|
||||
virtual void StartUp(); // override startup functions
|
||||
|
||||
};
|
||||
150
mozilla/lib/mac/embedding/powerplant/source/CBrowserWindow.cp
Normal file
150
mozilla/lib/mac/embedding/powerplant/source/CBrowserWindow.cp
Normal file
@ -0,0 +1,150 @@
|
||||
|
||||
#include "CBrowserWindow.h"
|
||||
#include "CWebShell.h"
|
||||
#include <LEditText.h>
|
||||
#include <LStaticText.h>
|
||||
|
||||
|
||||
// CBrowserWindow:
|
||||
// A simple browser window that hooks up a CWebShell to a minimal set of controls
|
||||
// (Back, Forward and Stop buttons + URL field + status bar).
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
paneID_BackButton = 'Back'
|
||||
, paneID_ForwardButton = 'Forw'
|
||||
, paneID_StopButton = 'Stop'
|
||||
, paneID_URLField = 'gUrl'
|
||||
, paneID_WebShellView = 'WebS'
|
||||
, paneID_StatusBar = 'Stat'
|
||||
, paneID_ChasingArrows = 'Arro'
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CBrowserWindow Default Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CBrowserWindow::CBrowserWindow()
|
||||
{
|
||||
mWebShellView = nil;
|
||||
mURLField = nil;
|
||||
mStatusBar = nil;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CBrowserWindow Stream Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CBrowserWindow::CBrowserWindow(LStream* inStream)
|
||||
: LWindow(inStream)
|
||||
{
|
||||
mWebShellView = nil;
|
||||
mURLField = nil;
|
||||
mStatusBar = nil;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ~CBrowserWindow Destructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CBrowserWindow::~CBrowserWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FinishCreateSelf
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CBrowserWindow::FinishCreateSelf()
|
||||
{
|
||||
UReanimator::LinkListenerToControls(this, this, wind_SampleBrowserWindow);
|
||||
StartListening();
|
||||
|
||||
// display the default url
|
||||
mWebShellView = static_cast<CWebShell*>(FindPaneByID(paneID_WebShellView));
|
||||
mURLField = dynamic_cast<LEditText*>(FindPaneByID(paneID_URLField));
|
||||
if (mWebShellView && mURLField)
|
||||
{
|
||||
LStr255 defaultURL;
|
||||
mWebShellView->GetURLString(defaultURL);
|
||||
mURLField->SetDescriptor(defaultURL);
|
||||
mURLField->SelectAll();
|
||||
SwitchTarget(mURLField);
|
||||
}
|
||||
|
||||
// display a default status
|
||||
mStatusBar = dynamic_cast<LStaticText*>(FindPaneByID(paneID_StatusBar));
|
||||
if (mStatusBar)
|
||||
mStatusBar->SetDescriptor("\pWarming up...");
|
||||
|
||||
// let the WebShell know where the status can be displayed
|
||||
if (mWebShellView)
|
||||
{
|
||||
mWebShellView->SetStatusBar(mStatusBar);
|
||||
mWebShellView->SetThrobber(FindPaneByID(paneID_ChasingArrows));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ListenToMessage
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CBrowserWindow::ListenToMessage(
|
||||
MessageT inMessage,
|
||||
void* ioParam)
|
||||
{
|
||||
ProcessCommand(inMessage, ioParam);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ObeyCommand
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Boolean
|
||||
CBrowserWindow::ObeyCommand(
|
||||
CommandT inCommand,
|
||||
void *ioParam)
|
||||
{
|
||||
#pragma unused(ioParam)
|
||||
|
||||
Boolean cmdHandled = false;
|
||||
if (mWebShellView)
|
||||
{
|
||||
switch (inCommand)
|
||||
{
|
||||
case paneID_BackButton:
|
||||
mWebShellView->Back();
|
||||
cmdHandled = true;
|
||||
break;
|
||||
|
||||
case paneID_ForwardButton:
|
||||
mWebShellView->Forward();
|
||||
cmdHandled = true;
|
||||
break;
|
||||
|
||||
case paneID_StopButton:
|
||||
mWebShellView->Stop();
|
||||
cmdHandled = true;
|
||||
break;
|
||||
|
||||
case paneID_URLField:
|
||||
LStr255 urlString;
|
||||
mURLField->GetDescriptor(urlString);
|
||||
mWebShellView->LoadURL(urlString);
|
||||
cmdHandled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cmdHandled)
|
||||
cmdHandled = Inherited::ObeyCommand(inCommand, ioParam);
|
||||
return cmdHandled;
|
||||
}
|
||||
48
mozilla/lib/mac/embedding/powerplant/source/CBrowserWindow.h
Normal file
48
mozilla/lib/mac/embedding/powerplant/source/CBrowserWindow.h
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#include <LWindow.h>
|
||||
#include <LListener.h>
|
||||
|
||||
class CWebShell;
|
||||
class LEditText;
|
||||
class LStaticText;
|
||||
|
||||
|
||||
// CBrowserWindow:
|
||||
// A simple browser window that hooks up a CWebShell to a minimal set of controls
|
||||
// (Back, Forward and Stop buttons + URL field + status bar).
|
||||
|
||||
|
||||
const ResIDT wind_SampleBrowserWindow = 128;
|
||||
|
||||
|
||||
class CBrowserWindow : public LWindow,
|
||||
public LListener
|
||||
{
|
||||
private:
|
||||
typedef LWindow Inherited;
|
||||
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('BroW') };
|
||||
|
||||
CBrowserWindow();
|
||||
CBrowserWindow(LStream* inStream);
|
||||
|
||||
virtual ~CBrowserWindow();
|
||||
|
||||
|
||||
virtual void FinishCreateSelf();
|
||||
virtual void ListenToMessage(
|
||||
MessageT inMessage,
|
||||
void* ioParam);
|
||||
|
||||
virtual Boolean ObeyCommand(
|
||||
CommandT inCommand,
|
||||
void *ioParam);
|
||||
|
||||
protected:
|
||||
CWebShell* mWebShellView;
|
||||
LEditText* mURLField;
|
||||
LStaticText* mStatusBar;
|
||||
};
|
||||
|
||||
|
||||
84
mozilla/lib/mac/embedding/powerplant/source/CUrlField.cp
Normal file
84
mozilla/lib/mac/embedding/powerplant/source/CUrlField.cp
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
#include "CUrlField.h"
|
||||
#include <LString.h>
|
||||
|
||||
|
||||
// CUrlField:
|
||||
// A text edit field that broadcasts its PaneID on Return or Enter.
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CUrlField Default Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CUrlField::CUrlField()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CUrlField Stream Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CUrlField::CUrlField(LStream* inStream)
|
||||
: LEditText(inStream)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ~CUrlField Destructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CUrlField::~CUrlField()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ HandleKeyPress
|
||||
// ---------------------------------------------------------------------------
|
||||
// Broadcast the paneID when the user hits Return or Enter
|
||||
|
||||
Boolean
|
||||
CUrlField::HandleKeyPress(const EventRecord &inKeyEvent)
|
||||
{
|
||||
Boolean keyHandled = true;
|
||||
Char16 theChar = (Char16) (inKeyEvent.message & charCodeMask);
|
||||
|
||||
if (theChar == char_Return || theChar == char_Enter)
|
||||
{
|
||||
Str255 urlString;
|
||||
BroadcastMessage(GetPaneID(), (void*)GetDescriptor(urlString));
|
||||
}
|
||||
else
|
||||
keyHandled = Inherited::HandleKeyPress(inKeyEvent);
|
||||
|
||||
return keyHandled;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ClickSelf
|
||||
// ---------------------------------------------------------------------------
|
||||
// Select everything when a single click gives us the focus
|
||||
|
||||
void
|
||||
CUrlField::ClickSelf(const SMouseDownEvent &inMouseDown)
|
||||
{
|
||||
Boolean wasTarget = IsTarget();
|
||||
|
||||
Inherited::ClickSelf(inMouseDown);
|
||||
|
||||
if (!wasTarget)
|
||||
{
|
||||
ControlEditTextSelectionRec selection;
|
||||
GetSelection(selection);
|
||||
if (selection.selStart == selection.selEnd)
|
||||
SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
29
mozilla/lib/mac/embedding/powerplant/source/CUrlField.h
Normal file
29
mozilla/lib/mac/embedding/powerplant/source/CUrlField.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#include <LEditText.h>
|
||||
|
||||
|
||||
// CUrlField:
|
||||
// A text edit field that broadcasts its PaneID on Return or Enter.
|
||||
|
||||
|
||||
|
||||
class CUrlField : public LEditText
|
||||
{
|
||||
private:
|
||||
typedef LEditText Inherited;
|
||||
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('UrlF') };
|
||||
|
||||
|
||||
CUrlField();
|
||||
CUrlField(LStream* inStream);
|
||||
|
||||
virtual ~CUrlField();
|
||||
|
||||
virtual Boolean HandleKeyPress(
|
||||
const EventRecord &inKeyEvent);
|
||||
|
||||
virtual void ClickSelf(
|
||||
const SMouseDownEvent &inMouseDown);
|
||||
};
|
||||
757
mozilla/lib/mac/embedding/powerplant/source/CWebShell.cp
Normal file
757
mozilla/lib/mac/embedding/powerplant/source/CWebShell.cp
Normal file
@ -0,0 +1,757 @@
|
||||
|
||||
|
||||
#include "CWebShell.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsRepeater.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
|
||||
// CWebShell:
|
||||
// A view that embeds a Raptor WebShell. It creates the WebShell and
|
||||
// dispatches the OS events to it.
|
||||
|
||||
|
||||
// IMPORTANT:
|
||||
// - ¥¥ root control warning ¥¥
|
||||
// - Erase on Update should be off
|
||||
|
||||
|
||||
nsMacMessageSink CWebShell::mMessageSink;
|
||||
|
||||
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
|
||||
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
||||
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
|
||||
|
||||
extern "C" void NS_SetupRegistry();
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CWebShell Default Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CWebShell::CWebShell()
|
||||
{
|
||||
mURL[0] = 0;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CWebShell Stream Constructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CWebShell::CWebShell(LStream* inStream)
|
||||
: LView(inStream)
|
||||
{
|
||||
*inStream >> (StringPtr) mURL;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ~CWebShell Destructor [public]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
CWebShell::~CWebShell()
|
||||
{
|
||||
if (mWebShell)
|
||||
delete mWebShell;
|
||||
|
||||
if (mWindow)
|
||||
delete mWindow;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ Init
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::Init()
|
||||
{
|
||||
// Initialize the Registry
|
||||
// Note: This can go away when Auto-Registration is implemented in all the Raptor DLLs.
|
||||
static Boolean gFirstTime = true;
|
||||
if (gFirstTime)
|
||||
{
|
||||
gFirstTime = false;
|
||||
NS_SetupRegistry();
|
||||
nsIImageManager *manager;
|
||||
NS_NewImageManager(&manager);
|
||||
}
|
||||
|
||||
mWindow = nil;
|
||||
mWebShell = nil;
|
||||
mThrobber = nil;
|
||||
mStatusBar = nil;
|
||||
mLoading = false;
|
||||
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// create top-level widget
|
||||
nsresult rv;
|
||||
rv = nsComponentManager::CreateInstance(kWindowCID, nsnull, kIWidgetIID, (void**)&mWindow);
|
||||
if (rv != NS_OK)
|
||||
return;
|
||||
|
||||
nsWidgetInitData initData;
|
||||
Rect portRect = GetMacPort()->portRect;
|
||||
nsRect r(portRect.left, portRect.top, portRect.right - portRect.left, portRect.bottom - portRect.top);
|
||||
|
||||
rv = mWindow->Create((nsNativeWidget)GetMacPort(), r, nsnull, nsnull);
|
||||
if (rv != NS_OK)
|
||||
return;
|
||||
mWindow->Show(PR_TRUE);
|
||||
|
||||
// create webshell
|
||||
rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&mWebShell);
|
||||
if (rv != NS_OK)
|
||||
return;
|
||||
|
||||
Rect webRect;
|
||||
CalcPortFrameRect(webRect);
|
||||
r.SetRect(webRect.left, webRect.top, webRect.right - webRect.left, webRect.bottom - webRect.top);
|
||||
PRBool allowPlugins = PR_FALSE;
|
||||
rv = mWebShell->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET),
|
||||
r.x, r.y, r.width, r.height,
|
||||
nsScrollPreference_kNeverScroll, //nsScrollPreference_kAuto,
|
||||
allowPlugins, PR_FALSE);
|
||||
if (rv != NS_OK)
|
||||
return;
|
||||
mWebShell->SetContainer((nsIWebShellContainer*)this);
|
||||
mWebShell->SetObserver((nsIStreamObserver*)this);
|
||||
mWebShell->Show();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FinishCreateSelf
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::FinishCreateSelf()
|
||||
{
|
||||
StartRepeating();
|
||||
|
||||
// load the default page
|
||||
nsString urlString;
|
||||
urlString.SetString((char*)&mURL[1], mURL[0]);
|
||||
mWebShell->LoadURL(urlString.GetUnicode());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ResizeFrameBy
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::ResizeFrameBy(
|
||||
SInt16 inWidthDelta,
|
||||
SInt16 inHeightDelta,
|
||||
Boolean inRefresh)
|
||||
{
|
||||
Inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
|
||||
HandleMoveOrResize();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ MoveBy
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::MoveBy(
|
||||
SInt32 inHorizDelta,
|
||||
SInt32 inVertDelta,
|
||||
Boolean inRefresh)
|
||||
{
|
||||
Inherited::MoveBy(inHorizDelta, inVertDelta, inRefresh);
|
||||
HandleMoveOrResize();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ HandleMoveOrResize
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::HandleMoveOrResize()
|
||||
{
|
||||
if (mWebShell && mWindow)
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// resize the top-level widget and the webshell
|
||||
Rect portRect = GetMacPort()->portRect;
|
||||
mWindow->Resize(portRect.right - portRect.left, portRect.bottom - portRect.top, PR_FALSE);
|
||||
|
||||
Rect webRect;
|
||||
CalcPortFrameRect(webRect);
|
||||
nsRect r(webRect.left, webRect.top, webRect.right - webRect.left, webRect.bottom - webRect.top);
|
||||
mWebShell->SetBounds(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ DrawSelf
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::DrawSelf()
|
||||
{
|
||||
EventRecord osEvent;
|
||||
osEvent.what = updateEvt;
|
||||
mMessageSink.DispatchOSEvent(osEvent, GetMacPort());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ActivateSelf [protected]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::ActivateSelf()
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
EventRecord osEvent;
|
||||
osEvent.what = activateEvt;
|
||||
osEvent.modifiers = activeFlag;
|
||||
mMessageSink.DispatchOSEvent(osEvent, GetMacPort());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ DeactivateSelf [protected]
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::DeactivateSelf()
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
EventRecord osEvent;
|
||||
osEvent.what = activateEvt;
|
||||
osEvent.modifiers = 0;
|
||||
mMessageSink.DispatchOSEvent(osEvent, GetMacPort());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ClickSelf
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::ClickSelf(
|
||||
const SMouseDownEvent &inMouseDown)
|
||||
{
|
||||
if (!IsTarget())
|
||||
SwitchTarget(this);
|
||||
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMouseDown.macEvent, GetMacPort());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ EventMouseUp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::EventMouseUp(
|
||||
const EventRecord &inMacEvent)
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, GetMacPort());
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FocusDraw
|
||||
// ---------------------------------------------------------------------------
|
||||
// Set the origin to (0, 0) and the clipRect to our port frame rect
|
||||
// Mostly stolen from LView::FocusDraw().
|
||||
|
||||
Boolean
|
||||
CWebShell::FocusDraw(
|
||||
LPane* /* inSubPane */)
|
||||
{
|
||||
// Check if revealed rect is empty
|
||||
Boolean revealed = (mRevealedRect.left < mRevealedRect.right);
|
||||
|
||||
if (this != sInFocusView) { // Skip if already in focus
|
||||
if (EstablishPort()) { // Set current Mac Port
|
||||
|
||||
// Set up local coordinate system
|
||||
// ::SetOrigin(mPortOrigin.h, mPortOrigin.v);
|
||||
::SetOrigin(0, 0);
|
||||
|
||||
// Clip to revealed area of View
|
||||
Rect clippingRect = mRevealedRect;
|
||||
// PortToLocalPoint(topLeft(clippingRect));
|
||||
// PortToLocalPoint(botRight(clippingRect));
|
||||
::ClipRect(&clippingRect);
|
||||
|
||||
sInFocusView = this; // Cache current Focus
|
||||
|
||||
} else {
|
||||
SignalPStr_("\pFocus View with no GrafPort");
|
||||
}
|
||||
}
|
||||
|
||||
return revealed;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ AdjustCursor
|
||||
// ---------------------------------------------------------------------------
|
||||
void
|
||||
CWebShell::AdjustCursor(
|
||||
Point /*inPortPt*/,
|
||||
const EventRecord &/*inMacEvent*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ DontBeTarget
|
||||
// ---------------------------------------------------------------------------
|
||||
void
|
||||
CWebShell::DontBeTarget()
|
||||
{
|
||||
if (mWebShell)
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// tell form controls that we are losing the focus
|
||||
mWebShell->RemoveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ HandleKeyPress
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Boolean
|
||||
CWebShell::HandleKeyPress(
|
||||
const EventRecord &inKeyEvent)
|
||||
{
|
||||
Boolean keyHandled = true;
|
||||
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
keyHandled = mMessageSink.DispatchOSEvent((EventRecord&)inKeyEvent, GetMacPort());
|
||||
|
||||
return keyHandled;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ SpendTime
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::SpendTime(
|
||||
const EventRecord& inMacEvent)
|
||||
{
|
||||
if (inMacEvent.what == osEvt || inMacEvent.what == nullEvent)
|
||||
{
|
||||
// set the QuickDraw origin
|
||||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, GetMacPort());
|
||||
}
|
||||
|
||||
// Enable Raptor background activity
|
||||
// Note: This will be moved to nsMacMessageSink very soon.
|
||||
// The application will not have to do it anymore.
|
||||
Repeater::DoRepeaters(inMacEvent);
|
||||
if (inMacEvent.what == nullEvent)
|
||||
Repeater::DoIdlers(inMacEvent);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ Back
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::Back()
|
||||
{
|
||||
if (mWebShell && (mWebShell->CanBack() == NS_OK))
|
||||
mWebShell->Back();
|
||||
else
|
||||
::SysBeep(1);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ Forward
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::Forward()
|
||||
{
|
||||
if (mWebShell && (mWebShell->CanForward() == NS_OK))
|
||||
mWebShell->Forward();
|
||||
else
|
||||
::SysBeep(1);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ Forward
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::Stop()
|
||||
{
|
||||
if (mWebShell && mLoading)
|
||||
mWebShell->Stop();
|
||||
else
|
||||
::SysBeep(1);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ LoadURL
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::LoadURL(LStr255& urlString)
|
||||
{
|
||||
if (mWebShell)
|
||||
{
|
||||
mURL = urlString;
|
||||
nsString nsURLString;
|
||||
nsURLString.SetString((char*)&mURL[1], mURL[0]);
|
||||
mWebShell->LoadURL(nsURLString.GetUnicode());
|
||||
}
|
||||
else
|
||||
::SysBeep(1);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ DisplayStatus
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
CWebShell::DisplayStatus(const PRUnichar* status)
|
||||
{
|
||||
if (mStatusBar)
|
||||
{
|
||||
nsAutoString statusStr = status;
|
||||
|
||||
Str255 aStr;
|
||||
aStr[0] = min(statusStr.Length(), 254);
|
||||
statusStr.ToCString((char*)&aStr[1], aStr[0] + 1);
|
||||
mStatusBar->SetDescriptor(aStr);
|
||||
|
||||
FocusDraw();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ OnStartRequest
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::OnStartRequest(nsIChannel* /*channel*/, nsISupports */*ctxt*/)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ OnProgress
|
||||
// ---------------------------------------------------------------------------
|
||||
/*
|
||||
NS_IMETHODIMP CWebShell::OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
if (mLoading)
|
||||
{
|
||||
nsAutoString url;
|
||||
if (aURL)
|
||||
{
|
||||
PRUnichar* str;
|
||||
aURL->ToString(&str);
|
||||
url = str;
|
||||
delete[] str;
|
||||
}
|
||||
url.Append(": progress ");
|
||||
url.Append(aProgress, 10);
|
||||
if (0 != aProgressMax)
|
||||
{
|
||||
url.Append(" (out of ");
|
||||
url.Append(aProgressMax, 10);
|
||||
url.Append(")");
|
||||
}
|
||||
DisplayStatus(url.GetUnicode());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ OnStatus
|
||||
// ---------------------------------------------------------------------------
|
||||
/*
|
||||
NS_IMETHODIMP CWebShell::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
||||
{
|
||||
#pragma unused (aURL)
|
||||
DisplayStatus(aMsg);
|
||||
return NS_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ OnStopRequest
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::OnStopRequest(nsIChannel* /*channel*/, nsISupports */*ctxt*/, nsresult /*status*/, const PRUnichar */*errorMsg*/)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ WillLoadURL
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::WillLoadURL(nsIWebShell* /*aShell*/,
|
||||
const PRUnichar* aURL,
|
||||
nsLoadType /*aReason*/)
|
||||
{
|
||||
nsAutoString url("Connecting to ");
|
||||
url.Append(aURL);
|
||||
|
||||
DisplayStatus(url.GetUnicode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ BeginLoadURL
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::BeginLoadURL(nsIWebShell* /*aShell*/,
|
||||
const PRUnichar* aURL)
|
||||
{
|
||||
mLoading = true;
|
||||
|
||||
if (mThrobber)
|
||||
mThrobber->Show();
|
||||
|
||||
DisplayStatus(aURL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ProgressLoadURL
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::ProgressLoadURL(nsIWebShell* /*aShell*/,
|
||||
const PRUnichar* /*aURL*/,
|
||||
PRInt32 /*aProgress*/,
|
||||
PRInt32 /*aProgressMax*/)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ EndLoadURL
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::EndLoadURL(nsIWebShell* /*aShell*/,
|
||||
const PRUnichar* /*aURL*/,
|
||||
nsresult /*aStatus*/)
|
||||
{
|
||||
mLoading = false;
|
||||
|
||||
if (mThrobber)
|
||||
mThrobber->Hide();
|
||||
|
||||
nsAutoString msg("Done.");
|
||||
DisplayStatus(msg.GetUnicode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ NewWebShell
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::NewWebShell(PRUint32 /*aChromeMask*/,
|
||||
PRBool /*aVisible*/,
|
||||
nsIWebShell *&aNewWebShell)
|
||||
{
|
||||
aNewWebShell = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FindWebShellWithName
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::FindWebShellWithName(const PRUnichar* /*aName*/,
|
||||
nsIWebShell*& aResult)
|
||||
{
|
||||
aResult = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ContentShellAdded
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::ContentShellAdded(nsIWebShell* /*aChildShell*/, nsIContent* /*frameNode*/)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CreatePopup
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
||||
PRInt32 aXPos, PRInt32 aYPos,
|
||||
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
||||
const nsString& aPopupAlignment,
|
||||
nsIDOMWindow* aWindow, nsIDOMWindow** outPopup)
|
||||
{
|
||||
#pragma unused (aElement)
|
||||
#pragma unused (aPopupContent)
|
||||
#pragma unused (aXPos)
|
||||
#pragma unused (aYPos)
|
||||
#pragma unused (aPopupType)
|
||||
#pragma unused (anAnchorAlignment)
|
||||
#pragma unused (aPopupAlignment)
|
||||
#pragma unused (aWindow)
|
||||
*outPopup = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ FocusAvailable
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::FocusAvailable(nsIWebShell* /*aFocusedWebShell*/, PRBool& aFocusTaken)
|
||||
{
|
||||
aFocusTaken = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CanCreateNewWebShell
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::CanCreateNewWebShell(PRBool& aResult)
|
||||
{
|
||||
aResult = PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ CanCreateNewWebShell
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::SetNewWebShellInfo(const nsString& /*aName*/, const nsString& /*anURL*/,
|
||||
nsIWebShell* /*aOpenerShell*/, PRUint32 /*aChromeMask*/,
|
||||
nsIWebShell** /*aNewShell*/, nsIWebShell** /*anInnerShell*/)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ ChildShellAdded
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP CWebShell::ChildShellAdded(nsIWebShell** /*aChildShell*/, nsIContent* /*frameNode*/)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
// ---------------------------------------------------------------------------
|
||||
// ¥ QueryInterface
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(CWebShell);
|
||||
NS_IMPL_RELEASE(CWebShell);
|
||||
|
||||
nsresult
|
||||
CWebShell::QueryInterface(const nsIID& aIID, void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtrResult = NULL;
|
||||
|
||||
if (aIID.Equals(kIStreamObserverIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIStreamObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIWebShellContainerIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtrResult = (void*) ((nsISupports*)((nsIWebShellContainer*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
152
mozilla/lib/mac/embedding/powerplant/source/CWebShell.h
Normal file
152
mozilla/lib/mac/embedding/powerplant/source/CWebShell.h
Normal file
@ -0,0 +1,152 @@
|
||||
|
||||
#include <LPane.h>
|
||||
#include <LView.h>
|
||||
#include <LCommander.h>
|
||||
#include <LPeriodical.h>
|
||||
#include "nsMacMessageSink.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIStreamObserver.h"
|
||||
|
||||
|
||||
class nsIWidget;
|
||||
class nsIWebShell;
|
||||
|
||||
|
||||
class CWebShell : public LView,
|
||||
public LCommander,
|
||||
public LPeriodical,
|
||||
public nsIStreamObserver,
|
||||
public nsIWebShellContainer
|
||||
{
|
||||
private:
|
||||
typedef LView Inherited;
|
||||
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('WebS') };
|
||||
|
||||
CWebShell();
|
||||
CWebShell(LStream* inStream);
|
||||
|
||||
virtual ~CWebShell();
|
||||
|
||||
// LPane
|
||||
virtual void FinishCreateSelf();
|
||||
virtual void ResizeFrameBy(
|
||||
SInt16 inWidthDelta,
|
||||
SInt16 inHeightDelta,
|
||||
Boolean inRefresh);
|
||||
|
||||
virtual void MoveBy( SInt32 inHorizDelta,
|
||||
SInt32 inVertDelta,
|
||||
Boolean inRefresh);
|
||||
virtual void DrawSelf();
|
||||
virtual void ClickSelf(
|
||||
const SMouseDownEvent &inMouseDown);
|
||||
virtual void EventMouseUp(
|
||||
const EventRecord &inMacEvent);
|
||||
|
||||
// LView
|
||||
virtual Boolean FocusDraw(
|
||||
LPane *inSubPane = nil);
|
||||
|
||||
virtual void AdjustCursor(
|
||||
Point inPortPt,
|
||||
const EventRecord &inMacEvent);
|
||||
|
||||
|
||||
// LCommander
|
||||
virtual void DontBeTarget();
|
||||
virtual Boolean HandleKeyPress(
|
||||
const EventRecord &inKeyEvent);
|
||||
|
||||
// LPeriodical
|
||||
virtual void SpendTime(
|
||||
const EventRecord& inMacEvent);
|
||||
|
||||
// CWebShell
|
||||
void GetURLString(LStr255& urlString) {urlString = mURL;}
|
||||
virtual void Back();
|
||||
virtual void Forward();
|
||||
virtual void Stop();
|
||||
virtual void LoadURL(LStr255& urlString);
|
||||
virtual void SetThrobber(LPane* throbber) {mThrobber = throbber;}
|
||||
virtual void SetStatusBar(LPane* statusBar) {mStatusBar = statusBar;}
|
||||
virtual void DisplayStatus(const PRUnichar* status);
|
||||
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIStreamObserver
|
||||
// NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt);
|
||||
// NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
// NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
||||
// NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult status, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
|
||||
|
||||
// nsIWebShellContainer
|
||||
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL,
|
||||
nsLoadType aReason);
|
||||
|
||||
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL);
|
||||
|
||||
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL,
|
||||
PRInt32 aProgress,
|
||||
PRInt32 aProgressMax);
|
||||
|
||||
NS_IMETHOD EndLoadURL(nsIWebShell* aShell,
|
||||
const PRUnichar* aURL,
|
||||
nsresult aStatus);
|
||||
|
||||
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
|
||||
PRBool aVisible,
|
||||
nsIWebShell *&aNewWebShell);
|
||||
|
||||
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName,
|
||||
nsIWebShell*& aResult);
|
||||
|
||||
NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode);
|
||||
|
||||
NS_IMETHOD CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
|
||||
PRInt32 aXPos, PRInt32 aYPos,
|
||||
const nsString& aPopupType, const nsString& anAnchorAlignment,
|
||||
const nsString& aPopupAlignment,
|
||||
nsIDOMWindow* aWindow, nsIDOMWindow** outPopup);
|
||||
|
||||
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
|
||||
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
|
||||
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
|
||||
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
|
||||
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
|
||||
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
|
||||
|
||||
|
||||
protected:
|
||||
// LPane
|
||||
virtual void ActivateSelf();
|
||||
virtual void DeactivateSelf();
|
||||
|
||||
// CWebShell
|
||||
virtual void Init();
|
||||
virtual void HandleMoveOrResize();
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
nsIWidget* mWindow;
|
||||
nsIWebShell* mWebShell;
|
||||
|
||||
LStr255 mURL;
|
||||
LPane* mThrobber;
|
||||
LPane* mStatusBar;
|
||||
Boolean mLoading;
|
||||
|
||||
static nsMacMessageSink mMessageSink;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user