r=edburns

SECTION: classes changes

M build.xml

- Removed spurious linebreak on Kyle's create.webclient.scripts.

M classes_spec/org/mozilla/webclient/BrowserControlCanvas.java

- Bugfix from Daniel Park

M classes_spec/org/mozilla/webclient/test/EMWindow.java

- Leverage new CurrentPage2 interface to display the Selection object.

M classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java
M classes_spec/org/mozilla/webclient/wrapper_nonnative/CurrentPageImpl.java

- Implement new methods from CurrentPage2.

M src_moz/CurrentPageActionEvents.cpp
M src_moz/CurrentPageActionEvents.h
M src_moz/CurrentPageImpl.cpp
M src_moz/gtk/GtkBrowserControlCanvasStub.cpp
M src_moz/gtk/StubFunctions.h

Native details for CurrentPage2.

SECTION: New files

A classes_spec/org/mozilla/webclient/Selection.java
A classes_spec/org/mozilla/webclient/CurrentPage2.java
A classes_spec/org/mozilla/webclient/wrapper_native/SelectionImpl.java
This commit is contained in:
edburns%acm.org 2003-04-09 17:42:41 +00:00
Родитель 33f25f62ef
Коммит b2ba0520fa
13 изменённых файлов: 656 добавлений и 17 удалений

Просмотреть файл

@ -202,8 +202,7 @@ depends="create.win32.webclient.scripts,create.unix.webclient.scripts"/>
<target name="create.win32.webclient.scripts"
if="build.win32.classes">
<condition property="debug.options" value="-Xdebug
-Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n">
<condition property="debug.options" value="-Xdebug -Xrunjdwp:transport=dt_shmem,address=jdbconn,server=y,suspend=n">
<equals arg1="${myenv.MOZ_DEBUG}" arg2="1"/>
</condition>
<condition property="debug.options" value="">
@ -221,8 +220,7 @@ ${myenv.MOZ_JDKHOME}/bin/java ${debug.options} org.mozilla.webclient.test.Embedd
<target name="create.unix.webclient.scripts"
if="build.unix.classes">
<condition property="debug.options" value="-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n">
<condition property="debug.options" value="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n">
<equals arg1="${myenv.MOZ_DEBUG}" arg2="1"/>
</condition>
<condition property="debug.options" value="">

Просмотреть файл

@ -52,7 +52,7 @@ import java.awt.*;
* See concrete subclasses for scope info.
* @version $Id: BrowserControlCanvas.java,v 1.4 2002-10-01 00:39:19 edburns%acm.org Exp $
* @version $Id: BrowserControlCanvas.java,v 1.5 2003-04-09 17:42:30 edburns%acm.org Exp $
* @see org.mozilla.webclient.win32.Win32BrowserControlCanvas
@ -229,6 +229,12 @@ public void setBounds(int x, int y, int w, int h)
super.setBounds(x, y, w, h);
Rectangle boundsRect = new Rectangle(0, 0, w - 1, h - 1);
if (webShell != null) {
if (boundsRect.width < 1) {
boundsRect.width = 1;
}
if (boundsRect.height < 1) {
boundsRect.height = 1;
}
System.out.println("in BrowserControlCanvas setBounds: x = " + x + " y = " + y + " w = " + w + " h = " + h);
try {
WindowControl wc = (WindowControl)

Просмотреть файл

@ -0,0 +1,35 @@
/* -*- 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): Daniel Park <daepark@apmindsf.com>
*/
package org.mozilla.webclient;
public interface CurrentPage2 extends CurrentPage
{
public Selection getSelection();
public void highlightSelection(Selection selection);
public void clearAllSelections();
}
// end of interface CurrentPage

Просмотреть файл

@ -0,0 +1,123 @@
/* -*- 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.
*/
package org.mozilla.webclient;
import org.w3c.dom.Node;
/**
* <b>Selection</b> is more like a DOM Range object which represents a
* portion of a document or a document fragment. This is described as
* all of the content between two boundary points, the start and end
* containers. A selection is define by the following properties:
* startContainer, endContainer, startOffset, endOffset and the text
* representation of the selection.
*
* <p>
* <ul>
*
* <li><b>startContainer</b>: This property is a reference to a Node
* within the document or document fragment. The start of the range
* is contained within this node and the boundary point is determined
* by the startOffset property.
*
* <li><b>endContainer</b>: This property is a reference to a Node within the
* document or document fragment. The end of the range is contained
* within this node and the boundary point is determined by the
* endOffset property.
*
* <li><b>startOffset</b>: This property has one of two meanings, depending
* upon the type of node that the startContainer references. If the
* startContainer is a Text node, Comment node or a CDATASection node
* then this offset represents the number of characters from the
* beginning of the node to where the boundary point lies. Any other
* type of node and it represents the child node index number that the
* boundary point lies BEFORE. If the offset is equal to the number
* of child nodes then the boundary point lies after the last child
* node.
*
* <li><b>endOffset</b>: This property has one of two meanings, depending
* upon the type of node that the endContainer references. If the
* endContainer is a Text node, Comment node or a CDATASection node
* then this offset represents the number of characters from the
* beginning of the node to where the boundary point lies. Any other
* type of node and it represents the child node index number that the
* boundary point lies BEFORE. If the offset is equal to the number
* of child nodes then the boundary point lies after the last child
* node.
*
* </ul>
*
* @author daepark@apmindsf.com
*/
public interface Selection {
/**
* Initialize this Selection object.
*
* @param selection the text representation of this selection
* @param startContainer the start of this selection is contained
* within this node
* @param endContainer the end of this selection is contained within
* this node
* @param startOffset the offset to which the selection starts
* within the startContainer
* @param endOffset the offset to which the selection ends within
* the endContainer
* @see #isValid
*/
public void init(String selection,
Node startContainer,
Node endContainer,
int startOffset,
int endOffset);
/**
* Get the text representation of this Selection object.
*/
public String toString();
/**
* Get the Node that contains the start of this selection.
*/
public Node getStartContainer();
/**
* Get the Node that contains the end of this selection.
*/
public Node getEndContainer();
/**
* Get the offset to which the selection starts within the startContainer.
*/
public int getStartOffset();
/**
* Get the offset to which the selection ends within the endContainer.
*/
public int getEndOffset();
/**
* Test if the selection properties have been set.
*/
public boolean isValid();
} // end interface "Selection"

Просмотреть файл

@ -59,7 +59,7 @@ import java.io.FileInputStream;
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.37 2002-08-31 02:09:12 edburns%acm.org Exp $
* @version $Id: EMWindow.java,v 1.38 2003-04-09 17:42:32 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
@ -76,7 +76,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
private BrowserControlCanvas browserCanvas;
private Navigation2 navigation = null;
private CurrentPage currentPage;
private CurrentPage2 currentPage;
private History history;
private static Preferences prefs;
private Bookmarks bookmarks;
@ -109,7 +109,7 @@ private UniversalDialog uniDialog = null;
private Component refreshButton;
private PopupMenu popup;
private MenuItem popup_ViewSource, popup_SelectAll;
private MenuItem popup_ViewSource, popup_SelectAll, popup_ViewSelection;
private PopupActionListener contextListener;
private String myBinDir;
@ -294,11 +294,13 @@ private UniversalDialog uniDialog = null;
popup.add(popup_ViewSource = new MenuItem("View Source as ByteArray"));
popup.add(popup_SelectAll = new MenuItem("Select All"));
popup.add(popup_ViewSelection = new MenuItem("View Selection"));
contextListener = new PopupActionListener();
popup_ViewSource.addActionListener (contextListener);
popup_SelectAll.addActionListener (contextListener);
popup_ViewSelection.addActionListener (contextListener);
show();
toFront();
@ -307,7 +309,7 @@ private UniversalDialog uniDialog = null;
navigation = (Navigation2)
browserControl.queryInterface(BrowserControl.NAVIGATION_NAME);
navigation.setPrompt(this);
currentPage = (CurrentPage)
currentPage = (CurrentPage2)
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
history = (History)
browserControl.queryInterface(BrowserControl.HISTORY_NAME);
@ -589,7 +591,7 @@ public void dialogDismissed(Dialog d) {
else if(searchString.equals("")) {
System.out.println("Clear button selected");
try {
CurrentPage currentPage = (CurrentPage)
CurrentPage2 currentPage = (CurrentPage2)
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
currentPage.resetFind();
}
@ -601,7 +603,7 @@ public void dialogDismissed(Dialog d) {
System.out.println("Tring to Find String - " + searchString);
System.out.println("Parameters are - Backwrads = " + findDialog.backwards + " and Matchcase = " + findDialog.matchcase);
try {
CurrentPage currentPage = (CurrentPage)
CurrentPage2 currentPage = (CurrentPage2)
browserControl.queryInterface(BrowserControl.CURRENT_PAGE_NAME);
currentPage.findInPage(searchString, !findDialog.backwards, findDialog.matchcase);
}
@ -967,6 +969,13 @@ public void actionPerformed(ActionEvent event) {
System.out.println("I will now Select All");
EMWindow.this.currentPage.selectAll();
}
else if (command.equals("View Selection")) {
Selection selection = EMWindow.this.currentPage.getSelection();
if (selection != null) {
System.err.println("you've selected: " + selection.toString());
}
}
}
}

Просмотреть файл

@ -27,7 +27,8 @@ import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.CurrentPage;
import org.mozilla.webclient.CurrentPage2;
import org.mozilla.webclient.Selection;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
@ -36,12 +37,13 @@ import java.io.*;
import java.net.*;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.mozilla.webclient.UnimplementedException;
import org.mozilla.dom.DOMAccessor;
public class CurrentPageImpl extends ImplObjectNative implements CurrentPage
public class CurrentPageImpl extends ImplObjectNative implements CurrentPage2
{
//
// Protected Constants
@ -97,6 +99,41 @@ public void copyCurrentSelectionToSystemClipboard()
nativeCopyCurrentSelectionToSystemClipboard(nativeWebShell);
}
}
public Selection getSelection() {
Selection selection = new SelectionImpl();
myFactory.throwExceptionIfNotInitialized();
Assert.assert_it(-1 != nativeWebShell);
synchronized(myBrowserControl) {
nativeGetSelection(nativeWebShell, selection);
}
return selection;
}
public void highlightSelection(Selection selection) {
if (selection != null && selection.isValid()) {
Node startContainer = selection.getStartContainer();
Node endContainer = selection.getEndContainer();
int startOffset = selection.getStartOffset();
int endOffset = selection.getEndOffset();
myFactory.throwExceptionIfNotInitialized();
Assert.assert_it(-1 != nativeWebShell);
synchronized(myBrowserControl) {
nativeHighlightSelection(nativeWebShell, startContainer, endContainer, startOffset, endOffset);
}
}
}
public void clearAllSelections() {
myFactory.throwExceptionIfNotInitialized();
Assert.assert_it(-1 != nativeWebShell);
synchronized(myBrowserControl) {
nativeClearAllSelections(nativeWebShell);
}
}
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
{
@ -235,6 +272,12 @@ public void selectAll()
//
native public void nativeCopyCurrentSelectionToSystemClipboard(int webShellPtr);
native public void nativeGetSelection(int webShellPtr,
Selection selection);
native public void nativeHighlightSelection(int webShellPtr, Node startContainer, Node endContainer, int startOffset, int endOffset);
native public void nativeClearAllSelections(int webShellPtr);
native public void nativeFindInPage(int webShellPtr, String stringToFind, boolean forward, boolean matchCase);
@ -268,7 +311,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("CurrentPageImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.18 2001-05-29 18:36:06 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.19 2003-04-09 17:42:34 edburns%acm.org Exp $");
}

Просмотреть файл

Просмотреть файл

@ -32,7 +32,8 @@ import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserType;
import org.mozilla.webclient.CurrentPage;
import org.mozilla.webclient.CurrentPage2;
import org.mozilla.webclient.Selection;
import org.mozilla.webclient.WrapperFactory;
import java.util.Properties;
@ -40,6 +41,7 @@ import java.io.*;
import java.net.*;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import ice.storm.*;
@ -73,7 +75,22 @@ public void copyCurrentSelectionToSystemClipboard()
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::copyCurrentSelectionToSystemClipboard has not yet been implemented.\n");
}
public Selection getSelection() {
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getSelection has not yet been implemented.\n");
}
public void highlightSelection(Selection selection) {
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::highlightSelection has not yet been implemented.\n");
}
public void clearAllSelections() {
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::clearAllSelections has not yet been implemented.\n");
}
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findInPage has not yet been implemented.\n");
public void findInPage(String stringToFind, boolean forward, boolean matchCase)
{
throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::findInPage has not yet been implemented.\n");
@ -190,7 +207,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 2001-07-27 21:01:08 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.2 2003-04-09 17:42:38 edburns%acm.org Exp $");
}

Просмотреть файл

@ -46,6 +46,12 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsIWebBrowserFind.h"
#include "nsIDOMWindow.h"
#include "nsISelection.h"
#include "nsIDOMRange.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMNode.h"
#include "nsCRT.h"
wsCopySelectionEvent::wsCopySelectionEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
@ -75,6 +81,261 @@ wsCopySelectionEvent::handleEvent ()
return result;
}
wsGetSelectionEvent::wsGetSelectionEvent(JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject yourSelection) :
nsActionEvent(),
mEnv(yourEnv),
mInitContext(yourInitContext),
mSelection(yourSelection)
{
}
void *
wsGetSelectionEvent::handleEvent()
{
void *result = nsnull;
if (mEnv != nsnull && mInitContext != nsnull && mSelection != nsnull) {
nsresult rv = nsnull;
// Get the DOM window
nsIDOMWindow *domWindow;
rv = mInitContext->webBrowser->GetContentDOMWindow(&domWindow);
if (NS_FAILED(rv) || domWindow == nsnull ) {
return (void *) rv;
}
// Get the selection object of the DOM window
nsISelection *selection;
rv = domWindow->GetSelection(&selection);
if (NS_FAILED(rv) || selection == nsnull) {
return (void *) rv;
}
// Get the range count
PRInt32 rangeCount;
rv = selection->GetRangeCount(&rangeCount);
if (NS_FAILED(rv) || rangeCount == 0) {
return (void *) rv;
}
// Get the actual selection string
PRUnichar *selectionStr;
rv = selection->ToString(&selectionStr);
if (NS_FAILED(rv)) {
return (void *) rv;
}
jstring string =
mEnv->NewString((jchar*)selectionStr, nsCRT::strlen(selectionStr));
// Get the first range object of the selection object
nsIDOMRange *range;
rv = selection->GetRangeAt(0, &range);
if (NS_FAILED(rv) || range == nsnull) {
return (void *) rv;
}
// Get the properties of the range object (startContainer,
// startOffset, endContainer, endOffset)
PRInt32 startOffset;
PRInt32 endOffset;
nsIDOMNode* startContainer;
nsIDOMNode* endContainer;
// start container
rv = range->GetStartContainer(&startContainer);
if (NS_FAILED(rv)) {
return (void *) rv;
}
// end container
rv = range->GetEndContainer(&endContainer);
if (NS_FAILED(rv)) {
return (void *) rv;
}
// start offset
rv = range->GetStartOffset(&startOffset);
if (NS_FAILED(rv)) {
return (void *) rv;
}
// end offset
rv = range->GetEndOffset(&endOffset);
if (NS_FAILED(rv)) {
return (void *) rv;
}
// get a handle on to acutal (java) Node representing the start
// and end containers
jlong node1Long = nsnull;
jlong node2Long = nsnull;
nsCOMPtr<nsIDOMNode> node1Ptr(do_QueryInterface(startContainer));
nsCOMPtr<nsIDOMNode> node2Ptr(do_QueryInterface(endContainer));
if (nsnull == (node1Long = (jlong)node1Ptr.get())) {
return result;
}
if (nsnull == (node2Long = (jlong)node2Ptr.get())) {
return result;
}
jclass clazz = nsnull;
jmethodID mid = nsnull;
if (nsnull == (clazz = ::util_FindClass(mEnv,
"org/mozilla/dom/DOMAccessor"))) {
return result;
}
if (nsnull == (mid = mEnv->GetStaticMethodID(clazz, "getNodeByHandle",
"(J)Lorg/w3c/dom/Node;"))) {
return result;
}
jobject node1 = (jobject) ((void *)::util_CallStaticObjectMethodlongArg(mEnv, clazz, mid, node1Long));
jobject node2 = (jobject) ((void *)::util_CallStaticObjectMethodlongArg(mEnv, clazz, mid, node2Long));
// prepare the (java) Selection object that is to be returned.
if (nsnull == (clazz = ::util_FindClass(mEnv, "org/mozilla/webclient/Selection"))) {
return result;
}
if (nsnull == (mid = mEnv->GetMethodID(clazz, "init",
"(Ljava/lang/String;Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;II)V"))) {
return result;
}
mEnv->CallVoidMethod(mSelection, mid,
string, node1, node2,
(jint)startOffset, (jint)endOffset);
}
return result;
}
wsHighlightSelectionEvent::wsHighlightSelectionEvent(JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset) :
nsActionEvent(),
mEnv(yourEnv),
mInitContext(yourInitContext),
mStartContainer(startContainer),
mEndContainer(endContainer),
mStartOffset(startOffset),
mEndOffset(endOffset)
{
}
void *
wsHighlightSelectionEvent::handleEvent()
{
void *result = nsnull;
if (mEnv != nsnull && mInitContext != nsnull &&
mStartContainer != nsnull && mEndContainer != nsnull &&
mStartOffset > -1 && mEndOffset > -1)
{
nsresult rv = nsnull;
// resolve ptrs to the nodes
jclass nodeClass = mEnv->FindClass("org/mozilla/dom/NodeImpl");
if (!nodeClass) {
return result;
}
jfieldID nodePtrFID = mEnv->GetFieldID(nodeClass, "p_nsIDOMNode", "J");
if (!nodePtrFID) {
return result;
}
// get the nsIDOMNode representation of the start and end containers
nsIDOMNode* node1 = (nsIDOMNode*)
mEnv->GetLongField(mStartContainer, nodePtrFID);
nsIDOMNode* node2 = (nsIDOMNode*)
mEnv->GetLongField(mEndContainer, nodePtrFID);
if (!node1 || !node2) {
return result;
}
// Get the DOM window
nsIDOMWindow* domWindow;
rv = mInitContext->webBrowser->GetContentDOMWindow(&domWindow);
if (NS_FAILED(rv) || domWindow == nsnull ) {
return (void *) rv;
}
// Get the selection object of the DOM window
nsISelection* selection;
rv = domWindow->GetSelection(&selection);
if (NS_FAILED(rv) || selection == nsnull) {
return (void *) rv;
}
nsCOMPtr<nsIDOMDocumentRange> docRange(do_QueryInterface(mInitContext->currentDocument));
if (docRange) {
nsCOMPtr<nsIDOMRange> range;
rv = docRange->CreateRange(getter_AddRefs(range));
if (range) {
rv = range->SetStart(node1, mStartOffset);
if (NS_FAILED(rv)) {
return (void *) rv;
}
rv = range->SetEnd(node2, mEndOffset);
if (NS_FAILED(rv)) {
return (void *) rv;
}
rv = selection->AddRange(range);
if (NS_FAILED(rv)) {
return (void *) rv;
}
}
}
}
return result;
}
wsClearAllSelectionEvent::wsClearAllSelectionEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext)
{
}
void *
wsClearAllSelectionEvent::handleEvent()
{
void *result = nsnull;
if (mInitContext != nsnull) {
nsresult rv = nsnull;
// Get the DOM window
nsIDOMWindow* domWindow;
rv = mInitContext->webBrowser->GetContentDOMWindow(&domWindow);
if (NS_FAILED(rv) || domWindow == nsnull ) {
return (void *) rv;
}
// Get the selection object of the DOM window
nsISelection* selection;
rv = domWindow->GetSelection(&selection);
if (NS_FAILED(rv) || selection == nsnull) {
return (void *) rv;
}
rv = selection->RemoveAllRanges();
if (NS_FAILED(rv)) {
return (void *) rv;
}
}
return result;
}
wsFindEvent::wsFindEvent(WebShellInitContext *yourInitContext) :
nsActionEvent(),
mInitContext(yourInitContext),

Просмотреть файл

@ -102,6 +102,42 @@ protected:
jlong mDoc;
};
class wsGetSelectionEvent: public nsActionEvent {
public:
wsGetSelectionEvent (JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject yourSelection);
void * handleEvent (void);
protected:
JNIEnv * mEnv;
WebShellInitContext *mInitContext;
jobject mSelection;
};
class wsHighlightSelectionEvent: public nsActionEvent {
public:
wsHighlightSelectionEvent (JNIEnv *yourEnv, WebShellInitContext *yourInitContext, jobject startContainer, jobject endContainer, PRInt32 startOffset, PRInt32 endOffset);
void * handleEvent (void);
protected:
JNIEnv *mEnv;
WebShellInitContext *mInitContext;
jobject mStartContainer;
jobject mEndContainer;
PRInt32 mStartOffset;
PRInt32 mEndOffset;
};
class wsClearAllSelectionEvent: public nsActionEvent {
public:
wsClearAllSelectionEvent (WebShellInitContext *yourInitContext);
void * handleEvent (void);
protected:
WebShellInitContext *mInitContext;
};
#endif /* CurrentPageActionEvents_h___ */

Просмотреть файл

@ -51,6 +51,66 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject selection)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed nativeGetSelection");
return;
}
PR_ASSERT(initContext->initComplete);
if (selection == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null Selection object passed to raptorWebShellGetSelection");
return;
}
wsGetSelectionEvent *actionEvent = new wsGetSelectionEvent(env, initContext, selection);
PLEvent *event = (PLEvent *) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeHighlightSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject startContainer, jobject endContainer, jint startOffset, jint endOffset)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeHighlightSelection");
return;
}
PR_ASSERT(initContext->initComplete);
wsHighlightSelectionEvent *actionEvent = new wsHighlightSelectionEvent(env, initContext, startContainer, endContainer, (PRInt32) startOffset, (PRInt32) endOffset);
PLEvent *event = (PLEvent *) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
}
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeClearAllSelections
(JNIEnv *env, jobject obj, jint webShellPtr)
{
WebShellInitContext *initContext = (WebShellInitContext *) webShellPtr;
if (initContext == nsnull) {
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeClearAllSelections");
return;
}
PR_ASSERT(initContext->initComplete);
wsClearAllSelectionEvent *actionEvent = new wsClearAllSelectionEvent(initContext);
PLEvent *event = (PLEvent *) *actionEvent;
::util_PostSynchronousEvent(initContext, event);
}
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeFindInPage

Просмотреть файл

@ -351,6 +351,25 @@ int locateStubFunctions(void *dll)
PR_LOG(webclientStubLog, PR_LOG_ERROR, ("got dlsym error %s\n", dlerror()));
return -1;
}
nativeGetSelection = (void (*) (JNIEnv *env, jobject obj, jint webShellPtr, jobject selection)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSelection");
if (!nativeGetSelection) {
PR_LOG(webclientStubLog, PR_LOG_ERROR, ("got dlsym error %s\n", dlerror()));
return -1;
}
nativeHighlightSelection = (void (*) (JNIEnv *env, jobject obj, jint webShellPtr, jobject startContainer, jobject endContainer, jint startOffset, jint endOffset)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeHighlightSelection");
if (!nativeHighlightSelection) {
PR_LOG(webclientStubLog, PR_LOG_ERROR, ("got dlsym error %s\n", dlerror()));
return -1;
}
nativeClearAllSelections = (void (*) (JNIEnv *env, jobject obj, jint webShellPtr)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeClearAllSelections");
if (!nativeClearAllSelections) {
PR_LOG(webclientStubLog, PR_LOG_ERROR, ("got dlsym error %s\n", dlerror()));
return -1;
}
nativeFindInPage = (void (*) (JNIEnv *, jobject, jint, jstring, jboolean, jboolean)) dlsym(dll, "Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeFindInPage");
if (!nativeFindInPage) {
PR_LOG(webclientStubLog, PR_LOG_ERROR, ("got dlsym error %s\n", dlerror()));
@ -648,6 +667,35 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp
(* nativeCopyCurrentSelectionToSystemClipboard) (env, obj, webShellPtr);
}
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeGetSelection
* Signature: (ILorg/mozilla/webclient/Selection;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject selection) {
(* nativeGetSelection) (env, obj, webShellPtr, selection);
}
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeHighlightSelection
* Signature: (ILorg/w3c/dom/Node;Lorg/w3c/dom/Node;II)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeHighlightSelection
(JNIEnv *env, jobject obj, jint webShellPtr, jobject startContainer, jobject endContainer, jint startOffset, jint endOffset) {
(* nativeHighlightSelection) (env, obj, webShellPtr, startContainer, endContainer, startOffset, endOffset);
}
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeClearAllSelections
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeClearAllSelections
(JNIEnv *env, jobject obj, jint webShellPtr) {
(* nativeClearAllSelections) (env, obj, webShellPtr);
/*
* Class: org_mozilla_webclient_wrapper_0005fnative_CurrentPageImpl
* Method: nativeFindInPage

Просмотреть файл

@ -81,6 +81,9 @@ jobject (* nativeGetPrefs) (JNIEnv *env, jobject obj, jint webShellPtr, jobject
void (* nativeRegisterPrefChangedCallback) (JNIEnv *env, jobject obj, jint webShellPtr, jobject callback, jstring prefName, jobject closure);
// from CurrentPageImpl.h
void (* nativeCopyCurrentSelectionToSystemClipboard) (JNIEnv *, jobject, jint);
void (* nativeGetSelection) (JNIEnv *, jobject, jint, jobject);
void (* nativeHighlightSelection) (JNIEnv *, jobject, jint, jobject, jobject, jint, jint);
void (* nativeClearAllSelections) (JNIEnv *, jobject, jint);
void (* nativeFindInPage) (JNIEnv *, jobject, jint, jstring, jboolean, jboolean);
void (* nativeFindNextInPage) (JNIEnv *, jobject, jint);
jstring (* nativeGetCurrentURL) (JNIEnv *, jobject, jint);