* @param {!Window} win * @param {?AmpDoc} parent * @param {!AmpDocOptions=} opt_options
(win, parent, opt_options)
| 236 | * @param {!AmpDocOptions=} opt_options |
| 237 | */ |
| 238 | constructor(win, parent, opt_options) { |
| 239 | /** @public @const {!Window} */ |
| 240 | this.win = win; |
| 241 | |
| 242 | /** @private {!{[key: ../enums.AMPDOC_SINGLETON_NAME_ENUM]: boolean}} */ |
| 243 | this.registeredSingleton_ = map(); |
| 244 | |
| 245 | /** @public @const {?AmpDoc} */ |
| 246 | this.parent_ = parent; |
| 247 | |
| 248 | /** @private @const */ |
| 249 | this.signals_ = (opt_options && opt_options.signals) || new Signals(); |
| 250 | |
| 251 | /** @private {!{[key: string]: string}} */ |
| 252 | this.params_ = (opt_options && opt_options.params) || map(); |
| 253 | |
| 254 | /** @protected {?{[key: string]: string}} */ |
| 255 | this.meta_ = null; |
| 256 | |
| 257 | /** @private @const {!{[key: string]: string}} */ |
| 258 | this.declaredExtensions_ = {}; |
| 259 | |
| 260 | const paramsVisibilityState = this.params_['visibilityState']; |
| 261 | devAssert( |
| 262 | !paramsVisibilityState || |
| 263 | isEnumValue(VisibilityState_Enum, paramsVisibilityState) |
| 264 | ); |
| 265 | |
| 266 | /** @private {?VisibilityState_Enum} */ |
| 267 | this.visibilityStateOverride_ = |
| 268 | (opt_options && opt_options.visibilityState) || |
| 269 | paramsVisibilityState || |
| 270 | null; |
| 271 | |
| 272 | // Start with `null` to be updated by updateVisibilityState_ in the end |
| 273 | // of the constructor to ensure the correct "update" logic and promise |
| 274 | // resolution. |
| 275 | /** @private {?VisibilityState_Enum} */ |
| 276 | this.visibilityState_ = null; |
| 277 | |
| 278 | /** @private @const {!Observable<!VisibilityState_Enum>} */ |
| 279 | this.visibilityStateHandlers_ = new Observable(); |
| 280 | |
| 281 | /** @private {?time} */ |
| 282 | this.lastVisibleTime_ = null; |
| 283 | |
| 284 | /** @private @const {!Array<!UnlistenDef>} */ |
| 285 | this.unsubsribes_ = []; |
| 286 | |
| 287 | const boundUpdateVisibilityState = this.updateVisibilityState_.bind(this); |
| 288 | if (this.parent_) { |
| 289 | this.unsubsribes_.push( |
| 290 | this.parent_.onVisibilityChanged(boundUpdateVisibilityState) |
| 291 | ); |
| 292 | } |
| 293 | addDocumentVisibilityChangeListener( |
| 294 | this.win.document, |
| 295 | boundUpdateVisibilityState |
nothing calls this directly
no test coverage detected