[webkit-dev] Getting text alignment in editing mode?

Darin Adler darin at apple.com
Fri Jan 23 10:44:10 PST 2009


On Jan 23, 2009, at 10:36 AM, Kevin Ollivier wrote:

> Thanks, do you have any examples of how e.g. the logic in  
> selectionHasStyle could be tripped up by (or be insufficient for)  
> block styles like this? Is it a matter of having it not query the  
> alignment for non-block elements when traversing nodes (because it  
> might return an invalid value?), or something else?

I'm not sure if there are any real problems. It's not an area I've  
considered deeply.

One thing worth considering is that the style might be set on elements  
where it has no effect. For example, you could have the style set on a  
span within a block, and it wouldn't do anything.

     <p style="align: left">a <span style="align: right">b</span> c</p>

Someone might argue that an Align Left menu item should be checked  
here, not "half-checked".

As with all editing and style, styles that are applied by CSS style  
sheet rules might create tricky cases.

Your question about skipping non-block elements when traversing nodes  
is more of a question about how to implement. We'd want to be careful  
about doing something like that, because CSS can change an element  
that's normally not a block into a block. I am not sure any of these  
cases are important. It also seems to me that for block styles we  
could be more efficient if we didn't ask every single element what its  
computed style is. But it seems smart to start simply.

If I was working on this, I'd start by making an implementation that  
uses stateStyle and then try to construct interesting test cases to  
see if there are problems in practice.

     -- Darin



More information about the webkit-dev mailing list