Re: Selection of a document that doesn't have a window

2012-01-17 Thread Aryeh Gregor
On Fri, Jan 13, 2012 at 5:12 PM, Ojan Vafai o...@chromium.org wrote:
 We could define it in terms of defaultView (or browsing context) and put our
 effort into getting interoperability on defaultView?

This is what I've done for now:

http://dvcs.w3.org/hg/editing/rev/4dc4d65cc87e

At least behavior is pretty clear in the easy case of
document.implemention.createHTMLDocument() or such.  In more
complicated cases, we probably want the same behavior as defaultView
anyway, so if we're going to define such behavior precisely we may as
well do it for defaultView instead of getSelection().

I've also filed a Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=718741



Re: Selection of a document that doesn't have a window

2012-01-17 Thread Ian Hickson
On Fri, 13 Jan 2012, Boris Zbarsky wrote:
 On 1/13/12 2:37 AM, Simon Pieters wrote:
  HTML uses this concept in lots of places, e.g.
  http://www.whatwg.org/specs/web-apps/current-work/#cookie-free-document-object
  
  A Document that has no browsing context.
 
 Ah, that's better than using defaultView (because behavior for 
 defaultView on navigation and such is not defined in the spec and is not 
 consistent across browsers).

What's undefined about defaultView?

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



Re: Selection of a document that doesn't have a window

2012-01-17 Thread Boris Zbarsky

On 1/17/12 4:55 PM, Ian Hickson wrote:

On Fri, 13 Jan 2012, Boris Zbarsky wrote:

On 1/13/12 2:37 AM, Simon Pieters wrote:

HTML uses this concept in lots of places, e.g.
http://www.whatwg.org/specs/web-apps/current-work/#cookie-free-document-object

A Document that has no browsing context.


Ah, that's better than using defaultView (because behavior for
defaultView on navigation and such is not defined in the spec and is not
consistent across browsers).


What's undefined about defaultView?


The main question is what, if anything, happens to it on document unload 
or destruction of the browsing context.  If I read the spec right, 
defaultView should just stay the same across those operations, but it's 
not clear to me whether it's on purpose.  It certainly doesn't match UAs 
in all cases, but UAs don't match each other very well either.


-Boris





Re: Selection of a document that doesn't have a window

2012-01-17 Thread Ian Hickson
On Tue, 17 Jan 2012, Boris Zbarsky wrote:
 On 1/17/12 4:55 PM, Ian Hickson wrote:
  On Fri, 13 Jan 2012, Boris Zbarsky wrote:
   On 1/13/12 2:37 AM, Simon Pieters wrote:
HTML uses this concept in lots of places, e.g.
http://www.whatwg.org/specs/web-apps/current-work/#cookie-free-document-object

A Document that has no browsing context.
   
   Ah, that's better than using defaultView (because behavior for
   defaultView on navigation and such is not defined in the spec and is not
   consistent across browsers).
  
  What's undefined about defaultView?
 
 The main question is what, if anything, happens to it on document unload 
 or destruction of the browsing context.  If I read the spec right, 
 defaultView should just stay the same across those operations, but it's 
 not clear to me whether it's on purpose.  It certainly doesn't match UAs 
 in all cases, but UAs don't match each other very well either.

As currently specced, it should do the same as any random property that 
was set to the Window object's value when the Document was created.

As in:

   // onload
   document.foo = window;

I don't understand what isn't clear here.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



Re: Selection of a document that doesn't have a window

2012-01-13 Thread Boris Zbarsky

On 1/13/12 2:37 AM, Simon Pieters wrote:

HTML uses this concept in lots of places, e.g.
http://www.whatwg.org/specs/web-apps/current-work/#cookie-free-document-object

A Document that has no browsing context.


Ah, that's better than using defaultView (because behavior for 
defaultView on navigation and such is not defined in the spec and is not 
consistent across browsers).


-Boris



Re: Selection of a document that doesn't have a window

2012-01-13 Thread Boris Zbarsky

On 1/13/12 12:18 PM, Aryeh Gregor wrote:

Actually, defaultView is defined to return the Document's browsing
context's WindowProxy object, if it has one, and null otherwise.


Hmm.  I guess the spec doesn't really define what happens to the 
association between a document and its browsing context in the 
interesting cases (window close, navigation away from document, removal 
of an iframe from the DOM, etc).  In practice, UAs are all over the map 
in terms of nulling out defaultView for some but not others of the above.



For now I'm inclined to go with defaultView being null, just because
that's at least readily testable.  If defaultView isn't defined well
enough, that should be fixed in the HTML spec.


I would prefer a definition that doesn't involve defaultView, actually. 
 I don't expect browsers to converge defaultView behavior any time in 
the near or medium future, so the testability would be illusory: tests 
would just depend on whether browsers implement defaultView correctly...


-Boris



Re: Selection of a document that doesn't have a window

2012-01-13 Thread Aryeh Gregor
On Fri, Jan 13, 2012 at 12:34 PM, Boris Zbarsky bzbar...@mit.edu wrote:
 I would prefer a definition that doesn't involve defaultView, actually.  I
 don't expect browsers to converge defaultView behavior any time in the near
 or medium future, so the testability would be illusory: tests would just
 depend on whether browsers implement defaultView correctly...

What well-defined alternative do you suggest?  Is the .document of
some Window?  That would be easy enough to test in simple cases, but
what if there's navigation and a reference to the Document is kept but
the Window is no longer accessible, or something like that?



Selection of a document that doesn't have a window

2012-01-12 Thread Aryeh Gregor
What does document.implementation.createHTMLDocument().getSelection() return?

* IE9 returns a Selection object unique to that document.
* Firefox 12.0a1 and Opera Next 12.00 alpha return the same thing as
document.getSelection().
* Chrome 17 dev returns null.

I prefer IE's behavior just for the sake of simplicity.  If we go with
Gecko/WebKit/Opera, we have to decide how to identify which documents
get their own selections and which don't.  The definition should
probably be something like documents that are returned by the
.document property of some window, but I have no idea if that's a
sane way to phrase it.

So should the spec follow IE?  If not, what definition should we use
to determine which documents get selections?



Re: Selection of a document that doesn't have a window

2012-01-12 Thread Ojan Vafai
Can you do anything useful with a selection on a document that doesn't have
a window? If so, the IE9 behavior makes sense. If not, I prefer the WebKit
behavior.

For phrasing it, could you define it in terms of document.defaultView? In
other words that document.getSelection is just return document.defaultView
? document.defaultView.getSelection() : null.

On Thu, Jan 12, 2012 at 7:58 AM, Aryeh Gregor a...@aryeh.name wrote:

 What does document.implementation.createHTMLDocument().getSelection()
 return?

 * IE9 returns a Selection object unique to that document.
 * Firefox 12.0a1 and Opera Next 12.00 alpha return the same thing as
 document.getSelection().
 * Chrome 17 dev returns null.

 I prefer IE's behavior just for the sake of simplicity.  If we go with
 Gecko/WebKit/Opera, we have to decide how to identify which documents
 get their own selections and which don't.  The definition should
 probably be something like documents that are returned by the
 .document property of some window, but I have no idea if that's a
 sane way to phrase it.

 So should the spec follow IE?  If not, what definition should we use
 to determine which documents get selections?




Re: Selection of a document that doesn't have a window

2012-01-12 Thread Simon Pieters

On Thu, 12 Jan 2012 16:58:58 +0100, Aryeh Gregor a...@aryeh.name wrote:

What does document.implementation.createHTMLDocument().getSelection()  
return?


* IE9 returns a Selection object unique to that document.
* Firefox 12.0a1 and Opera Next 12.00 alpha return the same thing as
document.getSelection().
* Chrome 17 dev returns null.

I prefer IE's behavior just for the sake of simplicity.  If we go with
Gecko/WebKit/Opera, we have to decide how to identify which documents
get their own selections and which don't.  The definition should
probably be something like documents that are returned by the
.document property of some window, but I have no idea if that's a
sane way to phrase it.


HTML uses this concept in lots of places, e.g.
http://www.whatwg.org/specs/web-apps/current-work/#cookie-free-document-object

A Document that has no browsing context.


So should the spec follow IE?  If not, what definition should we use
to determine which documents get selections?



--
Simon Pieters
Opera Software