зеркало из https://github.com/mozilla/pjs.git
Bug 78498 - Carbonize PPEmbed. r=pinkerton/sr=sfraser
This commit is contained in:
Родитель
b9075a2e9b
Коммит
0044ec43e9
|
@ -53,6 +53,7 @@ mailextras 1
|
|||
xptlink 0
|
||||
psm 0
|
||||
embedding_test 1
|
||||
embedding_test_carbon 0
|
||||
carbon 0 TARGET_CARBON
|
||||
useimg2 1 USE_IMG2
|
||||
lowmem 0 MOZ_MAC_LOWMEM
|
||||
|
|
|
@ -1648,6 +1648,9 @@ sub BuildEmbeddingProjects()
|
|||
|
||||
# $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
|
||||
my($D) = $main::DEBUG ? "Debug" : "";
|
||||
# $C becomes a component of target names for selecting either the Carbon or non-Carbon target of a project
|
||||
my($C) = $main::options{carbon} ? "Carbon" : "";
|
||||
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
StartBuildModule("embedding");
|
||||
|
@ -1658,15 +1661,21 @@ sub BuildEmbeddingProjects()
|
|||
BuildOneProject(":mozilla:embedding:base:macbuild:EmbedAPI.mcp", "EmbedAPI$D.o", 0, 0, 0);
|
||||
MakeAlias(":mozilla:embedding:base:macbuild:EmbedAPI$D.o", ":mozilla:dist:embedding:");
|
||||
|
||||
if ($main::options{embedding_test} && !$main::options{carbon})
|
||||
if ((!$main::options{carbon} && $main::options{embedding_test}) || ($main::options{carbon} && $main::options{embedding_test_carbon}))
|
||||
{
|
||||
if (-e GetCodeWarriorRelativePath("MacOS Support:PowerPlant"))
|
||||
my($PowerPlantPath) = $main::options{carbon} ? "Carbon Support:PowerPlant" : "MacOS Support:PowerPlant";
|
||||
if (-e GetCodeWarriorRelativePath($PowerPlantPath))
|
||||
{
|
||||
BuildOneProject(":mozilla:embedding:browser:powerplant:PPBrowser.mcp", "PPEmbed$D", 0, 0, 0);
|
||||
# Build PowerPlant and export the lib and the precompiled header
|
||||
BuildOneProject(":mozilla:lib:mac:PowerPlant:PowerPlant.mcp", "PowerPlant$C$D.o", 0, 0, 0);
|
||||
MakeAlias(":mozilla:lib:mac:PowerPlant:PowerPlant$C$D.o", ":mozilla:dist:mac:powerplant:");
|
||||
MakeAlias(":mozilla:lib:mac:PowerPlant:pch:PPHeaders$D" . "_pch", ":mozilla:dist:mac:powerplant:");
|
||||
|
||||
BuildOneProject(":mozilla:embedding:browser:powerplant:PPBrowser.mcp", "PPEmbed$C$D", 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
print("MacOS Support:PowerPlant does not exist - embedding sample will not be built\n");
|
||||
print("$PowerPlantPath does not exist - embedding sample will not be built\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Двоичные данные
embedding/browser/powerplant/PPBrowser.mcp
Двоичные данные
embedding/browser/powerplant/PPBrowser.mcp
Двоичный файл не отображается.
Двоичные данные
embedding/browser/powerplant/resources/Browser.ppob
Двоичные данные
embedding/browser/powerplant/resources/Browser.ppob
Двоичный файл не отображается.
Двоичные данные
embedding/browser/powerplant/resources/Browser.rsrc
Двоичные данные
embedding/browser/powerplant/resources/Browser.rsrc
Двоичный файл не отображается.
|
@ -35,8 +35,11 @@
|
|||
//*****************************************************************************
|
||||
|
||||
// Windows
|
||||
|
||||
// Views
|
||||
enum {
|
||||
wind_BrowserWindow = 129
|
||||
view_BrowserStatusBar = 130,
|
||||
view_BrowserToolBar = 131
|
||||
};
|
||||
|
||||
// Dialogs
|
||||
|
@ -113,6 +116,8 @@ enum {
|
|||
enum {
|
||||
cmd_OpenDirectory = 'ODir',
|
||||
cmd_OpenLinkInNewWindow = 'OLnN',
|
||||
|
||||
cmd_SaveAllAs = 'SvDc',
|
||||
|
||||
cmd_Back = 'Back',
|
||||
cmd_Forward = 'Forw',
|
||||
|
|
|
@ -198,11 +198,17 @@ NS_METHOD CAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFil
|
|||
nsresult rv;
|
||||
PRBool exists;
|
||||
nsCOMPtr<nsILocalFile> localDir;
|
||||
|
||||
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = directoryService->Get(NS_MAC_DOCUMENTS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
|
||||
OSErr err;
|
||||
long response;
|
||||
err = ::Gestalt(gestaltSystemVersion, &response);
|
||||
const char *prop = (!err && response >= 0x00001000) ? NS_MAC_USER_LIB_DIR : NS_MAC_DOCUMENTS_DIR;
|
||||
|
||||
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = localDir->AppendRelativePath(mProductDirName);
|
||||
|
|
|
@ -37,15 +37,21 @@
|
|||
#include <UGraphicUtils.h>
|
||||
#include <UEnvironment.h>
|
||||
#include <Appearance.h>
|
||||
#include <UConditionalDialogs.h>
|
||||
#include <LCMAttachment.h>
|
||||
#include <UCMMUtils.h>
|
||||
|
||||
#if PP_Target_Carbon
|
||||
#include <UNavServicesDialogs.h>
|
||||
#else
|
||||
#include <UConditionalDialogs.h>
|
||||
#endif
|
||||
|
||||
#include "ApplIDs.h"
|
||||
#include "CBrowserWindow.h"
|
||||
#include "CBrowserShell.h"
|
||||
#include "CUrlField.h"
|
||||
#include "CThrobber.h"
|
||||
#include "CIconServicesIcon.h"
|
||||
#include "CWebBrowserCMAttachment.h"
|
||||
#include "UMacUnicode.h"
|
||||
#include "CAppFileLocationProvider.h"
|
||||
|
@ -67,6 +73,7 @@
|
|||
#include "nsIFileSpec.h"
|
||||
#include "nsMPFileLocProvider.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "macstdlibextras.h"
|
||||
#include "SIOUX.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -97,14 +104,20 @@ int main()
|
|||
// Parameter is number of Master Pointer
|
||||
// blocks to allocate
|
||||
|
||||
|
||||
PP_PowerPlant::UQDGlobals::InitializeToolbox(&qd); // Initialize standard Toolbox managers
|
||||
|
||||
#if __PowerPlant__ >= 0x02100000
|
||||
PP_PowerPlant::UQDGlobals::InitializeToolbox();
|
||||
#else
|
||||
PP_PowerPlant::UQDGlobals::InitializeToolbox(&qd);
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
::InitializeSIOUX(false);
|
||||
#endif
|
||||
|
||||
|
||||
#if !TARGET_CARBON
|
||||
::InitTSMAwareApplication();
|
||||
#endif
|
||||
|
||||
new PP_PowerPlant::LGrowZone(20000); // Install a GrowZone function to catch low memory situations.
|
||||
|
||||
|
@ -114,7 +127,9 @@ int main()
|
|||
theApp.Run();
|
||||
}
|
||||
|
||||
#if !TARGET_CARBON
|
||||
::CloseTSMAwareApplication();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -141,6 +156,7 @@ CBrowserApp::CBrowserApp()
|
|||
RegisterClass_(PP_PowerPlant::LTabGroupView);
|
||||
RegisterClass_(PP_PowerPlant::LIconControl);
|
||||
RegisterClass_(PP_PowerPlant::LView);
|
||||
RegisterClass_(PP_PowerPlant::LDialogBox);
|
||||
|
||||
// Register the Appearance Manager/GA classes
|
||||
PP_PowerPlant::UControlRegistry::RegisterClasses();
|
||||
|
@ -150,6 +166,7 @@ CBrowserApp::CBrowserApp()
|
|||
RegisterClass_(CBrowserWindow);
|
||||
RegisterClass_(CUrlField);
|
||||
RegisterClass_(CThrobber);
|
||||
RegisterClass_(CIconServicesIcon);
|
||||
|
||||
#if USE_PROFILES
|
||||
RegisterClass_(LScroller);
|
||||
|
@ -343,28 +360,44 @@ void CBrowserApp::HandleAppleEvent(const AppleEvent& inAppleEvent,
|
|||
case 5000:
|
||||
{
|
||||
OSErr err;
|
||||
Handle dataH;
|
||||
|
||||
StAEDescriptor urlDesc;
|
||||
err = ::AEGetParamDesc(&inAppleEvent, keyDirectObject, typeWildCard, urlDesc);
|
||||
ThrowIfOSErr_(err);
|
||||
AEDesc finalDesc;
|
||||
|
||||
StAEDescriptor coerceDesc;
|
||||
if (urlDesc.DescriptorType() != typeChar) {
|
||||
err = ::AECoerceDesc(urlDesc, typeChar, coerceDesc);
|
||||
ThrowIfOSErr_(err);
|
||||
dataH = ((AEDesc)coerceDesc).dataHandle;
|
||||
finalDesc = coerceDesc;
|
||||
}
|
||||
else
|
||||
dataH = ((AEDesc)urlDesc).dataHandle;
|
||||
finalDesc = urlDesc;
|
||||
|
||||
Size dataSize = ::GetHandleSize(dataH);
|
||||
StHandleLocker lock(dataH);
|
||||
Size dataSize = ::AEGetDescDataSize(&finalDesc);
|
||||
StPointerBlock dataPtr(dataSize);
|
||||
err = ::AEGetDescData(&finalDesc, dataPtr.Get(), dataSize);
|
||||
ThrowIfOSErr_(err);
|
||||
|
||||
PRUint32 chromeFlags;
|
||||
|
||||
CBrowserWindow *theWindow = CBrowserWindow::CreateWindow(nsIWebBrowserChrome::CHROME_DEFAULT, -1, -1);
|
||||
// If the URL begins with "view-source:", go with less chrome
|
||||
nsDependentCString dataAsStr(dataPtr.Get(), dataSize);
|
||||
nsReadingIterator<char> start, end;
|
||||
dataAsStr.BeginReading(start);
|
||||
dataAsStr.EndReading(end);
|
||||
FindInReadable(NS_LITERAL_CSTRING("view-source:"), start, end);
|
||||
if ((start != end) && !start.size_backward())
|
||||
chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_CLOSE +
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_RESIZE;
|
||||
else
|
||||
chromeFlags = nsIWebBrowserChrome::CHROME_DEFAULT;
|
||||
|
||||
CBrowserWindow *theWindow = CBrowserWindow::CreateWindow(chromeFlags, -1, -1);
|
||||
ThrowIfNil_(theWindow);
|
||||
theWindow->SetSizeToContent(false);
|
||||
theWindow->GetBrowserShell()->LoadURL(*dataH, dataSize);
|
||||
theWindow->GetBrowserShell()->LoadURL(dataAsStr);
|
||||
|
||||
theWindow->Show();
|
||||
}
|
||||
|
@ -396,7 +429,7 @@ CBrowserApp::ObeyCommand(
|
|||
ThrowIfNil_(theWindow);
|
||||
theWindow->SetSizeToContent(false);
|
||||
// Just for demo sake, load a URL
|
||||
theWindow->GetBrowserShell()->LoadURL("http://www.mozilla.org");
|
||||
theWindow->GetBrowserShell()->LoadURL(nsDependentCString("http://www.mozilla.org"));
|
||||
theWindow->Show();
|
||||
}
|
||||
break;
|
||||
|
@ -427,7 +460,7 @@ CBrowserApp::ObeyCommand(
|
|||
CBrowserWindow *theWindow = CBrowserWindow::CreateWindow(nsIWebBrowserChrome::CHROME_DEFAULT, -1, -1);
|
||||
ThrowIfNil_(theWindow);
|
||||
theWindow->SetSizeToContent(false);
|
||||
theWindow->GetBrowserShell()->LoadURL(urlSpec.get());
|
||||
theWindow->GetBrowserShell()->LoadURL(urlSpec);
|
||||
theWindow->Show();
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +487,7 @@ CBrowserApp::FindCommandStatus(
|
|||
PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled,
|
||||
Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark,
|
||||
UInt16 &outMark,
|
||||
Str255 outName)
|
||||
{
|
||||
|
||||
|
@ -534,7 +567,11 @@ Boolean CBrowserApp::SelectFileObject(PP_PowerPlant::CommandT inCommand,
|
|||
// and Navigation Services. The latter allows opening
|
||||
// multiple files.
|
||||
|
||||
#if PP_Target_Carbon
|
||||
UNavServicesDialogs::LFileChooser chooser;
|
||||
#else
|
||||
UConditionalDialogs::LFileChooser chooser;
|
||||
#endif
|
||||
|
||||
NavDialogOptions *theDialogOptions = chooser.GetDialogOptions();
|
||||
if (theDialogOptions) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
// 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);
|
||||
UInt16 &outMark, Str255 outName);
|
||||
|
||||
virtual Boolean AttemptQuitSelf(SInt32 inSaveOption);
|
||||
|
||||
|
|
|
@ -46,8 +46,13 @@
|
|||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
#include "nsIWebBrowserPersist.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsWeakPtr.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsILocalFileMac.h"
|
||||
|
||||
#include <UModalDialogs.h>
|
||||
#include <LStream.h>
|
||||
|
@ -65,6 +70,12 @@
|
|||
#include "LCheckBox.h"
|
||||
#endif
|
||||
|
||||
#if PP_Target_Carbon
|
||||
#include <UNavServicesDialogs.h>
|
||||
#else
|
||||
#include <UConditionalDialogs.h>
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
|
||||
|
||||
// CBrowserShell static variables
|
||||
|
@ -137,7 +148,7 @@ void CBrowserShell::FinishCreateSelf()
|
|||
{
|
||||
FocusDraw();
|
||||
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(GetMacPort()));
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(Compat_GetMacWindow()));
|
||||
ThrowIfNil_(ourWindow);
|
||||
ourWindow->AddListener(this);
|
||||
|
||||
|
@ -197,7 +208,7 @@ void CBrowserShell::DrawSelf()
|
|||
{
|
||||
EventRecord osEvent;
|
||||
osEvent.what = updateEvt;
|
||||
mMessageSink.DispatchOSEvent(osEvent, GetMacPort());
|
||||
mMessageSink.DispatchOSEvent(osEvent, Compat_GetMacWindow());
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,20 +218,37 @@ void CBrowserShell::ClickSelf(const SMouseDownEvent &inMouseDown)
|
|||
SwitchTarget(this);
|
||||
|
||||
FocusDraw();
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMouseDown.macEvent, GetMacPort());
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMouseDown.macEvent, Compat_GetMacWindow());
|
||||
}
|
||||
|
||||
|
||||
void CBrowserShell::EventMouseUp(const EventRecord &inMacEvent)
|
||||
{
|
||||
FocusDraw();
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, GetMacPort());
|
||||
mMessageSink.DispatchOSEvent((EventRecord&)inMacEvent, Compat_GetMacWindow());
|
||||
|
||||
LEventDispatcher *dispatcher = LEventDispatcher::GetCurrentEventDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->UpdateMenus();
|
||||
}
|
||||
|
||||
#if __PowerPlant__ >= 0x02200000
|
||||
void CBrowserShell::AdjustMouseSelf(Point inPortPt,
|
||||
const EventRecord& inMacEvent,
|
||||
RgnHandle outMouseRgn)
|
||||
{
|
||||
static Point lastWhere = {0, 0};
|
||||
|
||||
if ((*(long*)&lastWhere != *(long*)&inMacEvent.where))
|
||||
{
|
||||
HandleMouseMoved(inMacEvent);
|
||||
lastWhere = inMacEvent.where;
|
||||
}
|
||||
Rect cursorRect = { inPortPt.h, inPortPt.v, inPortPt.h + 1, inPortPt.v + 1 };
|
||||
::RectRgn(outMouseRgn, &cursorRect);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void CBrowserShell::AdjustCursorSelf(Point /* inPortPt */,
|
||||
const EventRecord& inMacEvent)
|
||||
|
@ -233,7 +261,7 @@ void CBrowserShell::AdjustCursorSelf(Point /* inPortPt */,
|
|||
lastWhere = inMacEvent.where;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CBrowserShell: LCommander overrides
|
||||
|
@ -259,7 +287,7 @@ Boolean CBrowserShell::HandleKeyPress(const EventRecord &inKeyEvent)
|
|||
FocusDraw();
|
||||
|
||||
// dispatch the event
|
||||
Boolean keyHandled = mMessageSink.DispatchOSEvent((EventRecord&)inKeyEvent, GetMacPort());
|
||||
Boolean keyHandled = mMessageSink.DispatchOSEvent((EventRecord&)inKeyEvent, Compat_GetMacWindow());
|
||||
|
||||
return keyHandled;
|
||||
}
|
||||
|
@ -273,6 +301,16 @@ Boolean CBrowserShell::ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioPa
|
|||
|
||||
switch (inCommand)
|
||||
{
|
||||
case cmd_SaveAs:
|
||||
rv = SaveCurrentURI();
|
||||
ThrowIfError_(rv);
|
||||
break;
|
||||
|
||||
case cmd_SaveAllAs:
|
||||
rv = SaveDocument();
|
||||
ThrowIfError_(rv);
|
||||
break;
|
||||
|
||||
case cmd_Cut:
|
||||
rv = GetClipboardHandler(getter_AddRefs(clipCmd));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -350,14 +388,21 @@ Boolean CBrowserShell::ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioPa
|
|||
|
||||
void CBrowserShell::FindCommandStatus(PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled, Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark, Str255 outName)
|
||||
UInt16 &outMark, Str255 outName)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboardCommands> clipCmd;
|
||||
PRBool canDo;
|
||||
nsCOMPtr<nsIURI> currURI;
|
||||
|
||||
switch (inCommand)
|
||||
{
|
||||
case cmd_SaveAs:
|
||||
case cmd_SaveAllAs:
|
||||
rv = mWebBrowserAsWebNav->GetCurrentURI(getter_AddRefs(currURI));
|
||||
outEnabled = NS_SUCCEEDED(rv);
|
||||
break;
|
||||
|
||||
case cmd_Cut:
|
||||
rv = GetClipboardHandler(getter_AddRefs(clipCmd));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -425,7 +470,7 @@ void CBrowserShell::SpendTime(const EventRecord& inMacEvent)
|
|||
|
||||
unsigned char eventType = ((inMacEvent.message >> 24) & 0x00ff);
|
||||
if (eventType == suspendResumeMessage)
|
||||
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), GetMacPort());
|
||||
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -473,7 +518,7 @@ NS_METHOD CBrowserShell::SetWebBrowser(nsIWebBrowser* aBrowser)
|
|||
|
||||
FocusDraw();
|
||||
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(GetMacPort()));
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(Compat_GetMacWindow()));
|
||||
NS_ENSURE_TRUE(ourWindow, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIWidget> aWidget;
|
||||
|
@ -564,31 +609,168 @@ NS_METHOD CBrowserShell::Forward()
|
|||
|
||||
NS_METHOD CBrowserShell::Stop()
|
||||
{
|
||||
return mWebBrowserAsWebNav->Stop(nsIWebNavigation::STOP_ALL);
|
||||
return mWebBrowserAsWebNav->Stop(nsIWebNavigation::STOP_ALL);
|
||||
}
|
||||
|
||||
NS_METHOD CBrowserShell::Reload()
|
||||
{
|
||||
return mWebBrowserAsWebNav->Stop(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CBrowserShell: URL Loading
|
||||
//*****************************************************************************
|
||||
|
||||
NS_METHOD CBrowserShell::LoadURL(const char* urlText, SInt32 urlTextLen)
|
||||
|
||||
NS_METHOD CBrowserShell::LoadURL(const nsACString& urlText)
|
||||
{
|
||||
nsAutoString urlString;
|
||||
nsAutoString unicodeURL;
|
||||
CopyASCIItoUCS2(urlText, unicodeURL);
|
||||
return mWebBrowserAsWebNav->LoadURI(unicodeURL.get(), nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
}
|
||||
|
||||
NS_METHOD CBrowserShell::GetCurrentURL(nsACString& urlText)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
rv = mWebBrowserAsWebNav->GetCurrentURI(getter_AddRefs(currentURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString urlPath;
|
||||
rv = currentURI->GetSpec(getter_Copies(urlPath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
urlText.Assign(urlPath.get());
|
||||
|
||||
if (urlTextLen == -1)
|
||||
urlString.AssignWithConversion(urlText);
|
||||
else
|
||||
urlString.AssignWithConversion(urlText, urlTextLen);
|
||||
|
||||
return LoadURL(urlString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CBrowserShell: URI Saving
|
||||
//*****************************************************************************
|
||||
|
||||
NS_METHOD CBrowserShell::LoadURL(const nsString& urlText)
|
||||
NS_METHOD CBrowserShell::SaveDocument()
|
||||
{
|
||||
return mWebBrowserAsWebNav->LoadURI(urlText.get(), nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
FSSpec fileSpec;
|
||||
Boolean isReplacing;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (DoSaveFileDialog(fileSpec, isReplacing)) {
|
||||
if (isReplacing) {
|
||||
OSErr err = ::FSpDelete(&fileSpec);
|
||||
if (err) return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = SaveDocument(fileSpec);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD CBrowserShell::SaveCurrentURI()
|
||||
{
|
||||
FSSpec fileSpec;
|
||||
Boolean isReplacing;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (DoSaveFileDialog(fileSpec, isReplacing)) {
|
||||
if (isReplacing) {
|
||||
OSErr err = ::FSpDelete(&fileSpec);
|
||||
if (err) return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = SaveCurrentURI(fileSpec);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD CBrowserShell::SaveDocument(const FSSpec& outSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> wbPersist(do_GetInterface(mWebBrowser, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = mWebBrowserAsWebNav->GetDocument(getter_AddRefs(domDoc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
FSSpec nonConstOutSpec = outSpec;
|
||||
nsCOMPtr<nsILocalFileMac> localMacFile;
|
||||
rv = NS_NewLocalFileWithFSSpec(&nonConstOutSpec, PR_FALSE, getter_AddRefs(localMacFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(localMacFile, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFile> parentDir;
|
||||
rv = localFile->GetParent(getter_AddRefs(parentDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString outDirPath, outFilePath;
|
||||
parentDir->GetPath(getter_Copies(outDirPath));
|
||||
localFile->GetPath(getter_Copies(outFilePath));
|
||||
|
||||
rv = wbPersist->SaveDocument(domDoc, outFilePath, outDirPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD CBrowserShell::SaveCurrentURI(const FSSpec& outSpec)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> wbPersist(do_GetInterface(mWebBrowser, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
FSSpec nonConstOutSpec = outSpec;
|
||||
nsCOMPtr<nsILocalFileMac> localMacFile;
|
||||
rv = NS_NewLocalFileWithFSSpec(&nonConstOutSpec, PR_FALSE, getter_AddRefs(localMacFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(localMacFile, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString outFilePath;
|
||||
localFile->GetPath(getter_Copies(outFilePath));
|
||||
|
||||
rv = wbPersist->SaveCurrentURI(outFilePath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
Boolean CBrowserShell::DoSaveFileDialog(FSSpec& outSpec, Boolean& outIsReplacing)
|
||||
{
|
||||
#if PP_Target_Carbon
|
||||
UNavServicesDialogs::LFileDesignator designator;
|
||||
#else
|
||||
UConditionalDialogs::LFileDesignator designator;
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
nsAutoString docTitle;
|
||||
Str255 defaultName;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
rv = mWebBrowserAsWebNav->GetDocument(getter_AddRefs(domDoc));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDoc, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
htmlDoc->GetTitle(docTitle);
|
||||
}
|
||||
|
||||
// For now, we'll assume that we're saving HTML
|
||||
NS_NAMED_LITERAL_STRING(htmlSuffix, ".html");
|
||||
if (docTitle.IsEmpty())
|
||||
docTitle.AssignWithConversion("untitled");
|
||||
else {
|
||||
if (docTitle.Length() > 31 - htmlSuffix.Length())
|
||||
docTitle.Truncate(31 - htmlSuffix.Length());
|
||||
}
|
||||
docTitle.Append(htmlSuffix);
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(docTitle, defaultName);
|
||||
|
||||
Boolean result;
|
||||
|
||||
result = designator.AskDesignateFile(defaultName);
|
||||
if (result) {
|
||||
designator.GetFileSpec(outSpec);
|
||||
outIsReplacing = designator.IsReplacing();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CBrowserShell: Text Searching
|
||||
|
@ -694,7 +876,7 @@ void CBrowserShell::HandleMouseMoved(const EventRecord& inMacEvent)
|
|||
if (IsActive())
|
||||
{
|
||||
FocusDraw();
|
||||
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), GetMacPort());
|
||||
mMessageSink.DispatchOSEvent(const_cast<EventRecord&>(inMacEvent), Compat_GetMacWindow());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,15 @@ public:
|
|||
virtual void DrawSelf();
|
||||
virtual void ClickSelf(const SMouseDownEvent &inMouseDown);
|
||||
virtual void EventMouseUp(const EventRecord &inMacEvent);
|
||||
|
||||
#if __PowerPlant__ >= 0x02200000
|
||||
virtual void AdjustMouseSelf(Point /* inPortPt */,
|
||||
const EventRecord& inMacEvent,
|
||||
RgnHandle outMouseRgn);
|
||||
#else
|
||||
virtual void AdjustCursorSelf(Point inPortPt,
|
||||
const EventRecord& inMacEvent);
|
||||
#endif
|
||||
|
||||
// LCommander
|
||||
virtual void BeTarget();
|
||||
|
@ -92,7 +99,7 @@ public:
|
|||
virtual Boolean ObeyCommand(PP_PowerPlant::CommandT inCommand, void* ioParam);
|
||||
virtual void FindCommandStatus(PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled, Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark, Str255 outName);
|
||||
UInt16 &outMark, Str255 outName);
|
||||
|
||||
// LPeriodical
|
||||
virtual void SpendTime(const EventRecord& inMacEvent);
|
||||
|
@ -115,9 +122,18 @@ public:
|
|||
NS_METHOD Back();
|
||||
NS_METHOD Forward();
|
||||
NS_METHOD Stop();
|
||||
NS_METHOD Reload();
|
||||
|
||||
NS_METHOD LoadURL(const char* urlText, SInt32 urlTextLen = -1);
|
||||
NS_METHOD LoadURL(const nsString& urlText);
|
||||
NS_METHOD LoadURL(const nsACString& urlText);
|
||||
NS_METHOD GetCurrentURL(nsACString& urlText);
|
||||
|
||||
// Puts up a Save As dialog and saves current URI and all images, etc.
|
||||
NS_METHOD SaveDocument();
|
||||
// Puts up a Save As dialog and saves current URI only.
|
||||
NS_METHOD SaveCurrentURI();
|
||||
// Same as above but without UI
|
||||
NS_METHOD SaveDocument(const FSSpec& destFile);
|
||||
NS_METHOD SaveCurrentURI(const FSSpec& destFile);
|
||||
|
||||
// Puts up a find dialog and does the find operation
|
||||
Boolean Find();
|
||||
|
@ -140,6 +156,8 @@ protected:
|
|||
PRBool& wrapFind,
|
||||
PRBool& entireWord,
|
||||
PRBool& caseSensitive);
|
||||
virtual Boolean DoSaveFileDialog(FSSpec& outSpec, Boolean& outIsReplacing);
|
||||
|
||||
NS_METHOD GetClipboardHandler(nsIClipboardCommands **aCommand);
|
||||
|
||||
Boolean HasFormElements();
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
#include "CBrowserWindow.h"
|
||||
#include "CBrowserShell.h"
|
||||
|
@ -50,6 +51,13 @@
|
|||
#include <LBevelButton.h>
|
||||
#include <LProgressBar.h>
|
||||
|
||||
#if PP_Target_Carbon
|
||||
#include <UEventMgr.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
#include <InternetConfig.h>
|
||||
|
||||
// CBrowserWindow:
|
||||
|
@ -61,6 +69,7 @@ enum
|
|||
{
|
||||
paneID_BackButton = 'Back',
|
||||
paneID_ForwardButton = 'Forw',
|
||||
paneID_ReloadButton = 'RLoa',
|
||||
paneID_StopButton = 'Stop',
|
||||
paneID_URLField = 'gUrl',
|
||||
paneID_WebShellView = 'WebS',
|
||||
|
@ -158,97 +167,135 @@ CBrowserWindow::~CBrowserWindow()
|
|||
}
|
||||
|
||||
|
||||
CBrowserWindow* CBrowserWindow::CreateWindow(PRUint32 chromeFlags, PRInt32 width, PRInt32 height)
|
||||
CBrowserWindow* CBrowserWindow::CreateWindow(PRUint32 inChromeFlags, PRInt32 width, PRInt32 height)
|
||||
{
|
||||
const SInt16 kToolBarHeight = 34;
|
||||
const SInt16 kStatusBarHeight = 16;
|
||||
|
||||
CBrowserWindow *theWindow;
|
||||
PRUint32 chromeFlags;
|
||||
|
||||
if (chromeFlags == nsIWebBrowserChrome::CHROME_DEFAULT || chromeFlags == nsIWebBrowserChrome::CHROME_ALL)
|
||||
if (inChromeFlags == nsIWebBrowserChrome::CHROME_DEFAULT)
|
||||
chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_RESIZE |
|
||||
nsIWebBrowserChrome::CHROME_WINDOW_CLOSE |
|
||||
nsIWebBrowserChrome::CHROME_TOOLBAR |
|
||||
nsIWebBrowserChrome::CHROME_STATUSBAR;
|
||||
else
|
||||
chromeFlags = inChromeFlags;
|
||||
|
||||
// Bounds - Set to an arbitrary rect - we'll size it after all the subviews are in.
|
||||
Rect globalBounds;
|
||||
globalBounds.left = 4;
|
||||
globalBounds.top = 42;
|
||||
globalBounds.right = globalBounds.left + 600;
|
||||
globalBounds.bottom = globalBounds.top + 400;
|
||||
|
||||
// ProcID and attributes
|
||||
short windowDefProc;
|
||||
UInt32 windowAttrs = (windAttr_Enabled | windAttr_Targetable);
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG)
|
||||
{
|
||||
theWindow = dynamic_cast<CBrowserWindow*>(LWindow::CreateWindow(wind_BrowserWindow, LCommander::GetTopCommander()));
|
||||
ThrowIfNil_(theWindow);
|
||||
windowAttrs |= windAttr_Modal;
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
|
||||
{
|
||||
windowDefProc = kWindowMovableModalDialogProc;
|
||||
windowAttrs |= windAttr_TitleBar;
|
||||
}
|
||||
else
|
||||
windowDefProc = kWindowModalDialogProc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bounds - Set to an arbitrary rect - we'll size it after all the subviews are in.
|
||||
Rect globalBounds;
|
||||
globalBounds.left = 4;
|
||||
globalBounds.top = 42;
|
||||
globalBounds.right = globalBounds.left + 600;
|
||||
globalBounds.bottom = globalBounds.top + 400;
|
||||
|
||||
// ProcID and attributes
|
||||
short windowDefProc;
|
||||
UInt32 windowAttrs = (windAttr_Enabled | windAttr_Targetable);
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG)
|
||||
{
|
||||
windowAttrs |= windAttr_Modal;
|
||||
windowAttrs |= windAttr_Regular;
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
|
||||
{
|
||||
windowDefProc = kWindowMovableModalDialogProc;
|
||||
windowAttrs |= windAttr_TitleBar;
|
||||
}
|
||||
else
|
||||
windowDefProc = kWindowModalDialogProc;
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
|
||||
{
|
||||
windowDefProc = kWindowGrowDocumentProc;
|
||||
windowAttrs |= windAttr_Resizable;
|
||||
}
|
||||
else
|
||||
{
|
||||
windowAttrs |= windAttr_Regular;
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_WITH_SIZE)
|
||||
{
|
||||
windowDefProc = kWindowGrowDocumentProc;
|
||||
windowAttrs |= windAttr_Resizable;
|
||||
}
|
||||
else
|
||||
windowDefProc = kWindowDocumentProc;
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
|
||||
windowAttrs |= windAttr_CloseBox;
|
||||
}
|
||||
|
||||
Boolean isChrome = (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) != 0;
|
||||
theWindow = new CBrowserWindow(LCommander::GetTopCommander(), globalBounds, "\p", windowDefProc, windowAttrs, window_InFront, isChrome);
|
||||
ThrowIfNil_(theWindow);
|
||||
theWindow->SetUserCon(wind_BrowserWindow);
|
||||
windowDefProc = kWindowDocumentProc;
|
||||
|
||||
SPaneInfo aPaneInfo;
|
||||
SViewInfo aViewInfo;
|
||||
|
||||
aPaneInfo.paneID = paneID_WebShellView;
|
||||
aPaneInfo.width = globalBounds.right - globalBounds.left;
|
||||
aPaneInfo.height = globalBounds.bottom - globalBounds.top;
|
||||
if (!(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG) && chromeFlags & nsIWebBrowserChrome::CHROME_WITH_SIZE)
|
||||
aPaneInfo.height -= 15;
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)
|
||||
aPaneInfo.height -= kToolBarHeight;
|
||||
aPaneInfo.visible = true;
|
||||
aPaneInfo.enabled = true;
|
||||
aPaneInfo.bindings.left = true;
|
||||
aPaneInfo.bindings.top = true;
|
||||
aPaneInfo.bindings.right = true;
|
||||
aPaneInfo.bindings.bottom = true;
|
||||
aPaneInfo.left = 0;
|
||||
aPaneInfo.top = (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR) ? kToolBarHeight - 1 : 0;
|
||||
aPaneInfo.userCon = 0;
|
||||
aPaneInfo.superView = theWindow;
|
||||
|
||||
aViewInfo.imageSize.width = 0;
|
||||
aViewInfo.imageSize.height = 0;
|
||||
aViewInfo.scrollPos.h = aViewInfo.scrollPos.v = 0;
|
||||
aViewInfo.scrollUnit.h = aViewInfo.scrollUnit.v = 1;
|
||||
aViewInfo.reconcileOverhang = 0;
|
||||
|
||||
CBrowserShell *aShell = new CBrowserShell(aPaneInfo, aViewInfo);
|
||||
ThrowIfNil_(aShell);
|
||||
aShell->PutInside(theWindow, false);
|
||||
|
||||
// Now the window is constructed...
|
||||
theWindow->FinishCreate();
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
|
||||
windowAttrs |= windAttr_CloseBox;
|
||||
}
|
||||
|
||||
Boolean isChrome = (chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) != 0;
|
||||
theWindow = new CBrowserWindow(LCommander::GetTopCommander(), globalBounds, "\p", windowDefProc, windowAttrs, window_InFront, isChrome);
|
||||
ThrowIfNil_(theWindow);
|
||||
|
||||
SDimension16 windowSize, toolBarSize;
|
||||
theWindow->GetFrameSize(windowSize);
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)
|
||||
{
|
||||
LView::SetDefaultView(theWindow);
|
||||
LCommander::SetDefaultCommander(theWindow);
|
||||
LAttachable::SetDefaultAttachable(nil);
|
||||
|
||||
LView *toolBarView = static_cast<LView*>(UReanimator::ReadObjects(ResType_PPob, 131));
|
||||
ThrowIfNil_(toolBarView);
|
||||
|
||||
toolBarView->GetFrameSize(toolBarSize);
|
||||
toolBarView->PlaceInSuperFrameAt(0, 0, false);
|
||||
toolBarSize.width = windowSize.width;
|
||||
toolBarView->ResizeFrameTo(toolBarSize.width, toolBarSize.height, false);
|
||||
}
|
||||
|
||||
SPaneInfo aPaneInfo;
|
||||
SViewInfo aViewInfo;
|
||||
|
||||
aPaneInfo.paneID = paneID_WebShellView;
|
||||
aPaneInfo.width = windowSize.width;
|
||||
aPaneInfo.height = windowSize.height;
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR)
|
||||
aPaneInfo.height -= toolBarSize.height;
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)
|
||||
aPaneInfo.height -= kStatusBarHeight - 1;
|
||||
aPaneInfo.visible = true;
|
||||
aPaneInfo.enabled = true;
|
||||
aPaneInfo.bindings.left = true;
|
||||
aPaneInfo.bindings.top = true;
|
||||
aPaneInfo.bindings.right = true;
|
||||
aPaneInfo.bindings.bottom = true;
|
||||
aPaneInfo.left = 0;
|
||||
aPaneInfo.top = (chromeFlags & nsIWebBrowserChrome::CHROME_TOOLBAR) ? toolBarSize.height : 0;
|
||||
aPaneInfo.userCon = 0;
|
||||
aPaneInfo.superView = theWindow;
|
||||
|
||||
aViewInfo.imageSize.width = 0;
|
||||
aViewInfo.imageSize.height = 0;
|
||||
aViewInfo.scrollPos.h = aViewInfo.scrollPos.v = 0;
|
||||
aViewInfo.scrollUnit.h = aViewInfo.scrollUnit.v = 1;
|
||||
aViewInfo.reconcileOverhang = 0;
|
||||
|
||||
CBrowserShell *aShell = new CBrowserShell(aPaneInfo, aViewInfo);
|
||||
ThrowIfNil_(aShell);
|
||||
aShell->PutInside(theWindow, false);
|
||||
|
||||
if (chromeFlags & nsIWebBrowserChrome::CHROME_STATUSBAR)
|
||||
{
|
||||
LView::SetDefaultView(theWindow);
|
||||
LCommander::SetDefaultCommander(theWindow);
|
||||
LAttachable::SetDefaultAttachable(nil);
|
||||
|
||||
LView *statusView = static_cast<LView*>(UReanimator::ReadObjects(ResType_PPob, 130));
|
||||
ThrowIfNil_(statusView);
|
||||
|
||||
statusView->PlaceInSuperFrameAt(0, windowSize.height - kStatusBarHeight + 1, false);
|
||||
statusView->ResizeFrameTo(windowSize.width - 15, kStatusBarHeight, false);
|
||||
}
|
||||
|
||||
// Only add context menus to our default window type
|
||||
if (inChromeFlags == nsIWebBrowserChrome::CHROME_DEFAULT)
|
||||
{
|
||||
CWebBrowserCMAttachment *cmAttachment = new CWebBrowserCMAttachment(theWindow, 0);
|
||||
theWindow->AddAttachment(cmAttachment);
|
||||
}
|
||||
|
||||
// Now the window is constructed...
|
||||
theWindow->FinishCreate();
|
||||
|
||||
Rect theBounds;
|
||||
theWindow->GetGlobalBounds(theBounds);
|
||||
if (width == -1)
|
||||
|
@ -286,10 +333,17 @@ void CBrowserWindow::FinishCreate()
|
|||
// This needs to be done AFTER the subviews are constructed
|
||||
// but BEFORE the subviews do FinishCreateSelf.
|
||||
|
||||
Rect portRect = GetMacPort()->portRect;
|
||||
Rect portRect;
|
||||
|
||||
#if PP_Target_Carbon
|
||||
::GetWindowPortBounds(GetMacWindow(), &portRect);
|
||||
#else
|
||||
portRect = GetMacPort()->portRect;
|
||||
#endif
|
||||
|
||||
nsRect r(0, 0, portRect.right - portRect.left, portRect.bottom - portRect.top);
|
||||
|
||||
nsresult rv = mWindow->Create((nsNativeWidget)GetMacPort(), r, nsnull, nsnull, nsnull, nsnull, nsnull);
|
||||
nsresult rv = mWindow->Create(Compat_GetMacWindow(), r, nsnull, nsnull, nsnull, nsnull, nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
Throw_(NS_ERROR_GET_CODE(rv));
|
||||
|
||||
|
@ -309,9 +363,8 @@ void CBrowserWindow::FinishCreateSelf()
|
|||
{
|
||||
SetLatentSub(mBrowserShell);
|
||||
|
||||
// Find our subviews - When we have a way of creating this
|
||||
// window with various chrome flags, we may or may not have
|
||||
// all of these subviews so don't fail if they don't exist
|
||||
// Find our subviews - Depending on our chrome flags, we may or may
|
||||
// not have any of these subviews so don't fail if they don't exist
|
||||
mURLField = dynamic_cast<LEditText*>(FindPaneByID(paneID_URLField));
|
||||
mStatusBar = dynamic_cast<LStaticText*>(FindPaneByID(paneID_StatusBar));
|
||||
mThrobber = dynamic_cast<CThrobber*>(FindPaneByID(paneID_Throbber));
|
||||
|
@ -319,17 +372,20 @@ void CBrowserWindow::FinishCreateSelf()
|
|||
if (mProgressBar)
|
||||
mProgressBar->Hide();
|
||||
|
||||
mBackButton = dynamic_cast<LBevelButton*>(FindPaneByID(paneID_BackButton));
|
||||
mBackButton = dynamic_cast<LControl*>(FindPaneByID(paneID_BackButton));
|
||||
if (mBackButton)
|
||||
mBackButton->Disable();
|
||||
mForwardButton = dynamic_cast<LBevelButton*>(FindPaneByID(paneID_ForwardButton));
|
||||
mForwardButton = dynamic_cast<LControl*>(FindPaneByID(paneID_ForwardButton));
|
||||
if (mForwardButton)
|
||||
mForwardButton->Disable();
|
||||
mStopButton = dynamic_cast<LBevelButton*>(FindPaneByID(paneID_StopButton));
|
||||
mReloadButton = dynamic_cast<LControl*>(FindPaneByID(paneID_ReloadButton));
|
||||
if (mReloadButton)
|
||||
mReloadButton->Disable();
|
||||
mStopButton = dynamic_cast<LControl*>(FindPaneByID(paneID_StopButton));
|
||||
if (mStopButton)
|
||||
mStopButton->Disable();
|
||||
|
||||
UReanimator::LinkListenerToControls(this, this, mUserCon);
|
||||
UReanimator::LinkListenerToControls(this, this, view_BrowserToolBar);
|
||||
StartListening();
|
||||
StartBroadcasting();
|
||||
}
|
||||
|
@ -340,7 +396,14 @@ void CBrowserWindow::ResizeFrameBy(SInt16 inWidthDelta,
|
|||
Boolean inRefresh)
|
||||
{
|
||||
// Resize the widget BEFORE subviews get resized
|
||||
Rect portRect = GetMacPort()->portRect;
|
||||
Rect portRect;
|
||||
|
||||
#if PP_Target_Carbon
|
||||
::GetWindowPortBounds(GetMacWindow(), &portRect);
|
||||
#else
|
||||
portRect = GetMacPort()->portRect;
|
||||
#endif
|
||||
|
||||
mWindow->Resize(portRect.right - portRect.left, portRect.bottom - portRect.top, inRefresh);
|
||||
|
||||
Inherited::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
|
||||
|
@ -374,13 +437,12 @@ Boolean CBrowserWindow::ObeyCommand(CommandT inCommand,
|
|||
#pragma unused(ioParam)
|
||||
|
||||
Boolean cmdHandled = true;
|
||||
nsresult rv;
|
||||
|
||||
switch (inCommand)
|
||||
{
|
||||
case cmd_OpenLinkInNewWindow:
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
{
|
||||
// Get the URL from the link
|
||||
ThrowIfNil_(mContextMenuDOMNode);
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(mContextMenuDOMNode, &rv));
|
||||
|
@ -392,45 +454,20 @@ Boolean CBrowserWindow::ObeyCommand(CommandT inCommand,
|
|||
|
||||
nsCAutoString urlSpec;
|
||||
CopyUCS2toASCII(href, urlSpec);
|
||||
|
||||
// Send an AppleEvent to ourselves to open a new window with the given URL
|
||||
|
||||
// IMPORTANT: We need to make our target address using a ProcessSerialNumber
|
||||
// from GetCurrentProcess. This will cause our AppleEvent to be handled from
|
||||
// the event loop. Creating and showing a new window before the context menu
|
||||
// click is done being processed is fatal. If we make the target address with a
|
||||
// ProcessSerialNumber in which highLongOfPSN == 0 && lowLongOfPSN == kCurrentProcess,
|
||||
// the event will be dispatched to us directly and we die.
|
||||
|
||||
OSErr err;
|
||||
ProcessSerialNumber currProcess;
|
||||
StAEDescriptor selfAddrDesc;
|
||||
|
||||
err = ::GetCurrentProcess(&currProcess);
|
||||
ThrowIfOSErr_(err);
|
||||
err = ::AECreateDesc(typeProcessSerialNumber, (Ptr) &currProcess,
|
||||
sizeof(currProcess), selfAddrDesc);
|
||||
ThrowIfOSErr_(err);
|
||||
|
||||
AppleEvent getURLEvent;
|
||||
err = ::AECreateAppleEvent(kInternetEventClass, kAEGetURL,
|
||||
selfAddrDesc,
|
||||
kAutoGenerateReturnID,
|
||||
kAnyTransactionID,
|
||||
&getURLEvent);
|
||||
ThrowIfOSErr_(err);
|
||||
|
||||
StAEDescriptor urlDesc(typeChar, urlSpec.get(), urlSpec.Length());
|
||||
|
||||
err = ::AEPutParamDesc(&getURLEvent, keyDirectObject, urlDesc);
|
||||
if (err) {
|
||||
::AEDisposeDesc(&getURLEvent);
|
||||
Throw_(err);
|
||||
}
|
||||
UAppleEventsMgr::SendAppleEvent(getURLEvent);
|
||||
SendOpenURLEventToSelf(urlSpec);
|
||||
}
|
||||
break;
|
||||
|
||||
case cmd_ViewPageSource:
|
||||
{
|
||||
nsCAutoString currentURL;
|
||||
rv = mBrowserShell->GetCurrentURL(currentURL);
|
||||
ThrowIfError_(rv);
|
||||
currentURL.Insert("view-source:", 0);
|
||||
SendOpenURLEventToSelf(currentURL);
|
||||
}
|
||||
break;
|
||||
|
||||
case paneID_BackButton:
|
||||
mBrowserShell->Back();
|
||||
break;
|
||||
|
@ -438,10 +475,18 @@ Boolean CBrowserWindow::ObeyCommand(CommandT inCommand,
|
|||
case paneID_ForwardButton:
|
||||
mBrowserShell->Forward();
|
||||
break;
|
||||
|
||||
case paneID_ReloadButton:
|
||||
mBrowserShell->Reload();
|
||||
break;
|
||||
|
||||
case paneID_StopButton:
|
||||
mBrowserShell->Stop();
|
||||
break;
|
||||
|
||||
case cmd_Reload:
|
||||
mBrowserShell->Reload();
|
||||
break;
|
||||
|
||||
case paneID_URLField:
|
||||
{
|
||||
|
@ -449,7 +494,7 @@ Boolean CBrowserWindow::ObeyCommand(CommandT inCommand,
|
|||
mURLField->GetText(nil, 0, &urlTextLen);
|
||||
StPointerBlock urlTextPtr(urlTextLen, true, false);
|
||||
mURLField->GetText(urlTextPtr.Get(), urlTextLen, &urlTextLen);
|
||||
mBrowserShell->LoadURL(urlTextPtr.Get(), urlTextLen);
|
||||
mBrowserShell->LoadURL(nsDependentCString(urlTextPtr.Get(), urlTextLen));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -474,7 +519,7 @@ CBrowserWindow::FindCommandStatus(
|
|||
PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled,
|
||||
Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark,
|
||||
UInt16 &outMark,
|
||||
Str255 outName)
|
||||
{
|
||||
|
||||
|
@ -626,33 +671,37 @@ NS_METHOD CBrowserWindow::OnStatusNetStop(nsIWebProgress *progress, nsIRequest *
|
|||
mProgressBar->Hide();
|
||||
}
|
||||
|
||||
// Enable back, forward, stop
|
||||
// Enable back, forward, reload, stop
|
||||
if (mBackButton)
|
||||
mBrowserShell->CanGoBack() ? mBackButton->Enable() : mBackButton->Disable();
|
||||
if (mForwardButton)
|
||||
mBrowserShell->CanGoForward() ? mForwardButton->Enable() : mForwardButton->Disable();
|
||||
if (mReloadButton)
|
||||
mReloadButton->Enable();
|
||||
if (mStopButton)
|
||||
mStopButton->Disable();
|
||||
|
||||
// If this is a chrome window and it's first load, do some things.
|
||||
if (mIsChromeWindow && !mInitialLoadComplete) {
|
||||
// If this is the first load, do some things.
|
||||
if (!mInitialLoadComplete) {
|
||||
|
||||
// If we don't have a title yet, see if we can get one from the DOM
|
||||
LStr255 windowTitle;
|
||||
GetDescriptor(windowTitle);
|
||||
if (!windowTitle.Length())
|
||||
SetTitleFromDOMDocument();
|
||||
|
||||
// If we are being sized intrinsically, do it now
|
||||
if (mSizeToContent)
|
||||
SizeToContent();
|
||||
if (mIsChromeWindow) {
|
||||
// If we don't have a title yet, see if we can get one from the DOM
|
||||
LStr255 windowTitle;
|
||||
GetDescriptor(windowTitle);
|
||||
if (!windowTitle.Length())
|
||||
SetTitleFromDOMDocument();
|
||||
|
||||
// If we are being sized intrinsically, do it now
|
||||
if (mSizeToContent)
|
||||
SizeToContent();
|
||||
}
|
||||
|
||||
// If we deferred showing ourselves because waiting to be sized, do it now
|
||||
if (mVisible && !IsVisible())
|
||||
Show();
|
||||
|
||||
|
||||
mInitialLoadComplete = true;
|
||||
}
|
||||
mInitialLoadComplete = true;
|
||||
mBusy = false;
|
||||
|
||||
// Inform any other interested parties
|
||||
|
@ -758,7 +807,12 @@ NS_METHOD CBrowserWindow::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent
|
|||
// null event but will fill in the mouse location and modifier keys.
|
||||
|
||||
EventRecord macEvent;
|
||||
|
||||
#if PP_Target_Carbon
|
||||
UEventMgr::GetMouseAndModifiers(macEvent);
|
||||
#else
|
||||
::OSEventAvail(0, &macEvent);
|
||||
#endif
|
||||
|
||||
mContextMenuContext = aContextFlags;
|
||||
mContextMenuDOMNode = aNode;
|
||||
|
@ -796,6 +850,47 @@ NS_METHOD CBrowserWindow::SetTitleFromDOMDocument()
|
|||
return rv;
|
||||
}
|
||||
|
||||
void CBrowserWindow::SendOpenURLEventToSelf(const nsACString& url)
|
||||
{
|
||||
// Send an AppleEvent to ourselves to open a new window with the given URL
|
||||
|
||||
// IMPORTANT: We need to make our target address using a ProcessSerialNumber
|
||||
// from GetCurrentProcess. This will cause our AppleEvent to be handled from
|
||||
// the event loop. Creating and showing a new window before the context menu
|
||||
// click is done being processed is fatal. If we make the target address with a
|
||||
// ProcessSerialNumber in which highLongOfPSN == 0 && lowLongOfPSN == kCurrentProcess,
|
||||
// the event will be dispatched to us directly and we die.
|
||||
|
||||
OSErr err;
|
||||
ProcessSerialNumber currProcess;
|
||||
StAEDescriptor selfAddrDesc;
|
||||
|
||||
err = ::GetCurrentProcess(&currProcess);
|
||||
ThrowIfOSErr_(err);
|
||||
err = ::AECreateDesc(typeProcessSerialNumber, (Ptr) &currProcess,
|
||||
sizeof(currProcess), selfAddrDesc);
|
||||
ThrowIfOSErr_(err);
|
||||
|
||||
AppleEvent getURLEvent;
|
||||
err = ::AECreateAppleEvent(kInternetEventClass, kAEGetURL,
|
||||
selfAddrDesc,
|
||||
kAutoGenerateReturnID,
|
||||
kAnyTransactionID,
|
||||
&getURLEvent);
|
||||
ThrowIfOSErr_(err);
|
||||
|
||||
const nsPromiseFlatCString& flatURL = PromiseFlatCString(url);
|
||||
StAEDescriptor urlDesc(typeChar, flatURL.get(), flatURL.Length());
|
||||
|
||||
err = ::AEPutParamDesc(&getURLEvent, keyDirectObject, urlDesc);
|
||||
if (err) {
|
||||
::AEDisposeDesc(&getURLEvent);
|
||||
Throw_(err);
|
||||
}
|
||||
UAppleEventsMgr::SendAppleEvent(getURLEvent);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Window Creator
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
virtual void FindCommandStatus(PP_PowerPlant::CommandT inCommand,
|
||||
Boolean &outEnabled,
|
||||
Boolean &outUsesMark,
|
||||
PP_PowerPlant::Char16 &outMark,
|
||||
UInt16 &outMark,
|
||||
Str255 outName);
|
||||
|
||||
NS_METHOD GetWidget(nsIWidget** aWidget);
|
||||
|
@ -162,6 +162,7 @@ protected:
|
|||
// -----------------------------------
|
||||
|
||||
NS_METHOD SetTitleFromDOMDocument();
|
||||
void SendOpenURLEventToSelf(const nsACString& url);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWidget> mWindow;
|
||||
|
@ -172,7 +173,7 @@ protected:
|
|||
LEditText* mURLField;
|
||||
LStaticText* mStatusBar;
|
||||
CThrobber* mThrobber;
|
||||
LBevelButton *mBackButton, *mForwardButton, *mStopButton;
|
||||
LControl *mBackButton, *mForwardButton, *mReloadButton, *mStopButton;
|
||||
LProgressBar* mProgressBar;
|
||||
Boolean mBusy;
|
||||
Boolean mInitialLoadComplete;
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsIRegistry.h"
|
||||
|
||||
// ANSI
|
||||
#include <climits>
|
||||
|
||||
// Constants
|
||||
|
||||
const MessageT msg_OnNewProfile = 2000;
|
||||
|
|
|
@ -119,7 +119,7 @@ void CThrobber::NotifyError(nsIImageRequest *aImageRequest,
|
|||
|
||||
void CThrobber::FinishCreateSelf()
|
||||
{
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(GetMacPort()));
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(Compat_GetMacWindow()));
|
||||
ThrowIfNil_(ourWindow);
|
||||
|
||||
// Get the widget from the browser window
|
||||
|
|
|
@ -47,7 +47,7 @@ Boolean
|
|||
CUrlField::HandleKeyPress(const EventRecord &inKeyEvent)
|
||||
{
|
||||
Boolean keyHandled = true;
|
||||
Char16 theChar = (Char16) (inKeyEvent.message & charCodeMask);
|
||||
SInt16 theChar = (SInt16) (inKeyEvent.message & charCodeMask);
|
||||
|
||||
if (theChar == char_Return || theChar == char_Enter)
|
||||
{
|
||||
|
|
|
@ -79,6 +79,7 @@ NS_INTERFACE_MAP_BEGIN(CWebBrowserChrome)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
|
||||
|
@ -188,7 +189,12 @@ NS_IMETHODIMP CWebBrowserChrome::IsWindowModal(PRBool *_retval)
|
|||
|
||||
NS_IMETHODIMP CWebBrowserChrome::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
mBrowserWindow->ResizeWindowTo(aCX, aCY + kGrowIconSize);
|
||||
CBrowserShell *browserShell = mBrowserWindow->GetBrowserShell();
|
||||
NS_ENSURE_TRUE(browserShell, NS_ERROR_NULL_POINTER);
|
||||
|
||||
SDimension16 curSize;
|
||||
browserShell->GetFrameSize(curSize);
|
||||
mBrowserWindow->ResizeWindowBy(aCX - curSize.width, aCY - curSize.height);
|
||||
mBrowserWindow->SetSizeToContent(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -470,7 +476,7 @@ NS_IMETHODIMP CWebBrowserChrome::GetSiteWindow(void * *aSiteWindow)
|
|||
NS_ENSURE_ARG(aSiteWindow);
|
||||
NS_ENSURE_STATE(mBrowserWindow);
|
||||
|
||||
*aSiteWindow = mBrowserWindow->GetMacPort();
|
||||
*aSiteWindow = mBrowserWindow->Compat_GetMacWindow();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Двоичные данные
lib/mac/PowerPlant/PowerPlant.mcp
Двоичные данные
lib/mac/PowerPlant/PowerPlant.mcp
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче