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

Kevin Ollivier kevino at theolliviers.com
Fri Jan 23 15:30:55 PST 2009

Hi Darin,

On Jan 23, 2009, at 10:44 AM, Darin Adler wrote:

> 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.

Sounds about right to me. :-) Once we have a clear idea about how  
things behave in various scenarios using stateStyle, we should have a  
better idea of how to proceed and perhaps also of how we want  
getCommandState to handle cases like nested alignment tags.

Thanks for the detailed explanation!


>    -- Darin

More information about the webkit-dev mailing list