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

Method scheduleLayoutOrPreload

src/service/resources-impl.js:1537–1580  ·  view source on GitHub ↗

@override

(
    resource,
    layout,
    opt_parentPriority,
    opt_forceOutsideViewport
  )

Source from the content-addressed store, hash-verified

1535
1536 /** @override */
1537 scheduleLayoutOrPreload(
1538 resource,
1539 layout,
1540 opt_parentPriority,
1541 opt_forceOutsideViewport
1542 ) {
1543 if (resource.element.R1()) {
1544 return;
1545 }
1546 const isBuilt = resource.getState() != ResourceState_Enum.NOT_BUILT;
1547 const isDisplayed = resource.isDisplayed();
1548 if (!isBuilt || !isDisplayed) {
1549 devAssert(
1550 false,
1551 'Not ready for layout: %s (%s)',
1552 resource.debugid,
1553 resource.getState()
1554 );
1555 }
1556 const forceOutsideViewport = opt_forceOutsideViewport || false;
1557 if (!this.isLayoutAllowed_(resource, forceOutsideViewport)) {
1558 return;
1559 }
1560
1561 if (layout) {
1562 this.schedule_(
1563 resource,
1564 LAYOUT_TASK_ID_,
1565 LAYOUT_TASK_OFFSET_,
1566 opt_parentPriority || 0,
1567 forceOutsideViewport,
1568 resource.startLayout.bind(resource)
1569 );
1570 } else {
1571 this.schedule_(
1572 resource,
1573 PRELOAD_TASK_ID_,
1574 PRELOAD_TASK_OFFSET_,
1575 opt_parentPriority || 0,
1576 forceOutsideViewport,
1577 resource.startLayout.bind(resource)
1578 );
1579 }
1580 }
1581
1582 /**
1583 * Schedules a task.

Callers 3

discoverWork_Method · 0.95
test-resources.jsFile · 0.45
ensureLoadedMethod · 0.45

Calls 6

isLayoutAllowed_Method · 0.95
schedule_Method · 0.95
devAssertFunction · 0.90
isDisplayedMethod · 0.80
R1Method · 0.45
getStateMethod · 0.45

Tested by

no test coverage detected