[webkit-dev] Ruby Text Enhancements

David Hyatt hyatt at apple.com
Tue Sep 28 10:11:01 PDT 2010


On Sep 27, 2010, at 3:40 PM, Eric Mader wrote:

> 
> Are you saying that subclassing computeLogicalWidth() would still mean that I'm computing the margins at the initial calculation time?
> 

You'd be computing them whenever the ruby run's layout changed.  The problem with that is if you're setting margins based off surrounding content, you're not going to get a layout just because your surroundings changed.

>> It just doesn't seem like you can deal with all the corner cases without integrating right into line layout.  I don't see how else you can know if you have adequate available space to actually overhang without knowing what you've seen so far on the line and how much space you have left on the line.
> 
> This would require special-casing the ruby blocks in line layout code, right? I was trying to avoid this, hoping that I could just extend the existing ruby objects.
> 

Right.  It's kind of a minor miracle that Ruby has gotten this far without having to do this though. :)

>>>> This method makes several assumptions that I'm not 100% sure are always safe:
>>>> * That a RenderRuby object holds only 1 RenderRubyRun object.
>> 
>> I believe you can have multiple RenderRubyRuns inside a single RenderRuby.
>> 
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-ruby-element
>> 
>> "The ruby element allows one or more spans of phrasing content to be marked with ruby annotations."
>> 
>>>> * That the text for the ruby text and ruby base are always the direct child of the RenderRubyText and RenderRubyBase object.
>> 
>> I doubt that's a valid assumption.  I assume that you can have a content tree of markup underneath a RenderRubyText and a RenderRubyBase, e.g., if you put in some <i> and some <b>.  Anyway, I think you could just ask for the width() of the rubyText() and rubyBase() objects themselves rather than drilling down into their subtrees.
> 
> I couldn't figure out how to ask the RenderRubyText and RenderRubyRun objects for their width. They don't support the width() method. What method should I call?
> 

They should.  They are RenderBlocks, so they should have width() methods.  You may have just been getting bad results because you hooked in before the width was computed.  That's why computeLogicalWidth subclassing would work better for you.  Let the base class set up the margins and width, and then you override.

dave
(hyatt at apple.com)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100928/767174e6/attachment.html>


More information about the webkit-dev mailing list