void ContentLayerDelegate::paintContents(
    WebDisplayItemList* webDisplayItemList, WebContentLayerClient::PaintingControlSetting paintingControl)
{
    TRACE_EVENT0("blink,benchmark", "ContentLayerDelegate::paintContents");

    PaintController& paintController = m_graphicsLayer->paintController();
    paintController.setDisplayItemConstructionIsDisabled(
        paintingControl == WebContentLayerClient::DisplayListConstructionDisabled);
    paintController.setSubsequenceCachingIsDisabled(
        paintingControl == WebContentLayerClient::SubsequenceCachingDisabled);

    // We also disable caching when Painting or Construction are disabled. In both cases we would like
    // to compare assuming the full cost of recording, not the cost of re-using cached content.
    if (paintingControl != WebContentLayerClient::PaintDefaultBehavior
        && paintingControl != WebContentLayerClient::SubsequenceCachingDisabled)
        paintController.invalidateAll();

    GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
    if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled
        || paintingControl == WebContentLayerClient::DisplayListConstructionDisabled)
        disabledMode = GraphicsContext::FullyDisabled;

    if (paintingControl != PaintDefaultBehavior)
        m_graphicsLayer->paint(nullptr, disabledMode);
    paintArtifactToWebDisplayItemList(webDisplayItemList, paintController.paintArtifact(), paintableRegion());

    paintController.setDisplayItemConstructionIsDisabled(false);
    paintController.setSubsequenceCachingIsDisabled(false);
}
void ContentLayerDelegate::paintContents(
    WebDisplayItemList* webDisplayItemList, const WebRect& clip,
    WebContentLayerClient::PaintingControlSetting paintingControl)
{
    TRACE_EVENT1("blink,benchmark", "ContentLayerDelegate::paintContents", "clip_rect", toTracedValue(clip));

    // TODO(pdr): Remove when slimming paint v2 is further along. This is only
    // here so the browser is usable during development and does not crash due
    // to committing the new display items twice.
    if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
        paintArtifactToWebDisplayItemList(webDisplayItemList, m_painter->paintController()->paintArtifact(), clip);
        return;
    }

    PaintController* paintController = m_painter->paintController();
    ASSERT(paintController);
    paintController->setDisplayItemConstructionIsDisabled(
        paintingControl == WebContentLayerClient::DisplayListConstructionDisabled);

    // We also disable caching when Painting or Construction are disabled. In both cases we would like
    // to compare assuming the full cost of recording, not the cost of re-using cached content.
    if (paintingControl != WebContentLayerClient::PaintDefaultBehavior)
        paintController->invalidateAll();

    GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisabled;
    if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled
        || paintingControl == WebContentLayerClient::DisplayListConstructionDisabled)
        disabledMode = GraphicsContext::FullyDisabled;
    GraphicsContext context(*paintController, disabledMode);

    IntRect interestRect = clip;
    m_painter->paint(context, &interestRect);

    paintController->commitNewDisplayItems();
    paintArtifactToWebDisplayItemList(webDisplayItemList, paintController->paintArtifact(), clip);
}