MCPcopy
hub / github.com/ampproject/amphtml / whenContentIniLoadMeasure

Function whenContentIniLoadMeasure

src/ini-load.js:50–77  ·  view source on GitHub ↗
(
  elementOrAmpDoc,
  hostWin,
  rect,
  opt_prerenderableOnly
)

Source from the content-addressed store, hash-verified

48 * @return {!Promise}
49 */
50export function whenContentIniLoadMeasure(
51 elementOrAmpDoc,
52 hostWin,
53 rect,
54 opt_prerenderableOnly
55) {
56 const ampdoc = Services.ampdoc(elementOrAmpDoc);
57 return getMeasuredResources(ampdoc, hostWin, (r) => {
58 // TODO(jridgewell): Remove isFixed check here once the position
59 // is calculted correctly in a separate layer for embeds.
60 if (
61 !r.isDisplayed() ||
62 (!r.overlaps(rect) && !r.isFixed()) ||
63 (opt_prerenderableOnly && !r.prerenderAllowed())
64 ) {
65 return false;
66 }
67 return true;
68 }).then((resources) => {
69 const promises = [];
70 resources.forEach((r) => {
71 if (!EXCLUDE_INI_LOAD.includes(r.element.tagName)) {
72 promises.push(r.loadedOnce());
73 }
74 });
75 return Promise.all(promises);
76 });
77}
78
79/**
80 * A new way using direct measurement.

Callers 3

test-ini-load.jsFile · 0.90
registerIniLoadListenerFunction · 0.90
whenContentIniLoadFunction · 0.85

Calls 9

getMeasuredResourcesFunction · 0.85
isDisplayedMethod · 0.80
overlapsMethod · 0.80
loadedOnceMethod · 0.80
thenMethod · 0.45
isFixedMethod · 0.45
prerenderAllowedMethod · 0.45
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected