WebBluetoothCG / web-bluetooth

Bluetooth support for the Web.
http://www.w3.org/community/web-bluetooth/
Other
1.37k stars 185 forks source link

"current settings object's relevant global object" is not defined #593

Open Ms2ger opened 1 year ago

Ms2ger commented 1 year ago

https://webbluetoothcg.github.io/web-bluetooth/#handling-visibility-change https://webbluetoothcg.github.io/web-bluetooth/#handling-full-activity-loss

There's two occurrences of "current settings object's relevant global object" in the spec, but a settings object doesn't have a "relevant global object", only a "global object".

Using "current global object" is also an option.

However, I'm not sure how using the "current" anything works here.

reillyeon commented 1 year ago

The intent of this text is to attach these steps to the "loss of visibility" or "loss of full activity" event on any document. It feels like it should be something like,

When the user agent determines that a document is no longer fully active, it must run these steps:

  1. Let document be that document.
  2. ...

The abort all active watchAdvertisements algorithm should really be taking the document (or the document's navigator.bluetooth instance) as a parameter.

Does that make sense? Can you suggest the proper way to create such an event listener?

Ms2ger commented 1 year ago

Thanks! The <object> spec does something similar:

Whenever one of the following conditions occur: ...

... (do some stuff)

so I'm guessing something like what you quoted would be fine.

CC @annevk

annevk commented 1 year ago

Yeah, probably. Getting some of this formalized better is a long-standing issue of the HTML standard.

reillyeon commented 1 year ago

What do you think of this?

When a document's visibility state changes,

  1. Let document be the document.
  2. Let global be document's relevant global object.
  3. Queue a task on the Bluetooth event source with global and the following steps,
    1. If document’s visibility state is not "visible", then abort all active watchAdvertisements operations on global.

I'm unsure when I want to use the "document" concept vs. the "Document" interface.

To get the Bluetooth instance from a document it seems like I should go through the associated Navigator (given global) and define a similar "associated Bluetooth" concept which is used in the getter steps for the "bluetooth" attribute in the Navigator partial interface.