CheckPoint. Exact bytes of viewSource doesn't work yet. I think the
problem is that selectAll isn't working due to the window not being realized. We'll see. Next step is to get it working! M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java - rewrite getSource() to call native code, instead of using the DOM. M src_moz/CurrentPageImpl.cpp - re-enable nativeGetSource(). M src_moz/EmbedWindow.cpp M src_moz/EmbedWindow.h - fill out dtor - add InitNoChrome. M test/automated/src/classes/org/mozilla/webclient/CurrentPageTest.java - comment out test classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java src_moz/CurrentPageImpl.cpp src_moz/EmbedWindow.cpp src_moz/EmbedWindow.h test/automated/src/classes/org/mozilla/webclient/CurrentPageTest.java git-svn-id: svn://10.0.0.236/trunk@171314 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -203,6 +203,7 @@ public String getCurrentURL()
|
||||
|
||||
public Document getDOM()
|
||||
{
|
||||
// PENDING(edburns): run this on the event thread.
|
||||
Document result = nativeGetDOM(getNativeBrowserControl());
|
||||
return result;
|
||||
}
|
||||
@@ -227,11 +228,17 @@ public String getSource()
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Document doc = getDOM();
|
||||
String HTMLContent = null;
|
||||
final Selection selection = new SelectionImpl();
|
||||
|
||||
if (null != doc) {
|
||||
HTMLContent = domDumper.dump(doc);
|
||||
}
|
||||
|
||||
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
|
||||
public Object run() {
|
||||
nativeGetSource(CurrentPageImpl.this.getNativeBrowserControl(),
|
||||
selection);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
HTMLContent = selection.toString();
|
||||
|
||||
return HTMLContent;
|
||||
}
|
||||
|
||||
@@ -309,11 +316,7 @@ native public Document nativeGetDOM(int webShellPtr);
|
||||
|
||||
// webclient.PageInfo getPageInfo();
|
||||
|
||||
/* PENDING(ashuk): remove this from here and in the motif directory
|
||||
* native public String nativeGetSource();
|
||||
|
||||
* native public byte [] nativeGetSourceBytes(int webShellPtr, boolean viewMode);
|
||||
*/
|
||||
native public void nativeGetSource(int webShellPtr, Selection selection);
|
||||
|
||||
native public void nativeResetFind(int webShellPtr);
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#include "EmbedWindow.h"
|
||||
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIWebPageDescriptor.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIWebBrowserFind.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
@@ -458,44 +460,99 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Curren
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
|
||||
/* PENDING(ashuk): remove this from here and in the motif directory
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
(JNIEnv * env, jobject jobj)
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSource
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject selection)
|
||||
{
|
||||
jstring result = nsnull;
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
return result;
|
||||
// get the nsIWebPageDescriptor for the existing window
|
||||
nsCOMPtr<nsIWebBrowser> oldWebBrowser = nsnull;
|
||||
rv = nativeBrowserControl->mWindow->GetWebBrowser(getter_AddRefs(oldWebBrowser));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get existing webBrowser for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> oldDocShell = do_GetInterface(oldWebBrowser);
|
||||
if (!oldDocShell) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get existing docShell for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebPageDescriptor> oldPageDesc = do_GetInterface(oldDocShell);
|
||||
if (!oldPageDesc) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get existing pageDescriptor for view source window");
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsISupports> pageCookie = nsnull;
|
||||
rv = oldPageDesc->GetCurrentDescriptor(getter_AddRefs(pageCookie));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: GetCurrentDescriptor failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// create a new nsIDocShell
|
||||
EmbedWindow *embedWindow = new EmbedWindow();
|
||||
rv = embedWindow->InitNoChrome(nativeBrowserControl);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't init new window for view source");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = embedWindow->CreateWindow_(0,0);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't create new window for view source");
|
||||
return;
|
||||
}
|
||||
|
||||
// get the new page descriptor
|
||||
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
|
||||
rv = embedWindow->GetWebBrowser(getter_AddRefs(webBrowser));
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get webBrowser for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> newDocShell = do_GetInterface(webBrowser);
|
||||
if (!newDocShell) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get docShell for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebPageDescriptor> newPageDesc = do_GetInterface(newDocShell);
|
||||
if (!newPageDesc) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get pageDescriptor for view source window");
|
||||
return;
|
||||
}
|
||||
rv = newPageDesc->LoadPage(pageCookie,
|
||||
nsIWebPageDescriptor::DISPLAY_AS_SOURCE);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't load page for view source window");
|
||||
return;
|
||||
}
|
||||
// allow the page load to complete
|
||||
nativeBrowserControl->GetWrapperFactory()->ProcessEventLoop();
|
||||
|
||||
rv = embedWindow->SelectAll();
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't select all for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
rv = embedWindow->GetSelection(env, selection);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't get seletion for view source window");
|
||||
return;
|
||||
}
|
||||
|
||||
newPageDesc = nsnull;
|
||||
newDocShell = nsnull;
|
||||
webBrowser = nsnull;
|
||||
delete embedWindow;
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
* Method: nativeGetSourceBytes
|
||||
* Signature: ()[B
|
||||
*/
|
||||
|
||||
/* PENDING(ashuk): remove this from here and in the motif directory
|
||||
JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes
|
||||
(JNIEnv * env, jobject jobj, jint nativeBCPtr, jboolean viewMode)
|
||||
{
|
||||
|
||||
|
||||
NativeBrowserControl* nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
|
||||
|
||||
if (nativeBrowserControl->initComplete) {
|
||||
wsViewSourceEvent * actionEvent =
|
||||
new wsViewSourceEvent(nativeBrowserControl->docShell, ((JNI_TRUE == viewMode)? PR_TRUE : PR_FALSE));
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(nativeBrowserControl, event);
|
||||
}
|
||||
|
||||
jbyteArray result = nsnull;
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_webclient_impl_wrapper_0005fnative_CurrentPageImpl
|
||||
|
||||
@@ -64,6 +64,9 @@ EmbedWindow::EmbedWindow(void)
|
||||
EmbedWindow::~EmbedWindow(void)
|
||||
{
|
||||
ExitModalEventLoop(PR_FALSE);
|
||||
mBaseWindow = nsnull;
|
||||
mWebBrowser = nsnull;
|
||||
mOwner = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@@ -85,6 +88,25 @@ EmbedWindow::Init(NativeBrowserControl *aOwner)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedWindow::InitNoChrome(NativeBrowserControl *aOwner)
|
||||
{
|
||||
// save our owner for later
|
||||
mOwner = aOwner;
|
||||
|
||||
// create our nsIWebBrowser object and set up some basic defaults.
|
||||
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
||||
if (!mWebBrowser)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mWebBrowser->SetContainerWindow(nsnull);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(mWebBrowser);
|
||||
item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedWindow::CreateWindow_(PRUint32 width, PRUint32 height)
|
||||
{
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
virtual ~EmbedWindow();
|
||||
|
||||
nsresult Init (NativeBrowserControl *aOwner);
|
||||
nsresult InitNoChrome (NativeBrowserControl *aOwner);
|
||||
nsresult CreateWindow_ (PRUint32 width, PRUint32 height);
|
||||
void ReleaseChildren (void);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: CurrentPageTest.java,v 1.10 2005-03-22 15:58:51 edburns%acm.org Exp $
|
||||
* $Id: CurrentPageTest.java,v 1.11 2005-03-29 05:03:12 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -497,7 +497,7 @@ public class CurrentPageTest extends WebclientTestCase implements ClipboardOwner
|
||||
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);
|
||||
}
|
||||
|
||||
public void testGetSource() throws Exception {
|
||||
public void NOTtestGetSource() throws Exception {
|
||||
BrowserControl firstBrowserControl = null;
|
||||
DocumentLoadListenerImpl listener = null;
|
||||
Selection selection = null;
|
||||
|
||||
Reference in New Issue
Block a user