[WA1] GUI Selections (was Re: [whatwg] Web Forms 2.0)

Olav Junker Kj?r wrote:
> Matthew Raymond wrote:
>>| var myRange = document.getSelection();
>>
>>   The above gets the current selection within the document. If the 
>>document doesn't have a selection, it returns document.createRange(). 
>>Similarly, there will be a setSelection method:
> 
> You assume that the selection is a property of the document. This is 
> like IE, while in Mozilla its a propery of the window (if I understand 
> the API correctly).

    That's my understanding too, though I'm hardly an expert.

> I think it makes most sense to have the selection be a property of the 
> viewport i.e. the window object.

    Yeah, I was mainly trying to avoid breaking existing Mozilla scripts 
using window.getSelection. I suppose we could just rename the thing 
"getSelectionRange", though. The main question is whether we care about 
multiple selections and the like. Perhaps we could have 
getSelectionRange return the first selection in the part of the viewport 
that has focus...

> If we consider two frames containing 
> two different views of the same document (this is theoretically possible 
> according to the dom spec), it would seem natural to allow different 
> focus and selections in each view.

    Depends on whether the viewports are actually using the same 
document object. If each viewport has it's own document object that 
happens to be created from the same document, then the selections could 
just be obtained from the document object. I think that's the case when 
you open the same page in two different browser windows.

    I do see your point, though. For instance, two people could be 
viewing a web page together over some kind of conferencing software, in 
which case they could each be selecting something different in their own 
viewports but sharing the same document object.

> (If e.g. an HTML editor allowed two 
> different wiews on the same page while editing, this would matter.)

    Bad example. You wouldn't want to be running script on the DOM at 
the same time you're editing the markup. Point already made, though.

> Btw. the DocumentFocus interface in WA1 (section 11.3) also seem to 
> assume that focus is a propery of the document rather than the viewport. 
> Again I think its more correct to have it a property of the viewport.

   Yup, window.getSelectionRange it is, then...

Received on Thursday, 24 February 2005 08:10:27 UTC