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

Method layoutComplete_

src/service/resource.js:913–939  ·  view source on GitHub ↗

* @param {boolean} success * @param {!AbortSignal} signal * @param {*=} opt_reason * @return {!Promise|undefined}

(success, signal, opt_reason)

Source from the content-addressed store, hash-verified

911 * @return {!Promise|undefined}
912 */
913 layoutComplete_(success, signal, opt_reason) {
914 this.abortController_ = null;
915 if (signal.aborted) {
916 // We hit a race condition, where `layoutCallback` -> `unlayoutCallback`
917 // was called in quick succession. Since the unlayout was called before
918 // the layout completed, we want to remain in the unlayout state.
919 const err = dev().createError('layoutComplete race');
920 err.associatedElement = this.element;
921 dev().expectedError(TAG, err);
922 throw cancellation();
923 }
924 if (this.loadPromiseResolve_) {
925 this.loadPromiseResolve_();
926 this.loadPromiseResolve_ = null;
927 }
928 this.layoutPromise_ = null;
929 this.state_ = success
930 ? ResourceState_Enum.LAYOUT_COMPLETE
931 : ResourceState_Enum.LAYOUT_FAILED;
932 this.lastLayoutError_ = opt_reason;
933 if (success) {
934 dev().fine(TAG, 'layout complete:', this.debugid);
935 } else {
936 dev().fine(TAG, 'loading failed:', this.debugid, opt_reason);
937 return Promise.reject(opt_reason);
938 }
939 }
940
941 /**
942 * Returns true if the resource layout has not completed or failed.

Callers 1

startLayoutMethod · 0.95

Calls 5

devFunction · 0.90
cancellationFunction · 0.90
fineMethod · 0.80
createErrorMethod · 0.45
expectedErrorMethod · 0.45

Tested by

no test coverage detected