mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Instead of running paint requests during microtasks, we run them after updating layout for the current frame. After draining all the paint requests, we then drain whatever commits are available. It's still possible that requestPaint callbacks can dirty style and layout information, so we need to clean that information after servicing the requests. Ideally we'd block these callbacks from dirtying style or layout information. R=ojan@chromium.org Review URL: https://codereview.chromium.org/1027563002
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/core/page/PageAnimator.h"
|
|
|
|
#include "sky/engine/core/animation/DocumentAnimations.h"
|
|
#include "sky/engine/core/dom/Document.h"
|
|
#include "sky/engine/core/frame/FrameView.h"
|
|
#include "sky/engine/core/frame/LocalFrame.h"
|
|
#include "sky/engine/core/page/ChromeClient.h"
|
|
#include "sky/engine/core/page/Page.h"
|
|
#include "sky/engine/core/painting/PaintingTasks.h"
|
|
#include "sky/engine/platform/Logging.h"
|
|
|
|
namespace blink {
|
|
|
|
PageAnimator::PageAnimator(Page* page)
|
|
: m_page(page)
|
|
, m_servicingAnimations(false)
|
|
, m_updatingLayoutAndStyleForPainting(false)
|
|
{
|
|
}
|
|
|
|
void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime)
|
|
{
|
|
TemporaryChange<bool> servicing(m_servicingAnimations, true);
|
|
|
|
RefPtr<Document> document = m_page->mainFrame()->document();
|
|
|
|
DocumentAnimations::updateAnimationTimingForAnimationFrame(*document, monotonicAnimationStartTime);
|
|
document->serviceScriptedAnimations(monotonicAnimationStartTime);
|
|
}
|
|
|
|
void PageAnimator::scheduleVisualUpdate()
|
|
{
|
|
if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting)
|
|
return;
|
|
m_page->scheduleVisualUpdate();
|
|
}
|
|
|
|
void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame)
|
|
{
|
|
RefPtr<FrameView> view = rootFrame->view();
|
|
|
|
TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true);
|
|
|
|
view->setFrameRect(view->frameRect());
|
|
view->updateLayoutAndStyleForPainting();
|
|
|
|
// TODO(abarth): Remove these calls to updateLayoutAndStyleForPainting
|
|
// once requestPaint callbacks can't dirty layout.
|
|
while (PaintingTasks::serviceRequests())
|
|
view->updateLayoutAndStyleForPainting();
|
|
|
|
PaintingTasks::drainCommits();
|
|
|
|
ASSERT(m_page->mainFrame()->document()->lifecycle().state() == DocumentLifecycle::StyleAndLayoutClean);
|
|
}
|
|
|
|
}
|