New embedding routines to be called by host apps during message processing and idle time. b=44120. NOT PART OF BUILD (yet)

This commit is contained in:
locka%iol.ie 2001-01-17 21:10:46 +00:00
Родитель 6a5b25f5d5
Коммит 4bc897076e
2 изменённых файлов: 120 добавлений и 5 удалений

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

@ -29,15 +29,64 @@
#include "nsIDirectoryService.h"
/*
aPath -> the mozilla bin directory. If nsnull, the default is used
aProvider -> the application directory service provider. If nsnull, the
default (nsAppFileLocationProvider) is constructed and used.
*/
/**
* Function to initialise the Gecko embedding APIs. You *must* call this
* method before any others!
*
* aPath -> the mozilla bin directory. If nsnull, the default is used
* aProvider -> the application directory service provider. If nsnull, the
* default (nsAppFileLocationProvider) is constructed and used.
*/
extern nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
nsIDirectoryServiceProvider *appFileLocProvider);
/**
* Function to call to finish the Gecko embedding APIs.
*/
extern nsresult NS_TermEmbedding();
/*---------------------------------------------------------------------------*/
/* Event processing APIs. The native OS dependencies mean you must be */
/* building on a supported platform to get the functions below. */
/*---------------------------------------------------------------------------*/
#undef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
/* Win32 specific stuff */
#ifdef WIN32
#include "windows.h"
typedef MSG nsEmbedNativeEvent;
#define MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
#endif
/* Mac specific stuff */
/* TODO implementation left as an exercise for the reader */
/* GTK specific stuff */
/* TODO implementation left as an exercise for the reader */
#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
/**
* Function to call during the idle time in your application and/or as each
* event is processed. This function ensures things such as timers are fired
* correctly.
*/
extern nsresult NS_DoIdleEmbeddingStuff();
/**
* Function to call before handling an event. It gives Gecko the chance to
* handle the event first.
*
* aEvent -> the native UI event
* aWasHandled -> returns with PR_TRUE if the event was handled by Gecko
*/
extern nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled);
#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */
#endif /* NSEMBEDAPI_H */

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

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Author:
* Adam Lock <adamlock@netscape.com>
*
* Contributor(s):
*/
#include "nsEmbedAPI.h"
#ifndef WIN32
#error This file is for Win32!
#endif
#ifdef MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING
#include "nsWidgetsCID.h"
#include "nsITimer.h"
#include "nsITimerQueue.h"
static NS_DEFINE_CID(kTimerManagerCID, NS_TIMERMANAGER_CID);
nsresult NS_DoIdleEmbeddingStuff()
{
nsresult rv = NS_ERROR_FAILURE;
NS_WITH_SERVICE(nsITimerQueue, timerQueue, kTimerManagerCID, &rv);
if (NS_FAILED(rv))
{
return NS_ERROR_FAILURE;
}
if (timerQueue->HasReadyTimers(NS_PRIORITY_LOWEST))
{
MSG wmsg;
do
{
timerQueue->FireNextReadyTimer(NS_PRIORITY_LOWEST);
} while (timerQueue->HasReadyTimers(NS_PRIORITY_LOWEST) &&
!::PeekMessage(&wmsg, NULL, 0, 0, PM_NOREMOVE));
}
return NS_OK;
}
nsresult NS_HandleEmbeddingEvent(nsEmbedNativeEvent &aEvent, PRBool &aWasHandled)
{
aWasHandled = PR_FALSE;
return NS_OK;
}
#endif /* MOZ_SUPPORTS_EMBEDDING_EVENT_PROCESSING */