diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text')
3 files changed, 47 insertions, 24 deletions
diff --git a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java index 625ba4c..bd21e55 100644 --- a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java +++ b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java @@ -1053,14 +1053,6 @@ public class DefaultStyledDocument extends AbstractDocument implements Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); - - if (end != toRec.getEndOffset()) - { - recreateLeaves(end, toRec, onlyContent); - - if (onlyContent) - edit.addRemovedElement(target); - } } else paragraph.replace(0, 0, new Element[] { leaf }); diff --git a/libjava/classpath/javax/swing/text/GapContent.java b/libjava/classpath/javax/swing/text/GapContent.java index 1780d7d..4f06003 100644 --- a/libjava/classpath/javax/swing/text/GapContent.java +++ b/libjava/classpath/javax/swing/text/GapContent.java @@ -918,7 +918,7 @@ public class GapContent int mid = 0; while (low <= hi) { - mid = (low + hi) >> 1; + mid = (low + hi) >>> 1; final int d = a[mid]; if (d == key) return mid; diff --git a/libjava/classpath/javax/swing/text/html/HTMLDocument.java b/libjava/classpath/javax/swing/text/html/HTMLDocument.java index b7a7069..e714a85 100644 --- a/libjava/classpath/javax/swing/text/html/HTMLDocument.java +++ b/libjava/classpath/javax/swing/text/html/HTMLDocument.java @@ -39,13 +39,15 @@ exception statement from your version. */ package javax.swing.text.html; import gnu.classpath.NotImplementedException; - import gnu.javax.swing.text.html.CharacterAttributeTranslator; + import java.io.IOException; import java.net.URL; import java.util.HashMap; import java.util.Stack; import java.util.Vector; + +import javax.swing.JEditorPane; import javax.swing.text.AbstractDocument; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; @@ -59,9 +61,15 @@ import javax.swing.text.StyleConstants; import javax.swing.text.html.HTML.Tag; /** - * TODO: Add more comments here + * Represents the HTML document that is constructed by defining the text and + * other components (images, buttons, etc) in HTML language. This class can + * becomes the default document for {@link JEditorPane} after setting its + * content type to "text/html". HTML document also serves as an intermediate + * data structure when it is needed to parse HTML and then obtain the content of + * the certain types of tags. This class also has methods for modifying the HTML + * content. * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) * @author Anthony Balkissoon (abalkiss@redhat.com) * @author Lillian Angel (langel@redhat.com) */ @@ -640,17 +648,25 @@ public class HTMLDocument extends DefaultStyledDocument } } - public class HiddenAction extends TagAction + /** + * This action indicates that the content between starting and closing HTML + * elements (like script - /script) should not be visible. The content is + * still inserted and can be accessed when iterating the HTML document. The + * parser will only fire + * {@link javax.swing.text.html.HTMLEditorKit.ParserCallback#handleText} for + * the hidden tags, regardless from that html tags the hidden section may + * contain. + */ + public class HiddenAction + extends TagAction { /** * This method is called when a start tag is seen for one of the types * of tags associated with this Action. */ public void start(HTML.Tag t, MutableAttributeSet a) - throws NotImplementedException { - // FIXME: Implement. - print ("HiddenAction.start not implemented"); + blockOpen(t, a); } /** @@ -658,10 +674,8 @@ public class HTMLDocument extends DefaultStyledDocument * with this Action. */ public void end(HTML.Tag t) - throws NotImplementedException { - // FIXME: Implement. - print ("HiddenAction.end not implemented"); + blockClose(t); } } @@ -727,11 +741,17 @@ public class HTMLDocument extends DefaultStyledDocument } } + /** + * Inserts the elements that are represented by ths single tag with + * attributes (only). The closing tag, even if present, mut follow + * immediately after the starting tag without providing any additional + * information. Hence the {@link TagAction#end} method need not be + * overridden and still does nothing. + */ public class SpecialAction extends TagAction { /** - * This method is called when a start tag is seen for one of the types - * of tags associated with this Action. + * The functionality is delegated to {@link HTMLReader#addSpecialElement} */ public void start(HTML.Tag t, MutableAttributeSet a) { @@ -1407,10 +1427,21 @@ public class HTMLDocument extends DefaultStyledDocument * @param a the attribute set specifying the special content */ protected void addSpecialElement(HTML.Tag t, MutableAttributeSet a) - throws NotImplementedException { - // FIXME: Implement - print ("HTMLReader.addSpecialElement not implemented yet"); + a.addAttribute(StyleConstants.NameAttribute, t); + + // Migrate from the rather htmlAttributeSet to the faster, lighter and + // unchangeable alternative implementation. + AttributeSet copy = a.copyAttributes(); + + // TODO: Figure out why we must always insert this single character + // (otherwise the element does not appear). Either fix or add explaining + // comment or at least report a normal bug. + DefaultStyledDocument.ElementSpec spec; + spec = new DefaultStyledDocument.ElementSpec(copy, + DefaultStyledDocument.ElementSpec.ContentType, + new char[] {' '}, 0, 1 ); + parseBuffer.add(spec); } void printBuffer() |