[webkit-dev] Inline vs Inline Block and relative positioning for MathML
Alex Milowski
alex at milowski.org
Fri Aug 28 10:47:46 PDT 2009
On Thu, Aug 27, 2009 at 10:58 AM, David Hyatt<hyatt at apple.com> wrote:
> You really don't want to use relative positioning to move objects around
> like this. The objects should just be placed into the correct positions by
> the layout() method without having to resort to relative positioning.
>
> You also can't mutate a DOM-backed renderer's style like that as it could be
> shared by other renderers.
OK. I've been able to do this another way by wrapping the sub/super scripts
in an inline-table. I've also tweaked things so that style information
provided by the renderer is on an anonymous wrapper created by the
renderer.
>
> updateBoxModelInfoFromStyle is an internal method to styleWIll/DIdChange.
> It should never be called directly by anyone. I should probably make it so
> that it cannot be called from subclasses to make that less confusing.
There situations where I need to do this or its equivalent. For example, in
mfenced I need to adjust the height of the fencing after I know the maximum
height of the boxes stacked between the fencing (e.g. '{' and '}') and then
scale them to that height. I do that as an extension to the layout()
method where I line the inline-block layout the contained objects and
then adjust the open and close boxes via their style. I then need to
update the box from the style.
Looking at what updateBoxModelInfoFromStyle does, I can certainly just
call those setter methods myself. Why would that be preferred over
just calling updateBoxModelInfoFromStyle()?
>
> Raw casts are a no-no in the render tree. Always use the toRenderXXX
> method, e.g., toRenderBoxModelObject, toRenderBox, toRenderInline, etc.
OK. Got it.
>
> Solutions I can think of to this problem include adding a new CSS property
> to indicate that sub/sup objects should sit together.... or just make sure
> the line box code in placeBoxesHorizontally does a query to see if you're in
> MathML (which may be easier if some object is subclassed).
>
I know that at some point I will need to write algorithms for determining
a set of line boxes for certain constructs. For example, msubsup will
need to deal with "kerning" between the subscript/superscript and
the base depending on the glyph and other criteria. There will also
be other constructs that will probably need such things as well.
I've looked through how RenderBlock handles layout of inline children
and while I've made some progress on understanding what it is doing
but it is also complicated. Is there a simpler example I can look at?
Specifically, if I actually wanted to render msubsup myself and
layout the line boxes, I'd want to layout the base, find the last
line box's right edge, and then layout the superscript and subscript
from the same right edge. It is unclear to me exactly how to do
that right now and I'd love a simpler example to get a handle
on how line boxes are created, organized, and "painted".
--
--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