MCPcopy Index your code
hub / github.com/ampproject/amphtml / constructor

Method constructor

src/friendly-iframe-embed.js:362–401  ·  view source on GitHub ↗

* @param {!HTMLIFrameElement} iframe * @param {!FriendlyIframeSpec} spec * @param {!Promise} loadedPromise * @param {?./service/ampdoc-impl.AmpDocFie} ampdoc

(iframe, spec, loadedPromise, ampdoc)

Source from the content-addressed store, hash-verified

360 * @param {?./service/ampdoc-impl.AmpDocFie} ampdoc
361 */
362 constructor(iframe, spec, loadedPromise, ampdoc) {
363 /** @const {!HTMLIFrameElement} */
364 this.iframe = iframe;
365
366 /** @const {!Window} */
367 this.win = /** @type {!Window} */ (iframe.contentWindow);
368
369 /** @const {?./service/ampdoc-impl.AmpDocFie} */
370 this.ampdoc = ampdoc;
371
372 /** @const {!FriendlyIframeSpec} */
373 this.spec = spec;
374
375 /** @const {?AmpElement} */
376 this.host = spec.host || null;
377
378 /** @const @private {time} */
379 this.startTime_ = Date.now();
380
381 /** @private @const */
382 this.signals_ = this.ampdoc
383 ? this.ampdoc.signals()
384 : this.host
385 ? this.host.signals()
386 : new Signals();
387
388 /** @private @const {!Deferred} */
389 this.renderComplete_ = new Deferred();
390
391 /** @private @const {!Promise} */
392 this.winLoadedPromise_ = Promise.all([
393 loadedPromise,
394 this.whenRenderStarted(),
395 ]);
396 if (this.ampdoc) {
397 this.whenRenderComplete().then(() => this.ampdoc.setReady());
398 }
399
400 this.win.addEventListener('resize', () => this.handleResize_());
401 }
402
403 /**
404 * Ensures that all resources from this iframe have been released.

Callers

nothing calls this directly

Calls 8

whenRenderStartedMethod · 0.95
whenRenderCompleteMethod · 0.95
handleResize_Method · 0.95
nowMethod · 0.80
signalsMethod · 0.45
thenMethod · 0.45
setReadyMethod · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected