зеркало из https://github.com/mozilla/gecko-dev.git
PHOTON only, NOT PART OF BUILD
Fixes for printing (PR:112048), Fixes for context menu image saving, addition of scrollbar navigation via resources. Also removed references to nsIDiskDocument.h.
This commit is contained in:
Родитель
24ca068bb1
Коммит
762acd5b60
|
@ -159,8 +159,6 @@ EmbedPrivate::Init(PtWidget_t *aOwningWidget)
|
|||
mPrintGuard = NS_STATIC_CAST(nsIWebProgressListener *, mPrint);
|
||||
mPrint->Init(this);
|
||||
|
||||
m_PrintSettings = (nsIPrintSettings*)new nsPrintSettings();
|
||||
|
||||
// has the window creator service been set up?
|
||||
static int initialized = PR_FALSE;
|
||||
// Set up our window creator ( only once )
|
||||
|
@ -237,6 +235,10 @@ EmbedPrivate::Setup()
|
|||
uriListener = do_QueryInterface(mContentListenerGuard);
|
||||
webBrowser->SetParentURIContentListener(uriListener);
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(webBrowser));
|
||||
if (print)
|
||||
print->GetPrintSettings(getter_AddRefs(m_PrintSettings));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -320,7 +322,7 @@ EmbedPrivate::Destroy(void)
|
|||
mNavigation = nsnull;
|
||||
mFixup = nsnull;
|
||||
|
||||
m_PrintSettings = nsnull;
|
||||
//m_PrintSettings = nsnull;
|
||||
|
||||
// release session history
|
||||
mSessionHistory = nsnull;
|
||||
|
@ -401,6 +403,60 @@ EmbedPrivate::Forward(void)
|
|||
mNavigation->GoForward();
|
||||
}
|
||||
|
||||
void
|
||||
EmbedPrivate::ScrollUp(int amount)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> oDomWindow;
|
||||
nsresult rv = webBrowser->GetContentDOMWindow(getter_AddRefs(oDomWindow));
|
||||
|
||||
if (oDomWindow)
|
||||
rv = oDomWindow->ScrollBy(0, -amount);
|
||||
}
|
||||
void
|
||||
EmbedPrivate::ScrollDown(int amount)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> oDomWindow;
|
||||
nsresult rv = webBrowser->GetContentDOMWindow(getter_AddRefs(oDomWindow));
|
||||
|
||||
if (oDomWindow)
|
||||
rv = oDomWindow->ScrollBy(0, amount);
|
||||
}
|
||||
void
|
||||
EmbedPrivate::ScrollLeft(int amount)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> oDomWindow;
|
||||
nsresult rv = webBrowser->GetContentDOMWindow(getter_AddRefs(oDomWindow));
|
||||
|
||||
if (oDomWindow)
|
||||
rv = oDomWindow->ScrollBy(-amount, 0);
|
||||
}
|
||||
void
|
||||
EmbedPrivate::ScrollRight(int amount)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser;
|
||||
mWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> oDomWindow;
|
||||
nsresult rv = webBrowser->GetContentDOMWindow(getter_AddRefs(oDomWindow));
|
||||
|
||||
if (oDomWindow)
|
||||
rv = oDomWindow->ScrollBy(amount, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
EmbedPrivate::CanGoBack()
|
||||
{
|
||||
|
@ -471,7 +527,6 @@ EmbedPrivate::Print(PpPrintContext_t *pc)
|
|||
nsCOMPtr<nsIWebBrowserPrint> print( do_GetInterface( mWindow->mWebBrowser ) );
|
||||
|
||||
m_PrintSettings->SetEndPageRange((PRInt32) pc);
|
||||
m_PrintSettings->SetOrientation(1);
|
||||
print->Print(window, m_PrintSettings, mPrint);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,10 @@ class EmbedPrivate {
|
|||
void Reload(int32_t flags);
|
||||
void Back (void);
|
||||
void Forward (void);
|
||||
void ScrollUp(int amount);
|
||||
void ScrollDown(int amount);
|
||||
void ScrollLeft(int amount);
|
||||
void ScrollRight(int amount);
|
||||
void Cut (void);
|
||||
void Copy (void);
|
||||
void Paste (void);
|
||||
|
@ -142,7 +146,7 @@ nsCOMPtr<nsISupports> context;
|
|||
// the currently loaded uri
|
||||
nsString mURI;
|
||||
|
||||
nsIPrintSettings *m_PrintSettings;
|
||||
nsCOMPtr<nsIPrintSettings> m_PrintSettings;
|
||||
|
||||
// the number of widgets that have been created
|
||||
static PRUint32 sWidgetCount;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
// for do_CreateInstance
|
||||
#include <nsIComponentManager.h>
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
|
||||
#include <nsCWebBrowser.h>
|
||||
#include <nsIComponentManager.h>
|
||||
|
@ -188,7 +189,7 @@ EmbedWindow::SaveAs(char *fname)
|
|||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(fname, PR_TRUE, getter_AddRefs(file));
|
||||
persist->SaveDocument(nsnull, file, nsnull);
|
||||
persist->SaveDocument(nsnull, file, nsnull, nsnull, 0, 0);
|
||||
return (0);
|
||||
}
|
||||
return 1;
|
||||
|
@ -579,15 +580,15 @@ NS_IMETHODIMP EmbedWindow::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent
|
|||
memset(&cmenu, 0, sizeof(PtMozillaContextCb_t));
|
||||
if (aContextFlags & CONTEXT_NONE)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_NONE;
|
||||
if (aContextFlags & CONTEXT_LINK)
|
||||
else if (aContextFlags & CONTEXT_LINK)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_LINK;
|
||||
if (aContextFlags & CONTEXT_IMAGE)
|
||||
else if (aContextFlags & CONTEXT_IMAGE)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_IMAGE;
|
||||
if (aContextFlags & CONTEXT_DOCUMENT)
|
||||
else if (aContextFlags & CONTEXT_DOCUMENT)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_DOCUMENT;
|
||||
if (aContextFlags & CONTEXT_TEXT)
|
||||
else if (aContextFlags & CONTEXT_TEXT)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_TEXT;
|
||||
if (aContextFlags & CONTEXT_INPUT)
|
||||
else if (aContextFlags & CONTEXT_INPUT)
|
||||
cmenu.flags |= Pt_MOZ_CONTEXT_INPUT;
|
||||
|
||||
nsCOMPtr<nsIDOMMouseEvent> mouseEvent (do_QueryInterface( aEvent ));
|
||||
|
@ -597,24 +598,46 @@ NS_IMETHODIMP EmbedWindow::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent
|
|||
|
||||
PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo);
|
||||
|
||||
|
||||
/* store the url we clicked on */
|
||||
nsAutoString rightClickUrl;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
|
||||
if (aContextFlags & CONTEXT_IMAGE)
|
||||
{
|
||||
// Get the IMG SRC
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
if(NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
// Note that this string is in UCS2 format
|
||||
rv = linkElement->GetHref( rightClickUrl );
|
||||
if(NS_FAILED(rv)) {
|
||||
if( moz->rightClickUrl ) free( moz->rightClickUrl );
|
||||
moz->rightClickUrl = NULL;
|
||||
return NS_OK;
|
||||
rv = imgElement->GetSrc(rightClickUrl);
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
if( moz->rightClickUrl )
|
||||
free( moz->rightClickUrl );
|
||||
moz->rightClickUrl = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
|
||||
if(NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
if( moz->rightClickUrl ) free( moz->rightClickUrl );
|
||||
// Note that this string is in UCS2 format
|
||||
rv = linkElement->GetHref( rightClickUrl );
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
if( moz->rightClickUrl )
|
||||
free( moz->rightClickUrl );
|
||||
moz->rightClickUrl = NULL;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if( moz->rightClickUrl )
|
||||
free( moz->rightClickUrl );
|
||||
moz->rightClickUrl = ToNewCString(rightClickUrl);
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -62,8 +62,7 @@ CPPSRCS = \
|
|||
PtMozilla.cpp \
|
||||
EmbedStream.cpp \
|
||||
PromptService.cpp \
|
||||
nsUnknownContentTypeHandler.cpp \
|
||||
nsPrintSettingsImpl.cpp
|
||||
nsUnknownContentTypeHandler.cpp
|
||||
|
||||
SHARED_LIBRARY_LIBS= \
|
||||
$(DIST)/lib/libembed_base_s.$(LIB_SUFFIX) \
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsIDOMKeyListener.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "nsIDiskDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsMPFileLocProvider.h"
|
||||
|
@ -305,8 +304,26 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt )
|
|||
{
|
||||
if (argt->value == WWW_DIRECTION_FWD)
|
||||
moz->EmbedRef->Forward();
|
||||
else
|
||||
else if (argt->value == WWW_DIRECTION_BACK)
|
||||
moz->EmbedRef->Back();
|
||||
else
|
||||
{
|
||||
PhDim_t dim;
|
||||
|
||||
PtWidgetDim(widget, &dim);
|
||||
dim.w = (argt->value * dim.w)/100;
|
||||
dim.h = (argt->value * dim.h)/100;
|
||||
printf("Scroll: V: %d P: (%d, %d) \n", argt->value, dim.w, dim.h);
|
||||
|
||||
if (argt->value == WWW_DIRECTION_UP)
|
||||
moz->EmbedRef->ScrollUp(dim.h);
|
||||
else if (argt->value == WWW_DIRECTION_DOWN)
|
||||
moz->EmbedRef->ScrollDown(dim.h);
|
||||
else if (argt->value == WWW_DIRECTION_LEFT)
|
||||
moz->EmbedRef->ScrollLeft(dim.w);
|
||||
else if (argt->value == WWW_DIRECTION_RIGHT)
|
||||
moz->EmbedRef->ScrollRight(dim.w);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче