Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1442)

Unified Diff: Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Android/Mac fixes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/page/scrolling/ScrollingCoordinator.cpp
diff --git a/Source/core/page/scrolling/ScrollingCoordinator.cpp b/Source/core/page/scrolling/ScrollingCoordinator.cpp
index f8348db9b5183df793ebdadbc579bd48808f239c..19b5bb8998a7f12ee8273feee5905e4b89e6ec06 100644
--- a/Source/core/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/core/page/scrolling/ScrollingCoordinator.cpp
@@ -99,14 +99,18 @@ ScrollingCoordinator::~ScrollingCoordinator()
bool ScrollingCoordinator::touchHitTestingEnabled() const
{
- RenderView* contentRenderer = m_page->mainFrame()->contentRenderer();
- Settings* settings = m_page->mainFrame()->document()->settings();
+ if (!m_page->mainFrame()->isLocalFrame())
+ return false;
+ RenderView* contentRenderer = toLocalFrame(m_page->mainFrame())->contentRenderer();
+ Settings* settings = m_page->mainFrame()->settings();
return RuntimeEnabledFeatures::touchEnabled() && settings->compositorTouchHitTesting() && contentRenderer && contentRenderer->usesCompositing();
}
void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const Region& region)
{
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+ if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->view()->layerForScrolling())) {
Vector<IntRect> rects = region.rects();
WebVector<WebRect> webRects(rects.size());
for (size_t i = 0; i < rects.size(); ++i)
@@ -124,6 +128,11 @@ void ScrollingCoordinator::notifyLayoutUpdated()
void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
{
+ // FIXME: This function has a lot of dependencies on main frame always being
+ // local, so just early return if that's not the case.
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+
if (!shouldUpdateAfterCompositingChange())
return;
@@ -138,7 +147,7 @@ void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
// 2. Resize control areas, e.g. the small rect at the right bottom of div/textarea/iframe when
// CSS property "resize" is enabled.
// 3. Plugin areas.
- Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint());
+ Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScrollGestureOnMainThreadRegion(toLocalFrame(m_page->mainFrame()), IntPoint());
setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
m_scrollGestureRegionIsDirty = false;
}
@@ -148,7 +157,7 @@ void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
m_touchEventTargetRectsAreDirty = false;
}
- FrameView* frameView = m_page->mainFrame()->view();
+ FrameView* frameView = toLocalFrame(m_page->mainFrame())->view();
bool frameIsScrollable = frameView && frameView->isScrollable();
if (m_shouldScrollOnMainThreadDirty || m_wasFrameScrollable != frameIsScrollable) {
setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReasons());
@@ -161,7 +170,7 @@ void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
if (WebLayer* scrollingWebLayer = frameView ? toWebLayer(frameView->layerForScrolling()) : 0) {
scrollingWebLayer->setBounds(frameView->contentsSize());
// If there is a fullscreen element, set the scroll clip layer to 0 so main frame won't scroll.
- Document* mainFrameDocument = m_page->mainFrame()->document();
+ Document* mainFrameDocument = toLocalFrame(m_page->mainFrame())->document();
Element* fullscreenElement = FullscreenElementStack::fullscreenElementFrom(*mainFrameDocument);
if (fullscreenElement && fullscreenElement != mainFrameDocument->documentElement())
scrollingWebLayer->setScrollClipLayer(0);
@@ -323,7 +332,7 @@ void ScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea*
WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, orientation);
if (!scrollbarLayer) {
- Settings* settings = m_page->mainFrame()->document()->settings();
+ Settings* settings = m_page->mainFrame()->settings();
OwnPtr<WebScrollbarLayer> webScrollbarLayer;
if (settings->useSolidColorScrollbars()) {
@@ -610,7 +619,7 @@ void ScrollingCoordinator::setTouchEventTargetRects(LayerHitTestRects& layerRect
}
GraphicsLayerHitTestRects graphicsLayerRects;
- projectRectsToGraphicsLayerSpace(m_page->mainFrame(), layerRects, graphicsLayerRects);
+ projectRectsToGraphicsLayerSpace(toLocalFrame(m_page->mainFrame()), layerRects, graphicsLayerRects);
for (GraphicsLayerHitTestRects::const_iterator iter = graphicsLayerRects.begin(); iter != graphicsLayerRects.end(); ++iter) {
const GraphicsLayer* graphicsLayer = iter->key;
@@ -627,14 +636,14 @@ void ScrollingCoordinator::touchEventTargetRectsDidChange()
return;
// Wait until after layout to update.
- if (!m_page->mainFrame()->view() || m_page->mainFrame()->view()->needsLayout())
+ if (!toLocalFrame(m_page->mainFrame())->view() || toLocalFrame(m_page->mainFrame())->view()->needsLayout())
return;
// FIXME: scheduleAnimation() is just a method of forcing the compositor to realize that it
// needs to commit here. We should expose a cleaner API for this.
- RenderView* renderView = m_page->mainFrame()->contentRenderer();
+ RenderView* renderView = toLocalFrame(m_page->mainFrame())->contentRenderer();
if (renderView && renderView->compositor() && renderView->compositor()->staleInCompositingMode())
- m_page->mainFrame()->view()->scheduleAnimation();
+ toLocalFrame(m_page->mainFrame())->view()->scheduleAnimation();
m_touchEventTargetRectsAreDirty = true;
}
@@ -666,10 +675,10 @@ void ScrollingCoordinator::updateHaveWheelEventHandlers()
{
ASSERT(isMainThread());
ASSERT(m_page);
- if (!m_page->mainFrame()->view())
+ if (!m_page->mainFrame()->isLocalFrame() || !toLocalFrame(m_page->mainFrame())->view())
return;
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->view()->layerForScrolling())) {
bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventHandlers(EventHandlerRegistry::WheelEvent);
scrollLayer->setHaveWheelEventHandlers(haveHandlers);
}
@@ -679,13 +688,13 @@ void ScrollingCoordinator::updateHaveScrollEventHandlers()
{
ASSERT(isMainThread());
ASSERT(m_page);
- if (!m_page->mainFrame()->view())
+ if (!m_page->mainFrame()->isLocalFrame() || !toLocalFrame(m_page->mainFrame())->view())
return;
// Currently the compositor only cares whether there are scroll handlers anywhere on the page
// instead on a per-layer basis. We therefore only update this information for the root
// scrolling layer.
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->view()->layerForScrolling())) {
bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventHandlers(EventHandlerRegistry::ScrollEvent);
scrollLayer->setHaveScrollEventHandlers(haveHandlers);
}
@@ -693,7 +702,9 @@ void ScrollingCoordinator::updateHaveScrollEventHandlers()
void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
{
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+ if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->view()->layerForScrolling())) {
m_lastMainThreadScrollingReasons = reasons;
scrollLayer->setShouldScrollOnMainThread(reasons);
}
@@ -718,8 +729,12 @@ bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
if (&frameView->frame() != m_page->mainFrame())
return false;
+ // FIXME: And only if the main frame is not an OOPI.
+ if (!m_page->mainFrame()->isLocalFrame())
+ return false;
+
// We currently only support composited mode.
- RenderView* renderView = m_page->mainFrame()->contentRenderer();
+ RenderView* renderView = toLocalFrame(m_page->mainFrame())->contentRenderer();
if (!renderView)
return false;
return renderView->usesCompositing();
@@ -852,7 +867,7 @@ void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects");
ASSERT(touchHitTestingEnabled());
- Document* document = m_page->mainFrame()->document();
+ Document* document = toLocalFrame(m_page->mainFrame())->document();
if (!document || !document->view())
return;
@@ -883,7 +898,7 @@ void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView* frameView)
bool ScrollingCoordinator::isForMainFrame(ScrollableArea* scrollableArea) const
{
- return scrollableArea == m_page->mainFrame()->view();
+ return m_page->mainFrame()->isLocalFrame() ? scrollableArea == toLocalFrame(m_page->mainFrame())->view() : false;
}
void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
@@ -907,7 +922,7 @@ void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
if (!m_page)
return;
- FrameView* frameView = m_page->mainFrame()->view();
+ FrameView* frameView = toLocalFrame(m_page->mainFrame())->view();
if (!frameView)
return;
@@ -943,7 +958,9 @@ MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co
// The main thread scrolling reasons are applicable to scrolls of the main
// frame. If it does not exist or if it is not scrollable, there is no
// reason to force main thread scrolling.
- FrameView* frameView = m_page->mainFrame()->view();
+ if (!m_page->mainFrame()->isLocalFrame())
+ return static_cast<MainThreadScrollingReasons>(0);
+ FrameView* frameView = toLocalFrame(m_page->mainFrame())->view();
if (!frameView)
return static_cast<MainThreadScrollingReasons>(0);
@@ -975,13 +992,13 @@ String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin
String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
{
- ASSERT(m_page->mainFrame()->document()->lifecycle().state() >= DocumentLifecycle::CompositingClean);
+ ASSERT(toLocalFrame(m_page->mainFrame())->document()->lifecycle().state() >= DocumentLifecycle::CompositingClean);
return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons);
}
bool ScrollingCoordinator::frameViewIsDirty() const
{
- FrameView* frameView = m_page->mainFrame()->view();
+ FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? toLocalFrame(m_page->mainFrame())->view() : 0;
bool frameIsScrollable = frameView && frameView->isScrollable();
if (frameIsScrollable != m_wasFrameScrollable)
return true;

Powered by Google App Engine
This is Rietveld 408576698