harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-4662) [classlib][swing][html] CSS is used to specify HTML tag behavior
Date Wed, 22 Aug 2007 06:46:31 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-4662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12521706
] 

Vasily Zakharov commented on HARMONY-4662:
------------------------------------------

Alexey, the problem here is the specification states some behavior for elements, and replacing
CSS removes that behavior. For examples, <center> tag (see HARMONY-4572) stops centering
the text. The specification for it says "The CENTER element is exactly equivalent to specifying
the DIV element with the align attribute set to 'center'", and so user expects the <center>-ed
text would be centered. Capability to replace existing CSS is good, but it's strange to expect
the user would write "center { text-align: center }" in his new CSS, as that behavior is stated
in the specification.

Of course, default margins, font weights, sizes etc. can be set in default CSS. But there
probably should be some internal mechanism defining the element behind the default CSS. I
think, that could make our implementation better.

By the way, I tried to remove the default stylesheet in IE, and <center> tag works normally
there.

Could you please provide a link to the specification part that states that the tags can behave
differently than specified if default stylesheet is removed?


> [classlib][swing][html] CSS is used to specify HTML tag behavior
> ----------------------------------------------------------------
>
>                 Key: HARMONY-4662
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4662
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>         Attachments: Harmony.jpg, RI.jpg
>
>
> For now Harmony uses modules/swing/src/main/java/common/javax/swing/text/html/default.css
file to specify behavior for many HTML tags, like <center>, <b>, and some others.
Moreover, it seems that RI does the same for many tags. This is quite comfortable and efficient,
but is not quite compliant to HTML specification because default CSS may be replaced and tags
start to behave incompatibly to the specification.
> The following test shows how the tags operate by default and with default CSS replaced
with empty stylesheet:
> import java.awt.Container;
> import javax.swing.*;
> import javax.swing.border.*;
> import javax.swing.text.html.*;
> public class Test {
>     static final String testHTML =
>             "<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading
3</h3>"
>           + "<h4>Heading 4</h4><h5>Heading 5</h5><h6>Heading
6</h6>"
>           + "<p>paragraph</p><pre>  pre\n   pre</pre><center>center</center>"
>           + "<p><b>bold</b> <strong>strong</strong> <i>italic</i>
<em>em</em></p>"
>           + "<p><small>small</small> normal <big>big</big></p>"
>           + "<a>aaa</a> <a href=\"\">href</a> <code>code</code>
<tt>tt</tt>";
>     public static void main(String argv[]) {
>         try {
>             JFrame frame = new JFrame("Test");
>             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>             Container pane = frame.getContentPane();
>             pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
>             Border border = new BevelBorder(BevelBorder.LOWERED);
>             JEditorPane defaultPane = new JEditorPane("text/html", testHTML);
>             defaultPane.setBorder(new TitledBorder(border, "Default CSS",
>                     TitledBorder.LEFT, TitledBorder.ABOVE_TOP));
>             JEditorPane replacedPane = new JEditorPane("text/html", "");
>             replacedPane.setBorder(new TitledBorder(border, "Empty CSS",
>                     TitledBorder.LEFT, TitledBorder.ABOVE_TOP));
>             HTMLEditorKit editorKit = new HTMLEditorKit();
>             StyleSheet styleSheet = new StyleSheet();
>             editorKit.setStyleSheet(styleSheet);
>             replacedPane.setEditorKit(editorKit);
>             replacedPane.setText(testHTML);
>             pane.add(defaultPane);
>             pane.add(replacedPane);
>             frame.pack();
>             frame.setVisible(true);
>         } catch (Exception e) {
>             e.printStackTrace(System.out);
>         }
>     }
> }
> The attached screenshots demonstrate the behavior of RI and Harmony.
> As one may see, on both RI and Harmony only <b> and <i> tags operate normally
with empty stylesheet, and also <pre> tag retains part of its functionality (spaces
are not merged).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message