Here come two fixlets for javax.swing.text which are necessary for the HTML renderer to work properly.

2006-08-24  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/text/FlowView.java:
        (LogicalView.getAttributes): New method. Overrides super
        impl to return the attributes of the FlowView instance.
        * javax/swing/text/LabelView.java:
        (setPropertiesFromAttributes): Fetch attributes from
        View, rather then from the Element. (In the HTML
        package the getAttributes() method is overridden to
        return different attributes). Fetch font from the StyledDocument.

/Roman
Index: javax/swing/text/LabelView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/LabelView.java,v
retrieving revision 1.4
diff -u -1 -2 -r1.4 LabelView.java
--- javax/swing/text/LabelView.java	11 Aug 2006 12:33:16 -0000	1.4
+++ javax/swing/text/LabelView.java	24 Aug 2006 16:16:25 -0000
@@ -105,46 +105,43 @@
   {
     super(element);
     valid = false;
   }
 
   /**
    * Loads the properties of this label view from the element's text
    * attributes. This method is called from the constructor and the
    * [EMAIL PROTECTED] #changedUpdate} method
    */
   protected void setPropertiesFromAttributes()
   {
-    Element el = getElement();
-    AttributeSet atts = el.getAttributes();
+    AttributeSet atts = getAttributes();
     // We cannot use StyleConstants.getBackground() here, because that returns
     // BLACK as default (when background == null). What we need is the
     // background setting of the text component instead, which is what we get
     // when background == null anyway.
     background = (Color) atts.getAttribute(StyleConstants.Background);
     foreground = StyleConstants.getForeground(atts);
     setStrikeThrough(StyleConstants.isStrikeThrough(atts));
     setSubscript(StyleConstants.isSubscript(atts));
     setSuperscript(StyleConstants.isSuperscript(atts));
     setUnderline(StyleConstants.isUnderline(atts));
 
     // Determine the font.
-    String family = StyleConstants.getFontFamily(atts);
-    int size = StyleConstants.getFontSize(atts);
-    int style = Font.PLAIN;
-    if (StyleConstants.isBold(atts))
-        style |= Font.BOLD;
-    if (StyleConstants.isItalic(atts))
-      style |= Font.ITALIC;
-    font = new Font(family, style, size);
+    Document d = getDocument();
+    if (d instanceof StyledDocument)
+      {
+        StyledDocument doc = (StyledDocument) d;
+        font = doc.getFont(atts);
+      }
     valid = true;
   }
 
   /**
    * Receives notification when text attributes change in the chunk of
    * text that this view is responsible for. This simply calls
    * [EMAIL PROTECTED] #setPropertiesFromAttributes()}.
    *
    * @param e the document event
    * @param a the allocation of this view
    * @param vf the view factory to use for creating new views
    */
Index: javax/swing/text/FlowView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/FlowView.java,v
retrieving revision 1.15
diff -u -1 -2 -r1.15 FlowView.java
--- javax/swing/text/FlowView.java	7 Aug 2006 11:16:11 -0000	1.15
+++ javax/swing/text/FlowView.java	24 Aug 2006 16:16:25 -0000
@@ -320,24 +320,34 @@
    * visual representation, this is handled by the physical view implemented
    * in the <code>FlowView</code>.
    */
   class LogicalView extends BoxView
   {
     /**
      * Creates a new LogicalView instance.
      */
     LogicalView(Element el, int axis)
     {
       super(el, axis);
     }
+
+    /**
+     * Overridden to return the attributes of the parent
+     * (== the FlowView instance).
+     */
+    public AttributeSet getAttributes()
+    {
+      View p = getParent();
+      return p != null ? p.getAttributes() : null;
+    }
   }
 
   /**
    * The shared instance of FlowStrategy.
    */
   static final FlowStrategy sharedStrategy = new FlowStrategy();
 
   /**
    * The span of the <code>FlowView</code> that should be flowed.
    */
   protected int layoutSpan;
 

Reply via email to