Photon specific changes after synchronizing with the head branch.
Most of these changes were included in our released mozilla 1.0 package. git-svn-id: svn://10.0.0.236/trunk@137959 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -25,7 +25,7 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS=src
|
||||
DIRS=src webserver
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
EmbedContentListener::EmbedContentListener(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mOwner = nsnull;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
EmbedEventListener::EmbedEventListener(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mOwner = nsnull;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,12 +72,12 @@ EmbedPrintListener::InvokePrintCallback(int status, unsigned int cur, unsigned i
|
||||
}
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */
|
||||
NS_IMETHODIMP EmbedPrintListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aStateFlags, PRUint32 aStatus)
|
||||
NS_IMETHODIMP EmbedPrintListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus)
|
||||
{
|
||||
if (aStatus == nsIWebProgressListener::STATE_START) {
|
||||
if (aStateFlags & nsIWebProgressListener::STATE_START) {
|
||||
InvokePrintCallback(Pt_MOZ_PRINT_START, 0, 0);
|
||||
|
||||
} else if (aStatus == nsIWebProgressListener::STATE_STOP) {
|
||||
} else if (aStateFlags & nsIWebProgressListener::STATE_STOP) {
|
||||
InvokePrintCallback(Pt_MOZ_PRINT_COMPLETE, 0, 0);
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#include <nsIURI.h>
|
||||
#include <nsIWebProgress.h>
|
||||
#include <nsIURIFixup.h>
|
||||
#include <nsIDOMDocument.h>
|
||||
#include <nsIDOMNodeList.h>
|
||||
#include <nsISelection.h>
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
@@ -64,6 +67,7 @@
|
||||
#include <nsIFocusController.h>
|
||||
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
|
||||
// all of our local includes
|
||||
#include "EmbedPrivate.h"
|
||||
@@ -78,6 +82,9 @@
|
||||
#include "PtMozilla.h"
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
|
||||
static const char sWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1";
|
||||
|
||||
nsIAppShell *EmbedPrivate::sAppShell = nsnull;
|
||||
nsIPref *EmbedPrivate::sPrefs = nsnull;
|
||||
@@ -107,6 +114,9 @@ EmbedPrivate::~EmbedPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void mozilla_set_default_pref( nsIPref *pref );
|
||||
|
||||
nsresult
|
||||
EmbedPrivate::Init(PtWidget_t *aOwningWidget)
|
||||
{
|
||||
@@ -169,7 +179,7 @@ EmbedPrivate::Init(PtWidget_t *aOwningWidget)
|
||||
windowCreator = NS_STATIC_CAST(nsIWindowCreator *, creator);
|
||||
|
||||
// Attach it via the watcher service
|
||||
nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
||||
nsCOMPtr<nsIWindowWatcher> watcher = do_GetService(sWatcherContractID);
|
||||
if (watcher)
|
||||
watcher->SetWindowCreator(windowCreator);
|
||||
}
|
||||
@@ -184,7 +194,8 @@ EmbedPrivate::Init(PtWidget_t *aOwningWidget)
|
||||
sPrefs = pref.get();
|
||||
NS_ADDREF(sPrefs);
|
||||
//sPrefs->ResetPrefs();
|
||||
sPrefs->ReadUserPrefs(nsnull);
|
||||
rv = sPrefs->ReadUserPrefs(nsnull);
|
||||
if( ! NS_SUCCEEDED( rv ) ) mozilla_set_default_pref( pref );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +247,8 @@ EmbedPrivate::Setup()
|
||||
webBrowser->SetParentURIContentListener(uriListener);
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(webBrowser));
|
||||
if (print)
|
||||
print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings));
|
||||
// if (print)
|
||||
// print->GetNewPrintSettings(getter_AddRefs(m_PrintSettings));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -503,12 +514,53 @@ EmbedPrivate::Paste()
|
||||
clipboard->Paste();
|
||||
}
|
||||
|
||||
#include <nsIWebShell.h>
|
||||
void
|
||||
EmbedPrivate::SelectAll()
|
||||
{
|
||||
/*
|
||||
nsCOMPtr<nsIClipboardCommands> clipboard(do_GetInterface(mWindow->mWebBrowser));
|
||||
if (clipboard)
|
||||
clipboard->SelectAll();
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
mWindow->mWebBrowser->GetContentDOMWindow( getter_AddRefs( domWindow ) );
|
||||
if( !domWindow ) {
|
||||
NS_WARNING( "no dom window in content finished loading\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domDocument;
|
||||
domWindow->GetDocument( getter_AddRefs( domDocument ) );
|
||||
if( !domDocument ) {
|
||||
NS_WARNING( "no dom document\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> list;
|
||||
domDocument->GetElementsByTagName( NS_LITERAL_STRING( "body" ), getter_AddRefs( list ) );
|
||||
if( !list ) {
|
||||
NS_WARNING( "no list\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
list->Item( 0, getter_AddRefs( node ) );
|
||||
if( !node ) {
|
||||
NS_WARNING( "no node\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
domWindow->GetSelection( getter_AddRefs( selection ) );
|
||||
if( !selection ) {
|
||||
NS_WARNING( "no selection\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
selection->SelectAllChildren( node );
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -522,12 +574,18 @@ EmbedPrivate::Clear()
|
||||
void
|
||||
EmbedPrivate::Print(PpPrintContext_t *pc)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> window;
|
||||
mWindow->mWebBrowser->GetContentDOMWindow(getter_AddRefs(window));
|
||||
nsCOMPtr<nsIWebBrowserPrint> print( do_GetInterface( mWindow->mWebBrowser ) );
|
||||
nsCOMPtr<nsIWebBrowserPrint> browserAsPrint = do_GetInterface(mWindow->mWebBrowser);
|
||||
NS_ASSERTION(browserAsPrint, "No nsIWebBrowserPrint!");
|
||||
|
||||
m_PrintSettings->SetEndPageRange((PRInt32) pc);
|
||||
print->Print(m_PrintSettings, mPrint);
|
||||
nsCOMPtr<nsIPrintSettings> printSettings;
|
||||
browserAsPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings));
|
||||
if (printSettings)
|
||||
{
|
||||
printSettings->SetPrintSilent(PR_TRUE);
|
||||
printSettings->SetEndPageRange((PRInt32) pc);
|
||||
}
|
||||
|
||||
browserAsPrint->Print(printSettings, mPrint);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -549,24 +607,35 @@ EmbedPrivate::OpenStream(const char *aBaseURI, const char *aContentType)
|
||||
}
|
||||
|
||||
int
|
||||
EmbedPrivate::SaveAs(char *fname)
|
||||
EmbedPrivate::SaveAs(char *fname, char *dirname)
|
||||
{
|
||||
if (mWindow)
|
||||
return (mWindow->SaveAs(fname));
|
||||
return (mWindow->SaveAs(fname, dirname));
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
EmbedPrivate::SaveURI(char *aURI, char *fname)
|
||||
{
|
||||
{
|
||||
/* ATENTIE it was */
|
||||
#if 0
|
||||
if (mWindow && mFixup)
|
||||
{
|
||||
nsIURI* uri;
|
||||
|
||||
nsCString u(aURI);
|
||||
nsresult rv = mFixup->CreateFixupURI(ToNewUnicode(u), 0, &(uri));
|
||||
mFixup->CreateFixupURI(ToNewUnicode(u), 0, &(uri));
|
||||
return (mWindow->SaveURI(uri, fname));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mWindow && mFixup)
|
||||
{
|
||||
nsIURI* uri;
|
||||
mFixup->CreateFixupURI( NS_LITERAL_STRING(aURI), 0, &(uri));
|
||||
return (mWindow->SaveURI(uri, fname));
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -860,3 +929,37 @@ EmbedPrivate::GetPIDOMWindow(nsPIDOMWindow **aPIWin)
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void mozilla_set_default_pref( nsIPref *pref )
|
||||
{
|
||||
/*
|
||||
PtMozillaWidget_t *moz = ( PtMozillaWidget_t * ) widget;
|
||||
nsIPref *pref = moz->EmbedRef->GetPrefs();
|
||||
*/
|
||||
|
||||
/* translation set = Western European (ISO 8859-1) */
|
||||
pref->SetUnicharPref( "intl.charset.default", NS_ConvertASCIItoUCS2("iso8859-1").get());
|
||||
|
||||
/* HTML Options */
|
||||
pref->SetUnicharPref( "browser.visited_color", NS_ConvertASCIItoUCS2("#008080").get() );
|
||||
pref->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUCS2("#0000ff").get() );
|
||||
pref->SetUnicharPref( "browser.display.foreground_color", NS_ConvertASCIItoUCS2("#000000").get() );
|
||||
pref->SetUnicharPref( "browser.display.background_color", NS_ConvertASCIItoUCS2("#ffffff").get() );
|
||||
|
||||
pref->SetBoolPref( "browser.display.use_document_colors", PR_TRUE );
|
||||
pref->SetBoolPref( "browser.underline_anchors", PR_TRUE );
|
||||
pref->SetIntPref( "font.size.variable.x-western", VOYAGER_TEXTSIZE2 );
|
||||
pref->SetIntPref( "browser.history_expire_days", 4 );
|
||||
pref->SetIntPref( "browser.sessionhistory.max_entries", 50 );
|
||||
pref->SetIntPref( "browser.cache.check_doc_frequency", 2 );
|
||||
pref->SetBoolPref( "browser.cache.disk.enable", PR_TRUE );
|
||||
pref->SetIntPref( "browser.cache.disk.capacity", 5000 );
|
||||
pref->SetIntPref( "network.http.connect.timeout", 2400 );
|
||||
pref->SetIntPref( "network.http.max-connections", 4 );
|
||||
pref->SetCharPref( "network.proxy.http_port", "80" );
|
||||
pref->SetCharPref( "network.proxy.ftp_port", "80" );
|
||||
pref->SetCharPref( "network.proxy.gopher_port", "80" );
|
||||
|
||||
pref->SavePrefFile( nsnull );
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class EmbedPrivate {
|
||||
void Paste (void);
|
||||
void SelectAll (void);
|
||||
void Clear (void);
|
||||
int SaveAs(char *fname);
|
||||
int SaveAs(char *fname,char *dirname);
|
||||
int SaveURI(char *uri, char *fname);
|
||||
void CancelSaveURI();
|
||||
void Print(PpPrintContext_t *pc);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
EmbedProgress::EmbedProgress(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mOwner = nsnull;
|
||||
mSkipOnState = mDownloadDocument = 0;
|
||||
}
|
||||
@@ -66,11 +67,11 @@ EmbedProgress::Init(EmbedPrivate *aOwner)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 aStateFlags,
|
||||
PRUint32 aStatus)
|
||||
NS_IMETHODIMP
|
||||
EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRUint32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *) mOwner->mOwningWidget;
|
||||
PtCallbackList_t *cb = NULL;
|
||||
@@ -83,6 +84,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
nsString tmpString;
|
||||
tmpString.AssignWithConversion(uriString);
|
||||
|
||||
#if 0
|
||||
if( ( aStateFlags & STATE_IS_NETWORK ) && NS_FAILED( aStatus ) )
|
||||
{
|
||||
PtWebErrorCallback_t cbw;
|
||||
@@ -100,7 +102,6 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
switch( aStatus )
|
||||
{
|
||||
case NS_ERROR_UNKNOWN_HOST:
|
||||
case NS_ERROR_UNKNOWN_PROXY_HOST:
|
||||
cbw.reason = -12;
|
||||
break;
|
||||
case NS_ERROR_NET_TIMEOUT:
|
||||
@@ -113,21 +114,17 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
cbw.reason = -404;
|
||||
break;
|
||||
case NS_ERROR_CONNECTION_REFUSED:
|
||||
case NS_ERROR_PROXY_CONNECTION_REFUSED:
|
||||
cbw.reason = -13;
|
||||
break;
|
||||
|
||||
/* these will not cause the web error */
|
||||
case NS_BINDING_ABORTED:
|
||||
break;
|
||||
|
||||
default:
|
||||
cbw.reason = -1;
|
||||
break;
|
||||
}
|
||||
if( cbw.reason ) PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
if( cbw.reason != -1)
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
/* let it check for STATE_STOP */
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
|
||||
@@ -184,7 +181,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
cbinfo.reason = Pt_CB_MOZ_COMPLETE;
|
||||
cbinfo.cbdata = &cbcomplete;
|
||||
memset( &cbcomplete, 0, sizeof( PtWebCompleteCallback_t ) );
|
||||
strcpy(cbcomplete.url, (const char *)uriString);
|
||||
REMOVE_WHEN_NEW_PT_WEB_strcpy(cbcomplete.url, (const char *)uriString);
|
||||
|
||||
if( ( cb = moz->complete_cb ) )
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo);
|
||||
@@ -196,7 +193,8 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
||||
cbinfo.cbdata = &state;
|
||||
state.flags = aStateFlags;
|
||||
state.status = aStatus;
|
||||
state.url = (const char *)uriString;
|
||||
//state.url = (const char *)uriString;
|
||||
state.url = NULL;
|
||||
char *statusMessage = "";
|
||||
PRInt32 flags = aStateFlags;
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ NS_IMPL_ISUPPORTS1(EmbedStream, nsIInputStream)
|
||||
|
||||
EmbedStream::EmbedStream()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mOwner = nsnull;
|
||||
mOffset = 0;
|
||||
mDoingStream = PR_FALSE;
|
||||
@@ -117,8 +118,7 @@ EmbedStream::OpenStream(const char *aBaseURI, const char *aContentType)
|
||||
rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri,
|
||||
NS_STATIC_CAST(nsIInputStream *, this),
|
||||
nsDependentCString(aContentType),
|
||||
NS_LITERAL_CSTRING(""),
|
||||
1024); /* len */
|
||||
NS_LITERAL_CSTRING("") );
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@@ -272,9 +272,6 @@ EmbedStream::ReadSegments(nsWriteSegmentFun aWriter, void * aClosure,
|
||||
// XXX writeCount may be less than nBytes!! This is the wrong
|
||||
// way to synthesize ReadSegments.
|
||||
NS_ASSERTION(writeCount == nBytes, "data loss");
|
||||
|
||||
// errors returned from the writer end here!
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
nsMemory::Free(readBuf);
|
||||
|
||||
@@ -51,6 +51,7 @@ PtWidget_t *EmbedWindow::sTipWindow = nsnull;
|
||||
|
||||
EmbedWindow::EmbedWindow(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mOwner = nsnull;
|
||||
mVisibility = PR_FALSE;
|
||||
mIsModal = PR_FALSE;
|
||||
@@ -181,17 +182,28 @@ EmbedWindow::SetStatus(PRUint32 aStatusType, const PRUnichar *aStatus)
|
||||
}
|
||||
|
||||
int
|
||||
EmbedWindow::SaveAs(char *fname)
|
||||
EmbedWindow::SaveAs(char *fname, char *dirname)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(mWebBrowser));
|
||||
if (persist)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewNativeLocalFile(nsDependentCString(fname), PR_TRUE, getter_AddRefs(file));
|
||||
persist->SaveDocument(nsnull, file, nsnull, nsnull, 0, 0);
|
||||
return (0);
|
||||
}
|
||||
return 1;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist(do_GetInterface(mWebBrowser, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewNativeLocalFile(nsDependentCString(fname), PR_TRUE, getter_AddRefs(file));
|
||||
|
||||
/* the nsIWebBrowserPersist wants a parent directory where to download images and other items related to the document */
|
||||
/* we have to provide a directory, otherwise the current SaveDocument is marked as not finished and the next one is aborted */
|
||||
nsCOMPtr<nsILocalFile> parentDirAsLocal;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString( dirname ), PR_TRUE, getter_AddRefs(parentDirAsLocal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 flags;
|
||||
persist->GetPersistFlags( &flags );
|
||||
if( !(flags & nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES ) ) persist->SetPersistFlags( nsIWebBrowserPersist::PERSIST_FLAGS_REPLACE_EXISTING_FILES );
|
||||
|
||||
persist->SaveDocument(nsnull, file, parentDirAsLocal, nsnull, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -213,7 +225,6 @@ EmbedWindow::SaveURI(nsIURI *uri, char *fname)
|
||||
void
|
||||
EmbedWindow::CancelSaveURI()
|
||||
{
|
||||
PtMozillaWidget_t *w = (PtMozillaWidget_t *)(mOwner->mOwningWidget);
|
||||
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(mWebBrowser));
|
||||
persist->SetProgressListener(nsnull);
|
||||
persist->CancelSave();
|
||||
@@ -262,7 +273,6 @@ EmbedWindow::DestroyBrowserWindow(void)
|
||||
cb = moz->destroy_cb;
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.reason = Pt_CB_MOZ_DESTROY;
|
||||
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
|
||||
return NS_OK;
|
||||
@@ -271,7 +281,23 @@ EmbedWindow::DestroyBrowserWindow(void)
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *) mOwner->mOwningWidget;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaNewAreaCb_t resize;
|
||||
|
||||
if (!moz->resize_cb)
|
||||
return NS_OK;
|
||||
|
||||
cb = moz->resize_cb;
|
||||
memset(&cbinfo, 0, sizeof(cbinfo));
|
||||
cbinfo.reason = Pt_CB_MOZ_NEW_AREA;
|
||||
resize.flags = Pt_MOZ_NEW_AREA_SET_SIZE;
|
||||
resize.area.size.w = aCX;
|
||||
resize.area.size.h = aCY;
|
||||
cbinfo.cbdata = &resize;
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -319,8 +345,8 @@ EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaNewAreaCb_t resize;
|
||||
|
||||
nsresult rv = NS_ERROR_INVALID_ARG;
|
||||
#if 0
|
||||
if (aFlags & nsIEmbeddingSiteWindow::DIM_FLAGS_POSITION &&
|
||||
(aFlags & (nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_INNER |
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER))) {
|
||||
@@ -333,7 +359,7 @@ EmbedWindow::SetDimensions(PRUint32 aFlags, PRInt32 aX, PRInt32 aY,
|
||||
nsIEmbeddingSiteWindow::DIM_FLAGS_SIZE_OUTER)) {
|
||||
rv = mBaseWindow->SetSize(aCX, aCY, PR_TRUE);
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
|
||||
if (!moz->resize_cb)
|
||||
return NS_OK;
|
||||
@@ -415,7 +441,18 @@ EmbedWindow::SetTitle(const PRUnichar *aTitle)
|
||||
|
||||
info.type = Pt_MOZ_INFO_TITLE;
|
||||
info.status = 0;
|
||||
str = ToNewCString(mTitleString);
|
||||
|
||||
/* see if the title is empty */
|
||||
if( mTitleString.Length() == 0 ) {
|
||||
if( moz->EmbedRef->mURI.Length() > 0 )
|
||||
str = ToNewCString( moz->EmbedRef->mURI );
|
||||
else {
|
||||
str = (char*) nsMemory::Alloc( 2 );
|
||||
str[0] = ' '; str[1] = 0;
|
||||
}
|
||||
}
|
||||
else str = ToNewCString(mTitleString);
|
||||
|
||||
info.data = str;
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo);
|
||||
|
||||
@@ -442,10 +479,7 @@ EmbedWindow::GetVisibility(PRBool *aVisibility)
|
||||
NS_IMETHODIMP
|
||||
EmbedWindow::SetVisibility(PRBool aVisibility)
|
||||
{
|
||||
// We always set the visibility so that if it's chrome and we finish
|
||||
// the load we know that we have to show the window.
|
||||
mVisibility = aVisibility;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -486,11 +520,11 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords,
|
||||
pos.x = pos.y = 0;
|
||||
PtSetArg(&args[n++], Pt_ARG_POS, &pos, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_DIM, &dim, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_FLAGS, Pt_HIGHLIGHTED, (int)(~0));
|
||||
PtSetArg(&args[n++], Pt_ARG_FLAGS, Pt_HIGHLIGHTED, -1 );
|
||||
PtSetArg(&args[n++], Pt_ARG_FILL_COLOR, 0xfeffb1, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, tipString, 0);
|
||||
PtSetArg(&args[n++], Pt_ARG_BASIC_FLAGS, Pt_STATIC_GRADIENT | Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE |
|
||||
Pt_RIGHT_OUTLINE | Pt_BOTTOM_OUTLINE, (int)(~0));
|
||||
Pt_RIGHT_OUTLINE | Pt_BOTTOM_OUTLINE, -1 );
|
||||
PtCreateWidget(PtLabel, sTipWindow, n, args);
|
||||
|
||||
// realize the widget
|
||||
|
||||
@@ -62,7 +62,7 @@ class EmbedWindow : public nsIWebBrowserChrome,
|
||||
nsresult Init (EmbedPrivate *aOwner);
|
||||
nsresult CreateWindow (void);
|
||||
void ReleaseChildren (void);
|
||||
int SaveAs(char *fname);
|
||||
int SaveAs(char *fname,char *dirname);
|
||||
int SaveURI(nsIURI *uri, char *fname);
|
||||
void CancelSaveURI();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
EmbedWindowCreator::EmbedWindowCreator(void)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
EmbedWindowCreator::~EmbedWindowCreator()
|
||||
@@ -63,6 +64,10 @@ EmbedWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
cb = moz->new_window_cb;
|
||||
nwin.window_flags = aChromeFlags;
|
||||
|
||||
if( aChromeFlags == nsIWebBrowserChrome::CHROME_ALL ) /* the CHROME_ALL is passed when there are features specified for the new window */
|
||||
nwin.window_size.w = nwin.window_size.h = 0; /* the size will be the same as the main window */
|
||||
else nwin.window_size.w = nwin.window_size.h = 1; /* the window will be resized by Pt_CB_WEB_NEW_AREA */
|
||||
|
||||
PtSetParentWidget(NULL);
|
||||
if (PtInvokeCallbackList(cb, (PtWidget_t *) moz, &cbinfo) == Pt_CONTINUE)
|
||||
{
|
||||
|
||||
@@ -44,11 +44,12 @@ REQUIRES = xpcom \
|
||||
embed_base \
|
||||
pref \
|
||||
windowwatcher \
|
||||
profdirserviceprovider \
|
||||
mpfilelocprovider \
|
||||
webbrowserpersist \
|
||||
find \
|
||||
exthandler \
|
||||
helperAppDlg \
|
||||
profdirserviceprovider \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@@ -64,6 +65,26 @@ CPPSRCS = \
|
||||
PromptService.cpp \
|
||||
nsUnknownContentTypeHandler.cpp
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
# Static build stuff
|
||||
DEFINES += -D_BUILD_STATIC_BIN=1
|
||||
CPPSRCS += EmbedComponents.cpp
|
||||
|
||||
XP_LIBS += \
|
||||
$(PNG_LIBS) \
|
||||
$(MNG_LIBS) \
|
||||
$(JPEG_LIBS) \
|
||||
$(ZLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PSM
|
||||
XP_LIBS += \
|
||||
$(NSS_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS= \
|
||||
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libprofdirserviceprovider_s.$(LIB_SUFFIX) \
|
||||
@@ -92,3 +113,61 @@ endif
|
||||
endif
|
||||
|
||||
CXXFLAGS += $(MOZ_GTK_CFLAGS)
|
||||
|
||||
ifdef BUILD_STATIC_LIBS
|
||||
|
||||
# This is so sick! We'll work backwards from the embedding manifest to
|
||||
# produce the set of components that we need to link in to a
|
||||
# ``minimal'' embedding harness.
|
||||
EMBED_MANIFEST=$(topsrcdir)/embedding/config/basebrowser-qnx
|
||||
|
||||
ifdef MOZ_FAT_EMBED
|
||||
EMBED_LINK_COMPS=$(FINAL_LINK_COMPS)
|
||||
EMBED_LINK_COMP_NAMES=$(FINAL_LINK_COMP_NAMES)
|
||||
else
|
||||
EMBED_LINK_COMPS=embed-link-comps
|
||||
EMBED_LINK_COMP_NAMES=embed-link-comp-names
|
||||
endif
|
||||
|
||||
# Create a map that we can use to go from library name to component
|
||||
# symbol. N.B. that this will break if the $(FINAL_LINK_COMP_NAMES)
|
||||
# and $(FINAL_LINK_COMPS) somehow get out-of-sync and aren't in
|
||||
# _exactly_ the same order. (Hey, this is a hack!)
|
||||
components: $(FINAL_LINK_COMPS) $(FINAL_LINK_COMP_NAMES)
|
||||
cat $(FINAL_LINK_COMPS) $(FINAL_LINK_COMP_NAMES) | sort -k 1,1 > $@
|
||||
|
||||
# Compute the embedding libs by extracting them from the embedding
|
||||
# manifest.
|
||||
#
|
||||
# We start by selecting anything that starts with `components/', as
|
||||
# these are the component libraries. We print the `first' field to
|
||||
# strip off any crap after the library name. Next, we select for files
|
||||
# ending with `.so' so we end up with only the libraries. We then rip
|
||||
# off the `components/lib' prefix and the `.so' suffix, leaving just
|
||||
# the library name. This list is sorted, and joined with the list of
|
||||
# components that were actually _built_ to cull out anything that's
|
||||
# included in the manifest, but wasn't built.
|
||||
embed-link-comps: $(EMBED_MANIFEST) components
|
||||
grep '^components/' $< | \
|
||||
awk '{ print $$1; }' | \
|
||||
grep '\.so$$' | \
|
||||
sed -e 's.^components/lib..' -e 's/\.so//' | \
|
||||
sort | \
|
||||
join -o 1.1 - components > $@
|
||||
|
||||
# Compute the symbols we'll need for the ``minimal embedding client''
|
||||
# by joining the compoent list with the sorted list of embedding
|
||||
# components.
|
||||
embed-link-comp-names: embed-link-comps components
|
||||
sort embed-link-comps | join -o 1.1 - components > $@
|
||||
#sort embed-link-comps | join -o 2.2 - components > $@
|
||||
|
||||
EmbedComponents.cpp: EmbedComponents.cpp.in Makefile Makefile.in $(EMBED_LINK_COMP_NAMES)
|
||||
cat $< | \
|
||||
sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(shell cat $(EMBED_LINK_COMP_NAMES)),DECL_NSGETMODULE($(m)))|" | \
|
||||
sed -e "s|%MODULE_LIST%|$(foreach m, $(shell cat $(EMBED_LINK_COMP_NAMES)),MODULE($(m)),)|" \
|
||||
> $@
|
||||
|
||||
GARBAGE += EmbedComponents.cpp embed-link-comp-names embed-link-comps components
|
||||
endif
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
private:
|
||||
nsCOMPtr<nsIWindowWatcher> mWWatch;
|
||||
PtWidget_t *GetWebBrowser(nsIDOMWindow *aWindow);
|
||||
int InvokeDialogCallback(PtWidget_t *w, int type, char *title, char *text, char *msg, int *value);
|
||||
int InvokeDialogCallback(PtWidget_t *w, int type, char *title, char *text, char *checkbox_msg, int *value);
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
@@ -83,7 +83,8 @@ private:
|
||||
NS_IMPL_ISUPPORTS2(CPromptService, nsIPromptService, nsPIPromptService)
|
||||
|
||||
CPromptService::CPromptService() :
|
||||
mWWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)) {
|
||||
mWWatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
CPromptService::~CPromptService() {
|
||||
@@ -94,7 +95,7 @@ PtWidget_t *CPromptService::GetWebBrowser(nsIDOMWindow *aWindow)
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
PtWidget_t *val = 0;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!wwatch) return nsnull;
|
||||
|
||||
if( wwatch ) {
|
||||
@@ -117,12 +118,13 @@ PtWidget_t *CPromptService::GetWebBrowser(nsIDOMWindow *aWindow)
|
||||
}
|
||||
|
||||
int
|
||||
CPromptService::InvokeDialogCallback(PtWidget_t *w, int type, char *title, char *text, char *msg, int *value)
|
||||
CPromptService::InvokeDialogCallback(PtWidget_t *w, int type, char *title, char *text, char *checkbox_msg, int *value)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *) w;
|
||||
PtCallbackList_t *cb;
|
||||
PtCallbackInfo_t cbinfo;
|
||||
PtMozillaDialogCb_t dlg;
|
||||
PtWidget_t *parent;
|
||||
int ret;
|
||||
|
||||
if (!moz->dialog_cb)
|
||||
@@ -137,8 +139,9 @@ CPromptService::InvokeDialogCallback(PtWidget_t *w, int type, char *title, char
|
||||
dlg.type = type;
|
||||
dlg.title = title;
|
||||
dlg.text = text;
|
||||
if ((type == Pt_MOZ_DIALOG_ALERT_CHECK) || (type == Pt_MOZ_DIALOG_CONFIRM_CHECK))
|
||||
dlg.message = msg;
|
||||
dlg.checkbox_message = checkbox_msg;
|
||||
parent = PtFindDisjoint( w );
|
||||
dlg.parent = parent ? parent : w;
|
||||
|
||||
ret = PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
if (value)
|
||||
@@ -166,7 +169,7 @@ NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent,
|
||||
nsString mTitle(dialogTitle);
|
||||
nsString mText(text);
|
||||
nsString mMsg(checkboxMsg);
|
||||
int ret;
|
||||
int ret = 0;
|
||||
PtWidget_t *w = GetWebBrowser( parent );
|
||||
|
||||
InvokeDialogCallback(w, Pt_MOZ_DIALOG_ALERT, ToNewCString(mTitle), ToNewCString(mText), \
|
||||
@@ -201,8 +204,23 @@ NS_IMETHODIMP CPromptService::ConfirmCheck(nsIDOMWindow *parent,
|
||||
PRBool *checkValue,
|
||||
PRBool *_retval)
|
||||
{
|
||||
// TODO implement proper confirmation checkbox dialog
|
||||
return Confirm(parent, dialogTitle, text, _retval);
|
||||
nsString mTitle(dialogTitle);
|
||||
nsString mText(text);
|
||||
nsString mMsg(checkboxMsg);
|
||||
int ret = 0;
|
||||
PtWidget_t *w = GetWebBrowser( parent );
|
||||
|
||||
|
||||
if (InvokeDialogCallback(w, Pt_MOZ_DIALOG_CONFIRM_CHECK, ToNewCString(mTitle), ToNewCString(mText), \
|
||||
ToNewCString(mMsg), &ret) == Pt_CONTINUE)
|
||||
*_retval = PR_TRUE;
|
||||
else
|
||||
*_retval = PR_FALSE;
|
||||
if (checkValue)
|
||||
*checkValue = ret;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent,
|
||||
@@ -216,7 +234,7 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent,
|
||||
nsString mTitle(dialogTitle);
|
||||
nsString mText(text);
|
||||
nsString mMsg(checkboxMsg);
|
||||
int ret;
|
||||
int ret = 0;
|
||||
PtWidget_t *w = GetWebBrowser( parent );
|
||||
|
||||
|
||||
@@ -367,6 +385,8 @@ public:
|
||||
NS_IMPL_ISUPPORTS1(CPromptServiceFactory, nsIFactory)
|
||||
|
||||
CPromptServiceFactory::CPromptServiceFactory() {
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
CPromptServiceFactory::~CPromptServiceFactory() {
|
||||
|
||||
@@ -31,11 +31,15 @@
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIAppShell.h"
|
||||
|
||||
// for profiles
|
||||
#include <nsProfileDirServiceProvider.h>
|
||||
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIHistoryEntry.h"
|
||||
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
@@ -44,7 +48,6 @@
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsProfileDirServiceProvider.h"
|
||||
#include "nsIFocusController.h"
|
||||
#include <nsIWebBrowserFind.h>
|
||||
|
||||
@@ -72,7 +75,7 @@
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
#include "nsStaticComponent.h"
|
||||
nsresult PR_CALLBACK
|
||||
apprunner_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||
ph_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||
#endif
|
||||
|
||||
// Macro for converting from nscolor to PtColor_t
|
||||
@@ -99,7 +102,7 @@ static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
static void mozilla_set_pref( PtWidget_t *widget, char *option, char *value );
|
||||
static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value );
|
||||
static void mozilla_set_default_pref( PtWidget_t *widget );
|
||||
static void fix_translation_string( char *string );
|
||||
|
||||
PtWidgetClass_t *PtCreateMozillaClass( void );
|
||||
#ifndef _PHSLIB
|
||||
@@ -134,9 +137,13 @@ MozSetPreference(PtWidget_t *widget, int type, char *pref, void *data)
|
||||
int MozSavePageAs(PtWidget_t *widget, char *fname, int type)
|
||||
{
|
||||
PtMozillaWidget_t *moz = (PtMozillaWidget_t *) widget;
|
||||
if (!fname || !widget)
|
||||
return (-1);
|
||||
moz->EmbedRef->SaveAs(fname);
|
||||
char dirname[1024];
|
||||
|
||||
if (!fname || !widget) return -1;
|
||||
|
||||
sprintf( dirname, "%s.dir", fname );
|
||||
moz->EmbedRef->SaveAs( fname, dirname );
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -162,6 +169,9 @@ mozilla_defaults( PtWidget_t *widget )
|
||||
moz->EmbedRef = new EmbedPrivate();
|
||||
moz->EmbedRef->Init(widget);
|
||||
moz->EmbedRef->Setup();
|
||||
//JPB
|
||||
moz->disable_new_windows = 0;
|
||||
moz->disable_exception_dlg = 0;
|
||||
|
||||
// widget related
|
||||
basic->flags = Pt_ALL_OUTLINES | Pt_ALL_BEVELS | Pt_FLAT_FILL;
|
||||
@@ -170,8 +180,6 @@ mozilla_defaults( PtWidget_t *widget )
|
||||
Pt_BOTTOM_ANCHORED_TOP | Pt_RIGHT_ANCHORED_LEFT | Pt_ANCHORS_INVALID;
|
||||
|
||||
cntr->flags |= Pt_CHILD_GETTING_FOCUS;
|
||||
|
||||
mozilla_set_default_pref( widget );
|
||||
}
|
||||
|
||||
// widget destroy function
|
||||
@@ -228,16 +236,16 @@ mozilla_unrealized( PtWidget_t *widget )
|
||||
}
|
||||
|
||||
static PpPrintContext_t *moz_construct_print_context( WWWRequest *pPageInfo ) {
|
||||
PpPrintContext_t *pc;
|
||||
PpPrintContext_t *pc = NULL;
|
||||
int i;
|
||||
char *tmp;
|
||||
|
||||
pc = PpPrintCreatePC();
|
||||
|
||||
i = 0;
|
||||
while( pPageInfo->Print.data[i] == '\0' ) i++;
|
||||
tmp = &pPageInfo->Print.data[i];
|
||||
|
||||
|
||||
PpPrintSetPC( pc, INITIAL_PC, 0, Pp_PC_NAME, ( pPageInfo->Print.name != -1 ) ? &tmp[pPageInfo->Print.name]: NULL);
|
||||
|
||||
PpPrintSetPC( pc, INITIAL_PC, 0, Pp_PC_LOCATION, ( pPageInfo->Print.location != -1 ) ? &tmp[pPageInfo->Print.location]: NULL);
|
||||
@@ -270,7 +278,6 @@ static PpPrintContext_t *moz_construct_print_context( WWWRequest *pPageInfo ) {
|
||||
tmp = pc->control.tmp_target;
|
||||
pc->control = pPageInfo->Print.control;
|
||||
pc->control.tmp_target = tmp;
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
@@ -347,8 +354,13 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
||||
mozilla_set_pref(widget, (char*)argt->len, (char*)argt->value);
|
||||
break;
|
||||
|
||||
case Pt_ARG_MOZ_ENCODING:
|
||||
pref->SetUnicharPref( "intl.charset.default", NS_ConvertASCIItoUCS2((char*)argt->value).get());
|
||||
case Pt_ARG_MOZ_ENCODING: {
|
||||
char translation[1024];
|
||||
strcpy( translation, (char*)argt->value );
|
||||
fix_translation_string( translation );
|
||||
pref->SetUnicharPref( "intl.charset.default", NS_ConvertASCIItoUCS2( translation ).get());
|
||||
pref->SavePrefFile( nsnull );
|
||||
}
|
||||
break;
|
||||
|
||||
case Pt_ARG_MOZ_COMMAND:
|
||||
@@ -393,8 +405,8 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
||||
|
||||
case Pt_ARG_MOZ_WEB_DATA_URL:
|
||||
#if 0
|
||||
moz->MyBrowser->WebBrowserContainer->OpenStream( moz->MyBrowser->WebBrowser, "file://", "text/html" );
|
||||
strcpy( moz->url, (char*)argt->value );
|
||||
// moz->MyBrowser->WebBrowserContainer->OpenStream( moz->MyBrowser->WebBrowser, "file://", "text/html" );
|
||||
// strcpy( moz->url, (char*)argt->value );
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -456,7 +468,7 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
||||
cbinfo.cbdata = &cb;
|
||||
cb.type = WWW_DATA_BODY;
|
||||
cb.length = 32768;
|
||||
strcpy( cb.url, moz->url );
|
||||
cb.url = moz->url;
|
||||
PtInvokeCallbackList( moz->web_data_req_cb, (PtWidget_t *)moz, &cbinfo);
|
||||
}
|
||||
break;
|
||||
@@ -475,7 +487,7 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
||||
cbinfo.cbdata = &cb;
|
||||
cb.type = len ? WWW_DATA_BODY : WWW_DATA_CLOSE;
|
||||
cb.length = 32768;
|
||||
strcpy( cb.url, moz->url );
|
||||
cb.url = moz->url;
|
||||
PtInvokeCallbackList( moz->web_data_req_cb, (PtWidget_t *)moz, &cbinfo);
|
||||
}
|
||||
break;
|
||||
@@ -555,7 +567,7 @@ mozilla_get_info(PtWidget_t *widget, PtArg_t *argt)
|
||||
|
||||
nsCAutoString specString;
|
||||
url->GetSpec(specString);
|
||||
strcpy( HistoryReplyBuf[j].url, (char *) specString.get() );
|
||||
REMOVE_WHEN_NEW_PT_WEB_strcpy( HistoryReplyBuf[j].url, (char *) specString.get() );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -564,11 +576,6 @@ mozilla_get_info(PtWidget_t *widget, PtArg_t *argt)
|
||||
return (Pt_CONTINUE);
|
||||
}
|
||||
|
||||
#define VOYAGER_TEXTSIZE0 14
|
||||
#define VOYAGER_TEXTSIZE1 16
|
||||
#define VOYAGER_TEXTSIZE2 18
|
||||
#define VOYAGER_TEXTSIZE3 20
|
||||
#define VOYAGER_TEXTSIZE4 24
|
||||
|
||||
static void
|
||||
mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
|
||||
@@ -577,6 +584,7 @@ mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
|
||||
nsIPref *pref = moz->EmbedRef->GetPrefs();
|
||||
char buffer[1024];
|
||||
|
||||
|
||||
mozilla_get_pref( widget, option, buffer );
|
||||
if( buffer[0] && !strcmp( value, buffer ) )
|
||||
return; /* the option is already set */
|
||||
@@ -678,7 +686,9 @@ mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
|
||||
int n = atoi( value ), moz_value=3;
|
||||
if( n == 0 ) moz_value = 2; /* never */
|
||||
else if( n == 1 ) moz_value = 0; /* once */
|
||||
else moz_value = 1; /* always */
|
||||
else if( n == 2 ) moz_value = 1; /* always */
|
||||
|
||||
// mozilla wants: 0 = once-per-session, 1 = each-time, 2 = never, 3 = when-appropriate/automatically
|
||||
pref->SetIntPref( "browser.cache.check_doc_frequency", moz_value );
|
||||
}
|
||||
else if( !strcmp( option, "main_cache_dir" ) ) ; /* not used */
|
||||
@@ -710,8 +720,21 @@ mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
|
||||
else if( !strcmp( option, "mono_form_font" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "form_font" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "frame_spacing" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "disable_new_windows" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "disable_exception_dlg" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "disable_new_windows" ) ) /* disable new windows*/
|
||||
{
|
||||
if (strcmp(value, "TRUE") == 0)
|
||||
moz->disable_new_windows = 1;
|
||||
else
|
||||
moz->disable_new_windows = 0;
|
||||
}
|
||||
else if( !strcmp( option, "disable_exception_dlg" ) ) /* disable exception dialogs */
|
||||
{
|
||||
if (strcmp(value, "TRUE") == 0)
|
||||
moz->disable_exception_dlg = 1;
|
||||
else
|
||||
moz->disable_exception_dlg = 0;
|
||||
}
|
||||
|
||||
else if( !strcmp( option, "bDisableHighlight" ) ) ; /* not used */
|
||||
|
||||
/* HTTP cookie options */
|
||||
@@ -757,42 +780,10 @@ mozilla_set_pref( PtWidget_t *widget, char *option, char *value )
|
||||
else if( !strcmp( option, "Use_Anti_Alias" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "Use_Explicit_Accept_Headers" ) ) ; /* not used */
|
||||
else if( !strcmp( option, "Visitation_Horizon" ) ) ; /* not used */
|
||||
|
||||
pref->SavePrefFile( nsnull );
|
||||
}
|
||||
|
||||
|
||||
static void mozilla_set_default_pref( PtWidget_t *widget )
|
||||
{
|
||||
static int already_set = 0;
|
||||
PtMozillaWidget_t *moz = ( PtMozillaWidget_t * ) widget;
|
||||
nsIPref *pref = moz->EmbedRef->GetPrefs();
|
||||
|
||||
if( already_set )
|
||||
return;
|
||||
already_set = 1;
|
||||
|
||||
/* HTML Options */
|
||||
pref->SetUnicharPref( "browser.visited_color", NS_ConvertASCIItoUCS2("#008080").get() );
|
||||
pref->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUCS2("#0000ff").get() );
|
||||
pref->SetUnicharPref( "browser.display.foreground_color", NS_ConvertASCIItoUCS2("#000000").get() );
|
||||
pref->SetUnicharPref( "browser.display.background_color", NS_ConvertASCIItoUCS2("#ffffff").get() );
|
||||
|
||||
pref->SetBoolPref( "browser.display.use_document_colors", PR_TRUE );
|
||||
pref->SetBoolPref( "browser.underline_anchors", PR_TRUE );
|
||||
pref->SetIntPref( "font.size.variable.x-western", VOYAGER_TEXTSIZE2 );
|
||||
pref->SetIntPref( "browser.history_expire_days", 4 );
|
||||
pref->SetIntPref( "browser.sessionhistory.max_entries", 50 );
|
||||
pref->SetIntPref( "browser.cache.check_doc_frequency", 2 );
|
||||
pref->SetBoolPref( "browser.cache.disk.enable", PR_TRUE );
|
||||
pref->SetIntPref( "browser.cache.disk.capacity", 5000 );
|
||||
pref->SetIntPref( "network.http.connect.timeout", 2400 );
|
||||
pref->SetIntPref( "network.http.max-connections", 4 );
|
||||
pref->SetCharPref( "network.proxy.http_port", "80" );
|
||||
pref->SetCharPref( "network.proxy.ftp_port", "80" );
|
||||
pref->SetCharPref( "network.proxy.gopher_port", "80" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
PtMozillaWidget_t *moz = ( PtMozillaWidget_t * ) widget;
|
||||
nsIPref *pref = moz->EmbedRef->GetPrefs();
|
||||
@@ -823,6 +814,14 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
pref->GetBoolPref( "browser.display.use_document_colors", &val );
|
||||
sprintf( value, "%s", val == PR_TRUE ? "FALSE" : "TRUE" );
|
||||
}
|
||||
//JPB
|
||||
else if( !strcmp( option, "disable_new_windows" ) ) {
|
||||
sprintf( value, "%s", (moz->disable_new_windows == 1) ? "TRUE" : "FALSE" );
|
||||
}
|
||||
else if( !strcmp( option, "disable_exception_dlg" ) ) {
|
||||
sprintf( value, "%s", (moz->disable_exception_dlg == 1) ? "TRUE" : "FALSE" );
|
||||
}
|
||||
//JPB
|
||||
else if( !strcmp( option, "bUnderlineLinks" ) ) {
|
||||
PRBool val;
|
||||
pref->GetBoolPref( "browser.underline_anchors", &val );
|
||||
@@ -904,7 +903,9 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
if( s ) strcpy( value, s );
|
||||
}
|
||||
else if( !strcmp( option, "gopher_proxy_port" ) ) {
|
||||
pref->SetCharPref( "gopher_proxy_port", value );
|
||||
char *s = NULL;
|
||||
pref->CopyCharPref( "gopher_proxy_port", &s );
|
||||
if( s ) strcpy( value, s );
|
||||
}
|
||||
|
||||
/* TCP/IP options */
|
||||
@@ -933,9 +934,11 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
else if( !strcmp( option, "dcache_verify_policy" ) ) {
|
||||
int n, voyager_value = 0;
|
||||
pref->GetIntPref( "browser.cache.check_doc_frequency", &n );
|
||||
if( n == 0 ) voyager_value = 1;
|
||||
else if( n == 1 ) voyager_value = 2;
|
||||
else if( n == 2 ) voyager_value = 0;
|
||||
// 0 = once-per-session, 1 = each-time, 2 = never, 3 = when-appropriate/automatically
|
||||
if( n == 0 ) voyager_value = 1; /* voyager: 1 = once per session */
|
||||
else if( n == 1 ) voyager_value = 2; /* voyager: 2 = always */
|
||||
else if( n == 2 ) voyager_value = 0; /* voyager: 0 = never */
|
||||
else voyager_value = 1; /* mapp the when-appropriate/automatically to the once per session */
|
||||
sprintf( value, "%d", voyager_value );
|
||||
}
|
||||
|
||||
@@ -950,6 +953,13 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
pref->GetIntPref( "browser.sessionhistory.max_entries", &n );
|
||||
sprintf( value, "%d", n );
|
||||
}
|
||||
|
||||
else if( !strcmp( option, "clear_main_cache_on_exit" ) ) {
|
||||
strcpy( value, "FALSE" ); /* even if not used, match this with the default value */
|
||||
}
|
||||
else if( !strcmp( option, "quantize_jpegs" ) ) {
|
||||
strcpy( value, "FALSE" ); /* even if not used, match this with the default value */
|
||||
}
|
||||
else *value = 0;
|
||||
|
||||
}
|
||||
@@ -958,34 +968,45 @@ static void mozilla_get_pref( PtWidget_t *widget, char *option, char *value ) {
|
||||
static int
|
||||
StartupProfile(char *sProfileDir, char *sProfileName)
|
||||
{
|
||||
// initialize profiles
|
||||
if (sProfileDir && sProfileName)
|
||||
// initialize profiles
|
||||
if (sProfileDir && sProfileName)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> profileDir;
|
||||
NS_NewNativeLocalFile(nsDependentCString(sProfileDir), PR_TRUE,
|
||||
getter_AddRefs(profileDir));
|
||||
if (!profileDir)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = profileDir->AppendNative(nsDependentCString(sProfileName));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> profileDir;
|
||||
PRBool exists = PR_FALSE;
|
||||
PRBool isDir = PR_FALSE;
|
||||
profileDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
rv = profileDir->InitWithNativePath(nsDependentCString(sProfileDir));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
profileDir->Exists(&exists);
|
||||
profileDir->IsDirectory(&isDir);
|
||||
// if it exists and it isn't a directory then give up now.
|
||||
if (!exists)
|
||||
{
|
||||
rv = profileDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
if NS_FAILED(rv)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else if (exists && !isDir)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsProfileDirServiceProvider> locProvider;
|
||||
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
|
||||
if (!locProvider)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Directory service holds an strong reference to any
|
||||
// provider that is registered with it. Let it hold the
|
||||
// only ref. locProvider won't die when we leave this scope.
|
||||
rv = locProvider->Register();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = locProvider->SetProfileDir(profileDir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsProfileDirServiceProvider> locProvider;
|
||||
NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider));
|
||||
if (!locProvider)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Directory service holds an strong reference to any
|
||||
// provider that is registered with it. Let it hold the
|
||||
// only ref. locProvider won't die when we leave this scope.
|
||||
rv = locProvider->Register();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = locProvider->SetProfileDir(profileDir);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -999,7 +1020,7 @@ StartupEmbedding()
|
||||
|
||||
#ifdef _BUILD_STATIC_BIN
|
||||
// Initialize XPCOM's module info table
|
||||
NSGetStaticModuleInfo = apprunner_getModuleInfo;
|
||||
NSGetStaticModuleInfo = ph_getModuleInfo;
|
||||
#endif
|
||||
|
||||
rv = NS_InitEmbedding(nsnull, nsnull);
|
||||
@@ -1027,11 +1048,16 @@ StartupEmbedding()
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* the translation string that is passed by voyager ( Pt_ARG_WEB_ENCODING ) ( taken from /usr/photon/translations/charsets ->mime field ) */
|
||||
/* is required to be in a different form by the mozilla browser */
|
||||
static void fix_translation_string( char *string ) {
|
||||
/* for instance it has to be windows-1252 not Windows-1252 */
|
||||
if( !strncmp( string, "Windows", 7 ) ) *string = 'w';
|
||||
}
|
||||
|
||||
// PtMozilla class creation function
|
||||
PtWidgetClass_t *PtCreateMozillaClass( void )
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
static const PtResourceRec_t resources[] =
|
||||
{
|
||||
{ Pt_ARG_MOZ_GET_URL, mozilla_modify, Pt_QUERY_PREVENT },
|
||||
@@ -1090,7 +1116,7 @@ PtWidgetClass_t *PtCreateMozillaClass( void )
|
||||
if (StartupEmbedding() == -1)
|
||||
return (NULL);
|
||||
|
||||
// Init_nsUnknownContentTypeHandler_Factory( );
|
||||
Init_nsUnknownContentTypeHandler_Factory( );
|
||||
|
||||
nsCOMPtr<nsIFactory> promptFactory;
|
||||
NS_NewPromptServiceFactory(getter_AddRefs(promptFactory));
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <photon/PtWebClient.h>
|
||||
#include <photon/PpProto.h>
|
||||
#include "EmbedPrivate.h"
|
||||
|
||||
#if 0
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILoadGroup.h"
|
||||
@@ -85,7 +85,21 @@ extern PtWidgetClassRef_t *PtMozilla;
|
||||
#define Pt_CB_MOZ_UNKNOWN Pt_RESOURCE( 104, 39 )
|
||||
#define Pt_CB_MOZ_ERROR Pt_RESOURCE( 104, 40 )
|
||||
|
||||
#define MAX_URL_LENGTH 1024
|
||||
|
||||
#define MAX_URL_LENGTH 1024
|
||||
|
||||
/* this limmitation is removed from the new PtWebClient.h - a pointer is passed instead */
|
||||
#define REMOVE_WHEN_NEW_PT_WEB_strcpy( d, s ) \
|
||||
{\
|
||||
strncpy( (d), (s), MAX_URL_LENGTH-1 );\
|
||||
(d)[MAX_URL_LENGTH-1] = 0;\
|
||||
}
|
||||
|
||||
#define VOYAGER_TEXTSIZE0 14
|
||||
#define VOYAGER_TEXTSIZE1 16
|
||||
#define VOYAGER_TEXTSIZE2 18
|
||||
#define VOYAGER_TEXTSIZE3 20
|
||||
#define VOYAGER_TEXTSIZE4 24
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -153,9 +167,10 @@ typedef struct mozilla_authenticate_t
|
||||
typedef struct mozilla_dialog_t
|
||||
{
|
||||
int type;
|
||||
PtWidget_t *parent;
|
||||
char *title;
|
||||
char *text;
|
||||
char *message;
|
||||
char *checkbox_message;
|
||||
int ret_value;
|
||||
} PtMozillaDialogCb_t;
|
||||
|
||||
@@ -206,6 +221,7 @@ typedef struct mozilla_new_window_t
|
||||
{
|
||||
PtWidget_t *widget;
|
||||
unsigned int window_flags;
|
||||
PhDim_t window_size;
|
||||
} PtMozillaNewWindowCb_t;
|
||||
|
||||
typedef struct mozilla_prompt_t
|
||||
@@ -248,7 +264,7 @@ typedef struct mozilla_context_t
|
||||
typedef struct mozilla_data_request_cb_t {
|
||||
int type;
|
||||
int length;
|
||||
char url[MAX_URL_LENGTH];
|
||||
char *url;
|
||||
} PtMozillaDataRequestCb_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -302,6 +318,8 @@ typedef struct {
|
||||
PtModalCtrl_t ctrl;
|
||||
} PtMozillaAuthCtrl_t;
|
||||
|
||||
class EmbedPrivate;
|
||||
|
||||
typedef struct Pt_mozilla_client_widget
|
||||
{
|
||||
PtContainerWidget_t container;
|
||||
@@ -311,6 +329,8 @@ typedef struct Pt_mozilla_client_widget
|
||||
|
||||
char url[MAX_URL_LENGTH];
|
||||
int navigate_flags;
|
||||
int disable_exception_dlg;
|
||||
int disable_new_windows;
|
||||
|
||||
char *rightClickUrl; /* keep the url the user clicked on, to provide it latter for Pt_ARG_WEB_GET_CONTEXT */
|
||||
char *download_dest;
|
||||
|
||||
@@ -68,6 +68,8 @@ nsPrintSettings::nsPrintSettings() :
|
||||
mPrintPageDelay(500),
|
||||
mPrintSilent(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
/* member initializers and constructor code */
|
||||
nscoord halfInch = NS_INCHES_TO_TWIPS(0.5);
|
||||
mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch);
|
||||
|
||||
@@ -47,11 +47,13 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
#include "EmbedPrivate.h"
|
||||
#include "PtMozilla.h"
|
||||
|
||||
#include <photon/PtWebClient.h>
|
||||
|
||||
nsUnknownContentTypeHandler::nsUnknownContentTypeHandler( ) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsUnknownContentTypeHandler::~nsUnknownContentTypeHandler( ) { }
|
||||
@@ -118,7 +120,7 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher
|
||||
moz->EmbedRef->context = aContext;
|
||||
|
||||
strcpy( cb.content_type, mimeType );
|
||||
strcpy( cb.url, url );
|
||||
REMOVE_WHEN_NEW_PT_WEB_strcpy( cb.url, url );
|
||||
cb.content_length = strlen( cb.url );
|
||||
PtInvokeCallbackList( moz->web_unknown_cb, (PtWidget_t *)moz, &cbinfo);
|
||||
return rv;
|
||||
@@ -136,7 +138,7 @@ PtWidget_t *nsUnknownContentTypeHandler::GetWebBrowser(nsIDOMWindow *aWindow)
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
PtWidget_t *val = 0;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!wwatch) return nsnull;
|
||||
|
||||
if( wwatch ) {
|
||||
@@ -163,6 +165,7 @@ PtWidget_t *nsUnknownContentTypeHandler::GetWebBrowser(nsIDOMWindow *aWindow)
|
||||
NS_IMPL_ISUPPORTS2(nsWebProgressListener, nsIWebProgressListener, nsISupportsWeakReference);
|
||||
|
||||
nsWebProgressListener::nsWebProgressListener() {
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsWebProgressListener::~nsWebProgressListener() { }
|
||||
@@ -177,7 +180,7 @@ NS_IMETHODIMP nsWebProgressListener::OnProgressChange(nsIWebProgress *aProgress,
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsWebProgressListener::OnStateChange(nsIWebProgress* aWebProgress, nsIRequest *aRequest, PRInt32 progressStateFlags, nsresult aStatus) {
|
||||
NS_IMETHODIMP nsWebProgressListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRUint32 aStateFlags, nsresult aStatus) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsWebProgressListener::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI *location) {
|
||||
|
||||
@@ -31,16 +31,16 @@ LIBRARY_NAME = gfx_photon
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxPhModule
|
||||
GRE_MODULE = 1
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
widget \
|
||||
view \
|
||||
util \
|
||||
dom \
|
||||
pref \
|
||||
uconv \
|
||||
unicharutil \
|
||||
windowwatcher \
|
||||
locale \
|
||||
intl \
|
||||
$(NULL)
|
||||
@@ -70,11 +70,15 @@ CFLAGS += $(TK_CFLAGS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
-lgkgfx \
|
||||
-lgfxshared_s \
|
||||
$(NULL)
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXNONXP
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
-I$(srcdir)/../shared \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
||||
@@ -306,6 +306,13 @@ NS_IMETHODIMP nsDeviceContextPh :: GetSystemFont( nsSystemFontID aID, nsFont *aF
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetDrawingSurface( nsIRenderingContext &aContext, nsDrawingSurface &aSurface ) {
|
||||
nsRect aRect;
|
||||
GetClientRect( aRect );
|
||||
aContext.CreateDrawingSurface(aRect, 0, aSurface);
|
||||
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetClientRect( nsRect &aRect ) {
|
||||
nsresult rv = NS_OK;
|
||||
if( mIsPrinting ) { //( mSpec )
|
||||
@@ -446,18 +453,22 @@ int nsDeviceContextPh::prefChanged( const char *aPref, void *aClosure ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpStartJob(pc);
|
||||
mIsPrinting = 1;
|
||||
mIsPrintingStart = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) {
|
||||
if( mSpec ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpStartJob(pc);
|
||||
mIsPrinting = 1;
|
||||
mIsPrintingStart = 1;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: EndDocument( void ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpEndJob(pc);
|
||||
mIsPrinting = 0;
|
||||
if( mSpec ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpEndJob(pc);
|
||||
mIsPrinting = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -466,18 +477,22 @@ NS_IMETHODIMP nsDeviceContextPh :: AbortDocument( void ) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginPage( void ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
if( !mIsPrintingStart ) PpPrintNewPage( pc );
|
||||
PpContinueJob( pc );
|
||||
mIsPrintingStart = 0;
|
||||
if( mSpec ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
if( !mIsPrintingStart ) PpPrintNewPage( pc );
|
||||
PpContinueJob( pc );
|
||||
mIsPrintingStart = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: EndPage( void ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpSuspendJob(pc);
|
||||
if( mSpec ) {
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
PpSuspendJob(pc);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
int nsDeviceContextPh :: IsPrinting( void ) { return mIsPrinting ? 1 : 0; }
|
||||
|
||||
|
||||
@@ -67,6 +67,13 @@ public:
|
||||
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
|
||||
//get a low level drawing surface for rendering. the rendering context
|
||||
//that is passed in is used to create the drawing surface if there isn't
|
||||
//already one in the device context. the drawing surface is then cached
|
||||
//in the device context for re-use.
|
||||
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
|
||||
@@ -77,7 +84,7 @@ public:
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
nsDeviceContextSpecFactoryPh :: nsDeviceContextSpecFactoryPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsDeviceContextSpecFactoryPh :: ~nsDeviceContextSpecFactoryPh()
|
||||
@@ -57,6 +58,7 @@ nsDeviceContextSpecFactoryPh :: ~nsDeviceContextSpecFactoryPh()
|
||||
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryPh, nsIDeviceContextSpecFactory)
|
||||
|
||||
@@ -70,7 +72,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: Init(void)
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aIsPrintPreview)
|
||||
PRBool aQuiet)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWidget);
|
||||
PpPrintContext_t *pc = NULL;
|
||||
@@ -82,23 +84,12 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget
|
||||
|
||||
if (devSpec != nsnull)
|
||||
{
|
||||
PtWidget_t *widget = (PtWidget_t*) aWidget->GetNativeData( NS_NATIVE_WIDGET );
|
||||
PtWidget_t *disjoint = PtFindDisjoint( widget );
|
||||
if( !PtWidgetIsClass( disjoint, PtWindow ) )
|
||||
{
|
||||
PRInt32 range = 0;
|
||||
|
||||
aPrintSettings->GetEndPageRange(&range);
|
||||
if (range)
|
||||
pc = (PpPrintContext_t *) range;
|
||||
}
|
||||
|
||||
nsDeviceContextSpecPh* specPh = NS_STATIC_CAST(nsDeviceContextSpecPh*, devSpec);
|
||||
if (pc)
|
||||
{
|
||||
specPh->SetPrintContext(pc);
|
||||
}
|
||||
rv = specPh->Init(aWidget, aPrintSettings, PR_TRUE);
|
||||
rv = specPh->Init(aWidget, aPrintSettings, aQuiet);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNewSpec = devSpec;
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
NS_IMETHOD CreateDeviceContextSpec( nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aIsPrintPreview);
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryPh();
|
||||
|
||||
@@ -42,13 +42,26 @@
|
||||
#include "plstr.h"
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID( kPrintOptionsCID, NS_PRINTOPTIONS_CID );
|
||||
|
||||
nsDeviceContextSpecPh :: nsDeviceContextSpecPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mPC = nsnull;
|
||||
}
|
||||
|
||||
@@ -81,8 +94,10 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget,
|
||||
}
|
||||
else
|
||||
{
|
||||
PtSetParentWidget(parent);
|
||||
action = PtPrintSelection(parent, NULL, NULL, mPC, Pt_PRINTSEL_DFLT_LOOK);
|
||||
//PtSetParentWidget(parent);
|
||||
//action = PtPrintSelection(parent, NULL, NULL, mPC, Pt_PRINTSEL_DFLT_LOOK);
|
||||
PtSetParentWidget(NULL);
|
||||
action = PtPrintSelection(NULL, NULL, NULL, mPC, Pt_PRINTSEL_DFLT_LOOK);
|
||||
switch( action )
|
||||
{
|
||||
case Pt_PRINTSEL_PRINT:
|
||||
@@ -92,6 +107,9 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget,
|
||||
case Pt_PRINTSEL_CANCEL:
|
||||
rv = NS_ERROR_ABORT;
|
||||
break;
|
||||
default:
|
||||
rv = NS_ERROR_ABORT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +135,7 @@ void nsDeviceContextSpecPh :: SetPrintContext(PpPrintContext_t* pc)
|
||||
//***********************************************************
|
||||
nsPrinterEnumeratorPh::nsPrinterEnumeratorPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsPrinterEnumeratorPh::~nsPrinterEnumeratorPh()
|
||||
@@ -176,13 +195,19 @@ nsPrinterEnumeratorPh::DoEnumeratePrinters(PRBool aDoExtended, PRUint32* aCount,
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
char **plist = NULL;
|
||||
int pcount = 0, count = 0;
|
||||
int pcount = 0, count = 0, preview = 0;
|
||||
|
||||
if (!(plist = PpLoadPrinterList()))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
for (pcount = 0; plist[pcount] != NULL; pcount++);
|
||||
|
||||
/* allow at least one printer to be present, otherwise the "Preview" cannot be done in the PtPrintSelection() */
|
||||
if( !pcount ) {
|
||||
pcount = 1;
|
||||
preview = 1;
|
||||
}
|
||||
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(pcount * sizeof(PRUnichar*));
|
||||
if (!array)
|
||||
{
|
||||
@@ -193,7 +218,11 @@ nsPrinterEnumeratorPh::DoEnumeratePrinters(PRBool aDoExtended, PRUint32* aCount,
|
||||
while (count < pcount)
|
||||
{
|
||||
nsString newName;
|
||||
newName.AssignWithConversion(plist[count]);
|
||||
|
||||
if( !preview )
|
||||
newName.AssignWithConversion(plist[count]);
|
||||
else newName.AssignWithConversion( "Preview" );
|
||||
|
||||
PRUnichar *str = ToNewUnicode(newName);
|
||||
if (!str)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,8 @@ NS_IMPL_ISUPPORTS2( nsDrawingSurfacePh, nsIDrawingSurface, nsIDrawingSurfacePh )
|
||||
nsDrawingSurfacePh :: nsDrawingSurfacePh( )
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mDrawContext = nsnull;
|
||||
mGC = nsnull;
|
||||
|
||||
@@ -64,6 +64,7 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
nsFontMetricsPh::nsFontMetricsPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mDeviceContext = nsnull;
|
||||
mFont = nsnull;
|
||||
|
||||
@@ -152,9 +153,6 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
|
||||
mDeviceContext = aContext;
|
||||
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
|
||||
result = aContext->FirstExistingFont(aFont, firstFace);
|
||||
|
||||
str = ToNewCString(firstFace);
|
||||
@@ -178,7 +176,6 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
free (cstring);
|
||||
|
||||
char *font_default = NULL;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsIPref* prefs = nsnull;
|
||||
nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), (nsISupports**) &prefs);
|
||||
if (prefs)
|
||||
@@ -196,6 +193,7 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
|
||||
float scale = 1.0;
|
||||
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mDeviceContext->GetCanonicalPixelScale(scale);
|
||||
|
||||
@@ -244,14 +242,14 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
}
|
||||
|
||||
float dev2app;
|
||||
int height;
|
||||
double height;
|
||||
nscoord onePixel;
|
||||
|
||||
mDeviceContext->GetDevUnitsToAppUnits(dev2app);
|
||||
onePixel = NSToCoordRound(1 * dev2app);
|
||||
height = node->descender - node->ascender + 1.0;
|
||||
PfExtentText(&extent, NULL, NSFullFontName, " ", 1);
|
||||
mSpaceWidth = (int) ((extent.lr.x - extent.ul.x + 1) * dev2app);
|
||||
mSpaceWidth = NSToCoordRound((extent.lr.x - extent.ul.x + 1) * dev2app);
|
||||
|
||||
mLeading = NSToCoordRound(0);
|
||||
mEmHeight = NSToCoordRound(height * dev2app);
|
||||
@@ -261,9 +259,7 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
mAscent = mMaxAscent = NSToCoordRound(node->ascender * dev2app * -1.0);
|
||||
mDescent = mMaxDescent = NSToCoordRound(node->descender * dev2app);
|
||||
mMaxAdvance = NSToCoordRound(node->width * dev2app);
|
||||
|
||||
PfExtentText(&extent, NULL, NSFullFontName, "x", 1);
|
||||
mAveCharWidth = (int) ((extent.lr.x - extent.ul.x + 1) * dev2app);
|
||||
mAveCharWidth = mSpaceWidth;
|
||||
|
||||
mXHeight = NSToCoordRound((float)node->ascender * dev2app * 0.56f * -1.0); // 56% of ascent, best guess for non-true type
|
||||
mSuperscriptOffset = mXHeight; // XXX temporary code!
|
||||
@@ -410,8 +406,8 @@ NS_IMETHODIMP nsFontMetricsPh :: GetMaxAdvance( nscoord &aAdvance )
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetAveCharWidth( nscoord &aAveCharWidth)
|
||||
{
|
||||
aAveCharWidth = mAveCharWidth;
|
||||
return NS_OK;
|
||||
aAveCharWidth = mAveCharWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetFont(const nsFont *&aFont)
|
||||
@@ -451,6 +447,7 @@ struct nsFontFamily
|
||||
// The Font Enumerator
|
||||
nsFontEnumeratorPh::nsFontEnumeratorPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontEnumeratorPh, nsIFontEnumerator)
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDeviceContextPh.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsFontMetricsPh : public nsIFontMetrics
|
||||
@@ -80,7 +81,7 @@ public:
|
||||
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
|
||||
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
|
||||
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
|
||||
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
|
||||
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
|
||||
NS_IMETHOD GetFont(const nsFont *&aFont);
|
||||
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||
@@ -112,7 +113,7 @@ protected:
|
||||
nscoord mUnderlineSize;
|
||||
nscoord mUnderlineOffset;
|
||||
nscoord mSpaceWidth;
|
||||
nscoord mAveCharWidth;
|
||||
nscoord mAveCharWidth;
|
||||
|
||||
nsCOMPtr<nsIAtom> mLangGroup;
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "nsDeviceContextPh.h"
|
||||
#include "nsPrintOptionsPh.h"
|
||||
#include "nsFontList.h"
|
||||
#include "nsPrintSession.h"
|
||||
#include "gfxImageFrame.h"
|
||||
|
||||
// objects that just require generic constructors
|
||||
|
||||
@@ -71,7 +71,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
|
||||
|
||||
// our custom constructors
|
||||
|
||||
@@ -161,10 +161,10 @@ static const nsModuleComponentInfo components[] =
|
||||
"@mozilla.org/gfx/devicecontextspecfactory;1",
|
||||
//"@mozilla.org/gfx/device_context_spec_factory/Ph;1",
|
||||
nsDeviceContextSpecFactoryPhConstructor },
|
||||
{ "PrintSettings Service",
|
||||
NS_PRINTSETTINGSSERVICE_CID,
|
||||
// "@mozilla.org/gfx/printsettings-service;1",
|
||||
"@mozilla.org/gfx/printsettings-service;1",
|
||||
{ "Print Options",
|
||||
NS_PRINTOPTIONS_CID,
|
||||
// "@mozilla.org/gfx/printoptions;1",
|
||||
"@mozilla.org/gfx/printoptions;1",
|
||||
nsPrintOptionsPhConstructor },
|
||||
{ "Ph Font Enumerator",
|
||||
NS_FONT_ENUMERATOR_CID,
|
||||
@@ -185,10 +185,10 @@ static const nsModuleComponentInfo components[] =
|
||||
// "@mozilla.org/gfx/printer_enumerator/win;1",
|
||||
"@mozilla.org/gfx/printerenumerator;1",
|
||||
nsPrinterEnumeratorPhConstructor },
|
||||
{ "Print Session",
|
||||
NS_PRINTSESSION_CID,
|
||||
"@mozilla.org/gfx/printsession;1",
|
||||
nsPrintSessionConstructor }
|
||||
{ "windows image frame",
|
||||
GFX_IMAGEFRAME_CID,
|
||||
"@mozilla.org/gfx/image/frame;2",
|
||||
gfxImageFrameConstructor, },
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsGfxPhModule, components)
|
||||
|
||||
@@ -71,7 +71,7 @@ PhImage_t *MyPiResizeImage(PhImage_t *image,PhRect_t const *bounds,short w,short
|
||||
srcRect.lr.x = image->size.w - 1;
|
||||
srcRect.lr.y = image->size.h - 1;
|
||||
}
|
||||
|
||||
|
||||
oldRect.ul.x = oldRect.ul.y = 0;
|
||||
oldRect.lr.x = w - 1;
|
||||
oldRect.lr.y = h - 1;
|
||||
@@ -178,31 +178,35 @@ PhImage_t *MyPiResizeImage(PhImage_t *image,PhRect_t const *bounds,short w,short
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsImagePh, nsIImage)
|
||||
|
||||
#define IMAGE_SHMEM 0x1
|
||||
#define IMAGE_SHMEM 0x1
|
||||
#define IMAGE_SHMEM_THRESHOLD 4096
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
nsImagePh::nsImagePh()
|
||||
: mImageBits(nsnull)
|
||||
, mWidth(0)
|
||||
, mHeight(0)
|
||||
, mDepth(0)
|
||||
, mAlphaBits(nsnull)
|
||||
, mAlphaDepth(0)
|
||||
, mRowBytes(0)
|
||||
, mSizeImage(0)
|
||||
, mDecodedX1(0)
|
||||
, mDecodedY1(0)
|
||||
, mDecodedX2(0)
|
||||
, mDecodedY2(0)
|
||||
, mConvertedBits(nsnull)
|
||||
, mImageFlags(0)
|
||||
, mAlphaRowBytes(0)
|
||||
, mIsOptimized(PR_FALSE)
|
||||
, mPhImageCache(nsnull)
|
||||
, mPhImageZoom(nsnull)
|
||||
nsImagePh :: nsImagePh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
mImageBits = nsnull;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
mDepth = 0;
|
||||
mAlphaBits = nsnull;
|
||||
mAlphaDepth = 0;
|
||||
mRowBytes = 0;
|
||||
mSizeImage = 0;
|
||||
mAlphaHeight = 0;
|
||||
mAlphaWidth = 0;
|
||||
mConvertedBits = nsnull;
|
||||
mImageFlags = 0;
|
||||
mAlphaRowBytes = 0;
|
||||
mNaturalWidth = 0;
|
||||
mNaturalHeight = 0;
|
||||
mIsOptimized = PR_FALSE;
|
||||
memset(&mPhImage, 0, sizeof(PhImage_t));
|
||||
mPhImageZoom = NULL;
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
mPhImageCache=NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
@@ -220,11 +224,13 @@ nsImagePh :: ~nsImagePh()
|
||||
if (mConvertedBits != nsnull)
|
||||
DestroySRamImage(mConvertedBits);
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
if (mPhImageCache)
|
||||
{
|
||||
PhDCRelease(mPhImageCache);
|
||||
mPhImageCache=NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mAlphaBits != nsnull)
|
||||
{
|
||||
@@ -252,9 +258,25 @@ nsImagePh :: ~nsImagePh()
|
||||
*/
|
||||
nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMaskRequirements aMaskRequirements)
|
||||
{
|
||||
// gfxIImageFrame protects nsImagePh from multiple Init calls
|
||||
int type = -1;
|
||||
|
||||
if (mImageBits != nsnull)
|
||||
{
|
||||
if (mImageFlags & IMAGE_SHMEM)
|
||||
DestroySRamImage(mImageBits);
|
||||
else
|
||||
delete [] mImageBits;
|
||||
mImageBits = nsnull;
|
||||
}
|
||||
|
||||
if (mAlphaBits != nsnull)
|
||||
{
|
||||
delete [] mAlphaBits;
|
||||
mAlphaBits = nsnull;
|
||||
}
|
||||
|
||||
SetDecodedRect(0,0,0,0); //init
|
||||
|
||||
switch (aDepth)
|
||||
{
|
||||
case 24:
|
||||
@@ -278,6 +300,7 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
mDepth = aDepth;
|
||||
mIsTopToBottom = PR_TRUE;
|
||||
|
||||
/* Allocate the Image Data */
|
||||
mSizeImage = mNumBytesPixel * mWidth * mHeight;
|
||||
@@ -302,6 +325,14 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
|
||||
switch(aMaskRequirements)
|
||||
{
|
||||
default:
|
||||
case nsMaskRequirements_kNoMask:
|
||||
mAlphaBits = nsnull;
|
||||
mAlphaWidth = 0;
|
||||
mAlphaHeight = 0;
|
||||
mAlphaRowBytes = 0;
|
||||
break;
|
||||
|
||||
case nsMaskRequirements_kNeeds1Bit:
|
||||
mAlphaRowBytes = (aWidth + 7) / 8;
|
||||
mAlphaDepth = 1;
|
||||
@@ -310,6 +341,8 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
|
||||
|
||||
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
|
||||
mAlphaWidth = aWidth;
|
||||
mAlphaHeight = aHeight;
|
||||
break;
|
||||
|
||||
case nsMaskRequirements_kNeeds8Bit:
|
||||
@@ -319,10 +352,9 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
// 32-bit align each row
|
||||
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
|
||||
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
|
||||
mAlphaWidth = aWidth;
|
||||
mAlphaHeight = aHeight;
|
||||
break;
|
||||
|
||||
default:
|
||||
break; // avoid compiler warning
|
||||
}
|
||||
|
||||
mPhImage.image_tag = PtCRC((char *)mImageBits, mSizeImage);
|
||||
@@ -395,19 +427,44 @@ PRUint8* nsImagePh::GetAlphaBits()
|
||||
return mAlphaBits;
|
||||
}
|
||||
|
||||
PRInt32 nsImagePh::GetAlphaWidth()
|
||||
{
|
||||
return mAlphaWidth;
|
||||
}
|
||||
|
||||
PRInt32 nsImagePh::GetAlphaHeight()
|
||||
{
|
||||
return mAlphaHeight;
|
||||
}
|
||||
|
||||
PRInt32 nsImagePh::GetAlphaLineStride()
|
||||
{
|
||||
return mAlphaRowBytes;
|
||||
}
|
||||
|
||||
nsIImage *nsImagePh::DuplicateImage()
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void nsImagePh::SetAlphaLevel(PRInt32 aAlphaLevel)
|
||||
{
|
||||
mAlphaLevel=aAlphaLevel;
|
||||
}
|
||||
|
||||
PRInt32 nsImagePh::GetAlphaLevel()
|
||||
{
|
||||
return(mAlphaLevel);
|
||||
}
|
||||
|
||||
void nsImagePh::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
|
||||
{
|
||||
}
|
||||
|
||||
void nsImagePh :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
|
||||
{
|
||||
/* does this mean it's dirty? */
|
||||
mFlags = aFlags; // this should be 0'd out by Draw()
|
||||
if (aUpdateRect->YMost() > mDecodedY2)
|
||||
mDecodedY2 = aUpdateRect->YMost();
|
||||
if (aUpdateRect->XMost() > mDecodedX2)
|
||||
mDecodedX2 = aUpdateRect->XMost();
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------
|
||||
@@ -431,6 +488,7 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
{
|
||||
PhRect_t clip = { {aDX, aDY}, {aDX + aDWidth-1, aDY + aDHeight-1} };
|
||||
PhPoint_t pos = { aDX - aSX, aDY - aSY};
|
||||
int use_zoom = 0;
|
||||
|
||||
if( !aSWidth || !aSHeight || !aDWidth || !aDHeight ) return NS_OK;
|
||||
|
||||
@@ -456,43 +514,86 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
else
|
||||
#endif
|
||||
{
|
||||
#if 0
|
||||
if( (aSWidth != aDWidth || aSHeight != aDHeight) &&
|
||||
(mPhImageZoom == NULL || mPhImageZoom->size.w != aDWidth || mPhImageZoom->size.h != aDHeight))
|
||||
{
|
||||
if ( mPhImageZoom ) {
|
||||
if ( PgShmemDestroy( mPhImageZoom->image ) == -1 )
|
||||
free(mPhImageZoom->image);
|
||||
free( mPhImageZoom );
|
||||
}
|
||||
PhRect_t bounds = {{aSX, aSY}, {aSX + aSWidth - 1, aSY + aSHeight - 1}};
|
||||
|
||||
if ((aDHeight * mPhImage.bpl) < IMAGE_SHMEM_THRESHOLD)
|
||||
mPhImageZoom = MyPiResizeImage(&mPhImage, &bounds, aDWidth, aDHeight, Pi_USE_COLORS);
|
||||
else
|
||||
mPhImageZoom = MyPiResizeImage(&mPhImage, &bounds, aDWidth, aDHeight, Pi_USE_COLORS|Pi_SHMEM);
|
||||
if ( mPhImageZoom == NULL )
|
||||
///* ATENTIE */ printf( "this=%p size=%d,%d src=(%d %d %d %d) dest=(%d %d %d %d)\n",
|
||||
//this, mPhImage.size.w, mPhImage.size.h, aSX, aSY, aSWidth, aSHeight, aDX, aDY, aDWidth, aDHeight );
|
||||
|
||||
if( (aSWidth != aDWidth || aSHeight != aDHeight) ) {
|
||||
|
||||
/* the case below happens frequently - a 1x1 image needs to be stretched, or a line or a column */
|
||||
if( aSWidth == 1 && aSHeight == 1 || aSWidth == 1 && aSHeight == aDHeight || aDHeight == 1 && aSWidth == aDWidth ) {
|
||||
/* you can strech the image by drawing it repeateadly */
|
||||
|
||||
PhPoint_t space = { 0, 0 };
|
||||
PhPoint_t rep = { aDWidth, aDHeight };
|
||||
|
||||
PgSetMultiClip( 1, &clip );
|
||||
if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
|
||||
PgDrawRepPhImagemx( &mPhImage, 0, &pos, &rep, &space );
|
||||
else
|
||||
{
|
||||
PgMap_t map;
|
||||
map.dim.w = mAlphaWidth;
|
||||
map.dim.h = mAlphaHeight;
|
||||
map.bpl = mAlphaRowBytes;
|
||||
map.bpp = mAlphaDepth;
|
||||
map.map = (char *)mAlphaBits;
|
||||
PgSetAlphaBlend(&map, 0);
|
||||
PgAlphaOn();
|
||||
PgDrawRepPhImagemx( &mPhImage, 0, &pos, &rep, &space );
|
||||
PgAlphaOff();
|
||||
}
|
||||
PgSetMultiClip( 0, NULL );
|
||||
|
||||
return NS_OK;
|
||||
pos.x = aDX;
|
||||
pos.y = aDY;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
/* keeping the proportions, what is the size of mPhImageZoom that can give use the aDWidth and aDHeight? */
|
||||
PRInt32 scaled_w = aDWidth * mPhImage.size.w / aSWidth;
|
||||
PRInt32 scaled_h = aDHeight * mPhImage.size.h / aSHeight;
|
||||
use_zoom = 1;
|
||||
|
||||
if( mPhImageZoom == NULL || mPhImageZoom->size.w != scaled_w || mPhImageZoom->size.h != scaled_h || mDecodedY2_when_scaled != mDecodedY2 ) {
|
||||
|
||||
/* we already had a scaled image, but the scaling factor was different from what we need now */
|
||||
|
||||
if ( mPhImageZoom ) {
|
||||
mPhImageZoom->flags = Ph_RELEASE_IMAGE_ALL;
|
||||
PhReleaseImage( mPhImageZoom );
|
||||
free( mPhImageZoom );
|
||||
mPhImageZoom = NULL;
|
||||
}
|
||||
|
||||
/* record the mDecodedY1 at the time of scaling */
|
||||
mDecodedY2_when_scaled = mDecodedY2;
|
||||
|
||||
/* this is trying to estimate the image data size of the zoom image */
|
||||
if (( mPhImage.bpl * scaled_w * scaled_h / mPhImage.size.w ) < IMAGE_SHMEM_THRESHOLD)
|
||||
mPhImageZoom = MyPiResizeImage( &mPhImage, NULL, scaled_w, scaled_h, Pi_USE_COLORS);
|
||||
else mPhImageZoom = MyPiResizeImage( &mPhImage, NULL, scaled_w, scaled_h, Pi_USE_COLORS|Pi_SHMEM);
|
||||
|
||||
///* ATENTIE */ printf( "\t\t\tzoom from=%d,%d to=%d,%d\n", mPhImage.size.w, mPhImage.size.h, scaled_w, scaled_h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PgSetMultiClip( 1, &clip );
|
||||
if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
|
||||
PgDrawPhImagemx( &pos, mPhImageZoom ? mPhImageZoom : &mPhImage, 0 );
|
||||
PgDrawPhImagemx( &pos, use_zoom ? mPhImageZoom : &mPhImage, 0 );
|
||||
else
|
||||
{
|
||||
PgMap_t map;
|
||||
|
||||
map.dim.w = mWidth;
|
||||
map.dim.h = mHeight;
|
||||
map.dim.w = mAlphaWidth;
|
||||
map.dim.h = mAlphaHeight;
|
||||
map.bpl = mAlphaRowBytes;
|
||||
map.bpp = mAlphaDepth;
|
||||
map.map = (char *)mAlphaBits;
|
||||
PgSetAlphaBlend(&map, 0);
|
||||
PgAlphaOn();
|
||||
PgDrawPhImagemx( &pos, mPhImageZoom ? mPhImageZoom : &mPhImage, 0 );
|
||||
PgDrawPhImagemx( &pos, use_zoom ? mPhImageZoom : &mPhImage, 0 );
|
||||
PgAlphaOff();
|
||||
|
||||
}
|
||||
@@ -539,8 +640,8 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
{
|
||||
PgMap_t map;
|
||||
|
||||
map.dim.w = mWidth;
|
||||
map.dim.h = mHeight;
|
||||
map.dim.w = mAlphaWidth;
|
||||
map.dim.h = mAlphaHeight;
|
||||
map.bpl = mAlphaRowBytes;
|
||||
map.bpp = mAlphaDepth;
|
||||
map.map = (char *)mAlphaBits;
|
||||
@@ -720,6 +821,19 @@ nsImagePh::UnlockImagePixels(PRBool aMaskPixels)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Set the decoded dimens of the image
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsImagePh::SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2 )
|
||||
{
|
||||
mDecodedX1 = x1;
|
||||
mDecodedY1 = y1;
|
||||
mDecodedX2 = x2;
|
||||
mDecodedY2 = y2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
|
||||
* @update - saari 03/08/01
|
||||
@@ -770,6 +884,7 @@ NS_IMETHODIMP nsImagePh::DrawToImage(nsIImage* aDstImage,
|
||||
darea.pos.y = aDY;
|
||||
darea.size.w = sarea.size.w = aDWidth;
|
||||
darea.size.h = sarea.size.h = aDHeight;
|
||||
|
||||
if ((aDWidth != mPhImage.size.w) || (aDHeight != mPhImage.size.h))
|
||||
{
|
||||
release = 1;
|
||||
@@ -777,11 +892,12 @@ NS_IMETHODIMP nsImagePh::DrawToImage(nsIImage* aDstImage,
|
||||
pimage = MyPiResizeImage(&mPhImage, NULL, aDWidth, aDHeight, Pi_USE_COLORS);
|
||||
else
|
||||
pimage = MyPiResizeImage(&mPhImage, NULL, aDWidth, aDHeight, Pi_USE_COLORS|Pi_SHMEM);
|
||||
if( !pimage ) pimage = &mPhImage;
|
||||
}
|
||||
else
|
||||
pimage = &mPhImage;
|
||||
if ( pimage == NULL )
|
||||
return NS_OK;
|
||||
else pimage = &mPhImage;
|
||||
|
||||
if( pimage == NULL ) return NS_OK;
|
||||
|
||||
start = (aDY * dest->mPhImage.bpl) + (aDX * mNumBytesPixel);
|
||||
for (y = 0; y < pimage->size.h; y++)
|
||||
{
|
||||
@@ -803,6 +919,3 @@ NS_IMETHODIMP nsImagePh::DrawToImage(nsIImage* aDstImage,
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,15 +57,29 @@ public:
|
||||
virtual PRInt32 GetWidth();
|
||||
virtual PRUint8* GetBits();
|
||||
virtual void* GetBitInfo();
|
||||
virtual PRBool GetIsRowOrderTopToBottom() { return PR_TRUE; }
|
||||
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
|
||||
virtual PRInt32 GetLineStride();
|
||||
|
||||
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
|
||||
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
|
||||
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
|
||||
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
|
||||
virtual PRInt32 GetDecodedY2() { return mDecodedY2;}
|
||||
|
||||
NS_IMETHOD SetNaturalWidth(PRInt32 naturalwidth) { mNaturalWidth= naturalwidth; return NS_OK;}
|
||||
NS_IMETHOD SetNaturalHeight(PRInt32 naturalheight) { mNaturalHeight= naturalheight; return NS_OK;}
|
||||
virtual PRInt32 GetNaturalWidth() {return mNaturalWidth; }
|
||||
virtual PRInt32 GetNaturalHeight() {return mNaturalHeight; }
|
||||
|
||||
|
||||
virtual nsColorMap* GetColorMap();
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, \
|
||||
PRInt32 aSHeight, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord aDHeight);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
nsRect &aSrcRect, nsRect &aTileRect);
|
||||
|
||||
@@ -74,19 +88,26 @@ public:
|
||||
|
||||
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
|
||||
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
|
||||
virtual PRBool IsOptimized();
|
||||
|
||||
virtual nsresult Optimize(nsIDeviceContext* aContext);
|
||||
|
||||
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
|
||||
virtual PRUint8* GetAlphaBits();
|
||||
virtual PRInt32 GetAlphaWidth();
|
||||
virtual PRInt32 GetAlphaHeight();
|
||||
virtual PRInt32 GetAlphaLineStride();
|
||||
virtual nsIImage* DuplicateImage();
|
||||
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
|
||||
virtual PRInt32 GetAlphaLevel();
|
||||
/**
|
||||
* Get the alpha depth for the image mask
|
||||
* @update - lordpixel 2001/05/16
|
||||
* @return the alpha mask depth for the image, ie, 0, 1 or 8
|
||||
*/
|
||||
virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);}
|
||||
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
|
||||
|
||||
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
|
||||
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
|
||||
@@ -105,6 +126,8 @@ private:
|
||||
PRUint8* mImageBits; // starting address of DIB bits
|
||||
PRUint8 *mConvertedBits; // NEW
|
||||
PRInt32 mSizeImage; // number of bytes
|
||||
PRBool mIsTopToBottom;
|
||||
PRBool mIsOptimized;
|
||||
PRInt8 mNumBytesPixel; // number of bytes per pixel
|
||||
PRInt16 mNumPaletteColors; // either 8 or 0
|
||||
|
||||
@@ -117,12 +140,21 @@ private:
|
||||
PRUint8 *mAlphaBits; // alpha layer if we made one
|
||||
PRInt8 mAlphaDepth; // alpha layer depth
|
||||
PRInt16 mAlphaRowBytes; // number of bytes per row in the image for tha alpha
|
||||
PRInt16 mAlphaWidth; // alpha layer width
|
||||
PRInt16 mAlphaHeight; // alpha layer height
|
||||
PRInt8 mImageCache; // place to save off the old image for fast animation
|
||||
PRInt16 mAlphaLevel; // an alpha level every pixel uses
|
||||
PhImage_t mPhImage;
|
||||
PhImage_t *mPhImageZoom; // the zoomed version of mPhImage
|
||||
PRInt32 mDecodedY2_when_scaled;
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
PdOffscreenContext_t *mPhImageCache; // Cache for the image offscreen
|
||||
#endif
|
||||
|
||||
PRUint8 mFlags; // flags set by ImageUpdated
|
||||
PRUint8 mImageFlags; // flags set by ImageUpdated
|
||||
PRInt32 mNaturalWidth;
|
||||
PRInt32 mNaturalHeight;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -58,11 +58,13 @@ static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
|
||||
#define clry c->rect.lr.y
|
||||
|
||||
nsRegionPh :: nsRegionPh( ) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
mRegion = NULL;
|
||||
mRegionType = eRegionComplexity_empty;
|
||||
}
|
||||
|
||||
nsRegionPh :: nsRegionPh( PhTile_t *tiles ) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
mRegion = tiles; /* assume ownership */
|
||||
mRegionType = (mRegion == NULL) ? eRegionComplexity_empty : eRegionComplexity_complex;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ PhGC_t *nsRenderingContextPh::mPtGC = nsnull;
|
||||
|
||||
nsRenderingContextPh :: nsRenderingContextPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mGC = nsnull;
|
||||
mTranMatrix = nsnull;
|
||||
mClipRegion = nsnull;
|
||||
@@ -527,11 +529,10 @@ NS_IMETHODIMP nsRenderingContextPh :: GetLineStyle( nsLineStyle &aLineStyle )
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetFont( const nsFont& aFont, nsIAtom* aLangGroup )
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetFont( const nsFont& aFont, nsIAtom* aLangGroup )
|
||||
{
|
||||
nsIFontMetrics* newMetrics;
|
||||
nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, newMetrics );
|
||||
|
||||
nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, newMetrics );
|
||||
if( NS_SUCCEEDED( rv ) ) {
|
||||
rv = SetFont( newMetrics );
|
||||
NS_RELEASE( newMetrics );
|
||||
@@ -591,7 +592,7 @@ NS_IMETHODIMP nsRenderingContextPh :: GetCurrentTransform( nsTransform2D *&aTran
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface )
|
||||
NS_IMETHODIMP nsRenderingContextPh :: CreateDrawingSurface( const nsRect &aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface )
|
||||
{
|
||||
if( nsnull == mSurface ) {
|
||||
aSurface = nsnull;
|
||||
@@ -1064,6 +1065,84 @@ NS_IMETHODIMP nsRenderingContextPh::DrawString(const PRUnichar* aString, PRUint3
|
||||
return DrawString( p, strlen( p ), aX, aY, aSpacing );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, nscoord aX, nscoord aY )
|
||||
{
|
||||
nscoord width, height;
|
||||
|
||||
// we have to do this here because we are doing a transform below
|
||||
width = NSToCoordRound(mP2T * aImage->GetWidth());
|
||||
height = NSToCoordRound(mP2T * aImage->GetHeight());
|
||||
|
||||
return DrawImage( aImage, aX, aY, width, height );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, const nsRect& aRect )
|
||||
{
|
||||
return DrawImage( aImage, aRect.x, aRect.y, aRect.width, aRect.height );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight )
|
||||
{
|
||||
nscoord x, y, w, h;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTranMatrix->TransformCoord(&x, &y, &w, &h);
|
||||
return (aImage->Draw(*this, mSurface, x, y, w, h));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect )
|
||||
{
|
||||
nsRect sr,dr;
|
||||
|
||||
sr = aSRect;
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x -= mTranMatrix->GetXTranslationCoord();
|
||||
sr.y -= mTranMatrix->GetYTranslationCoord();
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
||||
return aImage->Draw(*this, mSurface,
|
||||
sr.x, sr.y,
|
||||
sr.width, sr.height,
|
||||
dr.x, dr.y,
|
||||
dr.width, dr.height);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/16/00 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawTile( nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1, nscoord aWidth,nscoord aHeight )
|
||||
{
|
||||
mTranMatrix->TransformCoord(&aX0,&aY0,&aWidth,&aHeight);
|
||||
mTranMatrix->TransformCoord(&aX1,&aY1);
|
||||
|
||||
nsRect srcRect (0, 0, aWidth, aHeight);
|
||||
nsRect tileRect(aX0, aY0, aX1-aX0, aY1-aY0);
|
||||
|
||||
((nsImagePh*)aImage)->DrawTile(*this, mSurface, srcRect, tileRect);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawTile( nsIImage *aImage, nscoord aSrcXOffset, nscoord aSrcYOffset, const nsRect &aTileRect )
|
||||
{
|
||||
nsRect tileRect( aTileRect );
|
||||
nsRect srcRect(0, 0, aSrcXOffset, aSrcYOffset);
|
||||
mTranMatrix->TransformCoord(&srcRect.x, &srcRect.y, &srcRect.width, &srcRect.height);
|
||||
mTranMatrix->TransformCoord(&tileRect.x, &tileRect.y, &tileRect.width, &tileRect.height);
|
||||
|
||||
if( tileRect.width > 0 && tileRect.height > 0 )
|
||||
((nsImagePh*)aImage)->DrawTile(*this, mSurface, srcRect.width, srcRect.height, tileRect);
|
||||
else
|
||||
NS_ASSERTION(aTileRect.width > 0 && aTileRect.height > 0,
|
||||
"You can't draw an image with a 0 width or height!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits( nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY, const nsRect &aDestBounds, PRUint32 aCopyFlags )
|
||||
{
|
||||
PhArea_t darea, sarea;
|
||||
@@ -1137,12 +1216,10 @@ NS_IMETHODIMP nsRenderingContextPh::GetBoundingMetrics(const PRUnichar* aStrin
|
||||
|
||||
void nsRenderingContextPh::UpdateGC()
|
||||
{
|
||||
nscolor acolor = mCurrentColor;
|
||||
|
||||
PgSetGC(mGC); /* new */
|
||||
PgSetStrokeColor(NS_TO_PH_RGB(acolor));
|
||||
PgSetTextColor(NS_TO_PH_RGB(acolor));
|
||||
PgSetFillColor(NS_TO_PH_RGB(acolor));
|
||||
PgSetStrokeColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetTextColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetFillColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetStrokeDash(mLineStyle, strlen((char *)mLineStyle), 0x10000);
|
||||
|
||||
// valuesMask = GdkGCValuesMask(valuesMask | GDK_GC_FUNCTION);
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
NS_IMETHOD SetColor(nscolor aColor);
|
||||
NS_IMETHOD GetColor(nscolor &aColor) const;
|
||||
|
||||
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
|
||||
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
|
||||
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
|
||||
|
||||
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
NS_IMETHOD Scale(float aSx, float aSy);
|
||||
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
|
||||
|
||||
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
|
||||
NS_IMETHOD CreateDrawingSurface(const nsRect &aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
|
||||
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
|
||||
|
||||
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
|
||||
@@ -167,6 +167,16 @@ public:
|
||||
NS_IMETHOD GetTextDimensions(const PRUnichar *aString, PRUint32 aLength,
|
||||
nsTextDimensions& aDimensions, PRInt32 *aFontID);
|
||||
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
|
||||
nscoord aWidth, nscoord aHeight);
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight);
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage, nscoord aSrcXOffset, nscoord aSrcYOffset,
|
||||
const nsRect &aTileRect);
|
||||
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
|
||||
@@ -190,9 +200,6 @@ public:
|
||||
#endif /* MOZ_MATHML */
|
||||
|
||||
|
||||
// nsIRenderingContextPh
|
||||
// NS_IMETHOD CreateDrawingSurface(PhGC_t *aGC, nsDrawingSurface &aSurface);
|
||||
|
||||
// NS_IMETHOD SetClipRegion(PhTile_t *aTileList, nsClipCombine aCombine, PRBool &aClipState);
|
||||
NS_IMETHOD CommonInit();
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
nsScreenManagerPh :: nsScreenManagerPh( ) {
|
||||
NS_INIT_ISUPPORTS();
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
// has changed.
|
||||
|
||||
@@ -44,11 +44,15 @@
|
||||
nsScreenPh :: nsScreenPh ( ) {
|
||||
PhSysInfo_t SysInfo;
|
||||
PhRect_t rect;
|
||||
char *p = NULL;
|
||||
char *p;
|
||||
int inp_grp;
|
||||
PhRid_t rid;
|
||||
PhRegion_t region;
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
p = NULL;
|
||||
|
||||
/* Initialize the data members */
|
||||
/* Get the Screen Size and Depth*/
|
||||
p = getenv("PHIG");
|
||||
|
||||
Reference in New Issue
Block a user