[webkit-dev] Handling Ignorable Text in a Renderer
Alex Milowski
alex at milowski.org
Wed Aug 26 13:19:02 PDT 2009
On Wed, Aug 26, 2009 at 12:06 PM, Alex Milowski<alex at milowski.org> wrote:
> In certain MathML constructs (e.g. mfenced) there are a number of child
> elements that make up the construct and need to be rendered. Any text
> between those child elements should be ignored. In fact, non-whitespace
> text in the wrong place is most certainly incorrect but something
> that can be recovered from.
>
> I don't want to remove the text from the DOM nodes but I need to
> keep the RenderText instances from being created or displayed. What
> is the correct way to do this?
>
> I've been trying to handle this in the renderer but it seems like that
> is really too late. I though about changing the attach method to exclude
> such ignorable text.
Here's what works but it feels like a hack:
RenderBlock* none = new (renderArena()) RenderBlock(document());
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(style());
newStyle->setDisplay(INLINE_BLOCK);
newStyle->setMaxWidth(Length(0,Fixed));
newStyle->setMaxHeight(Length(0,Fixed));
newStyle->setOverflowX(OHIDDEN);
newStyle->setOverflowY(OHIDDEN);
none->setStyle(newStyle.release());
RenderBlock::addChild(none, beforeChild);
none->addChild(child);
I basically create an inline block with zero width and height and then
set the overflow to hidden.
--
--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