- rename initContext to NativeBrowserControl, at both the native and

java layers.

- Rework NativeEventThread to be usable without having the
  browserControl window realized.

- change who owns the NativEventThread to be the BrowserControl, by
  proxy through WrapperFactoryImpl.  Again, this is with a view toward
  using webclient without the browserControl window realized.

A webclient/src_moz/NativeBrowserControl.h
A webclient/src_moz/NativeBrowserControl.cpp

- Centerpiece of native Object hierarchy.  Owned by NativeEventThread.

M webclient/build-tests.xml

- reformat

- add new test, currently failing, for Navigation.

M webclient/classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java

- destroy our nativeBrowserControl.

M webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java

- Added API for obtaining the NativeEventThread for a BrowserControl.

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java

- rename nativeWebShell to nativeBrowserControl

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java

- rename nativeWebShell to nativeBrowserControl

- add method to get the NativeEventThread for this instance.

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java

- remove dependency on WindowControl

- make this class be the owner of the nativeBrowserControl instance.

- rename nativeWebShell to nativeBrowserControl

- renamed nativeInitialize to nativeStartup

- added nativeShutdown

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java

- remove delete() method.

- no longer owns NativeEventThread

- no longer owns nativeBrowserControl

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java

- Take over NativeEventThread ownership responsibilities from
  WindowControlImpl (by proxy for BrowserControl).

M webclient/src_moz/CBrowserContainer.cpp
M webclient/src_moz/CBrowserContainer.h
M webclient/src_moz/CurrentPageActionEvents.cpp
M webclient/src_moz/CurrentPageActionEvents.h
M webclient/src_moz/CurrentPageImpl.cpp
M webclient/src_moz/HistoryActionEvents.cpp
M webclient/src_moz/HistoryActionEvents.h
M webclient/src_moz/HistoryImpl.cpp
M webclient/src_moz/NativeEventThreadActionEvents.cpp
M webclient/src_moz/NativeEventThreadActionEvents.h
M webclient/src_moz/NavigationActionEvents.cpp
M webclient/src_moz/NavigationActionEvents.h
M webclient/src_moz/NavigationImpl.cpp
M webclient/src_moz/PromptActionEvents.cpp
M webclient/src_moz/PromptActionEvents.h
M webclient/src_moz/WindowControlActionEvents.cpp
M webclient/src_moz/WindowControlActionEvents.h
M webclient/src_moz/WindowCreator.cpp
M webclient/src_moz/WindowCreator.h

- rename nativeWebShell to nativeBrowserControl

M webclient/src_moz/Makefile.in

- comment out not yet fixed per-window sources

- add NativeBrowserControl.cpp

M webclient/src_moz/NativeEventThread.cpp

- major refactoring.  Much of the work is now being done in
  NativeBrowserControl.cpp

M webclient/src_moz/WindowControlImpl.cpp

- remove functionality now located in NativeEventThread and
  NativeBrowserControl.

M webclient/src_moz/WrapperFactoryImpl.cpp

- flesh out native{Create,Destroy}BrowserControl.

M webclient/src_moz/ns_globals.h

- remove gActionQueue and gEmbeddedThread.  Moved into class
  NativeBrowserControl.

M webclient/src_moz/ns_util.cpp

- rename initContext to NativeBrowserControl

- get action queue from NativeBrowserControl

M webclient/src_moz/ns_util.h

- remove WebShellInitContext!  It's finally a class now, called
  NativeBrowserControl.

M webclient/test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java

- added new testcase to show create/deleteBrowserControl works.
This commit is contained in:
edburns%acm.org 2004-04-10 21:50:39 +00:00
parent 6d32713258
commit 0995c89706
41 changed files with 861 additions and 812 deletions

File diff suppressed because one or more lines are too long

View File

@ -114,6 +114,9 @@ public BrowserControlImpl(WrapperFactory yourWrapper)
void delete()
{
wrapperFactory.destroyNativeBrowserControl(this);
if (null != myCanvas) {
// Make sure we're not showing.
if (myCanvas.isShowing()) {
@ -146,7 +149,6 @@ void delete()
((ImplObject)windowControl).delete();
windowControl = null;
}
// since bookmarks and prefs are static, we must not deallocate them
// here. That is done in WrapperFactoryImpl.terminate()

View File

@ -65,6 +65,20 @@ public interface WrapperFactory {
public int getNativeBrowserControl(BrowserControl bc);
/**
* <p>I would like this method to be on BrowserControl itself, but
* that would mean exposing implementation specific elements on the
* public java API. Therefore, the WrapperFactory needs to be able
* to return the NativeEventThread given a java BrowserControl.</p>
*
*/
public Object getNativeEventThread(BrowserControl bc);
/***
* <p>Also destroys the NativeEventThread.</p>
*
*/
public void destroyNativeBrowserControl(BrowserControl bc);
}

View File

@ -174,7 +174,7 @@ public void removeBookmark(BookmarkEntry bookmark)
{
ParameterCheck.nonNull(bookmark);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getPageInfo has not yet been implemented.\n");
}
@ -185,8 +185,8 @@ public BookmarkEntry newBookmarkEntry(String url)
getBookmarks();
int newNode;
if (-1 != (newNode = nativeNewRDFNode(getNativeWebShell(), url, false))) {
result = new BookmarkEntryImpl(getNativeWebShell(),
if (-1 != (newNode = nativeNewRDFNode(getNativeBrowserControl(), url, false))) {
result = new BookmarkEntryImpl(getNativeBrowserControl(),
newNode, null);
// use put instead of setProperty for jdk1.1.x compatibility.
result.getProperties().put(BookmarkEntry.NAME, url);
@ -212,7 +212,7 @@ public BookmarkEntry newBookmarkFolder(String name)
BookmarkEntry result = null;
getBookmarks();
if (null == (result = new BookmarkEntryImpl(getNativeWebShell(), -1, null))) {
if (null == (result = new BookmarkEntryImpl(getNativeBrowserControl(), -1, null))) {
throw new NullPointerException("Can't create bookmark folder for: " +
name);
}

View File

@ -93,10 +93,10 @@ public CurrentPageImpl(WrapperFactory yourFactory,
public void copyCurrentSelectionToSystemClipboard()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeCopyCurrentSelectionToSystemClipboard(getNativeWebShell());
nativeCopyCurrentSelectionToSystemClipboard(getNativeBrowserControl());
}
}
@ -104,9 +104,9 @@ public Selection getSelection() {
Selection selection = new SelectionImpl();
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeGetSelection(getNativeWebShell(), selection);
nativeGetSelection(getNativeBrowserControl(), selection);
}
return selection;
@ -120,18 +120,18 @@ public void highlightSelection(Selection selection) {
int endOffset = selection.getEndOffset();
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeHighlightSelection(getNativeWebShell(), startContainer, endContainer, startOffset, endOffset);
nativeHighlightSelection(getNativeBrowserControl(), startContainer, endContainer, startOffset, endOffset);
}
}
}
public void clearAllSelections() {
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeClearAllSelections(getNativeWebShell());
nativeClearAllSelections(getNativeBrowserControl());
}
}
@ -141,7 +141,7 @@ public void findInPage(String stringToFind, boolean forward, boolean matchCase)
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeFindInPage(getNativeWebShell(), stringToFind, forward, matchCase);
nativeFindInPage(getNativeBrowserControl(), stringToFind, forward, matchCase);
}
}
@ -150,7 +150,7 @@ public void findNextInPage()
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeFindNextInPage(getNativeWebShell());
nativeFindNextInPage(getNativeBrowserControl());
}
}
@ -160,14 +160,14 @@ public String getCurrentURL()
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
result = nativeGetCurrentURL(getNativeWebShell());
result = nativeGetCurrentURL(getNativeBrowserControl());
}
return result;
}
public Document getDOM()
{
Document result = nativeGetDOM(getNativeWebShell());
Document result = nativeGetDOM(getNativeBrowserControl());
return result;
}
@ -176,7 +176,7 @@ public Properties getPageInfo()
Properties result = null;
/* synchronized(getBrowserControl()) {
result = nativeGetPageInfo(getNativeWebShell());
result = nativeGetPageInfo(getNativeBrowserControl());
}
return result;
*/
@ -254,7 +254,7 @@ public void resetFind()
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeResetFind(getNativeWebShell());
nativeResetFind(getNativeBrowserControl());
}
}
@ -263,7 +263,7 @@ public void selectAll()
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeSelectAll(getNativeWebShell());
nativeSelectAll(getNativeBrowserControl());
}
}
@ -272,7 +272,7 @@ public void print()
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativePrint(getNativeWebShell());
nativePrint(getNativeBrowserControl());
}
}
@ -281,7 +281,7 @@ public void printPreview(boolean preview)
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativePrintPreview(getNativeWebShell(), preview);
nativePrintPreview(getNativeBrowserControl(), preview);
}
}
@ -332,7 +332,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("CurrentPageImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.2 2004/03/05 15:34:24 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $");
}

View File

@ -29,7 +29,6 @@ import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.EventRegistration2;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.DocumentLoadEvent;
import org.mozilla.webclient.DocumentLoadListener;
@ -60,7 +59,7 @@ public class EventRegistrationImpl extends ImplObjectNative implements EventRegi
/**
* the Java thread for processing events, owned by WindowControlImpl
* the Java thread for processing events, owned by WrapperFactoryImpl
*/
@ -74,20 +73,9 @@ public EventRegistrationImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
// pull out the NativeEventThread from the WindowControl
try {
WindowControl windowControl = (WindowControl)
getBrowserControl().queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
if (windowControl instanceof WindowControlImpl) {
nativeEventThread =
((WindowControlImpl)windowControl).getNativeEventThread();
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
// pull out the NativeEventThread from the WrapperFactory
nativeEventThread = getNativeEventThread();
}
public void delete()
@ -121,7 +109,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -141,7 +129,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -161,7 +149,7 @@ public void addMouseListener(MouseListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -194,7 +182,7 @@ public void removeMouseListener(MouseListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -222,7 +210,7 @@ public void addNewWindowListener(NewWindowListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -242,7 +230,7 @@ public void removeNewWindowListener(NewWindowListener listener)
{
ParameterCheck.nonNull(listener);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
Assert.assert_it(null != nativeEventThread);
ParameterCheck.nonNull(listener);
@ -271,7 +259,7 @@ public static void main(String [] args)
Log.setApplicationName("EventRegistrationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.2 2004/03/05 15:34:24 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@ -77,21 +77,21 @@ public HistoryImpl(WrapperFactory yourFactory,
public void back()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeBack(getNativeWebShell());
nativeBack(getNativeBrowserControl());
}
}
public boolean canBack()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
boolean result = false;
synchronized(getBrowserControl()) {
result = nativeCanBack(getNativeWebShell());
result = nativeCanBack(getNativeBrowserControl());
}
return result;
}
@ -99,11 +99,11 @@ public boolean canBack()
public HistoryEntry [] getBackList()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
HistoryEntry [] result = null;
/* synchronized(getBrowserControl()) {
result = nativeGetBackList(getNativeWebShell());
result = nativeGetBackList(getNativeBrowserControl());
}
return result;
*/
@ -114,10 +114,10 @@ public HistoryEntry [] getBackList()
public void clearHistory()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
/* synchronized(getBrowserControl()) {
nativeClearHistory(getNativeWebShell());
nativeClearHistory(getNativeBrowserControl());
}
*/
@ -129,21 +129,21 @@ public void clearHistory()
public void forward()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeForward(getNativeWebShell());
nativeForward(getNativeBrowserControl());
}
}
public boolean canForward()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
boolean result = false;
synchronized(getBrowserControl()) {
result = nativeCanForward(getNativeWebShell());
result = nativeCanForward(getNativeBrowserControl());
}
return result;
}
@ -152,10 +152,10 @@ public HistoryEntry [] getForwardList()
{
HistoryEntry [] result = null;
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
/* synchronized(getBrowserControl()) {
result = nativeGetForwardList(getNativeWebShell());
result = nativeGetForwardList(getNativeBrowserControl());
}
return result;
*/
@ -167,10 +167,10 @@ public HistoryEntry [] getHistory()
{
HistoryEntry [] result = null;
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
/* synchronized(getBrowserControl()) {
result = nativeGetHistory(getNativeWebShell());
result = nativeGetHistory(getNativeBrowserControl());
}
return result;
*/
@ -182,11 +182,11 @@ public HistoryEntry getHistoryEntry(int historyIndex)
{
ParameterCheck.noLessThan(historyIndex, 0);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
HistoryEntry result = null;
/* synchronized(getBrowserControl()) {
result = nativeGetHistoryEntry(getNativeWebShell(), historyIndex);
result = nativeGetHistoryEntry(getNativeBrowserControl(), historyIndex);
}
return result;
*/
@ -197,11 +197,11 @@ public HistoryEntry getHistoryEntry(int historyIndex)
public int getCurrentHistoryIndex()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
int result = -1;
synchronized(getBrowserControl()) {
result = nativeGetCurrentHistoryIndex(getNativeWebShell());
result = nativeGetCurrentHistoryIndex(getNativeBrowserControl());
}
return result;
}
@ -210,21 +210,21 @@ public void setCurrentHistoryIndex(int historyIndex)
{
ParameterCheck.noLessThan(historyIndex, 0);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeSetCurrentHistoryIndex(getNativeWebShell(), historyIndex);
nativeSetCurrentHistoryIndex(getNativeBrowserControl(), historyIndex);
}
}
public int getHistoryLength()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
int result = -1;
synchronized(getBrowserControl()) {
result = nativeGetHistoryLength(getNativeWebShell());
result = nativeGetHistoryLength(getNativeBrowserControl());
}
return result;
}
@ -233,11 +233,11 @@ public String getURLForIndex(int historyIndex)
{
ParameterCheck.noLessThan(historyIndex, 0);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
String result = null;
synchronized(getBrowserControl()) {
result = nativeGetURLForIndex(getNativeWebShell(), historyIndex);
result = nativeGetURLForIndex(getNativeBrowserControl(), historyIndex);
}
return result;
}
@ -283,7 +283,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("HistoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.2 2004/03/05 15:34:24 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $");
}

View File

@ -80,30 +80,6 @@ public ImplObjectNative(WrapperFactory yourFactory,
myFactory = yourFactory;
}
/**
* Note how we call super.delete() at the end. THIS IS VERY IMPORTANT. <P>
* ImplObjectNative subclasses that further override delete() are <P>
<CODE><PRE>
BookmarksImpl.java
EventRegistrationImpl.java
NativeEventThread.java
WindowControlImpl.java
</PRE><CODE> <P>
* All other ImplObject subclasses don't have any local Ivars and thus
* don't need to override delete().
*/
public void delete()
{
getWrapperFactory().destroyNativeBrowserControl(getBrowserControl());
super.delete();
}
protected WrapperFactory getWrapperFactory() {
return myFactory;
}
@ -115,7 +91,7 @@ protected WrapperFactory getWrapperFactory() {
*/
protected int getNativeWebShell() {
protected int getNativeBrowserControl() {
if (-1 == nativeWebShell) {
nativeWebShell =
getWrapperFactory().getNativeBrowserControl(getBrowserControl());
@ -123,4 +99,9 @@ protected int getNativeWebShell() {
return nativeWebShell;
}
protected NativeEventThread getNativeEventThread() {
return (NativeEventThread)
getWrapperFactory().getNativeEventThread(getBrowserControl());
}
} // end of class ImplObject

View File

@ -34,7 +34,6 @@ import java.util.Enumeration;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserControlCanvas;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.DocumentLoadEvent;
import org.mozilla.webclient.DocumentLoadListener;
import org.mozilla.webclient.NewWindowEvent;
@ -84,15 +83,7 @@ private Vector listenersToRemove;
*/
private int nativeWebShell = -1;
/**
* a reference to the WindowControl that created us.
*/
private WindowControl windowControl;
private int nativeBrowserControl = -1;
private BrowserControl browserControl;
@ -115,7 +106,8 @@ private Enumeration tempEnum;
// Constructors
//
public NativeEventThread(String threadName, BrowserControl yourBrowserControl)
public NativeEventThread(String threadName, int yourNativeWebShell,
BrowserControl yourBrowserControl)
{
super(threadName);
ParameterCheck.nonNull(yourBrowserControl);
@ -126,25 +118,14 @@ public NativeEventThread(String threadName, BrowserControl yourBrowserControl)
browserControl = yourBrowserControl;
try {
windowControl = (WindowControl)
browserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
nativeWebShell = windowControl.getNativeWebShell();
browserControlCanvas = (BrowserControlCanvas)
browserControl.queryInterface(BrowserControl.BROWSER_CONTROL_CANVAS_NAME);
}
catch (Exception e) {
System.out.println("NativeEventThread constructor: Exception: " + e +
" " + e.getMessage());
}
nativeBrowserControl = yourNativeWebShell;
}
/**
* This is a very delicate method, and possibly subject to race
* condition problems. To combat this, our first step is to set our
* browserControlCanvas to null, within a synchronized block which
* browserControl to null, within a synchronized block which
* synchronizes on the same object used in the run() method's event
* loop. By setting the browserControlCanvas ivar to null, we cause the
* run method to return.
@ -156,7 +137,7 @@ public void delete()
// setting this to null causes the run thread to exit
synchronized(this) {
// this has to be inside the synchronized block!
browserControlCanvas = null;
browserControl = null;
synchronized (this) {
try {
wait();
@ -171,8 +152,7 @@ public void delete()
listenersToAdd = null;
doRemoveListeners();
listenersToRemove = null;
nativeWebShell = -1;
windowControl = null;
nativeBrowserControl = -1;
browserControl = null;
tempEnum = null;
}
@ -183,15 +163,15 @@ public void delete()
/**
* This method is the heart of webclient. It should only be called when
* WindowControlImpl.createWindow() is called. It calls
* nativeInitialize, which does the per-window initialization, including
* This method is the heart of webclient. It is called from
* {@link WrapperFactoryImpl#getNativeEventThread}. It calls
* nativeStartup, which does the per-window initialization, including
* creating the native event queue which corresponds to this instance,
* then enters into an infinite loop where processes native events, then
* checks to see if there are any listeners to add, and adds them if
* necessary.
* @see nativeInitialize
* @see nativeStartup
* @see nativeProcessEvents
@ -202,19 +182,18 @@ public void delete()
public void run()
{
// this.setPriority(Thread.MIN_PRIORITY);
Assert.assert_it(-1 != nativeWebShell);
Assert.assert_it(null != windowControl);
Assert.assert_it(-1 != nativeBrowserControl);
nativeInitialize(nativeWebShell);
nativeStartup(nativeBrowserControl);
// IMPORTANT: tell the windowControl, who is waiting for this
// IMPORTANT: tell the browserControl, who is waiting for this
// message, that we have initialized successfully.
synchronized(windowControl) {
synchronized(browserControl) {
try {
windowControl.notify();
browserControl.notify();
}
catch (Exception e) {
System.out.println("NativeEventThread.run: Exception: trying to send notify() to windowControl: " + e + " " + e.getMessage());
System.out.println("NativeEventThread.run: Exception: trying to send notify() to browserControl: " + e + " " + e.getMessage());
}
}
@ -229,11 +208,9 @@ public void run()
synchronized (this) {
// this has to be inside the synchronized block!
if (null == this.browserControlCanvas) {
// if we get here, this Thread is terminating, destroy
// the initContext and notify the WindowControl
((WindowControlImpl)windowControl).nativeDestroyInitContext(nativeWebShell);
if (null == this.browserControl) {
try {
nativeShutdown(nativeBrowserControl);
notify();
}
catch (Exception e) {
@ -243,7 +220,7 @@ public void run()
}
if (this == firstThread) {
nativeProcessEvents(nativeWebShell);
nativeProcessEvents(nativeBrowserControl);
}
if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
@ -252,7 +229,7 @@ public void run()
while (tempEnum.hasMoreElements()) {
WCEventListenerWrapper tempListener =
(WCEventListenerWrapper) tempEnum.nextElement();
nativeAddListener(nativeWebShell,tempListener.listener,
nativeAddListener(nativeBrowserControl,tempListener.listener,
tempListener.listenerClassName);
}
// use removeAllElements instead of clear for jdk1.1.x
@ -286,7 +263,7 @@ private void doRemoveListeners()
if (listenerObj instanceof String) {
listenerString = (String) listenerObj;
if (listenerString.equals("all")) {
nativeRemoveAllListeners(nativeWebShell);
nativeRemoveAllListeners(nativeBrowserControl);
return;
}
else {
@ -296,7 +273,7 @@ private void doRemoveListeners()
else {
WCEventListenerWrapper tempListener =
(WCEventListenerWrapper) listenerObj;
nativeRemoveListener(nativeWebShell,
nativeRemoveListener(nativeBrowserControl,
tempListener.listener,
tempListener.listenerClassName);
@ -312,6 +289,10 @@ private void doRemoveListeners()
// Package methods
//
int getNativeBrowserControl() {
return nativeBrowserControl;
}
/**
* Takes the abstract WebclientEventListener instance and adds it to a
@ -320,7 +301,7 @@ private void doRemoveListeners()
* The vector is a vector of WCEventListenerWrapper instances. In run()
* these are unpacked and sent to nativeAddListener like this:
* nativeAddListener(nativeWebShell,tempListener.listener,
* nativeAddListener(nativeBrowserControl,tempListener.listener,
* tempListener.listenerClassName); <P>
* @see run
@ -329,8 +310,7 @@ private void doRemoveListeners()
void addListener(WCEventListenerWrapper newListener)
{
Assert.assert_it(-1 != nativeWebShell);
Assert.assert_it(null != windowControl);
Assert.assert_it(-1 != nativeBrowserControl);
synchronized (this) {
if (null == listenersToAdd) {
@ -352,8 +332,7 @@ void addListener(WCEventListenerWrapper newListener)
void removeListener(WCEventListenerWrapper newListener)
{
Assert.assert_it(-1 != nativeWebShell);
Assert.assert_it(null != windowControl);
Assert.assert_it(-1 != nativeBrowserControl);
synchronized (this) {
if (null == listenersToRemove) {
@ -390,8 +369,7 @@ void nativeEventOccurred(WebclientEventListener target,
ParameterCheck.nonNull(target);
ParameterCheck.nonNull(targetClassName);
Assert.assert_it(-1 != nativeWebShell);
Assert.assert_it(null != windowControl);
Assert.assert_it(-1 != nativeBrowserControl);
WebclientEvent event = null;
@ -433,7 +411,7 @@ void nativeEventOccurred(WebclientEventListener target,
/**
* Takes the int from WindowControlImpl.nativeCreateInitContext, the
* Takes the int from ImplObjectNative.getNativeBrowserControl, the
* meaning of which is left up to the implementation, and does any
* per-window creation and initialization tasks. <P>
@ -442,7 +420,21 @@ void nativeEventOccurred(WebclientEventListener target,
*/
public native void nativeInitialize(int webShellPtr);
public native void nativeStartup(int webShellPtr);
/**
* Takes the int from ImplObjectNative.getNativeBrowserControl, the
* meaning of which is left up to the implementation, and does any
* per-window creation and initialization tasks. <P>
* For mozilla, this means creating the nsIWebShell instance, attaching
* to the native event queue, creating the nsISessionHistory instance, etc.
*/
public native void nativeShutdown(int webShellPtr);
/**

View File

@ -82,10 +82,10 @@ public void loadURL(String absoluteURL)
{
ParameterCheck.nonNull(absoluteURL);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeLoadURL(getNativeWebShell(), absoluteURL);
nativeLoadURL(getNativeBrowserControl(), absoluteURL);
}
}
@ -102,10 +102,10 @@ public void loadFromStream(InputStream stream, String uri,
}
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeLoadFromStream(getNativeWebShell(), stream,
nativeLoadFromStream(getNativeBrowserControl(), stream,
uri, contentType, contentLength,
loadInfo);
}
@ -115,20 +115,20 @@ public void refresh(long loadFlags)
{
ParameterCheck.noLessThan(loadFlags, 0);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeRefresh(getNativeWebShell(), loadFlags);
nativeRefresh(getNativeBrowserControl(), loadFlags);
}
}
public void stop()
{
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeStop(getNativeWebShell());
nativeStop(getNativeBrowserControl());
}
}
@ -136,10 +136,10 @@ public void setPrompt(Prompt yourPrompt)
{
ParameterCheck.nonNull(yourPrompt);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeSetPrompt(getNativeWebShell(), yourPrompt);
nativeSetPrompt(getNativeBrowserControl(), yourPrompt);
}
}
@ -155,7 +155,7 @@ public void post(String absoluteUrl,
{
ParameterCheck.nonNull(absoluteUrl);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
int postDataLength = 0;
int postHeadersLength = 0;
@ -174,7 +174,7 @@ public void post(String absoluteUrl,
}
synchronized(getBrowserControl()) {
nativePost(getNativeWebShell(),
nativePost(getNativeBrowserControl(),
absoluteUrl,
target,
postDataLength,
@ -223,7 +223,7 @@ public static void main(String [] args)
Log.setApplicationName("NavigationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.2 2004/03/05 15:34:24 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@ -52,8 +52,6 @@ public class WindowControlImpl extends ImplObjectNative implements WindowControl
// Relationship Instance Variables
protected NativeEventThread eventThread = null;
//
// Constructors and Initializers
//
@ -64,21 +62,6 @@ public WindowControlImpl(WrapperFactory yourFactory,
super(yourFactory, yourBrowserControl);
}
/**
* First, we delete our eventThread, which causes the eventThread to
* stop running, which causes the initContext to be deleted.
* deallocates native resources for this window.
*/
public void delete()
{
Assert.assert_it(null != eventThread, "eventThread shouldn't be null at delete time");
eventThread.delete();
eventThread = null;
}
//
// Class methods
//
@ -92,12 +75,6 @@ public void delete()
// Package Methods
//
NativeEventThread getNativeEventThread()
{
return eventThread;
}
//
// Methods from WindowControl
//
@ -106,10 +83,10 @@ public void setBounds(Rectangle newBounds)
{
ParameterCheck.nonNull(newBounds);
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeWebShell());
Assert.assert_it(-1 != getNativeBrowserControl());
synchronized(getBrowserControl()) {
nativeSetBounds(getNativeWebShell(), newBounds.x, newBounds.y,
nativeSetBounds(getNativeBrowserControl(), newBounds.x, newBounds.y,
newBounds.width, newBounds.height);
}
}
@ -119,37 +96,13 @@ public void createWindow(int nativeWindow, Rectangle bounds)
ParameterCheck.greaterThan(nativeWindow, 0);
ParameterCheck.nonNull(bounds);
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
synchronized(this) {
/**
getNativeWebShell() = nativeCreateInitContext(nativeWindow, bounds.x,
bounds.y, bounds.width,
bounds.height, getBrowserControl());
**/
eventThread = new NativeEventThread("EventThread-" +
getNativeWebShell(),
getBrowserControl());
// IMPORTANT: the nativeEventThread initializes all the
// native browser stuff, then sends us notify().
eventThread.start();
try {
wait();
}
catch (Exception e) {
System.out.println("WindowControlImpl.createWindow: interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
" " + e.getMessage());
}
}
}
}
public int getNativeWebShell()
{
getWrapperFactory().verifyInitialized();
return getNativeWebShell();
return getNativeBrowserControl();
}
public void moveWindowTo(int x, int y)
@ -157,7 +110,7 @@ public void moveWindowTo(int x, int y)
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeMoveWindowTo(getNativeWebShell(), x, y);
nativeMoveWindowTo(getNativeBrowserControl(), x, y);
}
}
@ -174,7 +127,7 @@ public void repaint(boolean forceRepaint)
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeRepaint(getNativeWebShell(), forceRepaint);
nativeRepaint(getNativeBrowserControl(), forceRepaint);
}
}
@ -183,7 +136,7 @@ public void setVisible(boolean newState)
getWrapperFactory().verifyInitialized();
synchronized(getBrowserControl()) {
nativeSetVisible(getNativeWebShell(), newState);
nativeSetVisible(getNativeBrowserControl(), newState);
}
}
@ -202,26 +155,6 @@ public void setFocus()
public native void nativeSetBounds(int webShellPtr, int x, int y,
int w, int h);
/**
* This method allows the native code to create a "context object" that
* is passed to all subsequent native methods. This context object is
* opaque to Java and should just be a pointer cast to a jint. For
* example, this method could create a struct that encapsulates the
* native window (from the nativeWindow argument), the x, y, width,
* height parameters for the window, and any other per browser window
* information. <P>
* Subsequent native methods would know how to turn this jint into the
* struct.
*/
public native int nativeCreateInitContext(int nativeWindow,
int x, int y, int width, int height, BrowserControl BrowserControlImpl);
public native void nativeDestroyInitContext(int nativeWindow);
public native void nativeMoveWindowTo(int webShellPtr, int x, int y);
public native void nativeRemoveFocus(int webShellPtr);
@ -245,7 +178,7 @@ public static void main(String [] args)
Log.setApplicationName("WindowControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.2 2004/03/05 15:34:24 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.3 2004/04/10 21:50:38 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

View File

@ -27,6 +27,7 @@ import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.impl.BrowserControlImpl;
import org.mozilla.webclient.Bookmarks;
import org.mozilla.webclient.Preferences;
import org.mozilla.webclient.ProfileManager;
@ -60,11 +61,11 @@ protected int nativeContext = -1;
/**
* <p>keys: BrowserControl instances</p>
*
* <p>values: the native counterpart to that BrowserControl
* instance, as an Integer.</p>
* <p>values: NativeEventThread instances that correspond to this
* window.</p>
*
*/
protected Map nativeBrowserControls = null;
protected Map nativeEventThreads = null;
// Relationship Instance Variables
@ -95,7 +96,7 @@ protected ProfileManager profileManager = null;
public WrapperFactoryImpl()
{
super();
nativeBrowserControls = new HashMap();
nativeEventThreads = new HashMap();
}
@ -257,34 +258,70 @@ public int getNativeContext() {
return nativeContext;
}
public int getNativeBrowserControl(BrowserControl bc) {
public Object getNativeEventThread(BrowserControl bc) {
verifyInitialized();
Integer result = null;
synchronized(this) {
if (null == (result = (Integer) nativeBrowserControls.get(bc))) {
NativeEventThread eventThread = null;
int nativeBrowserControl = -1;
synchronized(bc) {
// if this is the first time the nativeBrowserControl has been
// requested for this Java BrowserControl instance:
if (null ==
(eventThread = (NativeEventThread) nativeEventThreads.get(bc))) {
// spin up the NativeEventThread
try {
result = new Integer(nativeCreateBrowserControl(nativeContext));
nativeBrowserControls.put(bc, result);
nativeBrowserControl =
nativeCreateBrowserControl(nativeContext);
eventThread = new NativeEventThread("EventThread-" +
nativeBrowserControl,
nativeBrowserControl, bc);
// IMPORTANT: the nativeEventThread initializes all the
// native browser stuff, then sends us notify().
eventThread.start();
try {
bc.wait();
}
catch (Exception e) {
System.out.println("WindowControlImpl.createWindow: interrupted while waiting\n\t for NativeEventThread to notify(): " + e +
" " + e.getMessage());
}
nativeEventThreads.put(bc, eventThread);
}
catch (Exception e) {
result = new Integer(-1);
nativeBrowserControl = -1;
}
}
}
return result.intValue();
return eventThread;
}
public int getNativeBrowserControl(BrowserControl bc) {
NativeEventThread eventThread =
(NativeEventThread) getNativeEventThread(bc);
return eventThread.getNativeBrowserControl();
}
public void destroyNativeBrowserControl(BrowserControl bc) {
verifyInitialized();
Integer result = null;
NativeEventThread eventThread = null;
int nativeBrowserControl = -1;
synchronized(this) {
if (null != (result = (Integer) nativeBrowserControls.get(bc))) {
if (null !=
(eventThread = (NativeEventThread) nativeEventThreads.get(bc))){
nativeBrowserControl = eventThread.getNativeBrowserControl();
eventThread.delete();
try {
nativeDestroyBrowserControl(nativeContext, result.intValue());
nativeDestroyBrowserControl(nativeContext,
nativeBrowserControl);
}
catch (Exception e) {
System.out.println("Exception while destroying nativeBrowserControl:"
+ e.getMessage());
}
}
}

View File

@ -52,7 +52,7 @@ jobject gPromptProperties = nsnull;
PRInt32 CBrowserContainer::mInstanceCount = 0;
CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env,
WebShellInitContext *yourInitContext) :
NativeBrowserControl *yourInitContext) :
m_pOwner(pOwner), mJNIEnv(env), mInitContext(yourInitContext),
mDocTarget(nsnull), mMouseTarget(nsnull), mPrompt(nsnull),
mDomEventTarget(nsnull), inverseDepth(-1),

View File

@ -73,7 +73,7 @@ public:
public:
CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *yourJNIEnv, WebShellInitContext *yourInitContext);
CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *yourJNIEnv, NativeBrowserControl *yourInitContext);
CBrowserContainer();
@ -84,7 +84,7 @@ public:
protected:
nsIWebBrowser *m_pOwner;
JNIEnv *mJNIEnv;
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mDocTarget;
jobject mMouseTarget;
jobject mPrompt;

View File

@ -56,7 +56,7 @@
#include "nsIDOMNode.h"
#include "nsCRT.h"
wsCopySelectionEvent::wsCopySelectionEvent(WebShellInitContext *yourInitContext) :
wsCopySelectionEvent::wsCopySelectionEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -84,7 +84,7 @@ wsCopySelectionEvent::handleEvent ()
return result;
}
wsGetSelectionEvent::wsGetSelectionEvent(JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject yourSelection) :
wsGetSelectionEvent::wsGetSelectionEvent(JNIEnv *yourEnv, NativeBrowserControl *yourInitContext, jobject yourSelection) :
nsActionEvent(),
mEnv(yourEnv),
mInitContext(yourInitContext),
@ -218,7 +218,7 @@ wsGetSelectionEvent::handleEvent()
}
wsHighlightSelectionEvent::wsHighlightSelectionEvent(JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset) :
wsHighlightSelectionEvent::wsHighlightSelectionEvent(JNIEnv *yourEnv, NativeBrowserControl *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset) :
nsActionEvent(),
mEnv(yourEnv),
mInitContext(yourInitContext),
@ -302,7 +302,7 @@ wsHighlightSelectionEvent::handleEvent()
return result;
}
wsClearAllSelectionEvent::wsClearAllSelectionEvent(WebShellInitContext *yourInitContext) :
wsClearAllSelectionEvent::wsClearAllSelectionEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -339,7 +339,7 @@ wsClearAllSelectionEvent::handleEvent()
return result;
}
wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext) :
wsFindEvent::wsFindEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext),
mSearchString(nsnull),
@ -348,7 +348,7 @@ wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext) :
{
}
wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext, jstring searchString,
wsFindEvent::wsFindEvent(NativeBrowserControl *yourInitContext, jstring searchString,
jboolean forward, jboolean matchCase) :
nsActionEvent(),
mInitContext(yourInitContext),
@ -417,7 +417,7 @@ wsFindEvent::handleEvent ()
* wsGetURLEvent
*/
wsGetURLEvent::wsGetURLEvent(WebShellInitContext *yourInitContext) :
wsGetURLEvent::wsGetURLEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -474,7 +474,7 @@ wsGetURLEvent::handleEvent ()
} // handleEvent()
wsSelectAllEvent::wsSelectAllEvent(WebShellInitContext *yourInitContext) :
wsSelectAllEvent::wsSelectAllEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -552,7 +552,7 @@ wsGetDOMEvent::handleEvent ()
}
// Deal with the Print events. TODO: we need a print setup UI in Java
wsPrintEvent::wsPrintEvent(WebShellInitContext *yourInitContext) :
wsPrintEvent::wsPrintEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -587,7 +587,7 @@ wsPrintEvent::handleEvent ()
}
wsPrintPreviewEvent::wsPrintPreviewEvent(WebShellInitContext *yourInitContext, jboolean preview) :
wsPrintPreviewEvent::wsPrintPreviewEvent(NativeBrowserControl *yourInitContext, jboolean preview) :
nsActionEvent(),
mInitContext(yourInitContext), mInPreview(preview)
{

View File

@ -41,22 +41,22 @@
class wsCopySelectionEvent : public nsActionEvent {
public:
wsCopySelectionEvent(WebShellInitContext *yourInitContext);
wsCopySelectionEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsFindEvent : public nsActionEvent {
public:
wsFindEvent(WebShellInitContext *yourInitContext, jstring searchString,
wsFindEvent(NativeBrowserControl *yourInitContext, jstring searchString,
jboolean forward, jboolean matchCase);
wsFindEvent(WebShellInitContext *yourInitContext);
wsFindEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jstring mSearchString;
jboolean mForward;
jboolean mMatchCase;
@ -64,19 +64,19 @@ protected:
class wsGetURLEvent : public nsActionEvent {
public:
wsGetURLEvent (WebShellInitContext *yourInitContext);
wsGetURLEvent (NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsSelectAllEvent : public nsActionEvent {
public:
wsSelectAllEvent(WebShellInitContext *yourInitContext);
wsSelectAllEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
/* PENDING(ashuk): remove this from here and in the motif directory
@ -105,43 +105,43 @@ protected:
class wsPrintEvent : public nsActionEvent {
public:
wsPrintEvent(WebShellInitContext *yourInitContext);
wsPrintEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsPrintPreviewEvent : public nsActionEvent {
public:
wsPrintPreviewEvent(WebShellInitContext *yourInitContext, jboolean preview);
wsPrintPreviewEvent(NativeBrowserControl *yourInitContext, jboolean preview);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jboolean mInPreview;
};
class wsGetSelectionEvent: public nsActionEvent {
public:
wsGetSelectionEvent (JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject yourSelection);
wsGetSelectionEvent (JNIEnv *yourEnv, NativeBrowserControl *yourInitContext, jobject yourSelection);
void * handleEvent (void);
protected:
JNIEnv * mEnv;
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mSelection;
};
class wsHighlightSelectionEvent: public nsActionEvent {
public:
wsHighlightSelectionEvent (JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset);
wsHighlightSelectionEvent (JNIEnv *yourEnv, NativeBrowserControl *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset);
void * handleEvent (void);
protected:
JNIEnv *mEnv;
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mStartContainer;
jobject mEndContainer;
PRInt32 mStartOffset;
@ -151,11 +151,11 @@ protected:
class wsClearAllSelectionEvent: public nsActionEvent {
public:
wsClearAllSelectionEvent (WebShellInitContext *yourInitContext);
wsClearAllSelectionEvent (NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
#endif /* CurrentPageActionEvents_h___ */

View File

@ -42,7 +42,7 @@
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeCopyCurrentSelectionToSystemClipboard
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext->initComplete) {
wsCopySelectionEvent * actionEvent = new wsCopySelectionEvent(initContext);
@ -55,7 +55,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject selection)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl *initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed nativeGetSelection");
@ -79,7 +79,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeHighlightSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject startContainer, jobject endContainer, jint startOffset, jint endOffset)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl *initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeHighlightSelection");
@ -97,7 +97,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeClearAllSelections
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl *initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeClearAllSelections");
@ -121,7 +121,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
(JNIEnv *env, jobject obj, jint webShellPtr, jstring searchString, jboolean forward, jboolean matchCase)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
jstring searchStringGlobalRef = (jstring) ::util_NewGlobalRef(env, searchString);
@ -152,7 +152,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
//First get the FindComponent object
PRBool found = PR_TRUE;
@ -178,7 +178,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Curren
char * charResult = nsnull;
jstring urlString = nsnull;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL");
@ -208,7 +208,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Curren
JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeGetDOM
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
jobject result = nsnull;
jlong documentLong = nsnull;
jclass clazz = nsnull;
@ -272,7 +272,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Cur
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext->initComplete) {
wsViewSourceEvent * actionEvent =
@ -296,7 +296,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Cur
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeResetFind
(JNIEnv * env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
}
@ -310,7 +310,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativeSelectAll
(JNIEnv * env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext->initComplete) {
wsSelectAllEvent * actionEvent = new wsSelectAllEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
@ -326,7 +326,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativePrint
(JNIEnv * env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext->initComplete) {
wsPrintEvent * actionEvent = new wsPrintEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
@ -342,7 +342,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPa
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_CurrentPageImpl_nativePrintPreview
(JNIEnv * env, jobject obj, jint webShellPtr, jboolean preview)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext->initComplete) {
wsPrintPreviewEvent * actionEvent = new wsPrintPreviewEvent(initContext, preview);
PLEvent * event = (PLEvent*) *actionEvent;

View File

@ -179,7 +179,7 @@ wsGoToEvent::handleEvent ()
* wsGetHistoryLengthEvent
*/
wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(WebShellInitContext
wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(NativeBrowserControl
*yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
@ -212,7 +212,7 @@ wsGetHistoryLengthEvent::handleEvent ()
* wsGetHistoryIndexEvent
*/
wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(WebShellInitContext *yourInitContext) :
wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(NativeBrowserControl *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
@ -241,7 +241,7 @@ wsGetHistoryIndexEvent::handleEvent ()
* wsGetURLForIndexEvent
*/
wsGetURLForIndexEvent::wsGetURLForIndexEvent(WebShellInitContext *yourInitContext,
wsGetURLForIndexEvent::wsGetURLForIndexEvent(NativeBrowserControl *yourInitContext,
PRInt32 historyIndex) :
nsActionEvent(),
mInitContext(yourInitContext),

View File

@ -36,7 +36,7 @@
#include "nsIWebNavigation.h"
#include "nsISHistory.h"
struct WebShellInitContext;
struct NativeBrowserControl;
class wsCanBackEvent : public nsActionEvent {
public:
@ -85,29 +85,29 @@ protected:
class wsGetHistoryLengthEvent : public nsActionEvent {
public:
wsGetHistoryLengthEvent(WebShellInitContext *yourInitContext);
wsGetHistoryLengthEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsGetHistoryIndexEvent : public nsActionEvent {
public:
wsGetHistoryIndexEvent (WebShellInitContext *yourInitContext);
wsGetHistoryIndexEvent (NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsGetURLForIndexEvent : public nsActionEvent {
public:
wsGetURLForIndexEvent(WebShellInitContext *yourInitContext,
wsGetURLForIndexEvent(NativeBrowserControl *yourInitContext,
PRInt32 historyIndex);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
PRInt32 mHistoryIndex;
};

View File

@ -41,7 +41,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeBack
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellBack");
@ -69,7 +69,7 @@ JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeCanBac
void * voidResult;
// PRBool voidResult;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanBack");
@ -110,7 +110,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_HistoryIm
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellForward");
@ -136,7 +136,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Histo
jobject jobj = obj;
void * voidResult;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellCanForward");
@ -190,7 +190,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetCurrentHist
void * voidResult = nsnull;
jint result = -1;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryIndex");
@ -217,7 +217,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeSetCurrentHist
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetCurrentHistoryIndex");
@ -244,7 +244,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_HistoryImpl_nativeGetHistoryLeng
void * voidResult = nsnull;
jint result = -1;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryLength");
@ -272,7 +272,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Histor
char * charResult = nsnull;
jstring urlString = nsnull;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL");

View File

@ -85,34 +85,37 @@ REQUIRES = xpcom \
gtkembedmoz \
$(NULL)
# BROKEN SOURCES
# nsActions.cpp \
# CBrowserContainer.cpp \
# PromptActionEvents.cpp \
# CurrentPageImpl.cpp \
# CurrentPageActionEvents.cpp \
# HistoryImpl.cpp \
# HistoryActionEvents.cpp \
# ISupportsPeer.cpp \
# NativeEventThreadActionEvents.cpp \
# NavigationImpl.cpp \
# NavigationActionEvents.cpp \
# InputStreamShim.cpp \
# WindowControlImpl.cpp \
# WindowControlActionEvents.cpp \
# WindowCreator.cpp \
CPPSRCS = \
NativeBrowserControl.cpp \
NativeEventThread.cpp \
ns_util.cpp \
ns_util_export.cpp \
dom_util.cpp \
nsActions.cpp \
rdf_util.cpp \
BookmarksImpl.cpp \
CBrowserContainer.cpp \
PromptActionEvents.cpp \
CurrentPageImpl.cpp \
CurrentPageActionEvents.cpp \
HistoryImpl.cpp \
HistoryActionEvents.cpp \
ISupportsPeer.cpp \
NativeEventThread.cpp \
NativeEventThreadActionEvents.cpp \
NavigationImpl.cpp \
NavigationActionEvents.cpp \
InputStreamShim.cpp \
RDFEnumeration.cpp \
RDFTreeNode.cpp \
wsRDFObserver.cpp \
WindowControlImpl.cpp \
WindowControlActionEvents.cpp \
PreferencesImpl.cpp \
ProfileManagerImpl.cpp \
WrapperFactoryImpl.cpp \
WindowCreator.cpp \
$(NULL)
ifeq ($(OS_ARCH),Linux)

View File

@ -0,0 +1,285 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ann Sunhachawee
*/
#include "nsIEventQueueService.h" // for PLEventQueue
#include "nsIServiceManager.h" // for do_GetService
#include "nsEmbedAPI.h" // for NS_HandleEmbeddingEvent
#include "NativeBrowserControl.h"
#include "ns_util.h"
#ifdef XP_UNIX
#include <unistd.h>
#include "gdksuperwin.h"
#include "gtkmozarea.h"
extern "C" {
static int wc_x_error (Display *display,
XErrorEvent *error);
}
#endif
PLEventQueue *NativeBrowserControl::sActionQueue = nsnull;
PRThread *NativeBrowserControl::sEmbeddedThread = nsnull;
PRBool NativeBrowserControl::sInitComplete = PR_FALSE;
NativeBrowserControl::NativeBrowserControl(void)
{
parentHWnd = nsnull;
mNavigation = nsnull;
mSessionHistory = nsnull;
mWindow = nsnull;
mEnv = nsnull;
mNativeEventThread = nsnull;
}
NativeBrowserControl::~NativeBrowserControl()
{
// PENDING(edburns): assert that this widget has been destroyed
}
nsresult
NativeBrowserControl::Init(JNIEnv * env, jobject newNativeEventThread)
{
mFailureCode = NS_ERROR_FAILURE;
//
// Do java communication initialization
//
mEnv = env;
// store the java NativeEventThread class
mNativeEventThread = ::util_NewGlobalRef(env, newNativeEventThread);
// This enables the listener to call back into java
util_InitializeShareInitContext(mEnv, &mShareContext);
//
// create the singleton event queue
//
// create the static sActionQueue
if (nsnull == sEmbeddedThread) {
nsCOMPtr<nsIEventQueueService>
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
if (!aEventQService) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
// Create the event queue.
mFailureCode = aEventQService->CreateThreadEventQueue();
sEmbeddedThread = PR_GetCurrentThread();
if (!sEmbeddedThread) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: Create UI Thread EventQueue: %d\n",
mFailureCode));
// We need to do something different for Unix
nsIEventQueue * EQueue = nsnull;
mFailureCode = aEventQService->GetThreadEventQueue(sEmbeddedThread, &EQueue);
if (NS_FAILED(mFailureCode)) {
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: Get UI Thread EventQueue: %d\n",
mFailureCode));
#ifdef XP_UNIX
gdk_input_add(EQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
EQueue);
#endif
PLEventQueue * plEventQueue = nsnull;
EQueue->GetPLEventQueue(&plEventQueue);
sActionQueue = plEventQueue;
if (!sActionQueue) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: get ActionQueue: %d\n",
mFailureCode));
#ifdef XP_UNIX
// The gdk_x_error function exits in some cases, we don't
// want that.
XSetErrorHandler(wc_x_error);
#endif
sInitComplete = PR_TRUE;
}
//
// create the EmbedWindow
//
//
// create the WindowCreator: see
// NativeEventThread->InitializeWindowCreator
//
return NS_OK;
}
nsresult
NativeBrowserControl::Realize(void *parentWinPtr, PRBool *aAlreadyRealized)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
void
NativeBrowserControl::Unrealize(void)
{
}
void
NativeBrowserControl::Show(void)
{
}
void
NativeBrowserControl::Hide(void)
{
}
void
NativeBrowserControl::Resize(PRUint32 aWidth, PRUint32 aHeight)
{
}
void
NativeBrowserControl::Destroy(void)
{
if (nsnull != mNativeEventThread) {
::util_DeleteGlobalRef(mEnv, mNativeEventThread);
}
// PENDING(edburns): take over the stuff from
// WindowControlActionEvents
// wsDeallocateInitContextEvent::handleEvent()
}
PRUint32
NativeBrowserControl::ProcessEventLoop(void)
{
if (PR_GetCurrentThread() != sEmbeddedThread) {
return 0;
}
#ifdef XP_UNIX
while(gtk_events_pending()) {
gtk_main_iteration();
}
#else
// PENDING(mark): Does this work on the Mac?
MSG msg;
PRBool wasHandled;
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
if (::GetMessage(&msg, nsnull, 0, 0)) {
wasHandled = PR_FALSE;
::NS_HandleEmbeddingEvent(msg, wasHandled);
if (!wasHandled) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
#endif
::PR_Sleep(PR_INTERVAL_NO_WAIT);
if (sInitComplete && sActionQueue) {
PLEvent * event = nsnull;
PL_ENTER_EVENT_QUEUE_MONITOR(sActionQueue);
if (::PL_EventAvailable(sActionQueue)) {
event = ::PL_GetEvent(sActionQueue);
}
PL_EXIT_EVENT_QUEUE_MONITOR(sActionQueue);
if (event != nsnull) {
::PL_HandleEvent(event);
}
}
// PENDING(edburns): revisit this. Not sure why this is necessary, but
// this fixes bug 44327
// printf("%c", 8); // 8 is ASCII for backspace
return 1;
}
nsresult
NativeBrowserControl::GetFailureCode(void)
{
return mFailureCode;
}
/* static */
PRBool
NativeBrowserControl::IsInitialized(void)
{
return sInitComplete;
}
#ifdef XP_UNIX
static int
wc_x_error (Display *display,
XErrorEvent *error)
{
if (error->error_code)
{
char buf[64];
XGetErrorText (display, error->error_code, buf, 63);
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
}
return 0;
}
#endif

View File

@ -0,0 +1,116 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Kirk Baker <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ann Sunhachawee
*/
#ifndef NativeBrowserControl_h
#define NativeBrowserControl_h
#include <nsCOMPtr.h>
#include <nsIWebNavigation.h> // for all Navigation commands
#include <nsISHistory.h>
#include <nsIDOMEventReceiver.h>
#ifdef XP_PC
#include <windows.h> // for HWND
#endif
#include "ns_util.h"
class EmbedWindow;
/**
* <p>Native analog to BrowserControl. Hosts per-window things. Maps
* closely to EmbedPrivate in GtkEmbed.</p>
*
*/
class NativeBrowserControl {
public:
NativeBrowserControl();
~NativeBrowserControl();
//
// public API
//
nsresult Init (JNIEnv *env, jobject nativeEventThread);
nsresult Realize (void* parentWinPtr, PRBool *aAlreadyRealized);
void Unrealize (void);
void Show (void);
void Hide (void);
void Resize (PRUint32 aWidth, PRUint32 aHeight);
void Destroy (void);
/**
* This function processes methods inserted into NativeBrowserControl's
* actionQueue. It is called once during the initialization of the
* NativeEventThread java thread, and infinitely in
* NativeEventThread.run()'s event loop. The call to PL_HandleEvent
* below, ends up calling the nsActionEvent subclass's handleEvent()
* method. After which it calls nsActionEvent::destroyEvent().
*/
PRUint32 ProcessEventLoop(void);
nsresult GetFailureCode (void);
static PRBool IsInitialized (void);
//
// Relationship ivars
//
#ifdef XP_UNIX
GtkWidget * parentHWnd;
#else
HWND parentHWnd;
#endif
nsCOMPtr<nsIWebNavigation> mNavigation;
nsCOMPtr<nsISHistory> mSessionHistory;
EmbedWindow * mWindow;
nsCOMPtr<nsISupports> mWindowGuard;
JNIEnv * mEnv;
jobject mNativeEventThread;
ShareInitContext mShareContext;
//
// Class vars
//
static PLEventQueue * sActionQueue;
static PRThread * sEmbeddedThread;
private:
nsresult mFailureCode;
static PRBool sInitComplete;
};
#endif // NativeBrowserControl_h

View File

@ -28,7 +28,6 @@
*/
#include "org_mozilla_webclient_impl_wrapper_0005fnative_NativeEventThread.h"
#include "CBrowserContainer.h"
#include "ns_util.h"
#include "ns_globals.h"
@ -55,24 +54,15 @@
#include "nsIDocShellTreeItem.h"
#include "nsIEventQueueService.h"
//nsIWebShell is included in ns_util.h
#include "NativeEventThreadActionEvents.h"
// #include "NativeEventThreadActionEvents.h"
#include "nsIWindowWatcher.h"
#include "nsIComponentRegistrar.h"
#include "WindowCreator.h"
#include "NativeBrowserControl.h"
#include "prlog.h" // for PR_ASSERT
#ifdef XP_UNIX
#include <unistd.h>
#include "gdksuperwin.h"
#include "gtkmozarea.h"
extern "C" {
static int wc_x_error (Display *display,
XErrorEvent *error);
}
#endif
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
@ -114,53 +104,12 @@ static const char *NS_DOCSHELL_PROGID = "component://netscape/docshell/html";
// Local functions
//
#ifdef XP_UNIX
static int
wc_x_error (Display *display,
XErrorEvent *error)
{
if (error->error_code)
{
char buf[64];
XGetErrorText (display, error->error_code, buf, 63);
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
}
return 0;
}
#endif
/**
* Called from InitMozillaStuff().
*/
int processEventLoop(WebShellInitContext * initContext);
/**
* Called from Java nativeInitialize to create the webshell
* and other mozilla things, then start the event loop.
*/
nsresult InitMozillaStuff (WebShellInitContext * arg);
//
// Local data
//
static PRBool gFirstTime = PR_TRUE;
PLEventQueue * gActionQueue = nsnull;
PRThread * gEmbeddedThread = nsnull;
nsISHistory *gHistory = nsnull;
WindowCreator * gCreatorCallback = nsnull;
@ -176,47 +125,63 @@ char * errorMessages[] = {
// JNI methods
//
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeInitialize
(JNIEnv *env, jobject obj, jint webShellPtr)
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeStartup
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
nsresult rv = NS_ERROR_FAILURE;
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nsnull == initContext) {
if (!nativeBrowserControl) {
::util_ThrowExceptionToJava(env,
"NULL webShellPtr passed to nativeInitialize.");
"NULL nativeBCPtr passed to nativeStartup.");
return;
}
rv = InitMozillaStuff(initContext);
rv = nativeBrowserControl->Init(env, obj);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env,
errorMessages[initContext->initFailCode]);
errorMessages[3]);
return;
}
nativeBrowserControl->ProcessEventLoop();
while (initContext->initComplete == FALSE) {
while (!nativeBrowserControl->IsInitialized()) {
::PR_Sleep(PR_INTERVAL_NO_WAIT);
if (initContext->initFailCode != 0) {
::util_ThrowExceptionToJava(env, errorMessages[initContext->initFailCode]);
if (NS_FAILED(nativeBrowserControl->GetFailureCode())) {
::util_ThrowExceptionToJava(env, errorMessages[3]);
return;
}
}
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeProcessEvents
(JNIEnv *env, jobject obj, jint webShellPtr)
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeShutdown
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
WebShellInitContext * initContext = (WebShellInitContext *) webShellPtr;
nsresult rv = NS_ERROR_FAILURE;
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nsnull == initContext) {
if (!nativeBrowserControl) {
::util_ThrowExceptionToJava(env,
"NULL webShellPtr passed to nativeProcessEvents.");
"NULL nativeBCPtr passed to nativeStartup.");
return;
}
nativeBrowserControl->Destroy();
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeProcessEvents
(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
NativeBrowserControl * nativeBrowserControl = (NativeBrowserControl *) nativeBCPtr;
if (nsnull == nativeBrowserControl) {
::util_ThrowExceptionToJava(env,
"NULL nativeBCPtr passed to nativeProcessEvents.");
return;
}
processEventLoop(initContext);
nativeBrowserControl->ProcessEventLoop();
}
/**
@ -239,24 +204,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEve
*/
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeAddListener
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject typedListener,
jstring listenerString)
{
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
/***************
NativeBrowserControl *nativeBrowserControl = (NativeBrowserControl *)nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null initContext passed tonativeAddListener");
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBrowserControl passed tonativeAddListener");
return;
}
if (nsnull == initContext->nativeEventThread) {
// store the java EventRegistrationImpl class in the initContext
initContext->nativeEventThread =
::util_NewGlobalRef(env, obj); // VERY IMPORTANT!!
// This enables the listener to call back into java
}
jclass clazz = nsnull;
int listenerType = 0;
const char *listenerStringChars = ::util_GetStringUTFChars(env,
@ -289,33 +248,34 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NativeEve
::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't create NewGlobalRef\n\tfor argument");
return;
}
PR_ASSERT(initContext->browserContainer);
PR_ASSERT(nativeBrowserControl->browserContainer);
switch(listenerType) {
case DOCUMENT_LOAD_LISTENER:
initContext->browserContainer->AddDocumentLoadListener(globalRef);
nativeBrowserControl->browserContainer->AddDocumentLoadListener(globalRef);
break;
case MOUSE_LISTENER:
initContext->browserContainer->AddMouseListener(globalRef);
nativeBrowserControl->browserContainer->AddMouseListener(globalRef);
break;
case NEW_WINDOW_LISTENER:
if (gCreatorCallback)
gCreatorCallback->AddNewWindowListener(globalRef);
break;
}
*********************/
return;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveListener
(JNIEnv *env, jobject obj, jint webShellPtr, jobject typedListener,
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject typedListener,
jstring listenerString)
{
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
/*******************
NativeBrowserControl *nativeBrowserControl = (NativeBrowserControl *)nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null initContext passed to nativeRemoveListener");
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBrowserControl passed to nativeRemoveListener");
return;
}
@ -344,95 +304,32 @@ Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveLi
return;
}
PR_ASSERT(initContext->browserContainer);
PR_ASSERT(nativeBrowserControl->browserContainer);
switch(listenerType) {
case DOCUMENT_LOAD_LISTENER:
initContext->browserContainer->RemoveDocumentLoadListener();
nativeBrowserControl->browserContainer->RemoveDocumentLoadListener();
break;
case MOUSE_LISTENER:
initContext->browserContainer->RemoveMouseListener();
nativeBrowserControl->browserContainer->RemoveMouseListener();
break;
}
*****************/
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveAllListeners(JNIEnv *env, jobject obj, jint webShellPtr)
Java_org_mozilla_webclient_impl_wrapper_1native_NativeEventThread_nativeRemoveAllListeners(JNIEnv *env, jobject obj, jint nativeBCPtr)
{
WebShellInitContext *initContext = (WebShellInitContext *)webShellPtr;
/*******************
NativeBrowserControl *nativeBrowserControl = (NativeBrowserControl *)nativeBCPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null initContext passed to nativeRemoveAllListeners");
if (nativeBrowserControl == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null nativeBrowserControl passed to nativeRemoveAllListeners");
return;
}
initContext->browserContainer->RemoveAllListeners();
}
/**
* This function processes methods inserted into WebShellInitContext's
* actionQueue. It is called once during the initialization of the
* NativeEventThread java thread, and infinitely in
* NativeEventThread.run()'s event loop. The call to PL_HandleEvent
* below, ends up calling the nsActionEvent subclass's handleEvent()
* method. After which it calls nsActionEvent::destroyEvent().
*/
int processEventLoop(WebShellInitContext * initContext)
{
if (PR_GetCurrentThread() != gEmbeddedThread)
return 0;
if (nsnull == initContext)
return 0;
#ifdef XP_UNIX
while(gtk_events_pending()) {
gtk_main_iteration();
}
#else
// PENDING(mark): Does this work on the Mac?
MSG msg;
PRBool wasHandled;
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
if (::GetMessage(&msg, nsnull, 0, 0)) {
wasHandled = PR_FALSE;
::NS_HandleEmbeddingEvent(msg, wasHandled);
if (!wasHandled) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
#endif
::PR_Sleep(PR_INTERVAL_NO_WAIT);
if ((initContext->initComplete) && (gActionQueue)) {
PLEvent * event = nsnull;
PL_ENTER_EVENT_QUEUE_MONITOR(gActionQueue);
if (::PL_EventAvailable(gActionQueue)) {
event = ::PL_GetEvent(gActionQueue);
}
PL_EXIT_EVENT_QUEUE_MONITOR(gActionQueue);
if (event != nsnull) {
::PL_HandleEvent(event);
}
}
if (initContext->stopThread) {
initContext->stopThread++;
return 0;
}
// PENDING(edburns): revisit this. Not sure why this is necessary, but
// this fixes bug 44327
// printf("%c", 8); // 8 is ASCII for backspace
return 1;
nativeBrowserControl->browserContainer->RemoveAllListeners();
*******************/
}
// Ashu
@ -461,10 +358,11 @@ static void event_processor_callback(gpointer data,
/* InitializeWindowCreator creates and hands off an object with a callback
to a window creation function. This is how all new windows are opened,
except any created directly by the embedding app. */
nsresult InitializeWindowCreator(WebShellInitContext * initContext)
/*****************
nsresult InitializeWindowCreator(NativeBrowserControl * nativeBrowserControl)
{
// create an nsWindowCreator and give it to the WindowWatcher service
gCreatorCallback = new WindowCreator(initContext);
gCreatorCallback = new WindowCreator(nativeBrowserControl);
if (gCreatorCallback)
{
nsCOMPtr<nsIWindowCreator> windowCreator(NS_STATIC_CAST(nsIWindowCreator *, gCreatorCallback));
@ -480,213 +378,111 @@ nsresult InitializeWindowCreator(WebShellInitContext * initContext)
}
return NS_ERROR_FAILURE;
}
*******************/
void DoMozInitialization(WebShellInitContext * initContext)
{
if (gFirstTime) {
nsresult rv = nsnull;
JNIEnv * env = initContext->env;
const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE");
if (nsnull != webclientLogFile) {
PR_SetLogFile(webclientLogFile);
// If this fails, it just goes to stdout/stderr
}
InitializeWindowCreator(initContext);
}
}
nsresult InitMozillaStuff (WebShellInitContext * initContext)
nsresult InitMozillaStuff (NativeBrowserControl * nativeBrowserControl)
{
nsresult rv = nsnull;
DoMozInitialization(initContext);
if (gFirstTime) {
printf ("\n\nCreating Event Queue \n\n");
nsCOMPtr<nsIEventQueueService>
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
// if we get here, we know that aEventQService is not null.
if (!aEventQService) {
rv = NS_ERROR_FAILURE;
return rv;
}
//TODO Add tracing from nspr.
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", initContext));
}
#endif
// Create the Event Queue for the UI thread...
if (!aEventQService) {
initContext->initFailCode = kEventQueueError;
return rv;
}
// Create the event queue.
rv = aEventQService->CreateThreadEventQueue();
gEmbeddedThread = PR_GetCurrentThread();
// Create the action queue
if (gEmbeddedThread) {
if (gActionQueue == nsnull) {
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
// We need to do something different for Unix
nsIEventQueue * EQueue = nsnull;
rv = aEventQService->GetThreadEventQueue(gEmbeddedThread,
&EQueue);
if (NS_FAILED(rv)) {
initContext->initFailCode = kCreateWebShellError;
return rv;
}
#ifdef XP_UNIX
gdk_input_add(EQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
EQueue);
#endif
PLEventQueue * plEventQueue = nsnull;
EQueue->GetPLEventQueue(&plEventQueue);
gActionQueue = plEventQueue;
}
}
else {
initContext->initFailCode = kCreateWebShellError;
return NS_ERROR_UNEXPECTED;
}
#ifdef XP_UNIX
// The gdk_x_error function exits in some cases, we don't
// want that.
XSetErrorHandler(wc_x_error);
#endif
}
if (gFirstTime) {
gFirstTime = PR_FALSE;
}
PRBool allowPlugins = PR_TRUE;
/*
// Create the WebBrowser.
nsCOMPtr<nsIWebBrowser> webBrowser = nsnull;
webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
initContext->webBrowser = webBrowser;
nativeBrowserControl->webBrowser = webBrowser;
// Get the BaseWindow from the DocShell - upcast
// nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(webBrowser));
nsCOMPtr<nsIBaseWindow> docShellAsWin;
rv = webBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), getter_AddRefs(docShellAsWin));
initContext->baseWindow = docShellAsWin;
nativeBrowserControl->baseWindow = docShellAsWin;
printf ("Init the baseWindow\n");
#ifdef XP_UNIX
GtkWidget * bin;
bin = (GtkWidget *) initContext->gtkWinPtr;
bin = (GtkWidget *) nativeBrowserControl->gtkWinPtr;
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - before Init Call...\n", initContext));
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - before Init Call...\n", nativeBrowserControl));
}
rv = initContext->baseWindow->InitWindow((nativeWindow) bin, nsnull, initContext->x, initContext->y, initContext->w, initContext->h);
rv = nativeBrowserControl->baseWindow->InitWindow((nativeWindow) bin, nsnull, nativeBrowserControl->x, nativeBrowserControl->y, nativeBrowserControl->w, nativeBrowserControl->h);
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", initContext));
PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", nativeBrowserControl));
}
#else
rv = initContext->baseWindow->InitWindow((nativeWindow) initContext->parentHWnd, nsnull,
initContext->x, initContext->y, initContext->w, initContext->h);
rv = nativeBrowserControl->baseWindow->InitWindow((nativeWindow) nativeBrowserControl->parentHWnd, nsnull,
nativeBrowserControl->x, nativeBrowserControl->y, nativeBrowserControl->w, nativeBrowserControl->h);
#endif
printf("Create the BaseWindow...\n");
rv = initContext->baseWindow->Create();
rv = nativeBrowserControl->baseWindow->Create();
if (NS_FAILED(rv)) {
initContext->initFailCode = kInitWebShellError;
nativeBrowserControl->initFailCode = kInitWebShellError;
return rv;
}
// Create the DocShell
initContext->docShell = do_GetInterface(initContext->webBrowser);
nativeBrowserControl->docShell = do_GetInterface(nativeBrowserControl->webBrowser);
if (!initContext->docShell) {
initContext->initFailCode = kCreateDocShellError;
if (!nativeBrowserControl->docShell) {
nativeBrowserControl->initFailCode = kCreateDocShellError;
return rv;
}
// create our BrowserContainer, which implements many many things.
initContext->browserContainer =
new CBrowserContainer(initContext->webBrowser, initContext->env,
initContext);
nativeBrowserControl->browserContainer =
new CBrowserContainer(nativeBrowserControl->webBrowser, nativeBrowserControl->env,
nativeBrowserControl);
// set the WebShellContainer. This is a pain. It's necessary
// because nsWebShell.cpp still checks for mContainer all over the
// place.
nsCOMPtr<nsIWebShellContainer> wsContainer(do_QueryInterface(initContext->browserContainer));
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(initContext->docShell));
nsCOMPtr<nsIWebShellContainer> wsContainer(do_QueryInterface(nativeBrowserControl->browserContainer));
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(nativeBrowserControl->docShell));
webShell->SetContainer(wsContainer);
// set the TreeOwner
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(initContext->docShell));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner(do_QueryInterface(initContext->browserContainer));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(nativeBrowserControl->docShell));
nsCOMPtr<nsIDocShellTreeOwner> treeOwner(do_QueryInterface(nativeBrowserControl->browserContainer));
docShellAsItem->SetTreeOwner(treeOwner);
// set the docloaderobserver
nsCOMPtr<nsIDocumentLoaderObserver> observer(do_QueryInterface(initContext->browserContainer));
initContext->docShell->SetDocLoaderObserver(observer);
nsCOMPtr<nsIDocumentLoaderObserver> observer(do_QueryInterface(nativeBrowserControl->browserContainer));
nativeBrowserControl->docShell->SetDocLoaderObserver(observer);
printf("Creation Done.....\n");
// Get the WebNavigation Object from the DocShell
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(initContext->docShell));
initContext->webNavigation = webNav;
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(nativeBrowserControl->docShell));
nativeBrowserControl->webNavigation = webNav;
printf("Show the webBrowser\n");
// Show the webBrowser
rv = initContext->baseWindow->SetVisibility(PR_TRUE);
rv = nativeBrowserControl->baseWindow->SetVisibility(PR_TRUE);
if (NS_FAILED(rv)) {
initContext->initFailCode = kShowWebShellError;
nativeBrowserControl->initFailCode = kShowWebShellError;
return rv;
}
initContext->initComplete = TRUE;
nativeBrowserControl->initComplete = TRUE;
*/
wsRealizeBrowserEvent * actionEvent = new wsRealizeBrowserEvent(initContext);
wsRealizeBrowserEvent * actionEvent = new wsRealizeBrowserEvent(nativeBrowserControl);
PLEvent * event = (PLEvent*) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
::util_PostSynchronousEvent(nativeBrowserControl, event);
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 3,
("InitMozillaStuff(%lx): enter event loop\n", initContext));
("InitMozillaStuff(%lx): enter event loop\n", nativeBrowserControl));
}
#endif
processEventLoop(initContext);
*/
return rv;
}

View File

@ -37,13 +37,13 @@ static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kISHistoryIID, NS_ISHISTORY_IID);
static NS_DEFINE_CID(kSHistoryCID, NS_SHISTORY_CID);
extern WebShellInitContext* gNewWindowInitContext;
extern NativeBrowserControl* gNewWindowInitContext;
/*
* wsRealizeBrowserEvent
*/
wsRealizeBrowserEvent::wsRealizeBrowserEvent(WebShellInitContext * yourInitContext) :
wsRealizeBrowserEvent::wsRealizeBrowserEvent(NativeBrowserControl * yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{

View File

@ -52,16 +52,16 @@
#include <windows.h>
#endif
struct WebShellInitContext;
struct NativeBrowserControl;
class wsRealizeBrowserEvent : public nsActionEvent {
public:
wsRealizeBrowserEvent (WebShellInitContext * yourInitContext);
wsRealizeBrowserEvent (NativeBrowserControl * yourInitContext);
~wsRealizeBrowserEvent ();
void * handleEvent (void);
protected:
WebShellInitContext * mInitContext;
NativeBrowserControl * mInitContext;
};
#endif /* NativeEventThreadActionEvents_h___ */

View File

@ -82,7 +82,7 @@ wsLoadURLEvent::~wsLoadURLEvent ()
}
wsLoadFromStreamEvent::wsLoadFromStreamEvent(WebShellInitContext *yourInitCx,
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourInitCx,
void *globalStream,
nsString &uriToCopy,
const char *contentTypeToCopy,
@ -96,7 +96,7 @@ wsLoadFromStreamEvent::wsLoadFromStreamEvent(WebShellInitContext *yourInitCx,
NS_IF_ADDREF(mShim);
}
wsLoadFromStreamEvent::wsLoadFromStreamEvent(WebShellInitContext *yourInitCx,
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourInitCx,
InputStreamShim *yourShim) :
nsActionEvent(), mInitContext(yourInitCx), mUriString(nsnull),
mContentType(nsnull), mProperties(nsnull), mShim(yourShim)
@ -210,7 +210,7 @@ wsLoadFromStreamEvent::~wsLoadFromStreamEvent ()
/*
* wsPostEvent
*/
wsPostEvent::wsPostEvent(WebShellInitContext *yourInitContext,
wsPostEvent::wsPostEvent(NativeBrowserControl *yourInitContext,
nsIURI *absoluteUri,
const PRUnichar *targetToCopy,
PRInt32 targetLength,

View File

@ -40,7 +40,7 @@
#include "nsIURI.h"
#include "ns_util.h"
struct WebShellInitContext;
struct NativeBrowserControl;
class InputStreamShim;
@ -57,7 +57,7 @@ protected:
class wsLoadFromStreamEvent : public nsActionEvent {
public:
wsLoadFromStreamEvent(WebShellInitContext *yourInitContext,
wsLoadFromStreamEvent(NativeBrowserControl *yourInitContext,
void *globalStream,
nsString &uriToCopy,
const char *contentTypeToCopy,
@ -66,12 +66,12 @@ public:
void * handleEvent(void);
private:
wsLoadFromStreamEvent(WebShellInitContext *yourDocShell,
wsLoadFromStreamEvent(NativeBrowserControl *yourDocShell,
InputStreamShim *yourShim);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
nsString mUriString;
char *mContentType; // MUST be delete'd in destructor
void * mProperties; // MUST be util_deleteGlobalRef'd in destructor.
@ -81,7 +81,7 @@ protected:
class wsPostEvent : public nsActionEvent {
public:
wsPostEvent(WebShellInitContext *yourInitContext,
wsPostEvent(NativeBrowserControl *yourInitContext,
nsIURI *absoluteUrl,
const PRUnichar *targetToCopy,
PRInt32 targetLength,
@ -97,7 +97,7 @@ private:
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
nsCOMPtr<nsIURI> mAbsoluteURI;
nsString *mTarget;
const char *mPostData;

View File

@ -64,7 +64,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
return;
}
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellLoadURL");
@ -87,7 +87,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
(JNIEnv *env, jobject obj, jint webShellPtr, jobject stream, jstring uri,
jstring contentType, jint contentLength, jobject loadProperties)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
PRUnichar *uriStringUniChars = nsnull;
PRInt32 uriStringUniCharsLength = -1;
const char *contentTypeChars = nsnull;
@ -154,7 +154,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
(JNIEnv *env, jobject obj, jint webShellPtr, jstring absoluteURL, jstring target, jint postDataLength,
jstring postData, jint postHeadersLength, jstring postHeaders)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl *initContext = (NativeBrowserControl *) webShellPtr;
const PRUnichar *urlChars = nsnull;
PRInt32 urlLen;
const PRUnichar *targetChars = nsnull;
@ -274,7 +274,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRefresh");
@ -299,7 +299,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellStop");
@ -321,7 +321,7 @@ Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeSetPrompt
JNIEnv * pEnv = env;
jobject jobj = obj;
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetPrompt");

View File

@ -30,7 +30,7 @@
#include "nsReadableUtils.h"
#include "nsString2.h" // for nsAutoString
wsPromptUsernameAndPasswordEvent::wsPromptUsernameAndPasswordEvent(WebShellInitContext *yourInitContext,
wsPromptUsernameAndPasswordEvent::wsPromptUsernameAndPasswordEvent(NativeBrowserControl *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUint32 savePassword,
@ -103,7 +103,7 @@ void *wsPromptUsernameAndPasswordEvent::handleEvent()
return (void *) NS_OK;
}
wsPromptUniversalDialogEvent::wsPromptUniversalDialogEvent(WebShellInitContext *yourInitContext,
wsPromptUniversalDialogEvent::wsPromptUniversalDialogEvent(NativeBrowserControl *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUnichar **fieldOne,

View File

@ -30,13 +30,13 @@
#include "nsActions.h"
#include "ns_util.h"
struct WebShellInitContext;
struct NativeBrowserControl;
extern jobject gPromptProperties; // declared, defined in CBrowserContainer.cpp
class wsPromptUsernameAndPasswordEvent : public nsActionEvent {
public:
wsPromptUsernameAndPasswordEvent (WebShellInitContext *yourInitContext,
wsPromptUsernameAndPasswordEvent (NativeBrowserControl *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUint32 savePassword,
@ -46,7 +46,7 @@ public:
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mPromptGlobalRef;
wsStringStruct *mInStrings;
PRUint32 mSavePassword;
@ -57,7 +57,7 @@ protected:
class wsPromptUniversalDialogEvent : public nsActionEvent {
public:
wsPromptUniversalDialogEvent (WebShellInitContext *yourInitContext,
wsPromptUniversalDialogEvent (NativeBrowserControl *yourInitContext,
jobject yourPromptGlobalRef,
wsStringStruct *inStrings,
PRUnichar **fieldOne,
@ -70,7 +70,7 @@ public:
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mPromptGlobalRef;
wsStringStruct *mInStrings;
PRUnichar **mFieldOne;

View File

@ -73,7 +73,7 @@ wsResizeEvent::handleEvent ()
} // handleEvent()
wsDeallocateInitContextEvent::wsDeallocateInitContextEvent(WebShellInitContext* yourInitContext) :
wsDeallocateInitContextEvent::wsDeallocateInitContextEvent(NativeBrowserControl* yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{

View File

@ -36,7 +36,7 @@
#include "nsIBaseWindow.h"
struct WebShellInitContext;
struct NativeBrowserControl;
class wsResizeEvent : public nsActionEvent {
public:
@ -53,12 +53,12 @@ protected:
class wsDeallocateInitContextEvent : public nsActionEvent {
public:
wsDeallocateInitContextEvent(WebShellInitContext *yourInitContext);
wsDeallocateInitContextEvent(NativeBrowserControl *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
};
class wsMoveToEvent : public nsActionEvent {

View File

@ -41,7 +41,7 @@ JNIEXPORT void JNICALL
Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetBounds
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y, jint w, jint h)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeSetBounds");
@ -57,87 +57,10 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetBound
}
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeCreateInitContext
(JNIEnv *env, jobject obj, jint windowPtr, jint x, jint y,
jint width, jint height, jobject aBrowserControlImpl)
{
#ifdef XP_MAC
WindowPtr pWindow = (WindowPtr) windowPtr;
Rect webRect = pWindow->portRect;
// nsIWidget * pWidget = (nsIWidget *) widgetPtr;
#elif defined(XP_PC)
// elif defined(XP_WIN)
HWND parentHWnd = (HWND)windowPtr;
#elif defined(XP_UNIX)
GtkWidget * parentHWnd = (GtkWidget *) windowPtr;
#endif
if (parentHWnd == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null window handle passed to raptorWebShellCreate");
return (jint) 0;
}
WebShellInitContext* initContext = new WebShellInitContext;
initContext->initComplete = FALSE;
initContext->initFailCode = 0;
initContext->parentHWnd = parentHWnd;
initContext->webShell = nsnull;
initContext->docShell = nsnull;
initContext->baseWindow = nsnull;
initContext->webNavigation = nsnull;
initContext->presShell = nsnull;
// initContext->embeddedThread = nsnull;
// initContext->actionQueue = nsnull;
initContext->env = env;
initContext->nativeEventThread = nsnull;
initContext->stopThread = FALSE;
initContext->x = x;
initContext->y = y;
initContext->w = width;
initContext->h = height;
initContext->currentDocument = nsnull;
initContext->browserContainer = nsnull;
util_InitializeShareInitContext(env, &(initContext->shareContext));
#ifdef XP_UNIX
initContext->gtkWinPtr =
(int)::util_GetGTKWinPtrFromCanvas(env, aBrowserControlImpl);
#else
initContext->gtkWinPtr = nsnull;
#endif
return (jint) initContext;
}
JNIEXPORT void JNICALL
Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeDestroyInitContext
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeDestroyInitContext");
return;
}
wsDeallocateInitContextEvent * actionEvent =
new wsDeallocateInitContextEvent(initContext);
PLEvent * event = (PLEvent*) *actionEvent;
nsresult rv;
rv = (nsresult) ::util_PostSynchronousEvent(initContext, event);
if (NS_FAILED(rv)) {
::util_ThrowExceptionToJava(env, "Exception: Can't destroy initContext");
return;
}
// initContext->actionQueue = nsnull;
delete initContext;
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeMoveWindowTo
(JNIEnv *env, jobject obj, jint webShellPtr, jint x, jint y)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellMoveTo");
@ -155,7 +78,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowCon
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeRemoveFocus
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRemoveFocus");
@ -173,7 +96,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowCon
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeRepaint
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean forceRepaint)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRepaint");
@ -193,7 +116,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowCon
(JNIEnv *env, jobject obj, jint webShellPtr, jboolean newState)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRepaint");
return;
@ -209,7 +132,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowCon
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WindowControlImpl_nativeSetFocus
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr;
NativeBrowserControl* initContext = (NativeBrowserControl *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellSetFocus");

View File

@ -23,11 +23,11 @@
#include "nsIWebBrowserChrome.h"
#include "WindowCreator.h"
int processEventLoop(WebShellInitContext * initContext);
int processEventLoop(NativeBrowserControl * initContext);
WebShellInitContext* gNewWindowInitContext;
NativeBrowserControl* gNewWindowInitContext;
WindowCreator::WindowCreator(WebShellInitContext *yourInitContext)
WindowCreator::WindowCreator(NativeBrowserControl *yourInitContext)
{
mInitContext = yourInitContext;
mTarget = 0;

View File

@ -29,11 +29,11 @@
class WindowCreator : public nsIWindowCreator
{
private:
WebShellInitContext *mInitContext;
NativeBrowserControl *mInitContext;
jobject mTarget;
public:
WindowCreator(WebShellInitContext *yourInitContext);
WindowCreator(NativeBrowserControl *yourInitContext);
virtual ~WindowCreator();
NS_IMETHOD AddNewWindowListener(jobject target);

View File

@ -49,6 +49,8 @@
#include <windows.h> // for GetCurrentProcessId()
#endif
#include "NativeBrowserControl.h"
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
//
@ -293,11 +295,16 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDoesImp
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeCreateBrowserControl
(JNIEnv *env, jobject obj, jint nativeContext) {
return -1;
NativeBrowserControl* initContext = new NativeBrowserControl();
return (jint) initContext;
}
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDestroyBrowserControl
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeBrowserControl) {
return -1;
NativeBrowserControl* initContext =
(NativeBrowserControl *)nativeBrowserControl;
delete initContext;
return 0;
}

View File

@ -52,11 +52,4 @@ extern PRLogModuleInfo *prLogModuleInfo; // defined in WrapperFactory.cpp
class nsISHistory;
extern nsISHistory *gHistory; // defined in NativeEventThread.cpp
class nsIEventQueueService;
extern PLEventQueue * gActionQueue; // defined in NativeEventThread.cpp
class nsIThread;
extern PRThread * gEmbeddedThread; // defined in NativeEventThread.cpp
#endif // ns_globals_h

View File

@ -35,6 +35,8 @@
#include "nsString2.h"
#include "NativeBrowserControl.h"
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
#define kCommonDialogsProperties "chrome://global/locale/commonDialogs.properties"
@ -55,25 +57,25 @@ const char *gSupportedListenerInterfaces[] = {
nsnull
};
void util_PostEvent(WebShellInitContext * initContext, PLEvent * event)
void util_PostEvent(NativeBrowserControl * initContext, PLEvent * event)
{
PL_ENTER_EVENT_QUEUE_MONITOR(gActionQueue);
PL_ENTER_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
::PL_PostEvent(gActionQueue, event);
::PL_PostEvent(NativeBrowserControl::sActionQueue, event);
PL_EXIT_EVENT_QUEUE_MONITOR(gActionQueue);
PL_EXIT_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
} // PostEvent()
void *util_PostSynchronousEvent(WebShellInitContext * initContext, PLEvent * event)
void *util_PostSynchronousEvent(NativeBrowserControl * initContext, PLEvent * event)
{
void * voidResult = nsnull;
PL_ENTER_EVENT_QUEUE_MONITOR(gActionQueue);
PL_ENTER_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
voidResult = ::PL_PostSynchronousEvent(gActionQueue, event);
voidResult = ::PL_PostSynchronousEvent(NativeBrowserControl::sActionQueue, event);
PL_EXIT_EVENT_QUEUE_MONITOR(gActionQueue);
PL_EXIT_EVENT_QUEUE_MONITOR(NativeBrowserControl::sActionQueue);
return voidResult;
} // PostSynchronousEvent()

View File

@ -43,7 +43,6 @@
#include "nsIWebBrowser.h"
#include "nsIDocShell.h" // so we can save our nsIDocShell
#include "nsIBaseWindow.h" // to get methods like SetVisibility
#include "nsIWebNavigation.h" // for all Navigation commands
#include "nsIPresShell.h"
#include "nsIThread.h" // for PRThread
#include "nsIWebShell.h" // for nsIWebShell
@ -72,46 +71,14 @@
// local classes
//
// PENDING(edburns): this should be a class, and we should define a
// constructor and destructor for it.
struct WebShellInitContext {
#ifdef XP_UNIX
GtkWidget * parentHWnd;
#else
// PENDING(mark): Don't we need something for Mac?
HWND parentHWnd;
#endif
nsCOMPtr<nsIWebShell> webShell;
nsCOMPtr<nsIDocShell> docShell;
nsCOMPtr<nsIBaseWindow> baseWindow;
nsCOMPtr<nsIWebNavigation> webNavigation;
nsCOMPtr<nsIPresShell> presShell;
nsCOMPtr<nsIWebBrowser> webBrowser;
// PLEventQueue * actionQueue;
// PRThread * embeddedThread;
JNIEnv * env;
jobject nativeEventThread;
int stopThread;
int initComplete;
int initFailCode;
int x;
int y;
int w;
int h;
int gtkWinPtr;
nsCOMPtr<nsIDOMDocument> currentDocument;
nsCOMPtr<wcIBrowserContainer> browserContainer;
// This struct contains all per-window information not specific to mozilla
ShareInitContext shareContext;
};
class nsIProfile;
class nsIProfileInternal;
class nsIPref;
class nsIAppShell;
class NativeBrowserControl;
typedef struct WebclientContext {
struct WebclientContext {
nsIProfile *sProfile;
nsIProfileInternal *sProfileInternal;
nsIPref *sPrefs;
@ -142,7 +109,7 @@ extern const char *gSupportedListenerInterfaces[]; // defined in ns_util.cpp
* http://lxr.mozilla.org/mozilla/source/xpcom/threads/plevent.c#248
* which simply uses nice monitors to insert the event into the provided
* event queue, which is from WebShellInitContext->actionQueue, which is
* event queue, which is from NativeBrowserControl->actionQueue, which is
* created in NativeEventThread.cpp:InitMozillaStuff(). The events are
* processed in NativeEventThread.cpp:processEventLoop, which is called
* from the Java NativeEventThread.run(). See the code and comments for
@ -150,7 +117,7 @@ extern const char *gSupportedListenerInterfaces[]; // defined in ns_util.cpp
*/
void util_PostEvent (WebShellInitContext * initContext, PLEvent * event);
void util_PostEvent (NativeBrowserControl * initContext, PLEvent * event);
/**
@ -166,7 +133,7 @@ void util_PostEvent (WebShellInitContext * initContext, PLEvent * event);
*/
void * util_PostSynchronousEvent (WebShellInitContext * initContext, PLEvent * event);
void * util_PostSynchronousEvent (NativeBrowserControl * initContext, PLEvent * event);
typedef struct _wsStringStruct {
const PRUnichar *uniStr;

View File

@ -1,5 +1,5 @@
/*
* $Id: WrapperFactoryImplTest.java,v 1.1 2003/09/28 06:29:20 edburns%acm.org Exp $
* $Id: WrapperFactoryImplTest.java,v 1.2 2004/04/10 21:50:39 edburns%acm.org Exp $
*/
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
@ -30,7 +30,9 @@ import junit.framework.TestSuite;
import junit.framework.Test;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserControlFactory;
import org.mozilla.webclient.WebclientTestCase;
import org.mozilla.webclient.impl.BrowserControlImpl;
// WrapperFactoryImplTest.java
@ -65,4 +67,12 @@ public class WrapperFactoryImplTest extends WebclientTestCase {
}
}
public void testGetNativeBrowserControl() throws Exception {
WrapperFactoryImpl wrapper = new WrapperFactoryImpl();
wrapper.initialize(getBrowserBinDir());
BrowserControl bc = new BrowserControlImpl(wrapper);
assertTrue(-1 != wrapper.getNativeBrowserControl(bc));
BrowserControlFactory.deleteBrowserControl(bc);
}
}