MathML widget : XML or HTML elements?

Lars Knoll lars at trolltech.com
Wed Apr 10 15:02:07 BST 2002


> First a quick baseline question:  how do you let khtml know what the
> baseline of an element's rendering should be?  Currently, if the mathml
> object's baseline is not the same as its y-max, the formula doesn't get
> painted in line with surrounding text.

Have a look at RenderObject::baselinePosition(). You will need to reimplement
it.

> On Wednesday 10 April 2002 07:58, Lars Knoll wrote:
> > All this would probably mean a partly rewrite of KMathMLView, moving over
> > to khtml DOM classes, and maybe putting all that in a seperate subdir in
> > khtml.
>
> Is ElementImpl then the best parent class for mathml nodes?

I would guess so.

> > You might still need to hack the html/xml parsers to create your MathML
> > elements in this case and add the list of math tags to the taglist, but
> > you should not need to do much more.
>
> My only concern is that this would then dominate the taglist: there are
> around 200 MathML tags, in contrast to the ~100 tags that it currently
> consists of. Would this cause a performance hit?  I don't think it would
> actually, since the switch() statements will only check for them when
> there's an ID_MATH parent... so if this is acceptable (?) then it sounds
> like the solution to the problem.

It shouldn't. Still it might be a good idea to use a second hash table, and
add a hook in the html parser for that one. One reason for that is that
mathml elements are XML and thus case sensitive, while html elements arent.

> > > Furthermore, I currently have formatting defaults hardcoded into the
> > > widget (such as the % font size of superscripts).  I'd rather have this
> > > defined by a CSS style sheet.  How do you read in a style sheet?
> >
> > If you use khtml this gets automatically done for you. You get a style
> > element for every node in the DOM (a RenderStyle object) containing all
> > the definitions you need
>
> I think we may ultimately want to have a default MathML stylesheet that
> <math> rendering is based on.  A w3c.org example is at:
> 	http://www.w3.org/TR/MathML2/appendixg.html
> Can the MATH node trigger a reading in of some kmathml.css style sheet, or
> maybe I should just use that to base the defaults on?

I would read in the stylesheet. In the long term that solution is a lot more
flexible and easier to maintain. All you will need in that case need to do is
to modify the cssparser to convert mathml tagnames to id's according to the
hashtable you add and pass a flag to the cssstyleselector constructor which
causes it to parse the kmathml.css file aswell.

Lars





More information about the kfm-devel mailing list