( elementOrAmpDoc, hostWin, rect, opt_prerenderableOnly )
| 48 | * @return {!Promise} |
| 49 | */ |
| 50 | export 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. |
no test coverage detected