diff options
author | Roman Kennke <roman@kennke.org> | 2006-08-24 16:58:10 +0000 |
---|---|---|
committer | Roman Kennke <roman@kennke.org> | 2006-08-24 16:58:10 +0000 |
commit | 5aa8789a37162eeeafd0dec99877b1b15974b5d2 (patch) | |
tree | a02624ed9709d85844d66f660147b30914d278be /javax/swing/text/html/HTMLEditorKit.java | |
parent | 5ee15829d2d26ae4a4a67f677c79a498d40f686b (diff) | |
download | classpath-5aa8789a37162eeeafd0dec99877b1b15974b5d2.tar.gz |
2006-08-24 Roman Kennke <kennke@aicas.com>
* javax/swing/text/html/CSSParser.java: Removed.
* javax/swing/text/html/CSS.java
(getValue): New helper method. Returns special converter
instances for certain kinds of property values.
* javax/swing/text/html/HTMLDocument.java
(HTMLReader.CharacterAction.start): Don't translate tags
here. Instead, store the attributes directly with the tag
as key.
(content): Removed field. The Content object is handled
by AbstractDocument.
(styleSheet): Removed field. The styleSheet is the styleContext
of this document and handled by the DefaultStyledDocument already.
(HTMLDocument(Content,StyleSheet): Simply call super here.
The super classes already handle the content and styleContext.
(HTMLDocument()): Call this() with a default GapContent and
StyleSheet.
(getStyleSheet): Return the styleContext here.
(insertUpdate): New method. Overridden to add the
CONTENT dummy tag to the element's attributes.
(setBase): Set the base on the styleContext.
* javax/swing/text/html/HTMLEditorKit.java
(styleContext): Removed unneeded field.
(styleSheet): Made field private.
(HTMLEditorKit): Do nothing here. The StyleSheet is
created lazily in getStyleSheet(). A styleContext is not
needed here.
(getStyleSheet): Create StyleSheet correctly.
(insertHTML): Removed unneeded cast.
* javax/swing/text/html/InlineView.java
(attributes): New field.
(changedUpdate): Reload attributes. Trigger preferenceChanged.
(getAttributes): Implemented to fetch the attributes from
the stylesheet.
* javax/swing/text/html/MultiAttributeSet.java: New class.
Multiplexes between several AttributeSets.
* javax/swing/text/html/MultiStyle.java: New class.
Multiplexes between several Styles.
* javax/swing/text/html/ParagraphView.java
(attributes): New field.
(getAttributes): Implemented to fetch the attributes from
the stylesheet.
* javax/swing/text/html/StyleSheet.java
(CssParser): Removed inner class.
(CSSStyle): New inner class. Represents a style defined
by a CSS rule.
(CSSStyleSheetParserCallback): New class, for parsing
CSS stylesheets.
(css): New field. Stores the CSS rules.
(resolvedStyles): New field. Stores resolved styles.
(StyleSheet): Initialize resolvedStyles map.
(addRule): Removed bogus impl.
(getFont): Implemented to fetch font, based on CSS rules.
(getResolvedStyle): New helper method. Looks up resolved
styles, and resolves a style if necessary.
(resolveStyle): New pair of helper methods. Resolves
CSS style rules.
(getRule(String)): Provide rudimentary implementation.
(getRule(Tag,Element)): Implemented.
(getViewAttributes): Implemented.
(loadRules): Implemented.
(translateHTMLToCSS): Tagged as not implemented.
* javax/swing/text/html/ViewAttributeSet.java: New class.
Diffstat (limited to 'javax/swing/text/html/HTMLEditorKit.java')
-rw-r--r-- | javax/swing/text/html/HTMLEditorKit.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/javax/swing/text/html/HTMLEditorKit.java b/javax/swing/text/html/HTMLEditorKit.java index 5d77be8fd..14ce18e10 100644 --- a/javax/swing/text/html/HTMLEditorKit.java +++ b/javax/swing/text/html/HTMLEditorKit.java @@ -48,6 +48,8 @@ import java.awt.event.MouseMotionListener; import java.awt.Cursor; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Reader; import java.io.Serializable; import java.io.StringReader; @@ -64,7 +66,6 @@ import javax.swing.text.EditorKit; import javax.swing.text.Element; import javax.swing.text.MutableAttributeSet; import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; import javax.swing.text.StyledEditorKit; import javax.swing.text.TextAction; import javax.swing.text.View; @@ -804,7 +805,7 @@ public class HTMLEditorKit /** * The current style sheet. */ - StyleSheet styleSheet; + private StyleSheet styleSheet; /** * The ViewFactory for HTMLFactory. @@ -831,11 +832,6 @@ public class HTMLEditorKit */ LinkController mouseListener; - /** - * Style context for this editor. - */ - StyleContext styleContext; - /** The content type */ String contentType = "text/html"; @@ -850,11 +846,7 @@ public class HTMLEditorKit */ public HTMLEditorKit() { - super(); - styleContext = new StyleContext(); - styleSheet = new StyleSheet(); - styleSheet.importStyleSheet(getClass().getResource(DEFAULT_CSS)); - // FIXME: Set inputAttributes with default.css + // Nothing to do here. } /** @@ -923,8 +915,7 @@ public class HTMLEditorKit if (parser == null) throw new IOException("Parser is null."); - ParserCallback pc = ((HTMLDocument) doc).getReader - (offset, popDepth, pushDepth, insertTag); + ParserCallback pc = doc.getReader(offset, popDepth, pushDepth, insertTag); // FIXME: What should ignoreCharSet be set to? @@ -1154,8 +1145,18 @@ public class HTMLEditorKit { if (styleSheet == null) { - styleSheet = new StyleSheet(); - styleSheet.importStyleSheet(getClass().getResource(DEFAULT_CSS)); + try + { + styleSheet = new StyleSheet(); + InputStream in = getClass().getResourceAsStream(DEFAULT_CSS); + InputStreamReader r = new InputStreamReader(in); + styleSheet.loadRules(r, null); + r.close(); + } + catch (IOException ex) + { + // No style available. + } } return styleSheet; } |