/**
   * Initialize the layout to be shown.
   *
   * @param time The current time of the app in ms.
   * @param animate Whether to play an entry animation.
   */
  @Override
  public void show(long time, boolean animate) {
    super.show(time, animate);

    mLayoutTabs = null;
    setStaticTab(mTabModelSelector.getCurrentTabId());
  }
  @Override
  protected void notifySizeChanged(float width, float height, int orientation) {
    super.notifySizeChanged(width, height, orientation);
    if (mReaderModePanel == null) return;

    final boolean isToolbarVisible = getHeight() == getHeightMinusTopControls();
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;
    mReaderModePanel.onSizeChanged(width, height, isToolbarVisible, dpToPx);
  }
 @Override
 public void onTabCreated(
     long time,
     int tabId,
     int tabIndex,
     int sourceTabId,
     boolean newIsIncognito,
     boolean background,
     float originX,
     float originY) {
   super.onTabCreated(
       time, tabId, tabIndex, sourceTabId, newIsIncognito, background, originX, originY);
   if (!background) setStaticTab(tabId);
 }
  @Override
  protected void updateSceneLayer(
      Rect viewport,
      Rect contentViewport,
      LayerTitleCache layerTitleCache,
      TabContentManager tabContentManager,
      ResourceManager resourceManager,
      ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(
        viewport,
        contentViewport,
        layerTitleCache,
        tabContentManager,
        resourceManager,
        fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
      return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mReaderModeSceneLayer.update(mReaderModePanel, resourceManager);

    mSceneLayer.update(
        dpToPx, contentViewport, layerTitleCache, tabContentManager, fullscreenManager, layoutTab);

    // TODO(pedrosimonetti): Coordinate w/ dtrainor@ to improve integration with TreeProvider.
    SceneLayer overlayLayer = null;
    if (mSearchPanel.isShowing()) {
      overlayLayer = super.getSceneLayer();
    } else if (mReaderModePanel != null && mReaderModePanel.isShowing()) {
      overlayLayer = mReaderModeSceneLayer;
    }
    mSceneLayer.setContentSceneLayer(overlayLayer);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
      TabModelBase.logPerceivedTabSwitchLatencyMetric();
    }
  }
 @Override
 public void onTabPageLoadFinished(int id, boolean incognito) {
   super.onTabPageLoadFinished(id, incognito);
   unstallImmediately(id);
 }
 @Override
 public void onTabModelSwitched(boolean incognito) {
   super.onTabModelSwitched(incognito);
   setStaticTab(mTabModelSelector.getCurrentTabId());
 }
 @Override
 public void onTabSelecting(long time, int id) {
   setStaticTab(id);
   super.onTabSelecting(time, id);
 }
 @Override
 public void onTabSelected(long time, int id, int prevId, boolean incognito) {
   setStaticTab(id);
   super.onTabSelected(time, id, prevId, incognito);
 }
 @Override
 protected void updateLayout(long time, long dt) {
   super.updateLayout(time, dt);
   if (mLayoutTabs != null && mLayoutTabs.length > 0) mLayoutTabs[0].updateSnap(dt);
 }