diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-14 23:12:35 +0000 |
| commit | ffde862e033a0825e1e9972a89c0f1f80b261a8e (patch) | |
| tree | 97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/gnu/javax/swing/text/html | |
| parent | b415ff10527e977c3758234fd930e2c027bfa17d (diff) | |
| download | ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.zip | |
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92
* HACKING: Add more importing hints. Update automake version
requirement.
* configure.ac (gconf-peer): New enable AC argument.
Add --disable-gconf-peer and --enable-default-preferences-peer
to classpath configure when gconf is disabled.
* scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
gnu/java/awt/dnd/peer/gtk to bc. Classify
gnu/java/security/Configuration.java as generated source file.
* gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
gnu/java/lang/management/VMThreadMXBeanImpl.java,
gnu/java/lang/management/VMMemoryMXBeanImpl.java,
gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
classes.
* java/lang/management/VMManagementFactory.java: Likewise.
* java/net/VMURLConnection.java: Likewise.
* gnu/java/nio/VMChannel.java: Likewise.
* java/lang/Thread.java (getState): Add stub implementation.
* java/lang/Class.java (isEnum): Likewise.
* java/lang/Class.h (isEnum): Likewise.
* gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.
* javax/naming/spi/NamingManager.java: New override for StackWalker
functionality.
* configure, sources.am, Makefile.in, gcj/Makefile.in,
include/Makefile.in, testsuite/Makefile.in: Regenerated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/javax/swing/text/html')
6 files changed, 321 insertions, 38 deletions
diff --git a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java index 5f7309583ea..06732e401fe 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java +++ b/libjava/classpath/gnu/javax/swing/text/html/CharacterAttributeTranslator.java @@ -83,7 +83,7 @@ public class CharacterAttributeTranslator * @param colorName the color to convert. * @return the matching java.awt.color */ - private static Color getColor(String colorName) + public static Color getColor(String colorName) { colorName = colorName.toLowerCase(); try diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java b/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java new file mode 100644 index 00000000000..841db667e84 --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/GnuParserDelegator.java @@ -0,0 +1,178 @@ +/* GnuParserDelegator.java -- The parser delegator which uses Swing DTD + Copyright (C) 2006 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 gnu.javax.swing.text.html.parser; + +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; + +import javax.swing.text.BadLocationException; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.HTMLEditorKit.ParserCallback; +import javax.swing.text.html.parser.DTD; +import javax.swing.text.html.parser.ParserDelegator; +import javax.swing.text.html.parser.TagElement; + +/** + * This parser delegator uses the different DTD ({@link HTML_401Swing}). + * It is derived from the ParserDelegator for the compatibility reasons. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class GnuParserDelegator extends ParserDelegator implements Serializable +{ + class gnuParser + extends gnu.javax.swing.text.html.parser.support.Parser + { + private static final long serialVersionUID = 1; + + gnuParser(DTD d) + { + super(d); + } + + protected final void handleComment(char[] comment) + { + callBack.handleComment(comment, hTag.where.startPosition); + } + + protected final void handleEmptyTag(TagElement tag) + throws javax.swing.text.ChangedCharSetException + { + callBack.handleSimpleTag(tag.getHTMLTag(), getAttributes(), + hTag.where.startPosition + ); + } + + protected final void handleEndTag(TagElement tag) + { + callBack.handleEndTag(tag.getHTMLTag(), hTag.where.startPosition); + } + + protected final void handleError(int line, String message) + { + callBack.handleError(message, hTag.where.startPosition); + } + + protected final void handleStartTag(TagElement tag) + { + htmlAttributeSet attributes = gnu.getAttributes(); + + if (tag.fictional()) + attributes.addAttribute(ParserCallback.IMPLIED, Boolean.TRUE); + + callBack.handleStartTag(tag.getHTMLTag(), attributes, + hTag.where.startPosition + ); + } + + protected final void handleText(char[] text) + { + callBack.handleText(text, hTag.where.startPosition); + } + + DTD getDTD() + { + // Accessing the inherited gnu.javax.swing.text.html.parser.support.Parser + // field. super. is a workaround, required to support JDK1.3's javac. + return super.dtd; + } + } + + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = -1276686502624777206L; + + private DTD theDtd; + + /** + * The callback. + * This is package-private to avoid an accessor method. + */ + HTMLEditorKit.ParserCallback callBack; + + /** + * The reference to the working class of HTML parser that is + * actually used to parse the document. + * This is package-private to avoid an accessor method. + */ + gnuParser gnu; + + /** + * Create the parser that uses the given DTD to parse the document. + * + * @param theDtd the DTD + */ + public GnuParserDelegator(DTD theDtd) + { + this.theDtd = theDtd; + gnu = new gnuParser(theDtd); + } + + /** + * Parses the HTML document, calling methods of the provided callback. This + * method must be multithread - safe. + * + * @param reader The reader to read the HTML document from + * @param a_callback The callback that is notifyed about the presence of HTML + * elements in the document. + * @param ignoreCharSet If thrue, any charset changes during parsing are + * ignored. + * @throws java.io.IOException + */ + public void parse(Reader reader, + HTMLEditorKit.ParserCallback a_callback, + boolean ignoreCharSet) throws IOException + { + callBack = a_callback; + gnu.parse(reader); + + callBack.handleEndOfLineString(gnu.getEndOfLineSequence()); + try + { + callBack.flush(); + } + catch (BadLocationException ex) + { + // Convert this into the supported type of exception. + throw new IOException(ex.getMessage()); + } + } +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java index 1ed42a2ab98..c3c347e36e3 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401F.java @@ -759,23 +759,8 @@ public class HTML_401F defElement(BODY, 0, true, true, null, NONE , - new String[] { - PCDATA, A, ABBR, ACRONYM, - APPLET, B, BASEFONT, BDO, BIG, - BR, BUTTON, CITE, CODE, DFN, - EM, FONT, I, IFRAME, IMG, - INPUT, KBD, LABEL, MAP, OBJECT, - Q, S, SAMP, SCRIPT, SELECT, - SMALL, SPAN, STRIKE, STRONG, SUB, - SUP, TEXTAREA, TT, U, VAR, - ADDRESS, BLOCKQUOTE, CENTER, DEL, DIR, - DIV, DL, FIELDSET, FORM, H1, - H2, H3, H4, H5, H6, - HR, INS, ISINDEX, MENU, NOFRAMES, - NOSCRIPT, OL, P, PRE, TABLE, - UL - } - , + getBodyElements() + , new AttributeList[] { attr(sID, null, null, ID, IMPLIED), attr(CLASS, null, null, 0, IMPLIED), @@ -3634,7 +3619,7 @@ public class HTML_401F * Crate a content model, consisting of the single * element, specified by name. */ - private ContentModel model(String element) + protected ContentModel model(String element) { return new ContentModel(getElement(element)); } @@ -3653,7 +3638,7 @@ public class HTML_401F /** * Create the model HEAD, BODY - * @return + * @return the HTML content model of the whole document */ protected ContentModel createHtmlContentModel() { @@ -3725,5 +3710,27 @@ public class HTML_401F li.type = ul.type = ol.type = '|'; return li; } - + + /** + * Get elements that are allowed in the document body, at the zero level. + */ + protected String[] getBodyElements() + { + return new String[] { + PCDATA, A, ABBR, ACRONYM, + APPLET, B, BASEFONT, BDO, BIG, + BR, BUTTON, CITE, CODE, DFN, + EM, FONT, I, IFRAME, IMG, + INPUT, KBD, LABEL, MAP, OBJECT, + Q, S, SAMP, SCRIPT, SELECT, + SMALL, SPAN, STRIKE, STRONG, SUB, + SUP, TEXTAREA, TT, U, VAR, + ADDRESS, BLOCKQUOTE, CENTER, DEL, DIR, + DIV, DL, FIELDSET, FORM, H1, + H2, H3, H4, H5, H6, + HR, INS, ISINDEX, MENU, NOFRAMES, + NOSCRIPT, OL, P, PRE, TABLE, + UL + }; + } } diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java new file mode 100644 index 00000000000..9c934f647de --- /dev/null +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/HTML_401Swing.java @@ -0,0 +1,91 @@ +/* HTML_401Swing.java -- The HTML 4.01 DTD, adapted for HTML rendering in Swing + Copyright (C) 2006 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 gnu.javax.swing.text.html.parser; + +import javax.swing.text.html.parser.DTD; + +/** + * This class is necessary because the current implementation of the GNU + * Classpath Swing requires always enclose the text into paragraphs. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class HTML_401Swing extends HTML_401F +{ + /** + * The singleton instance; + */ + final static HTML_401Swing singleton = new HTML_401Swing(); + + /** + * Either takes the document (by name) from DTD table, or + * creates a new instance and registers it in the tabe. + * The document is registerd under name "-//W3C//DTD HTML 4.01 Frameset//EN". + * @return The new or existing DTD for parsing HTML 4.01 Frameset. + */ + public static DTD getInstance() + { + return singleton; + } + + /** + * Get elements that are allowed in the document body, at the zero level. + * This list disallows the text at this level (the implied P tag will be + * generated). It also disallows A, B, I, U, CITE and other similar + * elements that have the plain text inside. They will also be placed + * inside the generated implied P tags. + */ + protected String[] getBodyElements() + { + return new String[] { + APPLET, BASEFONT, + BR, BUTTON, + IFRAME, IMG, + INPUT, LABEL, MAP, OBJECT, + SCRIPT, SELECT, + TEXTAREA, + BLOCKQUOTE, CENTER, DEL, DIR, + DIV, DL, FIELDSET, FORM, H1, + H2, H3, H4, H5, H6, + HR, INS, ISINDEX, MENU, NOFRAMES, + NOSCRIPT, OL, P, PRE, TABLE, + UL + }; + } +} diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java index 45e1dce7b04..930a324f9b7 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/SmallHtmlAttributeSet.java @@ -100,8 +100,6 @@ public class SmallHtmlAttributeSet key = en.nextElement(); keys[i] = key; value = copyFrom.getAttribute(key); - if (value instanceof String) - value = ((String) value).toLowerCase(); values[i] = value; } } diff --git a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java index 1f9eee03a91..4d287a67763 100644 --- a/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java +++ b/libjava/classpath/gnu/javax/swing/text/html/parser/htmlValidator.java @@ -233,7 +233,9 @@ public abstract class htmlValidator Element fe = (Element) v; // notify the content model that we add the proposed tag - getCurrentContentModel().show(fe); + node ccm = getCurrentContentModel(); + if (ccm != null) + ccm.show(fe); openFictionalTag(fe); Object vv = tagIsValidForContext(tElement); @@ -301,13 +303,12 @@ public abstract class htmlValidator } /** - * Check if this tag is valid for the current context. - * Return Boolean.True if it is OK, Boolean.False - * if it is surely not OK or the Element that the - * content model recommends to insert making the situation - * ok. If Boolean.True is returned, the content model current - * position is moved forward. Otherwise this position remains - * the same. + * Check if this tag is valid for the current context. Return Boolean.True if + * it is OK, Boolean.False if it is surely not OK or the Element that the + * content model recommends to insert making the situation ok. If Boolean.True + * is returned, the content model current position is moved forward. Otherwise + * this position remains the same. + * * @param tElement * @return */ @@ -321,7 +322,7 @@ public abstract class htmlValidator // Check exclusions and inclusions. ListIterator iter = stack.listIterator(stack.size()); - hTag t; + hTag t = null; final int idx = tElement.getElement().index; // Check only known tags. @@ -331,19 +332,27 @@ public abstract class htmlValidator while (iter.hasPrevious()) { t = (hTag) iter.previous(); - if (!t.forcibly_closed) + if (! t.forcibly_closed) { - if (t.element.exclusions != null && - t.element.exclusions.get(idx) - ) + if (t.element.exclusions != null + && t.element.exclusions.get(idx)) return Boolean.FALSE; if (t.element.inclusions != null) inclusions.or(t.element.inclusions); } } - if (!inclusions.get(idx)) - return Boolean.FALSE; + if (! inclusions.get(idx)) + { + // If we need to insert something, and cannot do this, but + // it is allowed to insert the paragraph here, insert the + // paragraph. + Element P = dtd.getElement(HTML_401F.P); + if (inclusions.get(P.index)) + return P; + else + return Boolean.FALSE; + } } return Boolean.TRUE; } |

