bug 40330

a=edburns

This checkin mainly does two things:

1. Correctly populates the java.awt.event.MouseEvent subclass with the
  correct modifiers, x, y, and clickCount for the mozilla mouse event.

2. Adds a performance optimization: previously, every mouse event was
  causing a new instance of java.util.Properties to be created.  Now,
  only one Properties instance is created per-page, and it is cleared on
  each mouse event.

Also, I made the DOMMouseListenerImpl constructor initialize the
refCount to 0.  This allows the object to be correctly deleted.

M classes_spec/org/mozilla/webclient/test/EMWindow.java
M classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java
M src_moz/DOMMouseListenerImpl.cpp
M src_moz/DOMMouseListenerImpl.h
M src_moz/WindowControlImpl.cpp
M src_moz/jni_util.cpp
M src_moz/jni_util.h
M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h

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

* Added test code for MouseListener properties: buttons, modifiers, etc.

M classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java

* Added support for mouse modifiers.  Pull values out of the hash table,
  put them in the MouseEvent constructor.

M src_moz/DOMMouseListenerImpl.cpp

* Modified constructors so they initialize all ivars.

* changed usage model of properties object to share the lifetime of the
  DOMMouseListenerImpl instance.  Needed to make use of the new function
  util_ClearPropertiesObject() to do this.  Now we have only one call to
  util_DestroyPropertiesObject(), in the DOMMouseListenerImpl
  destructor.

M src_moz/DOMMouseListenerImpl.h

>     virtual ~DOMMouseListenerImpl();
>
98a101
> protected:
100a104,105
>
> void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent);

M src_moz/WindowControlImpl.cpp

* Initialize new WebShellInitConext member propertiesClass to nsnull

M src_moz/jni_util.cpp

* Added util_ClearPropertiesObject() an optimization.

* Store the jclass for java/util/Properties in an element in
  WebShellInitContext.  This prevents us from having to do FindClass
  each time a mouse event occurs.

* Added a parameter to util_StoreIntoPropertiesObject.

M src_moz/jni_util.h

* Added propertiesClass to WebShellInitContext

* Added new method ClearPropertiesObject

* Added new last argument to DestroyPropertiesObject

M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h

* Added function pointer for util_ClearPropertiesObject.


git-svn-id: svn://10.0.0.236/trunk@71756 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2000-06-08 02:16:06 +00:00
parent 0c56583a85
commit 9fac87eedf
9 changed files with 422 additions and 182 deletions

View File

@@ -45,14 +45,13 @@ import org.mozilla.util.Assert;
import org.w3c.dom.Document;
/**
*
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.13 2000-06-05 19:11:22 edburns%acm.org Exp $
* @version $Id: EMWindow.java,v 1.14 2000-06-08 02:16:06 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
@@ -236,7 +235,6 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc
EventRegistration eventRegistration =
(EventRegistration)
browserControl.queryInterface(BrowserControl.EVENT_REGISTRATION_NAME);
System.out.println("debug: edburns: adding DocumentLoadListener");
eventRegistration.addDocumentLoadListener(this);
eventRegistration.addMouseListener(this);
@@ -310,9 +308,7 @@ public void delete()
}
BrowserControlFactory.deleteBrowserControl(browserControl);
browserControl = null;
System.out.println("debug: edburns: about to hide");
this.hide();
System.out.println("debug: edburns: about to dispose");
this.dispose();
urlField = null;
browserCanvas = null;
@@ -530,9 +526,11 @@ public void eventDispatched(WebclientEvent event)
forwardButton.setEnabled(history.canForward());
statusLabel.setText("Done.");
currentDocument = currentPage.getDOM();
// add the new document to the domViewer
if (null != domViewer) {
domViewer.setDocument(currentDocument);
}
break;
}
}
@@ -544,12 +542,20 @@ public void eventDispatched(WebclientEvent event)
public void mouseClicked(java.awt.event.MouseEvent e)
{
System.out.println("mouseClicked");
int modifiers = e.getModifiers();
if (0 != (modifiers & InputEvent.BUTTON1_MASK)) {
System.out.println("Button1 ");
}
if (0 != (modifiers & InputEvent.BUTTON2_MASK)) {
System.out.println("Button2 ");
}
if (0 != (modifiers & InputEvent.BUTTON3_MASK)) {
System.out.println("Button3 ");
}
}
public void mouseEntered(java.awt.event.MouseEvent e)
{
System.out.println("mouseEntered");
if (e instanceof WCMouseEvent) {
WCMouseEvent wcMouseEvent = (WCMouseEvent) e;
Properties eventProps =
@@ -557,6 +563,18 @@ public void mouseEntered(java.awt.event.MouseEvent e)
if (null == eventProps) {
return;
}
if (e.isAltDown()) {
System.out.println("Alt ");
}
if (e.isControlDown()) {
System.out.println("Ctrl ");
}
if (e.isShiftDown()) {
System.out.println("Shift ");
}
if (e.isMetaDown()) {
System.out.println("Meta ");
}
String href = eventProps.getProperty("href");
if (null != href) {
// if it's a relative URL
@@ -569,7 +587,6 @@ public void mouseEntered(java.awt.event.MouseEvent e)
href = currentURL.substring(0, lastSlashIndex) + "/"+ href;
}
}
System.out.println(href);
statusLabel.setText(href);
}
}
@@ -578,19 +595,17 @@ public void mouseEntered(java.awt.event.MouseEvent e)
public void mouseExited(java.awt.event.MouseEvent e)
{
statusLabel.setText("");
System.out.println("mouseExited");
}
public void mousePressed(java.awt.event.MouseEvent e)
{
System.out.println("mousePressed");
}
public void mouseReleased(java.awt.event.MouseEvent e)
{
System.out.println("mouseReleased");
}
//
// Package methods
//

View File

@@ -28,11 +28,14 @@ import org.mozilla.util.ParameterCheck;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.InputEvent;
import java.awt.Component;
import org.mozilla.webclient.WCMouseEvent;
import org.mozilla.webclient.WebclientEvent;
import org.mozilla.webclient.WebclientEventListener;
import java.util.Properties;
/**
* This class wraps the user provided instance of
@@ -109,48 +112,90 @@ public void eventDispatched(WebclientEvent event)
{
ParameterCheck.nonNull(event);
WCMouseEvent mouseEvent;
Properties props = (Properties) event.getEventData();
int modifiers = 0, x = -1, y = -1, clickCount = 0;
String str;
boolean bool;
if (null != (str = props.getProperty("ClientX"))) {
x = Integer.valueOf(str).intValue();
}
if (null != (str = props.getProperty("ClientY"))) {
y = Integer.valueOf(str).intValue();
}
if (null != (str = props.getProperty("ClickCount"))) {
clickCount = Integer.valueOf(str).intValue();
}
if (null != (str = props.getProperty("Button"))) {
int button = Integer.valueOf(str).intValue();
if (1 == button) {
modifiers += InputEvent.BUTTON1_MASK;
}
if (2 == button) {
modifiers += InputEvent.BUTTON2_MASK;
}
if (3 == button) {
modifiers += InputEvent.BUTTON3_MASK;
}
}
if (null != (str = props.getProperty("Alt"))) {
bool = Boolean.valueOf(str).booleanValue();
if (bool) {
modifiers += InputEvent.ALT_MASK;
}
}
if (null != (str = props.getProperty("Ctrl"))) {
bool = Boolean.valueOf(str).booleanValue();
if (bool) {
modifiers += InputEvent.CTRL_MASK;
}
}
if (null != (str = props.getProperty("Meta"))) {
bool = Boolean.valueOf(str).booleanValue();
if (bool) {
modifiers += InputEvent.META_MASK;
}
}
if (null != (str = props.getProperty("Shift"))) {
bool = Boolean.valueOf(str).booleanValue();
if (bool) {
modifiers += InputEvent.SHIFT_MASK;
}
}
switch ((int) event.getType()) {
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_PRESSED, -1,
-1, -1, -1, -1, false, event);
modifiers, x, y, clickCount, false, event);
mouseListener.mousePressed(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_UP_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_RELEASED, -1,
-1, -1, -1, -1, false, event);
modifiers, x, y, clickCount, false, event);
mouseListener.mouseReleased(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_CLICK_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_CLICKED, -1,
-1, -1, -1, 1, false, event);
mouseListener.mouseClicked(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_DOUBLE_CLICK_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_CLICKED, -1,
-1, -1, -1, 2, false, event);
modifiers, x, y, clickCount, false, event);
mouseListener.mouseClicked(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_OVER_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_ENTERED, -1,
-1, -1, -1, -1, false, event);
modifiers, x, y, clickCount, false, event);
mouseListener.mouseEntered(mouseEvent);
break;
case (int) WCMouseEvent.MOUSE_OUT_EVENT_MASK:
mouseEvent =
new WCMouseEvent((Component) event.getSource(),
MouseEvent.MOUSE_EXITED, -1,
-1, -1, -1, -1, false, event);
modifiers, x, y, clickCount, false, event);
mouseListener.mouseExited(mouseEvent);
break;
}