flutter_flutter/engine/core/page/PageAnimator.cpp
Ojan Vafai f45642cf8c Get rid of ScrollView.
We only allow overflow scrolling. The frame isn't special.
This is a first step in making that happen. There's a lot of
code to remove after this patch, but this gets rid of
ScrollView and a bunch of frame-level scrolling code.

Had to add in a FrameWidget class so that Scrollbar.cpp had
a way of getting to FrameView::removeChild without pulling
a core class into platform. This might go away when we rip
out the Widget tree if we made it so that FrameView didn't
keep a list of Scrollbar instances.

Modified scrollbar.html to use overflow scrolling instead of
frame level scrolling. Once we get rid of the split between
Document and documentElement, we'll be able to make the root
element in the page scrollable as well (i.e. any child of the
Document).

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/646273006
2014-10-23 20:20:25 -07:00

80 lines
3.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 "config.h"
#include "core/page/PageAnimator.h"
#include "core/animation/DocumentAnimations.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/Page.h"
#include "platform/Logging.h"
namespace blink {
PageAnimator::PageAnimator(Page* page)
: m_page(page)
, m_animationFramePending(false)
, m_servicingAnimations(false)
, m_updatingLayoutAndStyleForPainting(false)
{
}
void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime)
{
m_animationFramePending = false;
TemporaryChange<bool> servicing(m_servicingAnimations, true);
WillBeHeapVector<RefPtrWillBeMember<Document> > documents;
documents.append(m_page->mainFrame()->document());
WTF_LOG(ScriptedAnimationController, "PageAnimator::serviceScriptedAnimations: #documents = %d",
static_cast<int>(documents.size()));
for (size_t i = 0; i < documents.size(); ++i) {
if (documents[i]->frame()) {
if (const FrameView::ScrollableAreaSet* scrollableAreas = documents[i]->view()->scrollableAreas()) {
for (FrameView::ScrollableAreaSet::iterator it = scrollableAreas->begin(); it != scrollableAreas->end(); ++it)
(*it)->serviceScrollAnimations(monotonicAnimationStartTime);
}
}
}
for (size_t i = 0; i < documents.size(); ++i)
DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i], monotonicAnimationStartTime);
for (size_t i = 0; i < documents.size(); ++i)
documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime);
}
void PageAnimator::scheduleVisualUpdate()
{
// FIXME: also include m_animationFramePending here. It is currently not there due to crbug.com/353756.
if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting)
return;
m_page->chrome().scheduleAnimation();
}
void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame)
{
RefPtr<FrameView> view = rootFrame->view();
TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true);
// In order for our child HWNDs (NativeWindowWidgets) to update properly,
// they need to be told that we are updating the screen. The problem is that
// the native widgets need to recalculate their clip region and not overlap
// any of our non-native widgets. To force the resizing, call
// setFrameRect(). This will be a quick operation for most frames, but the
// NativeWindowWidgets will update a proper clipping region.
view->setFrameRect(view->frameRect());
// setFrameRect may have the side-effect of causing existing page layout to
// be invalidated, so layout needs to be called last.
view->updateLayoutAndStyleForPainting();
}
}