[webkit-dev] Ruby Text Enhancements
hyatt at apple.com
Mon Sep 20 11:12:06 PDT 2010
On Sep 17, 2010, at 8:07 PM, Eric Mader wrote:
> I'm working on making the following enhancements to Ruby Text:
> 1) Implement the behavior of ruby-overhang:auto
> 2) implement the behavior of ruby-line-stacking:exclude-ruby
> 3) Add some Mac OS specific character properties to the ruby text
> 4) Turn off the underline when the ruby text is in a link
> I've looked at the code enough to know that the layout or ruby text is done by the normal block stacking in BlockLayout. I'm guessing that I can do at lest the first two tasks by changing the RenderRuby code to report a different width and / or height for the ruby block. Does this seem like the right way to do what I want?
> Assuming for the moment that it is, I have some questions:
> 1) What methods should I subclass to report the adjusted width and height?
I'm very hazy on the Ruby implementation. I believe it makes an inline-block with two block children vertically stacked, and then it uses text-align:center to center the ruby base. If so, this behavior has to be preserved when the ruby text is wider than the base.
I think a reasonable way to implement overhang therefore would be with negative margins applied to the ruby run. This way the correct layout of the Ruby object is preserved, and the surrounding text will just naturally get pushed inside the Ruby object to overlap it.
Basically you can compare the delta in width between the base and the text and then apply margins to either side of the ruby run based off how you want to overhang.
> 2) If the ruby text is wider than the ruby base and I report the width of the base as the width of the whole block will some of the ruby text get clipped, or will it all still draw?
It would all still draw as long as you set up overflow correctly. You can look for addLayoutOverflow methods. I think you may be able to use negative margins for overhang though without altering your reported width.
> 3) Ruby text is only allowed to overhang the base in some cases. To know when it's OK, I'll need to examine the neighboring text. Can I always find the neighboring text by walking the render tree?
This is going to be tricky. You basically want to walk the line box tree rather than the renderobject tree and then look at surrounding text.
> About turning off the underline if the ruby is in a link: I've looked at the styles and tried adding code to change the parts that I think relate to this, but haven't found anything that makes a difference. It's also occurred to me that I might be able to do this by writing a rule in <WebKit>WebCore/css/html.css, but I can't figure out exactly what the rule would look like. I tried adding "text-decoration: none" to the "ruby > rt" section, but that doesn't do it.
> (at first, I thought that is was probably overkill, but now I think that turning text-decoration off for all ruby text is probably right.)
There is no way to do this. The closest I see is:
This is not implemented in WebKit yet.
We'd probably need to add a new value to that property if Ruby is supposed to be skipped.
(hyatt at apple.com)
More information about the webkit-dev