MCPcopy Create free account
hub / github.com/ampproject/amphtml / doWork

Method doWork

src/service/resources-impl.js:1648–1676  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1646 VISIBLE: visible,
1647 } = VisibilityState_Enum;
1648 const doWork = () => {
1649 // If viewport size is 0, the manager will wait for the resize event.
1650 const viewportSize = this.viewport_.getSize();
1651 if (viewportSize.height > 0 && viewportSize.width > 0) {
1652 // 1. Handle all size-change requests. 1x mutate (+1 vsync measure/mutate for above-fold resizes).
1653 if (this.hasMutateWork_()) {
1654 this.mutateWork_();
1655 }
1656 // 2. Build/measure/in-viewport/schedule layouts. 1x mutate & measure.
1657 this.discoverWork_();
1658 // 3. Execute scheduled layouts and preloads. 1x mutate.
1659 let delay = this.work_();
1660 // 4. Deferred size-change requests (waiting for scrolling to stop) will shorten delay until next pass.
1661 if (this.hasMutateWork_()) {
1662 // Overflow mutate work.
1663 delay = Math.min(delay, MUTATE_DEFER_DELAY_);
1664 }
1665 if (this.visible_) {
1666 if (this.schedulePass(delay)) {
1667 dev().fine(TAG_, 'next pass:', delay);
1668 } else {
1669 dev().fine(TAG_, 'pass already scheduled');
1670 }
1671 } else {
1672 dev().fine(TAG_, 'document is not visible: no scheduling');
1673 }
1674 this.firstPassDone_.resolve();
1675 }
1676 };
1677 const noop = () => {};
1678 const pause = () => {
1679 this.resources_.forEach((r) => r.pause());

Callers

nothing calls this directly

Calls 9

hasMutateWork_Method · 0.95
mutateWork_Method · 0.95
discoverWork_Method · 0.95
work_Method · 0.95
schedulePassMethod · 0.95
devFunction · 0.90
fineMethod · 0.80
resolveMethod · 0.80
getSizeMethod · 0.45

Tested by

no test coverage detected