harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zakharov, Vasily M" <vasily.m.zakha...@intel.com>
Subject RE: [classlib][swing][html] CSS is used to specify HTML tag behavior
Date Wed, 22 Aug 2007 08:08:16 GMT
Alexey,

This is really not good, both Harmony and RI seem doing wrong here.

Is there a way to specify the element behavior in Swing Java code so
that that behavior could be overridden with style?

Maybe creating the base, non-replaceable CSS and specifying such things
there would resolve this problem.

Vasily


-----Original Message-----
From: Alexey Ivanov [mailto:alxey.ivanov@gmail.com] 
Sent: Wednesday, August 22, 2007 12:00 PM
To: dev@harmony.apache.org
Subject: Re: [classlib][swing][html] CSS is used to specify HTML tag
behavior

Andrey,

I don't think that it ignores -- I know it honors them with some
exceptions. I talked about attributes special case for <b> tag. Try
this code:

<b style="font-weight: normal">not bold</b>

In Harmony it would be rendered with bold font despite this style rule.

Additionally,
<html><head><style type="text/css">
    b { font-weight: normal }
</style></head><body>
<b>also not bold</b>
</body></html>

would be rendered in normal font weight, *not bold*, in all the
browsers whereas both Harmony and RI would render it bold.

That's what I talked about.

2007/8/22, Pavlenko, Andrey A <andrey.a.pavlenko@intel.com>:
> I think the best solution would be to merge the default CSS with
user's
> CSS.
>
> Alexey, why do you think Harmony ignores the style attribute of HTML
> elements? I've just created a simple test and it works fine for me:
>
> import javax.swing.JEditorPane;
> import javax.swing.JFrame;
>
> public class SwingTest {
>
>         public static void main(String[] args) {
>                 JFrame f = new JFrame();
>                 f.add(new JEditorPane("text/html",
>                                 "<center style='color: red'>Hello
> world!</center>"));
>                 f.pack();
>                 f.setVisible(true);
>         }
> }
>
> -----Original Message-----
> From: Alexey Ivanov [mailto:alxey.ivanov@gmail.com]
> Sent: Wednesday, August 22, 2007 11:29 AM
> To: dev@harmony.apache.org
> Subject: Re: [classlib][swing][html] CSS is used to specify HTML tag
> behavior
>
> Vasily,
>
> Yes, I agree with your considerations too.
>
> I guess we should create a mechanism to add another base.css that
> cannot be removed. I pointed to
> javax.swing.text.html.HTMLDocument.initDefaultCharacterAttributes
> which serves as such mechanism currently. We should find a better
> approach here because user should be able to override the defaults
> specified there as well. At least browsers allow this but neither
> Harmony nor RI does. Harmony is even worse since it ignores the style
> specified the style attribute on HTML element. However, I don't think
> there are many users who'd want to change that but it's a nice feature
> to have, so that Harmony behaves closer to HTML browsers and thus
> provides better HTML support than RI does.
>
> Regards,
> Alexey.
>
> P.S. I knew all browser provided the feature to user style sheet but
> had never tried it. Additionally this feature is quite hidden in
> options dialog boxes.
>
> 2007/8/22, Zakharov, Vasily M <vasily.m.zakharov@intel.com>:
> > Alexey,
> >
> > Thank you for your attention to this issue. I'm not sure it's a bug
> that
> > needs to be fixed (RI does the same, right), but I think it's an
> > important issue that worth keeping record of.
> >
> > I fully agree with all your considerations about using default
> > stylesheet for specyfying default document look. But there's look
> > (fonts, colors, sizes, weight, margins, padding etc.) and there's
the
> > specified element behavior. For example, <center> tag is expected to
> > center text by default - and in our implementation (and in RI) it
> > doesn't. It seems strange, uncomfortable and confusing to me, and
> > probably to the users who would like to replace the default
stylesheet
> > with their own. Making a user write "center { text-align: center}"
in
> > his stylesheet is strange indeed. And by the way, IE allows
replacing
> > the default stylesheet easily, and <center> tag works normally after
> > that.
> >
> > I'm not suggesting to remove the replace default stylesheet feature,
> and
> > I'm not suggesting to merge the existing default stylesheet with
> user's
> > one. I'm only suggesting to make some (not all) default stylesheet
> > declarations (specifying core elements behavior) actual even if
> default
> > stylesheet is removed.
> >
> > Particularly, I would expect <strong> behaving the same as <b> and
> <em>
> > the same as <i>, and <center> tag actually centering the text. Sure,
I
> > don't care about font sizes, margins etc.
> >
> >  Vasily
> >
> >
> > -----Original Message-----
> > From: Alexey Ivanov [mailto:alxey.ivanov@gmail.com]
> > Sent: Wednesday, August 22, 2007 10:38 AM
> > To: dev@harmony.apache.org
> > Subject: [classlib][swing][html] CSS is used to specify HTML tag
> > behavior
> >
> > Hello everyone,
> >
> > There was created JIRA issue HARMONY-4662 [1], which says that
> > specifying the default presentation of HTML tags using CSS. I
believe
> > this issue should be discussed here.
> >
> > In short, Harmony implementation of HTML support has default.css
file
> > which describes the default presentation of HTML elements. This
> > implementation is similar to that of RI. On the other hand,
programmer
> > can remove (or disable) this style sheet. It leads to the situation
> > where almost all tags look like a plain text.
> >
> > In my opinion, using CSS in this situation is the right thing to do.
> > 1) We can easily make adjustments to the way HTML document looks by
> > default.
> > 2) It gives application developers freedom for their application.
> > Developer can create their own default style sheet and easily
replace
> > the default one shipped with Harmony. Replacing is more effective
than
> > just overriding because Harmony-provided style sheet will be
excluded
> > from style resolution chain, which, in its turn, will free memory
and
> > will save time.
> > 3) I believe all modern browsers (Internet Explorer, Firefox, Opera)
> > use the similar methods to specify the default look of HTML. The
only
> > difference is that you cannot remove their default style sheet so
> > easily as in Swing.
> >
> > Other opinions, comments?
> >
> > Regards,
> > Alexey.
> >
> >
> > [1] https://issues.apache.org/jira/browse/HARMONY-4662
> >
> > Other links of interest:
> > Sample style sheet suggested by W3C:
> > http://www.w3.org/TR/REC-CSS2/sample.html
> > Index of HTML 4.01 elements:
> > http://www.w3.org/TR/html401/index/elements.html
> >
>

Mime
View raw message