A fix to these two methods. Oddly structured Documents were causing
GapContent errors (on the JDK as well, this isn't representative of our
implementation being fragile), so I replaced get Element-specific
getText call with a general getText(). This fixes the problem.
2005-09-27 Anthony Balkissoon <[EMAIL PROTECTED]>
* javax/swing/text/Utilities.java:
(getRowEnd): Call getText() rather than trying to get the Element-
specific portion to avoid GapContent errors.
(getRowStart): Likewise.
--Tony
On Tue, 2005-09-27 at 12:47 -0400, Anthony Balkissoon wrote:
> On Roman's advice, I changed the 2 methods to use binary searching
> rather than sequential searching. This is now committed.
>
> 2005-09-27 Anthony Balkissoon <[EMAIL PROTECTED]>
>
> * javax/swing/text/Utilities.java:
> (getRowEnd): New method.
> (getRowStart): New method.
>
> --Tony
>
> On Mon, 2005-09-26 at 16:34 -0400, Anthony Balkissoon wrote:
> > I implemented getRowStart and getRowEnd in javax.swing.text.Utilities.
> > This is RFC because of the issue raised in the large comment in each of
> > this methods (namely, performance). Some comments would be appreciated.
> >
> >
> > 2005-09-26 Anthony Balkissoon <[EMAIL PROTECTED]>
> >
> > * javax/swing/text/Utilities.java:
> > (getRowEnd): New method.
> > (getRowStart): New method.
> >
> > --Tony
> > _______________________________________________
> > Classpath-patches mailing list
> > [email protected]
> > http://lists.gnu.org/mailman/listinfo/classpath-patches
> _______________________________________________
> Classpath-patches mailing list
> [email protected]
> http://lists.gnu.org/mailman/listinfo/classpath-patches
Index: javax/swing/text/Utilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/Utilities.java,v
retrieving revision 1.12
diff -u -r1.12 Utilities.java
--- javax/swing/text/Utilities.java 27 Sep 2005 16:46:21 -0000 1.12
+++ javax/swing/text/Utilities.java 28 Sep 2005 14:44:22 -0000
@@ -408,10 +408,7 @@
public static final int getRowEnd(JTextComponent c, int offs)
throws BadLocationException
{
- Element root = c.getDocument().getDefaultRootElement();
- Element rowElement = root.getElement(root.getElementIndex(offs));
- String text = c.getText(rowElement.getStartOffset(),
- rowElement.getEndOffset());
+ String text = c.getText();
if (text == null)
return -1;
@@ -420,7 +417,7 @@
// line as the character at position offs
int high = offs + ((text.length() - 1 - offs) / 2);
int low = offs;
- int oldHigh = text.length();
+ int oldHigh = text.length() + 1;
while (true)
{
if (c.modelToView(high).y != c.modelToView(offs).y)
@@ -454,10 +451,7 @@
public static final int getRowStart(JTextComponent c, int offs)
throws BadLocationException
{
- Element root = c.getDocument().getDefaultRootElement();
- Element rowElement = root.getElement(root.getElementIndex(offs));
- String text = c.getText(rowElement.getStartOffset(),
- rowElement.getEndOffset());
+ String text = c.getText();
if (text == null)
return -1;
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches