Author= Daniel Park

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


git-svn-id: svn://10.0.0.236/trunk@140912 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2003-04-09 17:42:41 +00:00
parent cd3d35d3ff
commit ed7795ffac
13 changed files with 756 additions and 17 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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"

View File

@@ -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());
}
}
}
}

View File

@@ -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 $");
}

View File

@@ -0,0 +1,100 @@
/* -*- 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.
*
* Contributor(s): Daniel Park <daepark@apmindsf.com>
*
*/
package org.mozilla.webclient.wrapper_native;
import org.w3c.dom.Node;
import org.mozilla.webclient.Selection;
public class SelectionImpl extends Object implements Selection {
private String _selection = null;
private Node _startContainer = null;
private Node _endContainer = null;
private int _startOffset = -1;
private int _endOffset = -1;
/**
* Create an invalid (or uninitialized) Selection object.
*/
public SelectionImpl() {}
public void init(String selection,
Node startContainer,
Node endContainer,
int startOffset,
int endOffset)
{
_selection = selection;
_startContainer = startContainer;
_endContainer = endContainer;
_startOffset = startOffset;
_endOffset = endOffset;
}
/**
* Get the text representation of this Selection object.
*/
public String toString() {
return (_selection);
}
/**
* Get the Node that contains the start of this selection.
*/
public Node getStartContainer() {
return (_startContainer);
}
/**
* Get the Node that contains the end of this selection.
*/
public Node getEndContainer() {
return (_endContainer);
}
/**
* Get the offset to which the selection starts within the startContainer.
*/
public int getStartOffset() {
return (_startOffset);
}
/**
* Get the offset to which the selection ends within the endContainer.
*/
public int getEndOffset() {
return (_endOffset);
}
/**
* Test if the selection properties have been set.
*/
public boolean isValid() {
if (_selection == null ||
_startContainer == null ||
_endContainer == null ||
_startOffset == -1 ||
_endOffset == -1) {
return (false);
}
return (true);
}
} // end class "SelectionImpl"

View File

@@ -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 $");
}