зеркало из https://github.com/mozilla/pjs.git
This checkin refactors who owns the nativeWebShell pointer. It used to
be WindowControl, and now it's BrowserControl. I'm hoping this allows us to operate Webclient in a "headless" fashion. For example, you can imagine a web-crawler app that leverages DOM. A test/automated/src/test/NavigationTest.txt - fodder for testcase M build-tests.xml - reformat - add NavigationTest (fails) M classes_spec/org/mozilla/webclient/ImplObject.java - Refactoring: remove public ivars. Make them private, provide accessor. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - Refactoring: remove public ivars. Make them private, provide accessor. - Remove dependence on WindowControl - leverage new method on WrapperFactory: getNativeBrowserControl(). M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - Make BrowserControlImpl the owner of the nativeWebShell pointer. I'd like to see if it's possible for webclient to operate "headless" for certain applications, therefore, you may not have a WindowControl instance, which used to own the nativeWebShell pointer. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java - reformatting - Software Practice: avoid downcasting to implementation class. Since BrowserControlImpl is the owner of the nativeWebShell, but there is no mention of that in the public API, we modify the WrapperFactory contract to maintain a data structure of BrowserControl to nativeWebShell mappings. - add native{Create,Destroy}BrowserControl(), which is called from ImplObjectNative. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java - refactoring for removing public ivars. M classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java - refactoring for removing public ivars. - comment out nativeCreateInitContext temporarily M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java - implement new methods: - add native{Create,Destroy}BrowserControl(), which is called from ImplObjectNative. M classes_spec/org/mozilla/webclient/wrapper_nonnative/WrapperFactoryImpl.java - remove vertigo test M src_moz/ProfileManagerImpl.cpp - shutdown the current profile M src_moz/WrapperFactoryImpl.cpp - Spinup and Spindown the Appshell A test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - new test M test/automated/src/test/BrowserControlFactoryTest_correct - new test content
This commit is contained in:
Родитель
3d299efb97
Коммит
01982f4835
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -59,20 +59,13 @@ public abstract class ImplObject extends Object
|
|||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
|
||||
* My ivars are public for fast access from subclasses in the wrapper_*
|
||||
* packages.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* The BrowserControl to which I'm attached, used for locking and communication.
|
||||
|
||||
*/
|
||||
|
||||
public BrowserControl myBrowserControl = null;
|
||||
private BrowserControl myBrowserControl = null;
|
||||
|
||||
|
||||
//
|
||||
|
@ -86,6 +79,10 @@ public ImplObject(BrowserControl yourBrowserControl)
|
|||
myBrowserControl = yourBrowserControl;
|
||||
}
|
||||
|
||||
public BrowserControl getBrowserControl() {
|
||||
return myBrowserControl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* I know Java has automatic garbage collection and all, but explicitly
|
||||
|
|
|
@ -98,6 +98,7 @@ public BrowserControlImpl(WrapperFactory yourWrapper)
|
|||
ParameterCheck.nonNull(yourWrapper);
|
||||
|
||||
wrapperFactory = yourWrapper;
|
||||
Assert.assert_it(-1 != wrapperFactory.getNativeContext());
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,7 +169,6 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
|
|||
ParameterCheck.nonNull(interfaceName);
|
||||
|
||||
Assert.assert_it(null != wrapperFactory);
|
||||
// wrapperFactory.throwExceptionIfNotInitialized();
|
||||
|
||||
// At some point, it has to come down to hard coded string names,
|
||||
// right? Well, that point is here. There is an extensibility
|
||||
|
@ -241,23 +241,6 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
|
|||
return wrapperFactory.newImpl(interfaceName, this);
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
Log.setApplicationName("BrowserControlImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.1 2003-09-28 06:29:05 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class BrowserControlImpl
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: java; 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
|
||||
|
@ -55,4 +55,16 @@ public interface WrapperFactory {
|
|||
|
||||
public int getNativeContext();
|
||||
|
||||
/**
|
||||
* <p>I would like this method to be on BrowserControl itself, but
|
||||
* that would mean exposing native elements on the public java API.
|
||||
* Therefore, the WrapperFactory needs to be able to return the
|
||||
* native counterpart given a java BrowserControl.</p>
|
||||
*
|
||||
*/
|
||||
|
||||
public int getNativeBrowserControl(BrowserControl bc);
|
||||
|
||||
public void destroyNativeBrowserControl(BrowserControl bc);
|
||||
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
|
|||
BookmarkEntry bookmark)
|
||||
{
|
||||
ParameterCheck.nonNull(bookmark);
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
if (!(bookmark instanceof BookmarkEntryImpl)) {
|
||||
throw new IllegalArgumentException("Can't add bookmark unless BookmarkEntry obtained from Bookmarks.newBookmarkEntry()");
|
||||
|
@ -149,7 +149,7 @@ public void addBookmark(BookmarkEntry mayBeNullParent,
|
|||
|
||||
public TreeModel getBookmarks() throws IllegalStateException
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
if (null == bookmarksTree) {
|
||||
int nativeBookmarks;
|
||||
|
@ -173,8 +173,8 @@ public TreeModel getBookmarks() throws IllegalStateException
|
|||
public void removeBookmark(BookmarkEntry bookmark)
|
||||
{
|
||||
ParameterCheck.nonNull(bookmark);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
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(nativeWebShell, url, false))) {
|
||||
result = new BookmarkEntryImpl(nativeWebShell,
|
||||
if (-1 != (newNode = nativeNewRDFNode(getNativeWebShell(), url, false))) {
|
||||
result = new BookmarkEntryImpl(getNativeWebShell(),
|
||||
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(nativeWebShell, -1, null))) {
|
||||
if (null == (result = new BookmarkEntryImpl(getNativeWebShell(), -1, null))) {
|
||||
throw new NullPointerException("Can't create bookmark folder for: " +
|
||||
name);
|
||||
}
|
||||
|
|
|
@ -92,21 +92,21 @@ public CurrentPageImpl(WrapperFactory yourFactory,
|
|||
|
||||
public void copyCurrentSelectionToSystemClipboard()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeCopyCurrentSelectionToSystemClipboard(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeCopyCurrentSelectionToSystemClipboard(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public Selection getSelection() {
|
||||
Selection selection = new SelectionImpl();
|
||||
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeGetSelection(nativeWebShell, selection);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeGetSelection(getNativeWebShell(), selection);
|
||||
}
|
||||
|
||||
return selection;
|
||||
|
@ -119,55 +119,55 @@ public void highlightSelection(Selection selection) {
|
|||
int startOffset = selection.getStartOffset();
|
||||
int endOffset = selection.getEndOffset();
|
||||
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeHighlightSelection(nativeWebShell, startContainer, endContainer, startOffset, endOffset);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeHighlightSelection(getNativeWebShell(), startContainer, endContainer, startOffset, endOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllSelections() {
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
synchronized(myBrowserControl) {
|
||||
nativeClearAllSelections(nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeClearAllSelections(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
|
||||
{
|
||||
ParameterCheck.nonNull(stringToFind);
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindInPage(nativeWebShell, stringToFind, forward, matchCase);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeFindInPage(getNativeWebShell(), stringToFind, forward, matchCase);
|
||||
}
|
||||
}
|
||||
|
||||
public void findNextInPage()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeFindNextInPage(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeFindNextInPage(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public String getCurrentURL()
|
||||
{
|
||||
String result = null;
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetCurrentURL(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeGetCurrentURL(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Document getDOM()
|
||||
{
|
||||
Document result = nativeGetDOM(nativeWebShell);
|
||||
Document result = nativeGetDOM(getNativeWebShell());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,8 @@ public Properties getPageInfo()
|
|||
{
|
||||
Properties result = null;
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
result = nativeGetPageInfo(nativeWebShell);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
result = nativeGetPageInfo(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
|
@ -188,7 +188,7 @@ public Properties getPageInfo()
|
|||
|
||||
public String getSource()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
String HTMLContent = new String();
|
||||
String currURL = getCurrentURL();
|
||||
System.out.println("\nThe Current URL is -- " + currURL);
|
||||
|
@ -219,7 +219,7 @@ public String getSource()
|
|||
public byte [] getSourceBytes()
|
||||
{
|
||||
byte [] result = null;
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
|
||||
String HTMLContent = new String();
|
||||
|
@ -251,37 +251,37 @@ public byte [] getSourceBytes()
|
|||
|
||||
public void resetFind()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeResetFind(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeResetFind(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSelectAll(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeSelectAll(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public void print()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativePrint(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativePrint(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public void printPreview(boolean preview)
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativePrintPreview(nativeWebShell, preview);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativePrintPreview(getNativeWebShell(), 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.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public EventRegistrationImpl(WrapperFactory yourFactory,
|
|||
// pull out the NativeEventThread from the WindowControl
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
getBrowserControl().queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
|
||||
if (windowControl instanceof WindowControlImpl) {
|
||||
nativeEventThread =
|
||||
|
@ -120,8 +120,8 @@ public void delete()
|
|||
public void addDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -132,7 +132,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
|
|||
public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -152,7 +152,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -160,8 +160,8 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
|
|||
public void addMouseListener(MouseListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -185,7 +185,7 @@ public void addMouseListener(MouseListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -193,8 +193,8 @@ public void addMouseListener(MouseListener listener)
|
|||
public void removeMouseListener(MouseListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -213,7 +213,7 @@ public void removeMouseListener(MouseListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +221,8 @@ public void removeMouseListener(MouseListener listener)
|
|||
public void addNewWindowListener(NewWindowListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -233,7 +233,7 @@ public void addNewWindowListener(NewWindowListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.addListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ public void addNewWindowListener(NewWindowListener listener)
|
|||
public void removeNewWindowListener(NewWindowListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
Assert.assert_it(null != nativeEventThread);
|
||||
ParameterCheck.nonNull(listener);
|
||||
|
||||
|
@ -253,7 +253,7 @@ public void removeNewWindowListener(NewWindowListener listener)
|
|||
throw new NullPointerException("Can't instantiate WCEventListenerWrapper, out of memory.");
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeEventThread.removeListener(listenerWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("EventRegistrationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: EventRegistrationImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
|
|
@ -76,34 +76,34 @@ public HistoryImpl(WrapperFactory yourFactory,
|
|||
|
||||
public void back()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeBack(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeBack(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBack()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
boolean result = false;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeCanBack(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeCanBack(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public HistoryEntry [] getBackList()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
HistoryEntry [] result = null;
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
result = nativeGetBackList(nativeWebShell);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
result = nativeGetBackList(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
|
@ -113,11 +113,11 @@ public HistoryEntry [] getBackList()
|
|||
|
||||
public void clearHistory()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
nativeClearHistory(nativeWebShell);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
nativeClearHistory(getNativeWebShell());
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -128,22 +128,22 @@ public void clearHistory()
|
|||
|
||||
public void forward()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeForward(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeForward(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canForward()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
boolean result = false;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeCanForward(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeCanForward(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -151,11 +151,11 @@ public boolean canForward()
|
|||
public HistoryEntry [] getForwardList()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
result = nativeGetForwardList(nativeWebShell);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
result = nativeGetForwardList(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
|
@ -166,11 +166,11 @@ public HistoryEntry [] getForwardList()
|
|||
public HistoryEntry [] getHistory()
|
||||
{
|
||||
HistoryEntry [] result = null;
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
result = nativeGetHistory(nativeWebShell);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
result = nativeGetHistory(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
|
@ -181,12 +181,12 @@ public HistoryEntry [] getHistory()
|
|||
public HistoryEntry getHistoryEntry(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
HistoryEntry result = null;
|
||||
|
||||
/* synchronized(myBrowserControl) {
|
||||
result = nativeGetHistoryEntry(nativeWebShell, historyIndex);
|
||||
/* synchronized(getBrowserControl()) {
|
||||
result = nativeGetHistoryEntry(getNativeWebShell(), historyIndex);
|
||||
}
|
||||
return result;
|
||||
*/
|
||||
|
@ -196,12 +196,12 @@ public HistoryEntry getHistoryEntry(int historyIndex)
|
|||
|
||||
public int getCurrentHistoryIndex()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
int result = -1;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetCurrentHistoryIndex(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeGetCurrentHistoryIndex(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -209,22 +209,22 @@ public int getCurrentHistoryIndex()
|
|||
public void setCurrentHistoryIndex(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetCurrentHistoryIndex(nativeWebShell, historyIndex);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeSetCurrentHistoryIndex(getNativeWebShell(), historyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public int getHistoryLength()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
int result = -1;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetHistoryLength(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeGetHistoryLength(getNativeWebShell());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -232,12 +232,12 @@ public int getHistoryLength()
|
|||
public String getURLForIndex(int historyIndex)
|
||||
{
|
||||
ParameterCheck.noLessThan(historyIndex, 0);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
String result = null;
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
result = nativeGetURLForIndex(nativeWebShell, historyIndex);
|
||||
synchronized(getBrowserControl()) {
|
||||
result = nativeGetURLForIndex(getNativeWebShell(), historyIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ public String getURLForIndex(int historyIndex)
|
|||
// Native methods
|
||||
//
|
||||
|
||||
public native void nativeBack(int nativeWebShell);
|
||||
public native void nativeBack(int webShellPtr);
|
||||
|
||||
public native boolean nativeCanBack(int webShellPtr);
|
||||
|
||||
|
@ -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.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: HistoryImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.mozilla.util.ParameterCheck;
|
|||
import org.mozilla.webclient.ImplObject;
|
||||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.BrowserControl;
|
||||
import org.mozilla.webclient.WindowControl;
|
||||
|
||||
/**
|
||||
|
||||
|
@ -67,61 +66,16 @@ public abstract class ImplObjectNative extends ImplObject
|
|||
|
||||
// Relationship Instance Variables
|
||||
|
||||
/**
|
||||
private WrapperFactory myFactory = null;
|
||||
|
||||
* My ivars are public for fast access from subclasses in the wrapper_*
|
||||
* packages.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* a handle to the actual mozilla webShell, owned, allocated, and
|
||||
* released by WindowControl
|
||||
|
||||
*/
|
||||
|
||||
public int nativeWebShell = -1;
|
||||
|
||||
protected WrapperFactory myFactory = null;
|
||||
private int nativeWebShell = -1;
|
||||
|
||||
//
|
||||
// Constructors and Initializers
|
||||
//
|
||||
|
||||
public ImplObjectNative(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourBrowserControl);
|
||||
myFactory = yourFactory;
|
||||
|
||||
// If we're a WindowControlImpl instance, we can't ask ourself for
|
||||
// the nativeWebShell, since it hasn't yet been created!
|
||||
|
||||
if (!(this instanceof WindowControlImpl)) {
|
||||
// save the native webshell ptr
|
||||
try {
|
||||
WindowControl windowControl = (WindowControl)
|
||||
myBrowserControl.queryInterface(BrowserControl.WINDOW_CONTROL_NAME);
|
||||
nativeWebShell = windowControl.getNativeWebShell();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* This constructor doesn't initialize the nativeWebshell ivar
|
||||
|
||||
*/
|
||||
|
||||
public ImplObjectNative(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl,
|
||||
boolean notUsed)
|
||||
{
|
||||
BrowserControl yourBrowserControl) {
|
||||
super(yourBrowserControl);
|
||||
myFactory = yourFactory;
|
||||
}
|
||||
|
@ -130,9 +84,6 @@ public ImplObjectNative(WrapperFactory yourFactory,
|
|||
|
||||
* Note how we call super.delete() at the end. THIS IS VERY IMPORTANT. <P>
|
||||
|
||||
* Also, note how we don't de-allocate nativeWebShell, that is done in
|
||||
* the class that owns the nativeWebShell reference, WindowControlImpl. <P>
|
||||
|
||||
* ImplObjectNative subclasses that further override delete() are <P>
|
||||
|
||||
<CODE><PRE>
|
||||
|
@ -149,8 +100,7 @@ WindowControlImpl.java
|
|||
|
||||
public void delete()
|
||||
{
|
||||
nativeWebShell = -1;
|
||||
System.out.println("ImplObjectNative.delete()");
|
||||
getWrapperFactory().destroyNativeBrowserControl(getBrowserControl());
|
||||
super.delete();
|
||||
}
|
||||
|
||||
|
@ -158,5 +108,19 @@ protected WrapperFactory getWrapperFactory() {
|
|||
return myFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* <p>We do this lazily to allow for applications that don't use any
|
||||
* per-window features. </p>
|
||||
|
||||
*/
|
||||
|
||||
protected int getNativeWebShell() {
|
||||
if (-1 == nativeWebShell) {
|
||||
nativeWebShell =
|
||||
getWrapperFactory().getNativeBrowserControl(getBrowserControl());
|
||||
}
|
||||
return nativeWebShell;
|
||||
}
|
||||
|
||||
} // end of class ImplObject
|
||||
|
|
|
@ -62,8 +62,7 @@ public class NavigationImpl extends ImplObjectNative implements Navigation2
|
|||
//
|
||||
|
||||
public NavigationImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
BrowserControl yourBrowserControl) {
|
||||
super(yourFactory, yourBrowserControl);
|
||||
}
|
||||
|
||||
|
@ -82,11 +81,11 @@ public NavigationImpl(WrapperFactory yourFactory,
|
|||
public void loadURL(String absoluteURL)
|
||||
{
|
||||
ParameterCheck.nonNull(absoluteURL);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeLoadURL(nativeWebShell, absoluteURL);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeLoadURL(getNativeWebShell(), absoluteURL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,11 +101,11 @@ public void loadFromStream(InputStream stream, String uri,
|
|||
" is out of range. It is should be either -1 or greater than 0.");
|
||||
}
|
||||
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeLoadFromStream(nativeWebShell, stream,
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeLoadFromStream(getNativeWebShell(), stream,
|
||||
uri, contentType, contentLength,
|
||||
loadInfo);
|
||||
}
|
||||
|
@ -115,32 +114,32 @@ public void loadFromStream(InputStream stream, String uri,
|
|||
public void refresh(long loadFlags)
|
||||
{
|
||||
ParameterCheck.noLessThan(loadFlags, 0);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRefresh(nativeWebShell, loadFlags);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeRefresh(getNativeWebShell(), loadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeStop(nativeWebShell);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeStop(getNativeWebShell());
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrompt(Prompt yourPrompt)
|
||||
{
|
||||
ParameterCheck.nonNull(yourPrompt);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetPrompt(nativeWebShell, yourPrompt);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeSetPrompt(getNativeWebShell(), yourPrompt);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -155,8 +154,8 @@ public void post(String absoluteUrl,
|
|||
String postHeaders)
|
||||
{
|
||||
ParameterCheck.nonNull(absoluteUrl);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
int postDataLength = 0;
|
||||
int postHeadersLength = 0;
|
||||
|
@ -174,8 +173,8 @@ public void post(String absoluteUrl,
|
|||
postHeadersLength = postHeaders.length();
|
||||
}
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativePost(nativeWebShell,
|
||||
synchronized(getBrowserControl()) {
|
||||
nativePost(getNativeWebShell(),
|
||||
absoluteUrl,
|
||||
target,
|
||||
postDataLength,
|
||||
|
@ -224,7 +223,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("NavigationImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.1 2003-09-28 06:29:06 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
|
|
@ -61,7 +61,7 @@ protected NativeEventThread eventThread = null;
|
|||
public WindowControlImpl(WrapperFactory yourFactory,
|
||||
BrowserControl yourBrowserControl)
|
||||
{
|
||||
super(yourFactory, yourBrowserControl, false);
|
||||
super(yourFactory, yourBrowserControl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,6 @@ public void delete()
|
|||
Assert.assert_it(null != eventThread, "eventThread shouldn't be null at delete time");
|
||||
eventThread.delete();
|
||||
eventThread = null;
|
||||
nativeWebShell = -1;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -106,11 +105,11 @@ NativeEventThread getNativeEventThread()
|
|||
public void setBounds(Rectangle newBounds)
|
||||
{
|
||||
ParameterCheck.nonNull(newBounds);
|
||||
myFactory.verifyInitialized();
|
||||
Assert.assert_it(-1 != nativeWebShell);
|
||||
getWrapperFactory().verifyInitialized();
|
||||
Assert.assert_it(-1 != getNativeWebShell());
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetBounds(nativeWebShell, newBounds.x, newBounds.y,
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeSetBounds(getNativeWebShell(), newBounds.x, newBounds.y,
|
||||
newBounds.width, newBounds.height);
|
||||
}
|
||||
}
|
||||
|
@ -119,16 +118,18 @@ public void createWindow(int nativeWindow, Rectangle bounds)
|
|||
{
|
||||
ParameterCheck.greaterThan(nativeWindow, 0);
|
||||
ParameterCheck.nonNull(bounds);
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
synchronized(getBrowserControl()) {
|
||||
synchronized(this) {
|
||||
nativeWebShell = nativeCreateInitContext(nativeWindow, bounds.x,
|
||||
/**
|
||||
getNativeWebShell() = nativeCreateInitContext(nativeWindow, bounds.x,
|
||||
bounds.y, bounds.width,
|
||||
bounds.height, myBrowserControl);
|
||||
bounds.height, getBrowserControl());
|
||||
**/
|
||||
eventThread = new NativeEventThread("EventThread-" +
|
||||
nativeWebShell,
|
||||
myBrowserControl);
|
||||
getNativeWebShell(),
|
||||
getBrowserControl());
|
||||
|
||||
// IMPORTANT: the nativeEventThread initializes all the
|
||||
// native browser stuff, then sends us notify().
|
||||
|
@ -146,23 +147,23 @@ public void createWindow(int nativeWindow, Rectangle bounds)
|
|||
|
||||
public int getNativeWebShell()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
return nativeWebShell;
|
||||
return getNativeWebShell();
|
||||
}
|
||||
|
||||
public void moveWindowTo(int x, int y)
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeMoveWindowTo(nativeWebShell, x, y);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeMoveWindowTo(getNativeWebShell(), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFocus()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::removeFocus has not yet been implemented.\n");
|
||||
|
||||
|
@ -170,25 +171,25 @@ public void removeFocus()
|
|||
|
||||
public void repaint(boolean forceRepaint)
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeRepaint(nativeWebShell, forceRepaint);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeRepaint(getNativeWebShell(), forceRepaint);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean newState)
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
synchronized(myBrowserControl) {
|
||||
nativeSetVisible(nativeWebShell, newState);
|
||||
synchronized(getBrowserControl()) {
|
||||
nativeSetVisible(getNativeWebShell(), newState);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocus()
|
||||
{
|
||||
myFactory.verifyInitialized();
|
||||
getWrapperFactory().verifyInitialized();
|
||||
|
||||
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::setFocus has not yet been implemented.\n");
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ public native void nativeSetBounds(int webShellPtr, int x, int y,
|
|||
*/
|
||||
|
||||
public native int nativeCreateInitContext(int nativeWindow,
|
||||
int x, int y, int width, int height, BrowserControl myBrowserControlImpl);
|
||||
int x, int y, int width, int height, BrowserControl BrowserControlImpl);
|
||||
|
||||
public native void nativeDestroyInitContext(int nativeWindow);
|
||||
|
||||
|
@ -244,7 +245,7 @@ public static void main(String [] args)
|
|||
|
||||
Log.setApplicationName("WindowControlImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.1 2003-09-28 06:29:07 edburns%acm.org Exp $");
|
||||
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.2 2004-03-05 15:34:24 edburns%acm.org Exp $");
|
||||
|
||||
try {
|
||||
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);
|
||||
|
|
|
@ -35,6 +35,9 @@ import org.mozilla.webclient.ImplObject;
|
|||
import org.mozilla.webclient.impl.WrapperFactory;
|
||||
import org.mozilla.webclient.impl.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WrapperFactoryImpl extends Object implements WrapperFactory
|
||||
{
|
||||
//
|
||||
|
@ -54,6 +57,14 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory
|
|||
protected String platformCanvasClassName = null;
|
||||
protected boolean initialized = false;
|
||||
protected int nativeContext = -1;
|
||||
/**
|
||||
* <p>keys: BrowserControl instances</p>
|
||||
*
|
||||
* <p>values: the native counterpart to that BrowserControl
|
||||
* instance, as an Integer.</p>
|
||||
*
|
||||
*/
|
||||
protected Map nativeBrowserControls = null;
|
||||
|
||||
// Relationship Instance Variables
|
||||
|
||||
|
@ -84,6 +95,7 @@ protected ProfileManager profileManager = null;
|
|||
public WrapperFactoryImpl()
|
||||
{
|
||||
super();
|
||||
nativeBrowserControls = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,21 +168,15 @@ public Object newImpl(String interfaceName,
|
|||
result = new EventRegistrationImpl(this, browserControl);
|
||||
}
|
||||
if (BrowserControl.BOOKMARKS_NAME == interfaceName) {
|
||||
if (null == bookmarks) {
|
||||
bookmarks = new BookmarksImpl(this);
|
||||
}
|
||||
Assert.assert_it(null != bookmarks);
|
||||
result = bookmarks;
|
||||
}
|
||||
if (BrowserControl.PREFERENCES_NAME == interfaceName) {
|
||||
if (null == prefs) {
|
||||
prefs = new PreferencesImpl(this);
|
||||
}
|
||||
Assert.assert_it(null != prefs);
|
||||
result = prefs;
|
||||
}
|
||||
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
|
||||
if (null == profileManager) {
|
||||
profileManager = new ProfileManagerImpl(this);
|
||||
}
|
||||
Assert.assert_it(null != profileManager);
|
||||
result = profileManager;
|
||||
}
|
||||
}
|
||||
|
@ -251,6 +257,39 @@ public int getNativeContext() {
|
|||
return nativeContext;
|
||||
}
|
||||
|
||||
public int getNativeBrowserControl(BrowserControl bc) {
|
||||
verifyInitialized();
|
||||
Integer result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (null == (result = (Integer) nativeBrowserControls.get(bc))) {
|
||||
try {
|
||||
result = new Integer(nativeCreateBrowserControl(nativeContext));
|
||||
nativeBrowserControls.put(bc, result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
result = new Integer(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.intValue();
|
||||
}
|
||||
|
||||
public void destroyNativeBrowserControl(BrowserControl bc) {
|
||||
verifyInitialized();
|
||||
Integer result = null;
|
||||
|
||||
synchronized(this) {
|
||||
if (null != (result = (Integer) nativeBrowserControls.get(bc))) {
|
||||
try {
|
||||
nativeDestroyBrowserControl(nativeContext, result.intValue());
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// helper methods
|
||||
//
|
||||
|
@ -289,12 +328,12 @@ protected String getPlatformCanvasClassName()
|
|||
|
||||
/**
|
||||
|
||||
* This is called only once, at the very beginning of program execution.
|
||||
* <p>This is called only once, at the very beginning of program execution.
|
||||
* This method allows the native code to handle ONE TIME initialization
|
||||
* tasks. Per-window initialization tasks are handled in the
|
||||
* WindowControlImpl native methods. <P>
|
||||
* tasks. Per-window initialization tasks are handled in
|
||||
* {@link #nativeCreateBrowserControl}. </p>
|
||||
|
||||
* For mozilla, this means initializing XPCOM.
|
||||
* <p>For mozilla, this means initializing XPCOM.</p>
|
||||
|
||||
*/
|
||||
|
||||
|
@ -330,4 +369,19 @@ native void nativeTerminate(int nativeContext) throws Exception;
|
|||
|
||||
native boolean nativeDoesImplement(String interfaceName);
|
||||
|
||||
/**
|
||||
|
||||
* <p>The one and only entry point to do per-window initialization.</p>
|
||||
|
||||
*/
|
||||
native int nativeCreateBrowserControl(int nativeContext) throws Exception;
|
||||
|
||||
/*
|
||||
|
||||
* <p>The one and only de-allocater for the nativeBrowserControl</p>
|
||||
|
||||
*/
|
||||
native int nativeDestroyBrowserControl(int nativeContext,
|
||||
int nativeBrowserControl) throws Exception;
|
||||
|
||||
} // end of class WrapperFactoryImpl
|
||||
|
|
|
@ -153,23 +153,4 @@ public void terminate() throws Exception
|
|||
System.out.println("\n\n\n +++++ You should Never have reached Here - in terminate +++++ \n\n\n");
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_START
|
||||
|
||||
//
|
||||
// Test methods
|
||||
//
|
||||
|
||||
public static void main(String [] args)
|
||||
{
|
||||
Assert.setEnabled(true);
|
||||
WrapperFactory me = new WrapperFactoryImpl();
|
||||
Log.setApplicationName("WrapperFactoryImpl");
|
||||
Log.setApplicationVersion("0.0");
|
||||
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.1 2001-07-27 21:01:13 ashuk%eng.sun.com Exp $");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ----VERTIGO_TEST_END
|
||||
|
||||
} // end of class WrapperFactoryImpl
|
||||
|
|
|
@ -150,6 +150,13 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_ProfileMa
|
|||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv =
|
||||
wcContext->sProfile->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("ProfileManagerImpl_nativeShutdown: ShutDownCurrentProfile: rv: %d\n", rv));
|
||||
|
||||
NS_RELEASE(wcContext->sProfile);
|
||||
wcContext->sProfile = nsnull;
|
||||
NS_RELEASE(wcContext->sProfileInternal);
|
||||
|
|
|
@ -180,10 +180,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetu
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/************* PENDING(edburns): fix this when someone replies to my
|
||||
* 20030915 post to n.p.m.embedding
|
||||
|
||||
// appshell
|
||||
// XXX startup appshell service?
|
||||
// XXX create offscreen window for appshell service?
|
||||
|
@ -218,8 +214,6 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeAppSetu
|
|||
"Failed to Spinup AppShell");
|
||||
return;
|
||||
}
|
||||
****/
|
||||
|
||||
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeAppSetup: exiting\n"));
|
||||
|
@ -238,12 +232,15 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeTermina
|
|||
|
||||
PR_ASSERT(wcContext);
|
||||
|
||||
/********* PENDING(edburns): fix this when the above appshell logic
|
||||
is fixed
|
||||
if (wcContext->sAppShell) {
|
||||
rv = wcContext->sAppShell->Spindown();
|
||||
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
|
||||
("WrapperFactoryImpl_nativeTerminate: Spindown rv: %d\n",
|
||||
rv));
|
||||
|
||||
NS_RELEASE(wcContext->sAppShell);
|
||||
wcContext->sAppShell = nsnull;
|
||||
***/
|
||||
}
|
||||
PR_ASSERT(nsnull == wcContext->sProfile);
|
||||
PR_ASSERT(nsnull == wcContext->sProfileInternal);
|
||||
|
||||
|
@ -294,3 +291,13 @@ Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDoesImp
|
|||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeCreateBrowserControl
|
||||
(JNIEnv *env, jobject obj, jint nativeContext) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_WrapperFactoryImpl_nativeDestroyBrowserControl
|
||||
(JNIEnv *env, jobject obj, jint nativeContext, jint nativeBrowserControl) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* $Id: NavigationTest.java,v 1.1 2004-03-05 15:34:24 edburns%acm.org Exp $
|
||||
*/
|
||||
|
||||
/* -*- 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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun
|
||||
* Microsystems, Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
package org.mozilla.webclient;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
import junit.framework.Test;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
// NavigationTest.java
|
||||
|
||||
public class NavigationTest extends WebclientTestCase {
|
||||
|
||||
public NavigationTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return (new TestSuite(NavigationTest.class));
|
||||
}
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
//
|
||||
// Testcases
|
||||
//
|
||||
|
||||
public void testNavigation() throws Exception {
|
||||
BrowserControl firstBrowserControl = null;
|
||||
BrowserControlFactory.setAppData(getBrowserBinDir());
|
||||
firstBrowserControl = BrowserControlFactory.newBrowserControl();
|
||||
assertNotNull(firstBrowserControl);
|
||||
|
||||
Navigation nav = (Navigation)
|
||||
firstBrowserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
|
||||
assertNotNull(nav);
|
||||
File testPage = new File(getBrowserBinDir(),
|
||||
"../../java/webclient/test/automated/src/test/NavigationTest.txt");
|
||||
|
||||
System.out.println("Loading url: " + testPage.toURL().toString());
|
||||
nav.loadURL(testPage.toURL().toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +1,33 @@
|
|||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: /home/edburns/Projects/mozilla/MOZILLA_1_4/mozilla/dist/bin
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppInitialize: exiting
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: entering
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
|
||||
1024[80fc498]: ProfileManagerImpl_nativeStartup: exiting
|
||||
1024[80fc498]: PreferencesImpl_nativeStartup: entering
|
||||
1024[80fc498]: PreferencesImpl_nativeStartup: exiting
|
||||
1024[80fc498]: BookmarksImpl_nativeStartup: entering
|
||||
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188
|
||||
1024[80fc498]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file nsChromeRegistry.cpp, line 3188
|
||||
1024[80fc498]: BookmarksImpl_nativeStartup: exiting
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeAppSetup: exiting
|
||||
1024[80fc498]: BookmarksImpl_nativeShutdown: entering
|
||||
1024[80fc498]: BookmarksImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: PreferencesImpl_nativeShutdown: entering
|
||||
1024[80fc498]: PreferencesImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: ProfileManagerImpl_nativeShutdown: entering
|
||||
1024[80fc498]: ProfileManagerImpl_nativeShutdown: exiting
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: entering
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0
|
||||
1024[80fc498]: WrapperFactoryImpl_nativeTerminate: exiting
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: nativeBinDir: D:\Projects\mozilla\MOZILLA_NIH\mozilla\dist\bin
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_NewNativeLocalFile rv: 0
|
||||
0[18692650]: WARNING: Error parsing GRE default preferences. Is this an old-style embedding app?, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/modules/libpref/src/nsPrefService.cpp, line 757
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: NS_InitEmbedding rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppInitialize: exiting
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: entering
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: GetProfileCount rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: commandLineService initialize rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: profileInternal startupWithArgs rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeStartup: exiting
|
||||
0[18692650]: PreferencesImpl_nativeStartup: entering
|
||||
0[18692650]: PreferencesImpl_nativeStartup: exiting
|
||||
0[18692650]: BookmarksImpl_nativeStartup: entering
|
||||
0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18692650]: WARNING: NS_ENSURE_TRUE(NS_SUCCEEDED(rv)) failed, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/rdf/chrome/src/nsChromeRegistry.cpp, line 3185
|
||||
0[18692650]: BookmarksImpl_nativeStartup: exiting
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell create rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: AppShell spinup rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeAppSetup: exiting
|
||||
0[18692650]: BookmarksImpl_nativeShutdown: entering
|
||||
0[18692650]: BookmarksImpl_nativeShutdown: exiting
|
||||
0[18692650]: PreferencesImpl_nativeShutdown: entering
|
||||
0[18692650]: PreferencesImpl_nativeShutdown: exiting
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: entering
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: ShutDownCurrentProfile: rv: 0
|
||||
0[18692650]: ProfileManagerImpl_nativeShutdown: exiting
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: entering
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: Spindown rv: 0
|
||||
0[18692650]: WARNING: nsExceptionService ignoring thread destruction after shutdown, file d:/Projects/mozilla/MOZILLA_NIH/mozilla/xpcom/base/nsExceptionService.cpp, line 189
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: NS_TermEmbedding rv: 0
|
||||
0[18692650]: WrapperFactoryImpl_nativeTerminate: exiting
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This test file is for the NavigationTest.
|
Загрузка…
Ссылка в новой задаче