[cp-patches] Patch: Text components home and end actions

2005-12-20 Thread Lillian Angel
Tony and I implemented HOME and END actions for text components.
Unfortunately, we tried to implement a more efficient solution but
viewToModel was not returning the proper values. I added a TODO comment
in there, so it could get looked at later once we have viewToModel
fixed.

2005-12-20  Lillian Angel <[EMAIL PROTECTED]>

* javax/swing/text/DefaultEditorKit.java:
Added implementation for beginLineAction and
endLineAction.
* javax/swing/text/JTextComponent.java
(JTextComponent): Added key bindings for HOME and END.

Index: javax/swing/text/DefaultEditorKit.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultEditorKit.java,v
retrieving revision 1.25
diff -u -r1.25 DefaultEditorKit.java
--- javax/swing/text/DefaultEditorKit.java	21 Nov 2005 20:59:32 -	1.25
+++ javax/swing/text/DefaultEditorKit.java	20 Dec 2005 22:37:42 -
@@ -38,8 +38,10 @@
 
 package javax.swing.text;
 
+import java.awt.Point;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
@@ -698,6 +700,53 @@
 new InsertContentAction(),
 new InsertTabAction(),
 new PasteAction(),
+new TextAction(beginLineAction)
+{
+  public void actionPerformed(ActionEvent event)
+  {
+JTextComponent t = getTextComponent(event);
+try
+{
+  // TODO: There is a more efficent solution, but
+  // viewToModel doesn't work properly.
+  Point p = t.modelToView(t.getCaret().getDot()).getLocation();
+  int cur = t.getCaretPosition();
+  int y = p.y;
+  while (y == p.y && cur > 0)
+y = t.modelToView(--cur).getLocation().y;
+  if (cur != 0)
+cur++;
+  t.setCaretPosition(cur);
+}
+catch (BadLocationException ble)
+{
+  // Do nothing here.
+}
+  }
+},
+new TextAction(endLineAction)
+{
+  public void actionPerformed(ActionEvent event)
+  {
+JTextComponent t = getTextComponent(event);
+   try
+   {
+ Point p = t.modelToView(t.getCaret().getDot()).getLocation();
+ int cur = t.getCaretPosition();
+ int y = p.y;
+ int length = t.getDocument().getLength();
+ while (y == p.y && cur < length)
+   y = t.modelToView(++cur).getLocation().y;
+ if (cur != length)
+   cur--;
+ t.setCaretPosition(cur);
+   }
+   catch (BadLocationException ble)
+   {
+ // Nothing to do here
+   }
+  }
+},
 new TextAction(deleteNextCharAction) 
 { 
   public void actionPerformed(ActionEvent event)
Index: javax/swing/text/JTextComponent.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/JTextComponent.java,v
retrieving revision 1.46
diff -u -r1.46 JTextComponent.java
--- javax/swing/text/JTextComponent.java	21 Nov 2005 20:59:32 -	1.46
+++ javax/swing/text/JTextComponent.java	20 Dec 2005 22:37:42 -
@@ -945,6 +945,10 @@
  new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
KeyEvent.SHIFT_DOWN_MASK),
 DefaultEditorKit.selectionForwardAction),
+ new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
+   DefaultEditorKit.beginLineAction),
+ new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
+   DefaultEditorKit.endLineAction),
  new KeyBinding(KeyStroke.getKeyStroke("typed \u007f"),
 DefaultEditorKit.deleteNextCharAction)
 },
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Patch: JTree null root fix

2005-12-20 Thread Lillian Angel
For some reason, an exception was being thrown for a null root. It is
legal to set the root of a tree to null. This is now fixed. I took out
some revalidate calls that were not needed.

2005-12-20  Lillian Angel  <[EMAIL PROTECTED]>

* javax/swing/plaf/basic/BasicTreeUI.java
(pathWasExpanded): Removed unneeded revalidate call.
(pathWasCollapsed): Likewise.
(installUI): Fixed to check for null root.
(paint): Fixed to always update path.
(toggleExpandState): Removed call to update path.
(editingStopped): Likewise.
(editingCanceled): Likewise.
(treeStructureChanged): Likewise.
(treeExpanded): Likewise.
(treeCollapsed): Likewise.
(treeNodesChanged): Likewise.
(treeNodesInserted): Likewise.
(treeNodesRemoved): Likewise.
(updateCurrentVisiblePath): Added check for null root. If root 
is null, nothing should be painted or in the path.
* javax/swing/tree/DefaultTreeModel.java
(setRoot): Root can be null.

Index: javax/swing/plaf/basic/BasicTreeUI.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTreeUI.java,v
retrieving revision 1.115
diff -u -r1.115 BasicTreeUI.java
--- javax/swing/plaf/basic/BasicTreeUI.java	16 Nov 2005 16:55:20 -	1.115
+++ javax/swing/plaf/basic/BasicTreeUI.java	20 Dec 2005 21:29:00 -
@@ -1201,7 +1201,6 @@
   protected void pathWasExpanded(TreePath path)
   {
 validCachedPreferredSize = false;
-tree.revalidate();
 tree.repaint();
   }
 
@@ -1211,7 +1210,6 @@
   protected void pathWasCollapsed(TreePath path)
   {
 validCachedPreferredSize = false;
-tree.revalidate();
 tree.repaint();
   }
 
@@ -1354,9 +1352,13 @@
 setModel(mod);
 if (mod != null)
   {
-TreePath path = new TreePath(mod.getRoot());
-if (!tree.isExpanded(path))
-  toggleExpandState(path);
+Object root = mod.getRoot();
+if (root != null)
+  {
+TreePath path = new TreePath(root);
+if (!tree.isExpanded(path))
+  toggleExpandState(path);
+  }
   }
 treeSelectionModel = tree.getSelectionModel();
 
@@ -1406,8 +1408,7 @@
   public void paint(Graphics g, JComponent c)
   {
 JTree tree = (JTree) c;
-if (currentVisiblePath == null)
-  updateCurrentVisiblePath();
+updateCurrentVisiblePath();
 
 Rectangle clip = g.getClipBounds();
 Insets insets = tree.getInsets();
@@ -1636,7 +1637,7 @@
 tree.add(editingComponent.getParent());
 editingComponent.getParent().validate();
 validCachedPreferredSize = false;
-tree.revalidate();
+
 ((JTextField) editingComponent).requestFocusInWindow(false);
 editorTimer.start();
 return true;
@@ -1725,7 +1726,6 @@
   tree.collapsePath(path);
 else
   tree.expandPath(path);
-updateCurrentVisiblePath();
   }
 
   /**
@@ -2082,7 +2082,6 @@
   tree.requestFocusInWindow(false);
   editorTimer.stop();
   validCachedPreferredSize = false;
-  tree.revalidate();
   tree.repaint();
 }
 
@@ -2113,7 +2112,6 @@
   editorTimer.stop();
   isEditing = false;
   validCachedPreferredSize = false;
-  tree.revalidate();
   tree.repaint();
 }
   }// CellEditorHandler
@@ -2544,8 +2542,6 @@
   if ((event.getPropertyName()).equals("rootVisible"))
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
 }
@@ -2642,8 +2638,6 @@
 public void treeExpanded(TreeExpansionEvent event)
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
 
@@ -2656,8 +2650,6 @@
 public void treeCollapsed(TreeExpansionEvent event)
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
   }// TreeExpansionHandler
@@ -2847,8 +2839,6 @@
 public void treeNodesChanged(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
 
@@ -2863,8 +2853,6 @@
 public void treeNodesInserted(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
 
@@ -2882,8 +2870,6 @@
 public void treeNodesRemoved(TreeModelEvent e)
 {
   validCachedPreferredSize = false;
-  updateCurrentVisiblePath();
-  tree.revalidate();
   tree.repaint();
 }
 
@@ -2902,9 +2888,7 @@
   if (e.getPath().length == 1
   && !e.getPath()[0].equals(treeModel.getRoot()))
 tree.expandPath(new TreePath(treeModel.getRoot()));
-  updateCurrentVisiblePath();
 

[cp-patches] Patch for AbstractDocument fixes PR 25506

2005-12-20 Thread Anthony Balkissoon
Small fixlet fixes a long standing and annoying problem with text
components.

2005-12-20  Anthony Balkissoon  <[EMAIL PROTECTED]>

Fixes bug #25506
* javax/swing/text/AbstractDocument.java:
(insertString): Fire insert update whether the DocumentEvent was
changed or not.

--Tony
Index: javax/swing/text/AbstractDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/AbstractDocument.java,v
retrieving revision 1.41
diff -u -r1.41 AbstractDocument.java
--- javax/swing/text/AbstractDocument.java	15 Dec 2005 21:17:46 -	1.41
+++ javax/swing/text/AbstractDocument.java	20 Dec 2005 21:25:57 -
@@ -544,8 +544,7 @@
 insertUpdate(event, attributes);
 writeUnlock();
 
-if (event.modified)
-  fireInsertUpdate(event);
+fireInsertUpdate(event);
 if (undo != null)
   fireUndoableEditUpdate(new UndoableEditEvent(this, undo));
   }
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] FYI: BasicMenuItemUI fix

2005-12-20 Thread Lillian Angel
Can you send the patch for this?

On Mon, 2005-12-19 at 16:05 +0100, Roman Kennke wrote:
> My previous optimization for JComponent painting exposed a bug in
> BasicMenuItemUI which causes MenuItems to be rendered badly. This is
> fixed by this patch.
> 
> 
> 2005-12-19  Roman Kennke  <[EMAIL PROTECTED]>
> 
> * javax/swing/plaf/basic/BasicMenuItemUI.java
> (paintBackground): Also fill background for unselected items here.
> (paintMenuItem): Call paintBackground() with the background
> parameter.
> 
> 
> /Roman
> 
> 
> ___
> Classpath-patches mailing list
> Classpath-patches@gnu.org
> http://lists.gnu.org/mailman/listinfo/classpath-patches



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: [cp-patches] Patch: several fixes for DefaultStyledDocument

2005-12-20 Thread Anthony Balkissoon
On Tue, 2005-12-20 at 11:01 -0500, Anthony Balkissoon wrote:
> On Mon, 2005-12-19 at 17:54 -0500, Anthony Balkissoon wrote:
> > This is the first part of the work I'm doing on DefaultStyledDocument.
> > This fixes a couple issues associated with PR 24744 but the bug is not
> > completely fixed yet, so the testcase for that PR still crashes.  I will
> > continue to work on this but these changes are ready to go in and may
> > help get some text/html test apps up and running so I'm committing this
> > now.
> 
> This patch caused some Mauve regressions because it's causing an
> unexpected exception, I'm working on this and will also be checking in
> the Mauve tests I wrote while creating this patch.
> 
> --Tony

Okay, I've fixed the regressions and made progress with the attached
patch.  Yesterday I put code in ElementBuffer.insertContentTag to join
Elements if they had the same attribute sets.  This was incorrect and
led to the Mauve regressions.  The problem was that the wrong
information was being passed to insertContentTag.
DefaultStyledDocument.insertUpdate basically makes a list of
ElementSpecs that it wants the ElementBuffer to turn into Elements.
There was a problem in this method that was causing the wrong
ElementSpecs to be sent to the ElementBuffer (and eventually to
insertContentTag).  This is fixed, but the solution is somewhat of a
hack.  

The reason for the hack is as follows.  To create a LeafElement (a
structural object) we call AbstractDocument.createLeafElement which
takes as one of its parameters an AttributeSet that you want the
LeafElement to have.  However, in the process of creating the
LeafElement we actually add an attribute to the set that describes the
LeafElement's start and end offset positions.  So for instance, the
following code would print "false" (the parent, start_offset, end_offset
arguments are not important to this discussion):

SimpleAttributeSet set = new SimpleAttributeSet();
set.addAttribute("A", "B");
Element e = createLeafElement(parent, set, start_offset, end_offset);
System.out.println (e.isEqual(set));

And this is the basis of our problem .. before we were comparing the
AttributeSet that we were going to use to create an Element with the
attribute set from an Element that already existed and so we'd always
get that they were not equal.  So the hack basically calls
createLeafElement to create an Element from which we get an
AttributeSet, and we use _that_ set in our comparisons.  The element
returned from createLeafElement is then thrown away, we don't actually
add it to the Document structure.

Since I consider this a bit of a hack, comments are appreciated (Roman?)
in case another solution is preferred.

2005-12-20  Anthony Balkissoon  <[EMAIL PROTECTED]>

* javax/swing/text/DefaultStyledDocument.java:
(ElementBuffer.insertContentTag): If the direction is 
OriginateDirection split all the time, don't check the attribute sets.
Removed the special case for the first insertion.  These cases should
fall under the direction JoinPreviousDirection. Changed the comments to
reflect this.
(insertUpdate): Added a hack to get the right result when comparing
the attributes of the new ElementSpec to the attributes of either
the previous or next Element.

--Tony
Index: javax/swing/text/DefaultStyledDocument.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultStyledDocument.java,v
retrieving revision 1.21
diff -u -r1.21 DefaultStyledDocument.java
--- javax/swing/text/DefaultStyledDocument.java	19 Dec 2005 22:52:32 -	1.21
+++ javax/swing/text/DefaultStyledDocument.java	20 Dec 2005 18:24:13 -
@@ -866,89 +866,36 @@
   removed = new Element[0];
   index++;
 }
-  else if (current.getStartOffset() == offset
-   && current.getEndOffset() - 1 == endOffset)
-{
-  // This is if the new insertion covers the entire range of 
-  // current.  This will generally happen for the 
-  // first insertion into a new paragraph.
-  added = new Element[1];
-  added[0] = createLeafElement(paragraph, tagAtts,
-   offset, endOffset + 1);  
-}
   else if (current.getStartOffset() == offset)
-{
+{ 
   // This is if the new insertion happens immediately before 
-  // the current Element.  In this case, if there is
-  // a split, there are 2 resulting Elements.
-  
-  AttributeSet splitAtts = splitRes[1].getAttributes();  
-  if (attributeSetsAreSame(tagAtts, splitAtts))
-{
-  // If the attributes of the adjacent Elements are the same
-  // then we don't split them, we join 

[cp-patches] Patch: CSS Parser

2005-12-20 Thread Lillian Angel
Implemented some more parts of the CSS parser. I added some more
comments in to help with implementation later. I have reached a point
where I can no longer properly implement the functions since I am
currently unable to throughly test. I will come back to this and finish
the implementation soon.

2005-12-19  Lillian Angel  <[EMAIL PROTECTED]>

* javax/swing/text/html/CSSParser.java
(CSSParser): Initialized tokenBuffer with some
arbitrary size. This makes append much more efficent since
a new array will not been created with each append.
(append): Fixed append to create a new larger array if
needed.
(nextToken): Finished implemented. Should decrease the
tokenBufferLength if an identifier was read. This way " and '
are not added to the buffer.
(parse): Implemented to call the appropriate parsing function
based on parameter.
(getNextStatement): Implemented.
(parseAtRule): Added some helpful comments for implementing.
(parseRuleSet): Likewise.
(parseIdentifiers): Likewise.
(readComment): Likewise.
* javax/swing/text/html/StyleSheet.java
(addRule): Implemented.
(loadRules): Implemented.
(importStyleSheet): Removed implementation for now. It causes
a loop. Added FIXME
(startRule): Implemented.
(handleProperty): Implemented.
(addSelector): Implemented.

Index: ChangeLog
===
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.5866
diff -u -r1.5866 ChangeLog
--- ChangeLog	20 Dec 2005 15:59:45 -	1.5866
+++ ChangeLog	20 Dec 2005 18:54:07 -
@@ -1,5 +1,32 @@
 2005-12-19  Lillian Angel  <[EMAIL PROTECTED]>
 
+	* javax/swing/text/html/CSSParser.java
+	(CSSParser): Initialized tokenBuffer with some
+	arbitrary size. This makes append much more efficent since
+	a new array will not been created with each append.
+	(append): Fixed append to create a new larger array if
+	needed.
+	(nextToken): Finished implemented. Should decrease the
+	tokenBufferLength if an identifier was read. This way " and '
+	are not added to the buffer.
+	(parse): Implemented to call the appropriate parsing function
+	based on parameter.
+	(getNextStatement): Implemented.
+	(parseAtRule): Added some helpful comments for implementing.
+	(parseRuleSet): Likewise.
+	(parseIdentifiers): Likewise.
+	(readComment): Likewise.
+	* javax/swing/text/html/StyleSheet.java
+	(addRule): Implemented.
+	(loadRules): Implemented.
+	(importStyleSheet): Removed implementation for now. It causes
+	a loop. Added FIXME
+	(startRule): Implemented.
+	(handleProperty): Implemented.
+	(addSelector): Implemented.
+
+2005-12-19  Lillian Angel  <[EMAIL PROTECTED]>
+
 	* javax/swing/text/html/BlockView.java
 	(getStyleSheet): Implemented.
 	* javax/swing/text/html/CSSParser.java: New private class,
Index: javax/swing/text/html/CSSParser.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/CSSParser.java,v
retrieving revision 1.1
diff -u -r1.1 CSSParser.java
--- javax/swing/text/html/CSSParser.java	20 Dec 2005 15:59:45 -	1.1
+++ javax/swing/text/html/CSSParser.java	20 Dec 2005 18:54:09 -
@@ -149,7 +149,8 @@
   /**
* The character mapping in the document.
*/
-  private static final char[] charMapping = null; // FIXME
+  // FIXME: What is this used for?
+  private static final char[] charMapping = null;
 
   /**
* Set to true if one character has been read ahead.
@@ -162,7 +163,7 @@
   private int pushedChar;
 
   /**
-   *  Temporary place to hold identifiers.
+   * Temporary place to hold identifiers.
*/
   private StringBuffer unitBuffer;
 
@@ -212,6 +213,7 @@
   CSSParser()
   {
 unitBuffer = new StringBuffer();
+tokenBuffer = new char[10];
   }
 
   /**
@@ -221,12 +223,18 @@
*/
   private void append(char c)
   {
-char[] temp = new char[tokenBufferLength + 1];
-if (tokenBuffer != null)
-  System.arraycopy(tokenBuffer, 0, temp, 0, tokenBufferLength);
-temp[tokenBufferLength] = c;
+if (tokenBuffer.length >= tokenBufferLength)
+  {
+char[] temp = new char[tokenBufferLength * 2];
+if (tokenBuffer != null)
+  System.arraycopy(tokenBuffer, 0, temp, 0, tokenBufferLength);
+
+temp[tokenBufferLength] = c;
+tokenBuffer = temp;
+  }
+else
+  tokenBuffer[tokenBufferLength] = c;
 tokenBufferLength++;
-tokenBuffer = temp;
   }
 
   /**
@@ -244,10 +252,12 @@
 switch (next)
   {
   case '\"':
-// FIXME: Not Implemented
+if (tokenBufferLength > 0)
+  tokenBufferLength--;
 return IDENTIFIER;
   case '\'':
-// FIXME: Not Implemented
+if (tokenBufferLength > 0)
+  tokenBufferLength--;
 return IDENTIFIER;
   case '(':
 return PAR

Re: [cp-patches] Patch: several fixes for DefaultStyledDocument

2005-12-20 Thread Anthony Balkissoon
On Mon, 2005-12-19 at 17:54 -0500, Anthony Balkissoon wrote:
> This is the first part of the work I'm doing on DefaultStyledDocument.
> This fixes a couple issues associated with PR 24744 but the bug is not
> completely fixed yet, so the testcase for that PR still crashes.  I will
> continue to work on this but these changes are ready to go in and may
> help get some text/html test apps up and running so I'm committing this
> now.

This patch caused some Mauve regressions because it's causing an
unexpected exception, I'm working on this and will also be checking in
the Mauve tests I wrote while creating this patch.

--Tony



___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Patch: CSS Parser

2005-12-20 Thread Lillian Angel
After looking into StyleSheets quite a bit, I found we needed a
CSSParser. This is not a public class, so it has been hard to implement
with almost no documentation. It is partially implemented so far. I am
still working on it.

2005-12-19  Lillian Angel  <[EMAIL PROTECTED]>

* javax/swing/text/html/BlockView.java
(getStyleSheet): Implemented.
* javax/swing/text/html/CSSParser.java: New private class,
partially implemented.
* javax/swing/text/html/HTMLEditorKit.java
(createDefaultDocument): Fixed to create HTMLDocument with
default style sheet.
(getStyleSheet): Fixed to initialize style sheet if null.
* javax/swing/text/html/StyleSheet.java
(CssParser): New private inner class, partially implemented.

Index: javax/swing/text/html/BlockView.java
===
RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/BlockView.java,v
retrieving revision 1.2
diff -u -r1.2 BlockView.java
--- javax/swing/text/html/BlockView.java	15 Dec 2005 19:20:07 -	1.2
+++ javax/swing/text/html/BlockView.java	20 Dec 2005 15:53:32 -
@@ -294,7 +294,8 @@
*/
   protected StyleSheet getStyleSheet()
   {
-// FIXME: Not implemented properly.
-return new StyleSheet();
+StyleSheet styleSheet = new StyleSheet();
+styleSheet.importStyleSheet(getClass().getResource(HTMLEditorKit.DEFAULT_CSS));
+return styleSheet;
   }
 }
Index: javax/swing/text/html/CSSParser.java
===
RCS file: javax/swing/text/html/CSSParser.java
diff -N javax/swing/text/html/CSSParser.java
--- /dev/null	1 Jan 1970 00:00:00 -
+++ javax/swing/text/html/CSSParser.java	20 Dec 2005 15:53:32 -
@@ -0,0 +1,512 @@
+/* CSSParser.java --
+   Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.text.html;
+
+import java.io.*;
+
+/**
+ * Parses a CSS document. This works by way of a delegate that implements the
+ * CSSParserCallback interface. The delegate is notified of the following
+ * events: 
+ * - Import statement: handleImport 
+ * - Selectors handleSelector. This is invoked for each string. For example if 
+ * the Reader contained p, bar , a {}, the delegate would be notified 4 times, 
+ * for 'p,' 'bar' ',' and 'a'. 
+ * - When a rule starts, startRule 
+ * - Properties in the rule via the handleProperty. This
+ * is invoked one per property/value key, eg font size: foo;, would cause the
+ * delegate to be notified once with a value of 'font size'. 
+ * - Values in the rule via the handleValue, this is notified for the total value. 
+ * - When a rule ends, endRule
+ * 
+ * @author Lillian Angel ([EMAIL PROTECTED])
+ */
+class CSSParser
+{
+
+  /**
+   * Receives all information about the CSS document structure while parsing it.
+   * The methods are invoked by parser.
+   */
+  static interface CSSParserCallback
+  {
+/**
+ * Handles the import statment in the document.
+ * 
+ * @param imp - the import string
+ */
+public abstract void handleImport(String imp);
+
+/**
+ * Called when the start of a rule is encountered.
+ */
+public abstract void startRule();
+
+/**
+ * Called when the end of a rule is encounte