diff --git a/embedding/minimo/wince/Makefile.in b/embedding/minimo/wince/Makefile.in index 4761e5fabcf7..3f628122aa66 100755 --- a/embedding/minimo/wince/Makefile.in +++ b/embedding/minimo/wince/Makefile.in @@ -36,12 +36,9 @@ include $(DEPTH)/config/autoconf.mk MOZILLA_INTERNAL_API = 1 -PROGRAM = winEmbed$(BIN_SUFFIX) -RESFILE = winEmbed.res +PROGRAM = minimo$(BIN_SUFFIX) -MODULE = winEmbed - -PACKAGE_FILE = winembed.pkg +MODULE = minimo REQUIRES = xpcom \ string \ @@ -61,13 +58,14 @@ REQUIRES = xpcom \ layout \ content \ profdirserviceprovider \ + embedcomponents \ + appcomps \ $(NULL) CPPSRCS = \ winEmbed.cpp \ WebBrowserChrome.cpp \ WindowCreator.cpp \ - PromptService.cpp \ $(NULL) diff --git a/embedding/minimo/wince/MinimoPrivate.h b/embedding/minimo/wince/MinimoPrivate.h index 08a4f2f0ec2b..cb35aa8de9b3 100755 --- a/embedding/minimo/wince/MinimoPrivate.h +++ b/embedding/minimo/wince/MinimoPrivate.h @@ -42,13 +42,9 @@ #include "nsIDOMWindow.h" #include "nsIComponentRegistrar.h" -#include "PromptService.h" - // Local header files #include "winEmbed.h" #include "WebBrowserChrome.h" #include "WindowCreator.h" -#include "resource.h" -#include "PromptService.h" #endif // MINIMO_PRIVATE_H diff --git a/embedding/minimo/wince/PromptService.cpp b/embedding/minimo/wince/PromptService.cpp deleted file mode 100755 index 8566a0c5e5ad..000000000000 --- a/embedding/minimo/wince/PromptService.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#include "MinimoPrivate.h" - -class PromptService: public nsIPromptService -{ -public: - PromptService(); - virtual ~PromptService(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIPROMPTSERVICE -private: - nsCOMPtr mWWatch; - HWND WndForDOMWindow(nsIDOMWindow *aWindow); -}; - - -NS_IMPL_ISUPPORTS1(PromptService, nsIPromptService) - - PromptService::PromptService() -{ - mWWatch = do_GetService(NS_WINDOWWATCHER_CONTRACTID); -} - -PromptService::~PromptService() -{ -} - -HWND -PromptService::WndForDOMWindow(nsIDOMWindow *aWindow) -{ - nsCOMPtr chrome; - HWND val = NULL; - - if (mWWatch) { - nsCOMPtr fosterParent; - if (!aWindow) { // it will be a dependent window. try to find a foster parent. - mWWatch->GetActiveWindow(getter_AddRefs(fosterParent)); - aWindow = fosterParent; - } - mWWatch->GetChromeForWindow(aWindow, getter_AddRefs(chrome)); - } - - if (chrome) { - nsCOMPtr site(do_QueryInterface(chrome)); - if (site) { - site->GetSiteWindow(reinterpret_cast(&val)); - } - } - - return val; -} - -NS_IMETHODIMP -PromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialogTitle, const PRUnichar *text) -{ - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, text, dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::AlertCheck(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkboxMsg, - PRBool *checkValue) -{ - Alert(parent, dialogTitle, text); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::Confirm(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRBool *_retval) -{ - HWND wnd = WndForDOMWindow(parent); - int choice = MessageBoxW(wnd, text, dialogTitle, MB_YESNO | MB_ICONEXCLAMATION); - *_retval = choice == IDYES ? PR_TRUE : PR_FALSE; - return NS_OK; -} - -NS_IMETHODIMP -PromptService::ConfirmCheck(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - Confirm(parent, dialogTitle, text, _retval); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::Prompt(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **value, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, L"Prompt", dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **username, - PRUnichar **password, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, L"PromptUsernameAndPassword", dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::PromptPassword(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUnichar **password, - const PRUnichar *checkboxMsg, - PRBool *checkValue, - PRBool *_retval) -{ - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, L"PromptPassword", dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::Select(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, PRUint32 count, - const PRUnichar **selectList, - PRInt32 *outSelection, - PRBool *_retval) -{ - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, L"Select", dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -NS_IMETHODIMP -PromptService::ConfirmEx(nsIDOMWindow *parent, - const PRUnichar *dialogTitle, - const PRUnichar *text, - PRUint32 buttonFlags, - const PRUnichar *button0Title, - const PRUnichar *button1Title, - const PRUnichar *button2Title, - const PRUnichar *checkMsg, - PRBool *checkValue, - PRInt32 *buttonPressed) -{ - HWND wnd = WndForDOMWindow(parent); - MessageBoxW(wnd, L"ConfirmEx", dialogTitle, MB_OK | MB_ICONEXCLAMATION); - return NS_OK; -} - -class PromptServiceFactory : public nsIFactory { -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - - PromptServiceFactory(); - virtual ~PromptServiceFactory(); -}; - -//***************************************************************************** - -NS_IMPL_ISUPPORTS1(PromptServiceFactory, nsIFactory) - - PromptServiceFactory::PromptServiceFactory() { -} - -PromptServiceFactory::~PromptServiceFactory() { -} - -NS_IMETHODIMP -PromptServiceFactory::CreateInstance(nsISupports *aOuter, const nsIID & aIID, void **aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = NULL; - PromptService *inst = new PromptService; - if (!inst) - return NS_ERROR_OUT_OF_MEMORY; - - nsresult rv = inst->QueryInterface(aIID, aResult); - if (rv != NS_OK) { - // We didn't get the right interface, so clean up - delete inst; - } - - return rv; -} - -NS_IMETHODIMP -PromptServiceFactory::LockFactory(PRBool lock) -{ - return NS_OK; -} - -nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory) -{ - NS_ENSURE_ARG_POINTER(aFactory); - *aFactory = nsnull; - - PromptServiceFactory *result = new PromptServiceFactory; - if (!result) - return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(result); - *aFactory = result; - - return NS_OK; -} diff --git a/embedding/minimo/wince/PromptService.h b/embedding/minimo/wince/PromptService.h deleted file mode 100755 index a69af347b3ec..000000000000 --- a/embedding/minimo/wince/PromptService.h +++ /dev/null @@ -1,9 +0,0 @@ - -#include "nsIFactory.h" -#include "nsIPromptService.h" - - -#define NS_PROMPTSERVICE_CID \ - {0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}} - -nsresult NS_NewPromptServiceFactory(nsIFactory** aFactory); diff --git a/embedding/minimo/wince/WebBrowserChrome.cpp b/embedding/minimo/wince/WebBrowserChrome.cpp index d03850f5c4a3..bccdd174b8c5 100755 --- a/embedding/minimo/wince/WebBrowserChrome.cpp +++ b/embedding/minimo/wince/WebBrowserChrome.cpp @@ -46,17 +46,13 @@ #include "nsIDOMEventTarget.h" #include "nsIContent.h" -// Local includes -#include "resource.h" - #include "winEmbed.h" #include "WebBrowserChrome.h" - +#include "nsIWebBrowserSetup.h" WebBrowserChrome::WebBrowserChrome() { mNativeWindow = nsnull; - mSizeSet = PR_FALSE; } WebBrowserChrome::~WebBrowserChrome() @@ -76,43 +72,24 @@ nsresult WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY, if (!mWebBrowser) return NS_ERROR_FAILURE; + + // Configure what the web browser can and cannot do + nsCOMPtr webBrowserAsSetup(do_QueryInterface(mWebBrowser)); + + webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, PR_TRUE); + webBrowserAsSetup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER, PR_TRUE); + + (void)mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); - nsCOMPtr dsti = do_QueryInterface(mWebBrowser); - dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper); - nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); - mNativeWindow = WebBrowserChromeUI::CreateNativeWindow(NS_STATIC_CAST(nsIWebBrowserChrome*, this)); if (!mNativeWindow) - return NS_ERROR_FAILURE; - - browserBaseWindow->InitWindow( mNativeWindow, - nsnull, - aX, aY, aCX, aCY); - browserBaseWindow->Create(); - - nsCOMPtr listener(NS_STATIC_CAST(nsIWebProgressListener*, this)); - nsCOMPtr thisListener(do_GetWeakReference(listener)); - (void)mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIWebProgressListener)); - - // get the content DOM window for that web browser - nsCOMPtr domWindow; - mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow)); - if (!domWindow) return NS_ERROR_FAILURE; - // get the private DOM window - nsCOMPtr domWindowPrivate = do_QueryInterface(domWindow); - // and the root window for that DOM window - nsPIDOMWindow* piWin = domWindowPrivate->GetPrivateRoot(); - - nsCOMPtr eventHandler = do_QueryInterface(piWin->GetChromeEventHandler()); - eventHandler->AddEventListenerByIID(this, NS_GET_IID(nsIDOMMouseListener)); - - // The window has been created. Now register for history notifications - mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsISHistoryListener)); + browserBaseWindow->InitWindow( mNativeWindow, nsnull, aX, aY, aCX, aCY); + browserBaseWindow->Create(); if (mWebBrowser) { @@ -120,6 +97,7 @@ nsresult WebBrowserChrome::CreateBrowser(PRInt32 aX, PRInt32 aY, NS_ADDREF(*aBrowser); return NS_OK; } + return NS_ERROR_FAILURE; } @@ -135,14 +113,6 @@ NS_INTERFACE_MAP_BEGIN(WebBrowserChrome) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow) - NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) // optional - NS_INTERFACE_MAP_ENTRY(nsISHistoryListener) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsIObserver) - NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener) - NS_INTERFACE_MAP_ENTRY(nsITooltipListener) - NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener) - NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener) NS_INTERFACE_MAP_END //***************************************************************************** @@ -171,7 +141,6 @@ NS_IMETHODIMP WebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstance NS_IMETHODIMP WebBrowserChrome::SetStatus(PRUint32 aType, const PRUnichar* aStatus) { - WebBrowserChromeUI::UpdateStatusBarText(this, aStatus); return NS_OK; } @@ -211,33 +180,21 @@ NS_IMETHODIMP WebBrowserChrome::DestroyBrowserWindow(void) // IN: The desired browser client area dimensions. NS_IMETHODIMP WebBrowserChrome::SizeBrowserTo(PRInt32 aWidth, PRInt32 aHeight) { - /* This isn't exactly correct: we're setting the whole window to - the size requested for the browser. At time of writing, though, - it's fine and useful for winEmbed's purposes. */ - WebBrowserChromeUI::SizeTo(this, aWidth, aHeight); - mSizeSet = PR_TRUE; + SetWindowPos((HWND)mNativeWindow, NULL, 0, 0, aWidth, aHeight, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); return NS_OK; } NS_IMETHODIMP WebBrowserChrome::ShowAsModal(void) { - if (mDependentParent) - AppCallbacks::EnableChromeWindow(mDependentParent, PR_FALSE); - mContinueModalLoop = PR_TRUE; - AppCallbacks::RunEventLoop(mContinueModalLoop); - - if (mDependentParent) - AppCallbacks::EnableChromeWindow(mDependentParent, PR_TRUE); - return NS_OK; } NS_IMETHODIMP WebBrowserChrome::IsWindowModal(PRBool *_retval) { - *_retval = PR_FALSE; - return NS_ERROR_NOT_IMPLEMENTED; + *_retval = mContinueModalLoop; + return NS_OK; } NS_IMETHODIMP WebBrowserChrome::ExitModalEventLoop(nsresult aStatus) @@ -260,242 +217,59 @@ NS_IMETHODIMP WebBrowserChrome::FocusPrevElement() return NS_ERROR_NOT_IMPLEMENTED; } -//***************************************************************************** -// WebBrowserChrome::nsIWebProgressListener -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::OnProgressChange(nsIWebProgress *progress, nsIRequest *request, - PRInt32 curSelfProgress, PRInt32 maxSelfProgress, - PRInt32 curTotalProgress, PRInt32 maxTotalProgress) -{ - WebBrowserChromeUI::UpdateProgress(this, curTotalProgress, maxTotalProgress); - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::OnStateChange(nsIWebProgress *progress, nsIRequest *request, - PRUint32 progressStateFlags, nsresult status) -{ - if ((progressStateFlags & STATE_START) && (progressStateFlags & STATE_IS_DOCUMENT)) - { - WebBrowserChromeUI::UpdateBusyState(this, PR_TRUE); - } - - if ((progressStateFlags & STATE_STOP) && (progressStateFlags & STATE_IS_DOCUMENT)) - { - WebBrowserChromeUI::UpdateBusyState(this, PR_FALSE); - WebBrowserChromeUI::UpdateProgress(this, 0, 100); - WebBrowserChromeUI::UpdateStatusBarText(this, nsnull); - - if (NS_FAILED(status)) - { - nsString wStr; - char buffer[100]; - sprintf(buffer, "Error loading page (status=%x)", status); - wStr.AppendLiteral(buffer); - WebBrowserChromeUI::UpdateStatusBarText(this, wStr.get()); - -#ifdef DEBUG - printf(buffer); -#endif - } - } - - return NS_OK; -} - - -NS_IMETHODIMP WebBrowserChrome::OnLocationChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsIURI *location) -{ - PRBool isSubFrameLoad = PR_FALSE; // Is this a subframe load - if (aWebProgress) { - nsCOMPtr domWindow; - nsCOMPtr topDomWindow; - aWebProgress->GetDOMWindow(getter_AddRefs(domWindow)); - if (domWindow) { // Get root domWindow - domWindow->GetTop(getter_AddRefs(topDomWindow)); - } - if (domWindow != topDomWindow) - isSubFrameLoad = PR_TRUE; - } - if (!isSubFrameLoad) - WebBrowserChromeUI::UpdateCurrentURI(this); - return NS_OK; -} - -NS_IMETHODIMP -WebBrowserChrome::OnStatusChange(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, - nsresult aStatus, - const PRUnichar* aMessage) -{ - WebBrowserChromeUI::UpdateStatusBarText(this, aMessage); - return NS_OK; -} - - - -NS_IMETHODIMP -WebBrowserChrome::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 state) -{ - return NS_OK; -} - -//***************************************************************************** -// WebBrowserChrome::nsISHistoryListener -//***************************************************************************** - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryNewEntry(nsIURI * aNewURI) -{ - return SendHistoryStatusMessage(aNewURI, "add"); -} - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryGoBack(nsIURI * aBackURI, PRBool * aContinue) -{ - // For now, let the operation continue - *aContinue = PR_TRUE; - return SendHistoryStatusMessage(aBackURI, "back"); -} - - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryGoForward(nsIURI * aForwardURI, PRBool * aContinue) -{ - // For now, let the operation continue - *aContinue = PR_TRUE; - return SendHistoryStatusMessage(aForwardURI, "forward"); -} - - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryGotoIndex(PRInt32 aIndex, nsIURI * aGotoURI, PRBool * aContinue) -{ - // For now, let the operation continue - *aContinue = PR_TRUE; - return SendHistoryStatusMessage(aGotoURI, "goto", aIndex); -} - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryReload(nsIURI * aURI, PRUint32 aReloadFlags, PRBool * aContinue) -{ - // For now, let the operation continue - *aContinue = PR_TRUE; - return SendHistoryStatusMessage(aURI, "reload", 0 /* no info to pass here */, aReloadFlags); -} - -NS_IMETHODIMP -WebBrowserChrome::OnHistoryPurge(PRInt32 aNumEntries, PRBool *aContinue) -{ - // For now let the operation continue - *aContinue = PR_FALSE; - return SendHistoryStatusMessage(nsnull, "purge", aNumEntries); -} - -nsresult -WebBrowserChrome::SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1, PRUint32 aReloadFlags) -{ - nsCAutoString uriCStr; - if (aURI) - { - aURI->GetSpec(uriCStr); - } - - nsString uriAStr; - - if(!(strcmp(operation, "back"))) - { - // Going back. XXX Get string from a resource file - uriAStr.AppendLiteral("Going back to url:"); - AppendUTF8toUTF16(uriCStr, uriAStr); - } - else if (!(strcmp(operation, "forward"))) - { - // Going forward. XXX Get string from a resource file - uriAStr.AppendLiteral("Going forward to url:"); - AppendUTF8toUTF16(uriCStr, uriAStr); - } - else if (!(strcmp(operation, "reload"))) - { - // Reloading. XXX Get string from a resource file - if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY && - aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) - { - uriAStr.Append(NS_LITERAL_STRING("Reloading url,(bypassing proxy and cache) :")); - } - else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) - { - uriAStr.Append(NS_LITERAL_STRING("Reloading url, (bypassing proxy):")); - } - else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) - { - uriAStr.Append(NS_LITERAL_STRING("Reloading url, (bypassing cache):")); - } - else - { - uriAStr.Append(NS_LITERAL_STRING("Reloading url, (normal):")); - } - AppendUTF8toUTF16(uriCStr, uriAStr); - } - else if (!(strcmp(operation, "add"))) - { - // Adding new entry. XXX Get string from a resource file - AppendUTF8toUTF16(uriCStr, uriAStr); - uriAStr.AppendLiteral(" added to session History"); - } - else if (!(strcmp(operation, "goto"))) - { - // Goto. XXX Get string from a resource file - uriAStr.AppendLiteral("Going to HistoryIndex:"); - uriAStr.AppendInt(info1); - uriAStr.AppendLiteral(" Url:"); - AppendUTF8toUTF16(uriCStr, uriAStr); - } - else if (!(strcmp(operation, "purge"))) - { - // Purging old entries - uriAStr.AppendInt(info1); - uriAStr.AppendLiteral(" purged from Session History"); - } - - WebBrowserChromeUI::UpdateStatusBarText(this, uriAStr.get()); - - return NS_OK; -} - //***************************************************************************** // WebBrowserChrome::nsIEmbeddingSiteWindow //***************************************************************************** -NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) +NS_IMETHODIMP WebBrowserChrome::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY) { - return NS_ERROR_NOT_IMPLEMENTED; + nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); + + if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) + { + MoveWindow((HWND)mNativeWindow, aX, aY, aCX, aCY, PR_TRUE); + return NS_OK; + } + else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) + { + RECT rect; + GetWindowRect((HWND)mNativeWindow, &rect); + MoveWindow((HWND)mNativeWindow, aX, aY, rect.right-rect.left, rect.bottom-rect.top, TRUE); + return NS_OK; + } + else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | + nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) { + RECT rect; + GetWindowRect((HWND)mNativeWindow, &rect); + MoveWindow((HWND)mNativeWindow, rect.left, rect.top, aCX, aCY, TRUE); + return NS_OK; + } + return NS_ERROR_INVALID_ARG; } -NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) +NS_IMETHODIMP WebBrowserChrome::GetDimensions(PRUint32 aFlags, PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY) { - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) - { - *x = 0; - *y = 0; - } - if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER || - aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER) - { - *cx = 0; - *cy = 0; - } - return NS_ERROR_NOT_IMPLEMENTED; + nsCOMPtr browserBaseWindow = do_QueryInterface(mWebBrowser); + + if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION && + (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | + nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) { + return browserBaseWindow->GetPositionAndSize(aX, aY, aCX, aCY); + } + else if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION) { + return browserBaseWindow->GetPosition(aX, aY); + } + else if (aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER | + nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) { + return browserBaseWindow->GetSize(aCX, aCY); + } + return NS_ERROR_INVALID_ARG; } /* void setFocus (); */ NS_IMETHODIMP WebBrowserChrome::SetFocus() { - WebBrowserChromeUI::SetFocus(this); + ::SetFocus((HWND)mNativeWindow); return NS_OK; } @@ -533,124 +307,3 @@ NS_IMETHODIMP WebBrowserChrome::GetSiteWindow(void * *aSiteWindow) *aSiteWindow = mNativeWindow; return NS_OK; } - - -//***************************************************************************** -// WebBrowserChrome::nsIObserver -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) -{ - nsresult rv = NS_OK; - if (strcmp(aTopic, "profile-change-teardown") == 0) - { - // A profile change means death for this window - WebBrowserChromeUI::Destroy(this); - } - return rv; -} - -//***************************************************************************** -// WebBrowserChrome::nsIContextMenuListener -//***************************************************************************** - -/* void OnShowContextMenu (in unsigned long aContextFlags, in nsIDOMEvent aEvent, in nsIDOMNode aNode); */ -NS_IMETHODIMP WebBrowserChrome::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode) -{ - WebBrowserChromeUI::ShowContextMenu(this, aContextFlags, aEvent, aNode); - return NS_OK; -} - -//***************************************************************************** -// WebBrowserChrome::nsITooltipListener -//***************************************************************************** - -/* void OnShowTooltip (in long aXCoords, in long aYCoords, in wstring aTipText); */ -NS_IMETHODIMP WebBrowserChrome::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) -{ - WebBrowserChromeUI::ShowTooltip(this, aXCoords, aYCoords, aTipText); - return NS_OK; -} - -/* void OnHideTooltip (); */ -NS_IMETHODIMP WebBrowserChrome::OnHideTooltip() -{ - WebBrowserChromeUI::HideTooltip(this); - return NS_OK; -} - -//***************************************************************************** -// WebBrowserChrome::nsIDOMEventListener -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::HandleEvent(nsIDOMEvent* aEvent) -{ - return NS_OK; -} - -//***************************************************************************** -// WebBrowserChrome::nsIDOMMouseEvent -//***************************************************************************** - -NS_IMETHODIMP WebBrowserChrome::MouseDown(nsIDOMEvent* aDOMEvent) -{ - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::MouseUp(nsIDOMEvent* aDOMEvent) -{ - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::MouseClick(nsIDOMEvent* aDOMEvent) -{ - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::MouseDblClick(nsIDOMEvent* aDOMEvent) -{ - nsCOMPtr mouseEvent = do_QueryInterface(aDOMEvent); - if (!mouseEvent) - return NS_OK; - - // We want to hide events that are in anonymous content such as a scrollbar. - - nsCOMPtr nsEvent(do_QueryInterface(aDOMEvent)); - if (!nsEvent) - return NS_OK; - - nsCOMPtr targetNode; - aDOMEvent->GetTarget(getter_AddRefs(targetNode)); - - nsCOMPtr originalTargetNode; - nsEvent->GetOriginalTarget(getter_AddRefs(originalTargetNode)); - - if (originalTargetNode != targetNode) - return NS_OK; - - PRInt32 screenX, screenY; - mouseEvent->GetScreenX(&screenX); - mouseEvent->GetScreenY(&screenY); - - boolean handled = WebBrowserChromeUI::DoubleClick(this, screenX, screenY); - - if (handled) - { - aDOMEvent->StopPropagation(); - aDOMEvent->PreventDefault(); - } - - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::MouseOver(nsIDOMEvent* aDOMEvent) -{ - return NS_OK; -} - -NS_IMETHODIMP WebBrowserChrome::MouseOut(nsIDOMEvent* aDOMEvent) -{ - return NS_OK; -} - - diff --git a/embedding/minimo/wince/WebBrowserChrome.h b/embedding/minimo/wince/WebBrowserChrome.h index 52a08c50d417..b8a33e440a72 100755 --- a/embedding/minimo/wince/WebBrowserChrome.h +++ b/embedding/minimo/wince/WebBrowserChrome.h @@ -38,7 +38,6 @@ #include "nsIBaseWindow.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIWebNavigation.h" -#include "nsIWebProgressListener.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIWebBrowser.h" @@ -47,8 +46,6 @@ #include "nsISHistoryListener.h" #include "nsIContextMenuListener.h" #include "nsITooltipListener.h" -#include "nsIDOMMouseListener.h" -#include "nsIDOMMouseEvent.h" class WebBrowserChromeUI { @@ -56,35 +53,13 @@ public: static nativeWindow CreateNativeWindow(nsIWebBrowserChrome* chrome); static void Destroy(nsIWebBrowserChrome* chrome); static void Destroyed(nsIWebBrowserChrome* chrome); - static void SetFocus(nsIWebBrowserChrome *chrome); - static void UpdateStatusBarText(nsIWebBrowserChrome *aChrome, const PRUnichar* aStatusText); - static void UpdateCurrentURI(nsIWebBrowserChrome *aChrome); - static void UpdateBusyState(nsIWebBrowserChrome *aChrome, PRBool aBusy); - static void UpdateProgress(nsIWebBrowserChrome *aChrome, PRInt32 aCurrent, PRInt32 aMax); - static void GetResourceStringById(PRInt32 aID, char ** aReturn); - static void ShowContextMenu(nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode); - static void ShowTooltip(nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText); - static void HideTooltip(nsIWebBrowserChrome *aChrome); - static void ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow); - static void SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight); - - static boolean DoubleClick(nsIWebBrowserChrome *aChrome, PRInt32 x, PRInt32 y); - - }; class WebBrowserChrome : public nsIWebBrowserChrome, public nsIWebBrowserChromeFocus, - public nsIWebProgressListener, public nsIEmbeddingSiteWindow, public nsIInterfaceRequestor, - public nsISHistoryListener, - public nsIObserver, - public nsIContextMenuListener, - public nsITooltipListener, - public nsSupportsWeakReference, - public nsIDOMMouseListener - + public nsSupportsWeakReference { public: WebBrowserChrome(); @@ -93,42 +68,18 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIWEBBROWSERCHROME NS_DECL_NSIWEBBROWSERCHROMEFOCUS - NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIEMBEDDINGSITEWINDOW NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSISHISTORYLISTENER - NS_DECL_NSIOBSERVER - NS_DECL_NSICONTEXTMENULISTENER - NS_DECL_NSITOOLTIPLISTENER - // nsIDOMEventListener - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); - - // nsIDOMMouseListener - NS_IMETHOD MouseDown(nsIDOMEvent* aDOMEvent); - NS_IMETHOD MouseUp(nsIDOMEvent* aDOMEvent); - NS_IMETHOD MouseClick(nsIDOMEvent* aDOMEvent); - NS_IMETHOD MouseDblClick(nsIDOMEvent* aDOMEvent); - NS_IMETHOD MouseOver(nsIDOMEvent* aDOMEvent); - NS_IMETHOD MouseOut(nsIDOMEvent* aDOMEvent); - - - nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, - nsIWebBrowser **aBrowser); - - void SetParent(nsIWebBrowserChrome *aParent) - { mDependentParent = aParent; } + nsresult CreateBrowser(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, nsIWebBrowser **aBrowser); protected: - nsresult SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRInt32 info1=0, PRUint32 info2=0); nativeWindow mNativeWindow; PRUint32 mChromeFlags; PRBool mContinueModalLoop; - PRBool mSizeSet; nsCOMPtr mWebBrowser; - nsCOMPtr mDependentParent; // opener (for dependent windows only) }; #endif /* __WebBrowserChrome__ */ diff --git a/embedding/minimo/wince/WindowCreator.cpp b/embedding/minimo/wince/WindowCreator.cpp index 2bb3517331fb..2cb2d39adc5d 100755 --- a/embedding/minimo/wince/WindowCreator.cpp +++ b/embedding/minimo/wince/WindowCreator.cpp @@ -30,7 +30,7 @@ #include "nsIWebBrowserChrome.h" #include "WindowCreator.h" -#include "winEmbed.h" +#include "MinimoPrivate.h" WindowCreator::WindowCreator() { @@ -42,12 +42,70 @@ WindowCreator::~WindowCreator() NS_IMPL_ISUPPORTS1(WindowCreator, nsIWindowCreator) -NS_IMETHODIMP -WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *parent, - PRUint32 chromeFlags, - nsIWebBrowserChrome **_retval) +nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome) { - NS_ENSURE_ARG_POINTER(_retval); - AppCallbacks::CreateBrowserWindow(PRInt32(chromeFlags), parent, _retval); - return *_retval ? NS_OK : NS_ERROR_FAILURE; + if (!chrome) + return NS_ERROR_FAILURE; + + nsCOMPtr embeddingSite = do_QueryInterface(chrome); + HWND hWnd; + embeddingSite->GetSiteWindow((void **) & hWnd); + + if (!hWnd) + return NS_ERROR_NULL_POINTER; + + RECT rect; + GetClientRect(hWnd, &rect); + + // Make sure the browser is visible and sized + nsCOMPtr webBrowser; + chrome->GetWebBrowser(getter_AddRefs(webBrowser)); + nsCOMPtr webBrowserAsWin = do_QueryInterface(webBrowser); + if (webBrowserAsWin) + { + webBrowserAsWin->SetPositionAndSize(rect.left, + rect.top, + rect.right - rect.left, + rect.bottom - rect.top, + PR_TRUE); + webBrowserAsWin->SetVisibility(PR_TRUE); + } + + return NS_OK; +} + +NS_IMETHODIMP +WindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent, + PRUint32 aChromeFlags, + nsIWebBrowserChrome **aNewWindow) +{ + NS_ENSURE_ARG_POINTER(aNewWindow); + + WebBrowserChrome * chrome = new WebBrowserChrome(); + if (!chrome) + return NS_ERROR_FAILURE; + + // now an extra addref; the window owns itself (to be released by + // WebBrowserChromeUI::Destroy) + NS_ADDREF(chrome); + + chrome->SetChromeFlags(aChromeFlags); + + // Insert the browser + nsCOMPtr newBrowser; + chrome->CreateBrowser(-1, -1, -1, -1, getter_AddRefs(newBrowser)); + + if (!newBrowser) + { + NS_RELEASE(chrome); + return NS_ERROR_FAILURE; + } + + // and an addref on the way out. + NS_ADDREF(chrome); + *aNewWindow = NS_STATIC_CAST(nsIWebBrowserChrome*, chrome); + + ResizeEmbedding(chrome); + + return NS_OK; } diff --git a/embedding/minimo/wince/all.js b/embedding/minimo/wince/all.js index 00e183fcd320..eb8f5a8a5b2c 100755 --- a/embedding/minimo/wince/all.js +++ b/embedding/minimo/wince/all.js @@ -182,3 +182,5 @@ pref("ui.key.menuAccessKey", 18); pref("ui.key.menuAccessKeyFocuses", false); pref("ui.key.saveLink.shift", true); pref("viewmanager.do_doublebuffering", true); + +pref("browser.xul.error_pages.enabled", true); diff --git a/embedding/minimo/wince/minimo-link-comps b/embedding/minimo/wince/minimo-link-comps index 6ecaef110047..9723f24b54b0 100755 --- a/embedding/minimo/wince/minimo-link-comps +++ b/embedding/minimo/wince/minimo-link-comps @@ -3,6 +3,7 @@ mozuconv i18n necko jar50 +rdf pref caps gkparser @@ -13,12 +14,16 @@ gklayout docshell embedcmp webbrwsr -editor +texteditor txmgr appshell -chrmlite +chrome mork xmlextra t8iix websrvcs popuplite +snav +tkitcmps +gkplugin +softkey diff --git a/embedding/minimo/wince/minimo-link-names b/embedding/minimo/wince/minimo-link-names index 66da77b2f33e..c6f55f7c752e 100755 --- a/embedding/minimo/wince/minimo-link-names +++ b/embedding/minimo/wince/minimo-link-names @@ -3,6 +3,7 @@ nsUConvModule nsI18nModule necko_core_and_primary_protocols nsJarModule +nsRDFModule nsPrefModule nsSecurityManagerModule nsParserModule @@ -16,9 +17,13 @@ Browser_Embedding_Module nsEditorModule nsTransactionManagerModule appshell -chromelite +nsChromeModule nsMorkModule nsXMLExtrasModule TransformiixModule nsWebServicesModule popuplite +SpatialNavigationModule +nsToolkitCompsModule +nsPluginModule +SoftKeyBoardModule diff --git a/embedding/minimo/wince/mozconfig/ppc2003arm b/embedding/minimo/wince/mozconfig/ppc2003arm index 0a78210afdc7..5fa232c522b5 100755 --- a/embedding/minimo/wince/mozconfig/ppc2003arm +++ b/embedding/minimo/wince/mozconfig/ppc2003arm @@ -8,10 +8,10 @@ CROSS_COMPILE=1 CXX=arm-wince-gcc LD=arm-wince-link AR=arm-wince-lib -mk_add_options AR=arm-wince-lib - AS=arm-wince-as +mk_add_options AR=arm-wince-lib + ac_add_options --target=arm-wince ac_add_options --enable-win32-target=WINCE ac_add_options --enable-default-toolkit=windows @@ -23,7 +23,7 @@ ac_add_options --disable-md ac_add_options --disable-activex ac_add_options --disable-activex-scripting ac_add_options --disable-oji -ac_add_options --disable-plugins +#ac_add_options --disable-plugins WINCE=1 mk_add_options WINCE=1 @@ -34,16 +34,13 @@ mk_add_options TARGET_DEVICE=device MINIMO=1 mk_add_options MINIMO=1 -# disable XUL support to reduce codesize -ac_add_options --disable-xul - # enable minimal profile support ac_add_options --disable-profilesharing ac_add_options --disable-profilelocking ac_add_options --enable-single-profile # disable features and skip various build steps -ac_add_options --enable-extensions="xml-rpc xmlextras transformiix webservices" +ac_add_options --enable-extensions="xml-rpc xmlextras transformiix webservices spatialnavigation" ac_add_options --disable-accessibility ac_add_options --disable-composer ac_add_options --enable-plaintext-editor-only @@ -66,7 +63,7 @@ ac_add_options --disable-logging ac_add_options --disable-tests # build minimal set of protocol handlers -ac_add_options --enable-necko-protocols=http,file,res,jar +ac_add_options --enable-necko-protocols=about,data,http,file,res,jar # build minimal set of image decoders ac_add_options --enable-image-decoders=png,gif,jpeg @@ -82,4 +79,5 @@ ac_add_options --disable-debug ac_add_options --disable-shared ac_add_options --enable-static +#for now. ac_add_options --disable-crypto diff --git a/embedding/minimo/wince/mozconfig/ppc2003emu b/embedding/minimo/wince/mozconfig/ppc2003emu index ce26059ecbb3..a5ecb60e9c70 100755 --- a/embedding/minimo/wince/mozconfig/ppc2003emu +++ b/embedding/minimo/wince/mozconfig/ppc2003emu @@ -34,16 +34,13 @@ mk_add_options TARGET_DEVICE=emulator MINIMO=1 mk_add_options MINIMO=1 -# disable XUL support to reduce codesize -ac_add_options --disable-xul - # enable minimal profile support ac_add_options --disable-profilesharing ac_add_options --disable-profilelocking ac_add_options --enable-single-profile # disable features and skip various build steps -ac_add_options --enable-extensions="xml-rpc xmlextras transformiix webservices" +ac_add_options --enable-extensions="xml-rpc xmlextras transformiix webservices spatialnavigation" ac_add_options --disable-accessibility ac_add_options --disable-composer ac_add_options --enable-plaintext-editor-only @@ -66,7 +63,7 @@ ac_add_options --disable-logging ac_add_options --disable-tests # build minimal set of protocol handlers -ac_add_options --enable-necko-protocols=http,file,res,jar +ac_add_options --enable-necko-protocols=about,data,http,file,res,jar # build minimal set of image decoders ac_add_options --enable-image-decoders=png,gif,jpeg @@ -82,7 +79,6 @@ ac_add_options --disable-debug ac_add_options --disable-shared ac_add_options --enable-static -ac_add_options --disable-crypto +#ac_add_options --disable-crypto -# XPCALL Code is busted on the emulator? ac_add_options --disable-jsloader diff --git a/embedding/minimo/wince/winEmbed.cpp b/embedding/minimo/wince/winEmbed.cpp index e568197f64ba..edc8e5c9b25b 100755 --- a/embedding/minimo/wince/winEmbed.cpp +++ b/embedding/minimo/wince/winEmbed.cpp @@ -30,8 +30,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include // for IID_DestNetInternet - #include "MinimoPrivate.h" #ifdef _BUILD_STATIC_BIN @@ -40,188 +38,64 @@ nsresult PR_CALLBACK app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count); #endif -#define STATUS_DIALOG_H 50 -#define HEADSUP_DIALOG_H 300 - -#define MENU_HEIGHT 26 - -// Foward declarations of functions included in this code module: -static BOOL CALLBACK BrowserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK StatusDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -static BOOL CALLBACK HeadsUpDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - -static nsresult OverrideMozillaComponents(); -static nsresult InitializeWindowCreator(); -static nsresult OpenWebPage(const char * url); -static nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome); - // Profile chooser stuff static nsresult StartupProfile(); // Global variables static PRBool gRunCondition = PR_TRUE; -static UINT gDialogCount = 0; -static HINSTANCE ghInstanceApp = NULL; -static BOOL gActive = TRUE; -static BOOL gBusy = TRUE; -static HANDLE gConnectionHandle = NULL; - -// minimo/wince/ list of URLs to populate the URL drop down list with -static const TCHAR *gDefaultURLs[] = -{ - _T("http://browsertest.web.aol.com/tests/javascript/javascpt/index.htm"), - _T("http://mecha.mozilla.org/buster/test_url_25.html"), - _T("http://www.cnn.com/"), - _T("http://www.disney.com/"), - _T("http://www.ebay.com/"), - _T("http://www.go.com/"), - _T("http://www.google.com/"), - _T("http://www.hotmail.com/"), - _T("http://www.javasoft.com/") - _T("http://www.mozilla.org/"), - _T("http://www.mozilla.org/quality/browser/standards/html/"), - _T("http://www.netscape.com/"), - _T("http://www.quicken.com/"), - _T("http://www.shockwave.com/"), - _T("http://www.slashdot.org/"), - _T("http://www.travelocity.com/"), - _T("http://www.yahoo.com/"), -}; - - -typedef struct MinimoWindowContext -{ - HWND mMainWindow; - HWND mStatusWindow; - HWND mHeadsUpWindow; - -} MinimoWindowContext; - - -PRBool LowOnMemory() -{ - MEMORYSTATUS memStats; - memStats.dwLength = sizeof( memStats); - - GlobalMemoryStatus( (LPMEMORYSTATUS)&memStats ); - - if (memStats.dwAvailPhys <= (262144) /*1024*256*/) - return PR_TRUE; - return PR_FALSE; -} - -void AdjustSIP(BOOL bRaise) -{ - HWND hnd; - - if( hnd = FindWindow(_T("SipWndClass"),NULL) ) - { - if( bRaise ) { - ShowWindow(hnd, SW_SHOW); - } else { - ShowWindow(hnd, SW_HIDE); - } - } -} - -HWND GetBrowserFromChrome(nsIWebBrowserChrome *aChrome) -{ - if (!aChrome) - { - return NULL; - } - nsCOMPtr baseWindow = do_QueryInterface(aChrome); - HWND hwnd = NULL; - baseWindow->GetSiteWindow((void **) & hwnd); - return hwnd; -} - -HWND GetBrowserDlgFromChrome(nsIWebBrowserChrome *aChrome) -{ - return GetParent(GetBrowserFromChrome(aChrome)); -} - -void DoPPCConnection(nsIWebBrowserChrome* aChrome) -{ - if (gConnectionHandle) { - ConnMgrReleaseConnection(gConnectionHandle,0); - gConnectionHandle = nsnull; - } - - GUID gNetworkID; - (void) ConnMgrMapURL("http://www.mozilla.org", &gNetworkID, 0); - - DWORD status; - CONNMGR_CONNECTIONINFO conn_info; - memset(&conn_info, 0, sizeof(CONNMGR_CONNECTIONINFO)); - - conn_info.cbSize = sizeof(CONNMGR_CONNECTIONINFO); - conn_info.dwParams = CONNMGR_PARAM_GUIDDESTNET; - conn_info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE; - conn_info.bExclusive = FALSE; - conn_info.bDisabled = FALSE; - - conn_info.guidDestNet= gNetworkID; - - WebBrowserChromeUI::UpdateStatusBarText(aChrome, L"Attempting data communication"); - - printf("Trying GUID from ConnMgrMapURL\n"); - - if(ConnMgrEstablishConnectionSync(&conn_info, &gConnectionHandle, 1000, &status) != S_OK && - gNetworkID != IID_DestNetInternet) - { - conn_info.guidDestNet = IID_DestNetInternet; - - printf("Trying GUID IID_DestNetInternet\n"); - - if(ConnMgrEstablishConnectionSync(&conn_info, &gConnectionHandle, 5000, &status) != S_OK) - { - WebBrowserChromeUI::UpdateStatusBarText(aChrome, L"Could not connect to network"); - return; - } - } - - if (status != CONNMGR_STATUS_CONNECTED) - WebBrowserChromeUI::UpdateStatusBarText(aChrome, L"Could not connect to network. Status isn't connected"); -} - -PRBool SetupAndVerifyPPCConnection(nsIWebBrowserChrome* aChrome) -{ - DWORD status; - if (!gConnectionHandle) - DoPPCConnection(aChrome); - - if (gConnectionHandle) - { - ConnMgrConnectionStatus(gConnectionHandle, &status); - if (status != CONNMGR_STATUS_CONNECTED) - { - DoPPCConnection(aChrome); - } - } - - if (status != CONNMGR_STATUS_CONNECTED) - return PR_FALSE; - - return PR_TRUE; -} - +static UINT gBrowserCount = 0; LRESULT CALLBACK MainWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { + nsIWebBrowserChrome *chrome = (nsIWebBrowserChrome *) GetWindowLong(hWnd, GWL_USERDATA); + nsCOMPtr webBrowser; + if (chrome) + chrome->GetWebBrowser(getter_AddRefs(webBrowser)); + switch (Msg) { + case WM_SYSCOMMAND: + if (wParam == SC_CLOSE) + { + WebBrowserChromeUI::Destroy(chrome); + return TRUE; + } + break; + case WM_ACTIVATE: + { + nsCOMPtr focus(do_GetInterface(webBrowser)); + if (!focus) + return 0; + + switch (wParam) + { + case WA_ACTIVE: + focus->Activate(); + break; + + case WA_INACTIVE: + focus->Deactivate(); + } + } + return 0; + + case WM_CLOSE: + WebBrowserChromeUI::Destroy(chrome); return 0; case WM_DESTROY: - PostQuitMessage(0); - break; + if (gBrowserCount == 0) + gRunCondition = PR_FALSE; + return 0; + default: return DefWindowProc(hWnd, Msg, wParam, lParam); } - return 0; + + + return -1; // default handles all! } @@ -233,8 +107,8 @@ void RegisterMainWindowClass() wc.lpfnWndProc = (WNDPROC) MainWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = ghInstanceApp; - wc.hIcon = NULL; //LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BASICDIALOG)); + wc.hInstance = GetModuleHandle(NULL); + wc.hIcon = NULL; wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH); wc.lpszMenuName = 0; @@ -278,8 +152,6 @@ int main(int argc, char *argv[]) return FALSE; } - ghInstanceApp = GetModuleHandle(NULL); - #ifdef _BUILD_STATIC_BIN // Initialize XPCOM's module info table NSGetStaticModuleInfo = app_getModuleInfo; @@ -295,457 +167,34 @@ int main(int argc, char *argv[]) return 1; } - InitializeWindowCreator(); - - OverrideMozillaComponents(); RegisterMainWindowClass(); + + WindowCreator *creatorCallback = new WindowCreator(); + if (!creatorCallback) + return 1; + + { + const static char* start_url = "chrome://embed/content/mini-nav.xul"; + //const static char* start_url = "http://www.meer.net/~dougt/test.html"; + //const static char* start_url = "resource://gre/res/start.html"; + + + nsCOMPtr newWindow; + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); + + wwatch->SetWindowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)); + wwatch->OpenWindow(nsnull, start_url, "_blank", "chrome,dialog=no,all", nsnull, getter_AddRefs(newWindow)); + } - WSADATA wsaData; - WSAStartup( MAKEWORD( 1, 1 ), &wsaData ); - - // Open the initial browser window - OpenWebPage("resource://gre/res/start.html"); - - WPARAM rv = AppCallbacks::RunEventLoop(gRunCondition); + RunEventLoop(gRunCondition); // Close down Embedding APIs NS_TermEmbedding(); - - - if (gConnectionHandle) - ConnMgrReleaseConnection(gConnectionHandle,0); - - WSACleanup(); - - return rv; -} - -nsresult OverrideMozillaComponents() -{ - // Register our own native prompting service for message boxes, login - // prompts etc. - nsCOMPtr promptFactory; - nsresult rv = NS_NewPromptServiceFactory(getter_AddRefs(promptFactory)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr registrar; - rv = NS_GetComponentRegistrar(getter_AddRefs(registrar)); - if (NS_FAILED(rv)) return rv; - - static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID); - - rv = registrar->RegisterFactory(kPromptServiceCID, - "Prompt Service", - NS_PROMPTSERVICE_CONTRACTID, - promptFactory); - return rv; -} - -/* InitializeWindowCreator creates and hands off an object with a callback - to a window creation function. This is how all new windows are opened, - except any created directly by the embedding app. */ -nsresult InitializeWindowCreator() -{ - // create an nsWindowCreator and give it to the WindowWatcher service - WindowCreator *creatorCallback = new WindowCreator(); - if (creatorCallback) - { - nsCOMPtr windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)); - if (windowCreator) - { - nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); - if (wwatch) - { - wwatch->SetWindowCreator(windowCreator); - return NS_OK; - } - } - } - return NS_ERROR_FAILURE; -} - -void LoadURL(nsIWebBrowserChrome* aChrome, nsIWebNavigation* webNavigation, char* url) -{ - WebBrowserChromeUI::UpdateBusyState(aChrome, PR_TRUE); - - SetupAndVerifyPPCConnection(aChrome); - - webNavigation->LoadURI(NS_ConvertASCIItoUCS2(url).get(), - nsIWebNavigation::LOAD_FLAGS_NONE, - nsnull, - nsnull, - nsnull); -} - -nsresult OpenWebPage(const char *url) -{ - nsresult rv; - - // Create the chrome object. Note that it leaves this function - // with an extra reference so that it can released correctly during - // destruction (via Win32UI::Destroy) - - nsCOMPtr chrome; - rv = AppCallbacks::CreateBrowserWindow(nsIWebBrowserChrome::CHROME_ALL, - nsnull, getter_AddRefs(chrome)); - if (NS_SUCCEEDED(rv)) - { - // Start loading a page - nsCOMPtr newBrowser; - chrome->GetWebBrowser(getter_AddRefs(newBrowser)); - nsCOMPtr webNav(do_QueryInterface(newBrowser)); - - LoadURL(chrome, webNav, (char*)url); - return NS_OK; - } - - return rv; -} - -nsresult ResizeEmbedding(nsIWebBrowserChrome* chrome) -{ - if (!chrome) - return NS_ERROR_FAILURE; - - nsCOMPtr embeddingSite = do_QueryInterface(chrome); - HWND hWnd; - embeddingSite->GetSiteWindow((void **) & hWnd); - - if (!hWnd) - return NS_ERROR_NULL_POINTER; - - RECT rect; - GetClientRect(hWnd, &rect); - - // Make sure the browser is visible and sized - nsCOMPtr webBrowser; - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - nsCOMPtr webBrowserAsWin = do_QueryInterface(webBrowser); - if (webBrowserAsWin) - { - webBrowserAsWin->SetPositionAndSize(rect.left, - rect.top, - rect.right - rect.left, - rect.bottom - rect.top, - PR_TRUE); - webBrowserAsWin->SetVisibility(PR_TRUE); - } - return NS_OK; } -void UpdateUI(nsIWebBrowserChrome *aChrome) -{ - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - aChrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - - PRBool canGoBack = PR_FALSE; - PRBool canGoForward = PR_FALSE; - if (webNavigation) - { - webNavigation->GetCanGoBack(&canGoBack); - webNavigation->GetCanGoForward(&canGoForward); - } - - PRBool canCutSelection = PR_FALSE; - PRBool canCopySelection = PR_FALSE; - PRBool canPaste = PR_FALSE; - - nsCOMPtr clipCmds = do_GetInterface(webBrowser); - if (clipCmds) - { - clipCmds->CanCutSelection(&canCutSelection); - clipCmds->CanCopySelection(&canCopySelection); - clipCmds->CanPaste(&canPaste); - } - - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return; - - HWND button; - - button = GetDlgItem(mwcontext->mStatusWindow, IDC_BACK); - if (button) - EnableWindow(button, canGoBack); - - button = GetDlgItem(mwcontext->mStatusWindow, IDC_FORWARD); - if (button) - EnableWindow(button, canGoForward); -} - -void LoadURLInURLBar(HWND hwndDlg, nsIWebBrowserChrome* chrome, nsIWebNavigation* webNavigation) -{ - TCHAR szURL[2048]; - memset(szURL, 0, sizeof(szURL)); - GetDlgItemText(hwndDlg, IDC_ADDRESS, szURL, sizeof(szURL) / sizeof(szURL[0]) - 1); - - LoadURL(chrome, webNavigation, szURL); -} - -BOOL CALLBACK HeadsUpDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return FALSE; - - HWND hwndBrowser = GetDlgItem(mwcontext->mMainWindow, IDC_BROWSER); - - nsIWebBrowserChrome *chrome = nsnull ; - if (hwndBrowser) - { - chrome = (nsIWebBrowserChrome *) GetWindowLong(hwndBrowser, GWL_USERDATA); - } - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - if (chrome) - { - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - } - - switch (uMsg) - { - case WM_COMMAND: - { - if (!webBrowser) - { - return TRUE; - } - - // Test which command was selected - switch (LOWORD(wParam)) - { - case IDC_ADDRESS: - if (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE) - { - // User has changed the address field so enable the Go button - EnableWindow(GetDlgItem(hwndDlg, IDC_GO), TRUE); - } - else if (HIWORD(wParam) == CBN_SELENDOK) - { - HWND hwndAddress = GetDlgItem(hwndDlg, IDC_ADDRESS); - - // Find the current selected item and get the item's length. - int t = SendMessage(hwndAddress, CB_GETCURSEL, 0, 0); - int l = SendMessage(hwndAddress, CB_GETLBTEXTLEN, t, 0); - - // Get the text - char* buffer = new char[l + 1]; - SendMessage(hwndAddress, CB_GETLBTEXT, t, (long) buffer); - - // Set the text area so that we can see it - SetDlgItemText(hwndDlg, IDC_ADDRESS, buffer); - - delete buffer; - } - break; - - case IDC_GO: - LoadURLInURLBar(hwndDlg, chrome, webNavigation); - ::ShowWindow(hwndDlg, SW_HIDE); - break; - - case IDC_STOP: - webNavigation->Stop(nsIWebNavigation::STOP_ALL); - UpdateUI(chrome); - break; - - case IDC_RELOAD: - webNavigation->Reload(nsIWebNavigation::LOAD_FLAGS_NONE); - break; - - case IDC_Hide: - { - RECT rect; - ::ShowWindow(mwcontext->mHeadsUpWindow, SW_HIDE); - ::GetWindowRect(mwcontext->mHeadsUpWindow, &rect); - ::InvalidateRect(mwcontext->mMainWindow, &rect, TRUE); - ::SetForegroundWindow(mwcontext->mMainWindow); - break; - } - - case IDM_EXIT: - PostMessage(hwndDlg, WM_SYSCOMMAND, SC_CLOSE, 0); - break; - - // Go menu commands - case IDC_BACK: - case MOZ_GoBack: - webNavigation->GoBack(); - UpdateUI(chrome); - break; - - case IDC_FORWARD: - case MOZ_GoForward: - webNavigation->GoForward(); - UpdateUI(chrome); - break; - - } - } - } - return FALSE; -} - - -static HBRUSH yellowBrush = NULL; - -BOOL CALLBACK StatusDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return FALSE; - - HWND hwndBrowser = GetDlgItem(mwcontext->mMainWindow, IDC_BROWSER); - - nsIWebBrowserChrome *chrome = nsnull ; - if (hwndBrowser) - { - chrome = (nsIWebBrowserChrome *) GetWindowLong(hwndBrowser, GWL_USERDATA); - } - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - if (chrome) - { - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - } - - switch (uMsg) { - - case WM_INITDIALOG: - { - yellowBrush = CreateSolidBrush(RGB(255,255,204)); - } - return TRUE; - - case WM_CTLCOLORDLG: - return (BOOL) yellowBrush; - - case WM_DESTROY: - DeleteObject(yellowBrush); - break; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_STOP: - webNavigation->Stop(nsIWebNavigation::STOP_ALL); - UpdateUI(chrome); - } - } - } - return FALSE; -} - -BOOL CALLBACK BrowserDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - // Get the browser and other pointers since they are used a lot below - HWND hwndBrowser = GetDlgItem(hwndDlg, IDC_BROWSER); - nsIWebBrowserChrome *chrome = nsnull ; - if (hwndBrowser) - { - chrome = (nsIWebBrowserChrome *) GetWindowLong(hwndBrowser, GWL_USERDATA); - } - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - if (chrome) - { - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - } - - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return FALSE; - - // Test the message - switch (uMsg) - { - case WM_SYSCOMMAND: - if (wParam == SC_CLOSE) - { - WebBrowserChromeUI::Destroy(chrome); - return TRUE; - } - break; - - case WM_HIBERNATE: /* not sure about this */ - // fall through. - case WM_CLOSE: - { - gActive = FALSE; - gRunCondition = FALSE; - - DestroyWindow(mwcontext->mStatusWindow); - DestroyWindow(mwcontext->mHeadsUpWindow); - DestroyWindow(mwcontext->mMainWindow); - free((void*) mwcontext); - } - return 0; - - case WM_DESTROY: - PostQuitMessage(0); - return 0; - - - case WM_ACTIVATE: - { - nsCOMPtr focus(do_GetInterface(webBrowser)); - if (!focus) - return 0; - - switch (wParam) - { - case WA_ACTIVE: - gActive = TRUE; - if (focus) - focus->Activate(); - break; - - case WA_INACTIVE: - if (focus) - focus->Deactivate(); - default: - break; - } - } - return 0; - - case WM_SIZE: - { - if (!mwcontext || !chrome) - return 0; - - int screenH = GetSystemMetrics(SM_CYSCREEN); - int screenW = GetSystemMetrics(SM_CXSCREEN) ; - - MoveWindow(mwcontext->mMainWindow, 0, MENU_HEIGHT, screenW, screenH - MENU_HEIGHT, TRUE); - - RECT rt; - GetClientRect(mwcontext->mMainWindow, &rt); - - MoveWindow(mwcontext->mHeadsUpWindow, rt.left, rt.top, rt.right, HEADSUP_DIALOG_H, TRUE); - MoveWindow(mwcontext->mStatusWindow, rt.left, rt.top, rt.right, STATUS_DIALOG_H, TRUE); - - HWND hwndBrowser = GetDlgItem(mwcontext->mMainWindow, IDC_BROWSER); - if (hwndBrowser) - MoveWindow(hwndBrowser, rt.left, rt.top, rt.right, rt.bottom, TRUE); - - ResizeEmbedding(chrome); - return 0; - } - } - return FALSE; -} - nsresult StartupProfile() { nsCOMPtr appDataDir; @@ -753,7 +202,10 @@ nsresult StartupProfile() if (NS_FAILED(rv)) return rv; - appDataDir->Append(NS_LITERAL_STRING("winembed")); + rv = appDataDir->Append(NS_LITERAL_STRING("minimo")); + if (NS_FAILED(rv)) + return rv; + nsCOMPtr localAppDataDir(do_QueryInterface(appDataDir)); nsCOMPtr locProvider; @@ -768,34 +220,9 @@ nsresult StartupProfile() return locProvider->SetProfileDir(localAppDataDir); } -void -KillCurrentLoad(nsIWebBrowserChrome* aChrome) -{ - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - - aChrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - if (webNavigation) - webNavigation->Stop(nsIWebNavigation::STOP_ALL); - - HWND win = GetBrowserDlgFromChrome(aChrome); - - WebBrowserChromeUI::UpdateStatusBarText(aChrome, L"Running Low on Memory. Cancelling page load."); - - MessageBox(win, "Running Low on Memory. Cancelling page load.", "Note", 0); - - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(win, GWL_USERDATA); - if (!mwcontext) - return; - - ::ShowWindow(mwcontext->mStatusWindow, SW_HIDE); -} - nativeWindow WebBrowserChromeUI::CreateNativeWindow(nsIWebBrowserChrome* chrome) { - HWND mainWindow = CreateWindow("Minimo Main Window", "Minimo", WS_VISIBLE, @@ -805,88 +232,21 @@ WebBrowserChromeUI::CreateNativeWindow(nsIWebBrowserChrome* chrome) CW_USEDEFAULT, NULL, NULL, - ghInstanceApp, + GetModuleHandle(NULL), NULL); - - - - // Load the browser dialog from resource - HWND hwndDialog = CreateDialog(ghInstanceApp, - MAKEINTRESOURCE(IDD_BROWSER), - mainWindow, - BrowserDlgProc); - if (!hwndDialog) - return NULL; - - HWND statusDialog = CreateDialog(ghInstanceApp, - MAKEINTRESOURCE(IDD_STATUS_DISPLAY), - mainWindow, - StatusDlgProc); - - if (!statusDialog) { - MessageBox(0, "statusDialog failed", "error", 0); - return NULL; - } - - HWND headsupDialog = CreateDialog(ghInstanceApp, - MAKEINTRESOURCE(IDD_HEADSUP_DISPLAY), - mainWindow, - HeadsUpDlgProc); - - if (!headsupDialog) - { - MessageBox(0, "headsupDialog failed", "error", 0); - return NULL; - } - - int screenH = GetSystemMetrics(SM_CYSCREEN); - int screenW = GetSystemMetrics(SM_CXSCREEN) ; - - MoveWindow(mainWindow, 0, MENU_HEIGHT, screenW, screenH - MENU_HEIGHT, TRUE); - - RECT rt; - GetClientRect(mainWindow, &rt); - - MoveWindow(hwndDialog, rt.left, rt.top, rt.right, rt.bottom, TRUE); - MoveWindow(headsupDialog, rt.left, rt.top, rt.right, HEADSUP_DIALOG_H, TRUE); - MoveWindow(statusDialog, rt.left, rt.top, rt.right, STATUS_DIALOG_H, TRUE); - - // Fetch the browser window handle - HWND hwndBrowser = GetDlgItem(hwndDialog, IDC_BROWSER); - MoveWindow(hwndBrowser, rt.left, rt.top, rt.right, rt.bottom, TRUE); - // Add some interesting URLs to the address drop down - HWND hwndAddress = GetDlgItem(headsupDialog, IDC_ADDRESS); - if (hwndAddress) { - for (int i = 0; i < sizeof(gDefaultURLs) / sizeof(gDefaultURLs[0]); i++) - { - SendMessage(hwndAddress, CB_ADDSTRING, 0, (LPARAM) gDefaultURLs[i]); - } - } - - SetWindowLong(hwndBrowser, GWL_USERDATA, (LONG)chrome); // save the browser LONG_PTR. - SetWindowLong(hwndBrowser, GWL_STYLE, GetWindowLong(hwndBrowser, GWL_STYLE) | WS_CLIPCHILDREN); - - MinimoWindowContext *mwcontext = (MinimoWindowContext*) malloc(sizeof(MinimoWindowContext)); - if (!mwcontext) - return NULL; - - mwcontext->mMainWindow = hwndDialog; - mwcontext->mStatusWindow = statusDialog; - mwcontext->mHeadsUpWindow = headsupDialog; - - SetWindowLong(hwndDialog, GWL_USERDATA, (LONG)mwcontext); - SetWindowLong(headsupDialog, GWL_USERDATA, (LONG)mwcontext); - SetWindowLong(statusDialog, GWL_USERDATA, (LONG)mwcontext); - - // Activate the window - PostMessage(hwndDialog, WM_ACTIVATE, WA_ACTIVE, 0); - - ::ShowWindow(hwndDialog, SW_SHOW); - - gDialogCount++; - - return hwndBrowser; + SetWindowLong(mainWindow, GWL_USERDATA, (LONG)chrome); // save the browser LONG_PTR. + + PostMessage(mainWindow, WM_ACTIVATE, WA_ACTIVE, 0); + + SHFullScreen(mainWindow, SHFS_HIDETASKBAR); + SHFullScreen(mainWindow, SHFS_HIDESIPBUTTON); + + ::ShowWindow(mainWindow, SW_SHOW); + + gBrowserCount++; + + return mainWindow; } void @@ -902,7 +262,9 @@ WebBrowserChromeUI::Destroy(nsIWebBrowserChrome* chrome) chrome->ExitModalEventLoop(NS_OK); - HWND hwndDlg = GetBrowserDlgFromChrome(chrome); + nsCOMPtr baseWindow = do_QueryInterface(chrome); + HWND hwndDlg = NULL; + baseWindow->GetSiteWindow((void **) & hwndDlg); if (hwndDlg == NULL) return; @@ -920,271 +282,28 @@ WebBrowserChromeUI::Destroy(nsIWebBrowserChrome* chrome) NS_RELEASE(chrome); } - -// -// FUNCTION: Called as the final act of a chrome object during its destructor -// void WebBrowserChromeUI::Destroyed(nsIWebBrowserChrome* chrome) { - HWND hwndDlg = GetBrowserDlgFromChrome(chrome); - if (hwndDlg == NULL) - { - return; - } - - // Clear the window user data - HWND hwndBrowser = GetDlgItem(hwndDlg, IDC_BROWSER); - SetWindowLong(hwndBrowser, GWL_USERDATA, nsnull); - DestroyWindow(hwndBrowser); - DestroyWindow(hwndDlg); - - --gDialogCount; - if (gDialogCount == 0) + nsCOMPtr baseWindow = do_QueryInterface(chrome); + HWND hwnd = NULL; + baseWindow->GetSiteWindow((void **) & hwnd); + if (hwnd) + DestroyWindow(hwnd); + + if (--gBrowserCount == 0) { // Quit when there are no more browser objects PostQuitMessage(0); } } -void -WebBrowserChromeUI::SetFocus(nsIWebBrowserChrome *chrome) -{ - HWND hwndDlg = GetBrowserDlgFromChrome(chrome); - if (hwndDlg == NULL) - { - return; - } - - HWND hwndBrowser = GetDlgItem(hwndDlg, IDC_BROWSER); - ::SetFocus(hwndBrowser); -} - -void -WebBrowserChromeUI::UpdateStatusBarText(nsIWebBrowserChrome *aChrome, const PRUnichar* aStatusText) -{ - if (!aChrome) - return; - - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return; - - nsCString status; - if (aStatusText) - status.AssignWithConversion(aStatusText); - - SetDlgItemText(mwcontext->mStatusWindow, IDC_STATUS, status.get()); - - if (LowOnMemory()) - KillCurrentLoad(aChrome); -} - -void -WebBrowserChromeUI::UpdateCurrentURI(nsIWebBrowserChrome *aChrome) -{ - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - aChrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - - nsCOMPtr currentURI; - webNavigation->GetCurrentURI(getter_AddRefs(currentURI)); - if (currentURI) - { - nsCAutoString uriString; - currentURI->GetAsciiSpec(uriString); - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (mwcontext) - SetDlgItemText(mwcontext->mHeadsUpWindow, IDC_ADDRESS, uriString.get()); - } -} - -void -WebBrowserChromeUI::UpdateBusyState(nsIWebBrowserChrome *aChrome, PRBool aBusy) -{ - if (LowOnMemory()) - KillCurrentLoad(aChrome); - - gBusy = aBusy; - - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return; - - if (aBusy) { - ::ShowWindow(mwcontext->mStatusWindow, SW_SHOW); - ::SetForegroundWindow(mwcontext->mStatusWindow); - } - else - { - RECT rect; - ::ShowWindow(mwcontext->mStatusWindow, SW_HIDE); - ::GetWindowRect(mwcontext->mStatusWindow, &rect); - ::InvalidateRect(mwcontext->mMainWindow, &rect, TRUE); - ::SetForegroundWindow(mwcontext->mMainWindow); - - nsMemory::HeapMinimize(PR_TRUE); - } - - - HWND button; - button = GetDlgItem(mwcontext->mHeadsUpWindow, IDC_STOP); - - if (button) - EnableWindow(button, aBusy); - - button = GetDlgItem(mwcontext->mHeadsUpWindow, IDC_GO); - - if (button) - EnableWindow(button, !aBusy); - - UpdateUI(aChrome); -} - -void -WebBrowserChromeUI::UpdateProgress(nsIWebBrowserChrome *aChrome, PRInt32 aCurrent, PRInt32 aMax) -{ - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return; - - HWND hwndProgress = GetDlgItem(mwcontext->mStatusWindow, IDC_PROGRESS); - - if (aCurrent < 0) - { - aCurrent = 0; - } - if (aCurrent > aMax) - { - aMax = aCurrent + 20; // What to do? - } - if (hwndProgress) - { - SendMessage(hwndProgress, PBM_SETRANGE, 0, MAKELPARAM(0, aMax)); - SendMessage(hwndProgress, PBM_SETPOS, aCurrent, 0); - } - - if (LowOnMemory()) - KillCurrentLoad(aChrome); -} - -void -WebBrowserChromeUI::ShowContextMenu(nsIWebBrowserChrome *aChrome, PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode) -{ -} - -void -WebBrowserChromeUI::ShowTooltip(nsIWebBrowserChrome *aChrome, PRInt32 aXCoords, PRInt32 aYCoords, const PRUnichar *aTipText) -{ -} - -void -WebBrowserChromeUI::HideTooltip(nsIWebBrowserChrome *aChrome) -{ -} - -void -WebBrowserChromeUI::ShowWindow(nsIWebBrowserChrome *aChrome, PRBool aShow) -{ - HWND win = GetBrowserDlgFromChrome(aChrome); - ::ShowWindow(win, aShow ? SW_SHOW : SW_HIDE); -} - -void WebBrowserChromeUI::SizeTo(nsIWebBrowserChrome *aChrome, PRInt32 aWidth, PRInt32 aHeight) -{ -} - -boolean -WebBrowserChromeUI::DoubleClick(nsIWebBrowserChrome *aChrome, PRInt32 x, PRInt32 y) -{ - HWND hwndDlg = GetBrowserDlgFromChrome(aChrome); - MinimoWindowContext* mwcontext = (MinimoWindowContext*) GetWindowLong(hwndDlg, GWL_USERDATA); - if (!mwcontext) - return false; - - HWND hwndBrowser = GetDlgItem(mwcontext->mMainWindow, IDC_BROWSER); - - nsIWebBrowserChrome *chrome = nsnull ; - if (hwndBrowser) - { - chrome = (nsIWebBrowserChrome *) GetWindowLong(hwndBrowser, GWL_USERDATA); - } - nsCOMPtr webBrowser; - nsCOMPtr webNavigation; - if (chrome) - { - chrome->GetWebBrowser(getter_AddRefs(webBrowser)); - webNavigation = do_QueryInterface(webBrowser); - } - - // Stop any current load. - webNavigation->Stop(nsIWebNavigation::STOP_ALL); - - - // Show our heads up display. - ::ShowWindow(mwcontext->mHeadsUpWindow, SW_SHOW); - return true; -} - - -//----------------------------------------------------------------------------- -// AppCallbacks -//----------------------------------------------------------------------------- - -nsresult AppCallbacks::CreateBrowserWindow(PRUint32 aChromeFlags, - nsIWebBrowserChrome *aParent, - nsIWebBrowserChrome **aNewWindow) -{ - WebBrowserChrome * chrome = new WebBrowserChrome(); - if (!chrome) - return NS_ERROR_FAILURE; - - // the interface to return and one addref, which we assume will be - // immediately released - CallQueryInterface(NS_STATIC_CAST(nsIWebBrowserChrome*, chrome), aNewWindow); - // now an extra addref; the window owns itself (to be released by - // WebBrowserChromeUI::Destroy) - NS_ADDREF(*aNewWindow); - - chrome->SetChromeFlags(aChromeFlags); - chrome->SetParent(aParent); - - // Insert the browser - nsCOMPtr newBrowser; - chrome->CreateBrowser(-1, -1, -1, -1, getter_AddRefs(newBrowser)); - if (!newBrowser) - return NS_ERROR_FAILURE; - - // Place it where we want it. - ResizeEmbedding(NS_STATIC_CAST(nsIWebBrowserChrome*, chrome)); - - // if opened as chrome, it'll be made visible after the chrome has loaded. - // otherwise, go ahead and show it now. - if (!(aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)) - WebBrowserChromeUI::ShowWindow(*aNewWindow, PR_TRUE); - - return NS_OK; -} - -void AppCallbacks::EnableChromeWindow(nsIWebBrowserChrome *aWindow, - PRBool aEnabled) -{ - HWND hwnd = GetBrowserDlgFromChrome(aWindow); - ::EnableWindow(hwnd, aEnabled ? TRUE : FALSE); -} - static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); -PRUint32 AppCallbacks::RunEventLoop(PRBool &aRunCondition) +PRUint32 RunEventLoop(PRBool &aRunCondition) { MSG msg; - HANDLE hFakeEvent = ::CreateEventA(NULL, TRUE, FALSE, NULL); - + PRBool eventAvail; + nsCOMPtr eventQ; nsCOMPtr eqs = do_GetService(kEventQueueServiceCID); if (!eqs) @@ -1202,22 +321,19 @@ PRUint32 AppCallbacks::RunEventLoop(PRBool &aRunCondition) aRunCondition = PR_FALSE; break; } - - eventQ->ProcessPendingEvents(); + + eventQ->PendingEvents(&eventAvail); + if (eventAvail) + eventQ->ProcessPendingEvents(); ::TranslateMessage(&msg); ::DispatchMessage(&msg); } // Do idle stuff - if (gActive) - { - if (!gBusy) - ::MsgWaitForMultipleObjects(1, &hFakeEvent, FALSE, 5000, QS_ALLEVENTS); - + eventQ->PendingEvents(&eventAvail); + if (eventAvail) eventQ->ProcessPendingEvents(); - } } - ::CloseHandle(hFakeEvent); return msg.wParam; } diff --git a/embedding/minimo/wince/winEmbed.h b/embedding/minimo/wince/winEmbed.h index 54e0976f48e5..ddbcb4406d16 100755 --- a/embedding/minimo/wince/winEmbed.h +++ b/embedding/minimo/wince/winEmbed.h @@ -1,44 +1,6 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: Mozilla-sample-code 1.0 - * - * Copyright (c) 2002 Netscape Communications Corporation and - * other contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this Mozilla sample software and associated documentation files - * (the "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Contributor(s): - * - * ***** END LICENSE BLOCK ***** */ -#include "prtypes.h" -class nsIWebBrowserChrome; -namespace AppCallbacks -{ - nsresult CreateBrowserWindow(PRUint32 aChromeFlags, - nsIWebBrowserChrome *aParent, - nsIWebBrowserChrome **aNewWindow); - - void EnableChromeWindow(nsIWebBrowserChrome *aWindow, PRBool aEnabled); - - PRUint32 RunEventLoop(PRBool &aRunCondition); -} +extern nsresult CreateBrowserWindow(PRUint32 aChromeFlags, nsIWebBrowserChrome *aParent, nsIWebBrowserChrome **aNewWindow); +extern PRUint32 RunEventLoop(PRBool &aRunCondition); +extern HWND GetBrowserFromChrome(nsIWebBrowserChrome *aChrome);