[webkit-dev] Inline vs Inline Block and relative positioning for MathML
Alex Milowski
alex at milowski.org
Thu Aug 27 09:35:56 PDT 2009
I'm struggling with something I don't quite understand. I get a different
behavior when the superscript is an instance of RenderInline versus
and inline-block instance of RenderBlock for the superscript. Specifically,
it works just fine in the case of the RenderInline but not when the superscript
is an instance of RenderBlock.
What I need to do is relatively position the superscript back to the right most
edge of the base. The layout has first the base, then the subscript, and
then the superscript. The superscript is then relatively positioned back
to the base's right edge as it starts out at the right edge of the subscript.
Here's the layout code that partially works:
void RenderMathSubSup::layout() {
RenderBlock::layout();
RenderBoxModelObject *base = (RenderBoxModelObject *)firstChild();
RenderBoxModelObject *subscript = base ? (RenderBoxModelObject
*)base->nextSibling() : 0;
RenderBoxModelObject *superscript = subscript ?
(RenderBoxModelObject *)subscript->nextSibling() : 0;
if (superscript) {
int adjust =
superscript->offsetLeft()-base->offsetLeft()-base->offsetWidth()-1;
superscript->style()->setLeft(Length(-adjust,Fixed));
superscript->style()->setPosition(RelativePosition);
superscript->updateBoxModelInfoFromStyle();
int baseSub = base->offsetWidth()+subscript->offsetWidth()+1;
int baseSup = base->offsetWidth()+superscript->offsetWidth()+1;
style()->setWidth(Length(baseSub>baseSup ? baseSub : baseSup,Fixed));
updateBoxModelInfoFromStyle();
markContainingBlocksForLayout();
}
}
What confuses me is that the calculated block position is correct for the
superscript and I can inspect that in the Console in Safari but the actual
glyphs rendered are still in the original place. That leads me to believe that
a repaint was not actually invoked.
Any ideas?
I've been digging through the source code for examples but most of
the renders seem to either have their own layout code and rely upon
existing layouts of inline or block flows.
--
--Alex Milowski
"The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered."
Bertrand Russell in a footnote of Principles of Mathematics
More information about the webkit-dev
mailing list