[webkit-dev] DOMRange and khtml::Selection direction

Darin Adler darin at apple.com
Thu Aug 11 09:53:30 PDT 2005


On Aug 11, 2005, at 2:04 AM, Duncan Wilcox wrote:

> I don't think I fully understand the concept of selection affinity,  
> so I don't know if it might be used for the purpose of also setting  
> the selection direction (in -[WebCoreBridge  
> setSelectedDOMRange:affinity:closeTyping:]),

It should not. Selection affinity determines which of two possible  
points to use for a caret or selection boundary in the case where  
there's a line break and the caret could appear either at the end of  
one line or the beginning of the next. Those are two separate concepts.

> otherwise the proposal would be to add a couple new methods to  
> WebView to access the current selection's direction:
>
> typedef enum {
>     WebViewSelectionForward,
>     WebViewSelectionBackward
> } WebViewSelectionDirection;
>
> - (void)setSelectionDirection:(WebViewSelectionDirection)direction;
> - (WebViewSelectionDirection)selectionDirection;
>
> These methods would trivially resolve in swapping m_base/m_extent,  
> when needed.
>
> Please excuse the poor choice of names, I'll leave that up to the  
> Apple API approval process.

We will need to do something like this to solve the problem. A  
completely separate method would be inconvenient. I think I'd prefer  
a new class that includes both a range and a selection direction, or  
something along those lines.

You don't mention how the selection direction would be passed to the  
delegate method, but I assume you'd suggest n additional parameter.

     -- Darin




More information about the webkit-dev mailing list