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

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: Rebased 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
« no previous file with comments | « Source/core/page/SpatialNavigation.cpp ('k') | Source/core/plugins/DOMMimeType.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8a27fd9411ad495abc6057de08a592674d511aed 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 = m_page->deprecatedLocalMainFrame()->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(m_page->deprecatedLocalMainFrame()->view()->layerForScrolling())) {
Vector<IntRect> rects = region.rects();
WebVector<WebRect> webRects(rects.size());
for (size_t i = 0; i < rects.size(); ++i)
@@ -124,6 +128,9 @@ void ScrollingCoordinator::notifyLayoutUpdated()
void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
{
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+
if (!shouldUpdateAfterCompositingChange())
return;
@@ -138,7 +145,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(m_page->deprecatedLocalMainFrame(), IntPoint());
setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMainThreadRegion);
m_scrollGestureRegionIsDirty = false;
}
@@ -148,7 +155,7 @@ void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded()
m_touchEventTargetRectsAreDirty = false;
}
- FrameView* frameView = m_page->mainFrame()->view();
+ FrameView* frameView = m_page->deprecatedLocalMainFrame()->view();
bool frameIsScrollable = frameView && frameView->isScrollable();
if (m_shouldScrollOnMainThreadDirty || m_wasFrameScrollable != frameIsScrollable) {
setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReasons());
@@ -161,7 +168,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 = m_page->deprecatedLocalMainFrame()->document();
Element* fullscreenElement = FullscreenElementStack::fullscreenElementFrom(*mainFrameDocument);
if (fullscreenElement && fullscreenElement != mainFrameDocument->documentElement())
scrollingWebLayer->setScrollClipLayer(0);
@@ -323,7 +330,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 +617,7 @@ void ScrollingCoordinator::setTouchEventTargetRects(LayerHitTestRects& layerRect
}
GraphicsLayerHitTestRects graphicsLayerRects;
- projectRectsToGraphicsLayerSpace(m_page->mainFrame(), layerRects, graphicsLayerRects);
+ projectRectsToGraphicsLayerSpace(m_page->deprecatedLocalMainFrame(), layerRects, graphicsLayerRects);
for (GraphicsLayerHitTestRects::const_iterator iter = graphicsLayerRects.begin(); iter != graphicsLayerRects.end(); ++iter) {
const GraphicsLayer* graphicsLayer = iter->key;
@@ -627,14 +634,14 @@ void ScrollingCoordinator::touchEventTargetRectsDidChange()
return;
// Wait until after layout to update.
- if (!m_page->mainFrame()->view() || m_page->mainFrame()->view()->needsLayout())
+ if (!m_page->deprecatedLocalMainFrame()->view() || m_page->deprecatedLocalMainFrame()->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 = m_page->deprecatedLocalMainFrame()->contentRenderer();
if (renderView && renderView->compositor() && renderView->compositor()->staleInCompositingMode())
- m_page->mainFrame()->view()->scheduleAnimation();
+ m_page->deprecatedLocalMainFrame()->view()->scheduleAnimation();
m_touchEventTargetRectsAreDirty = true;
}
@@ -666,10 +673,10 @@ void ScrollingCoordinator::updateHaveWheelEventHandlers()
{
ASSERT(isMainThread());
ASSERT(m_page);
- if (!m_page->mainFrame()->view())
+ if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view())
return;
- if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerForScrolling())) {
+ if (WebLayer* scrollLayer = toWebLayer(m_page->deprecatedLocalMainFrame()->view()->layerForScrolling())) {
bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventHandlers(EventHandlerRegistry::WheelEvent);
scrollLayer->setHaveWheelEventHandlers(haveHandlers);
}
@@ -679,13 +686,13 @@ void ScrollingCoordinator::updateHaveScrollEventHandlers()
{
ASSERT(isMainThread());
ASSERT(m_page);
- if (!m_page->mainFrame()->view())
+ if (!m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->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(m_page->deprecatedLocalMainFrame()->view()->layerForScrolling())) {
bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventHandlers(EventHandlerRegistry::ScrollEvent);
scrollLayer->setHaveScrollEventHandlers(haveHandlers);
}
@@ -693,7 +700,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(m_page->deprecatedLocalMainFrame()->view()->layerForScrolling())) {
m_lastMainThreadScrollingReasons = reasons;
scrollLayer->setShouldScrollOnMainThread(reasons);
}
@@ -718,8 +727,11 @@ bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
if (&frameView->frame() != m_page->mainFrame())
return false;
+ if (!m_page->mainFrame()->isLocalFrame())
+ return false;
+
// We currently only support composited mode.
- RenderView* renderView = m_page->mainFrame()->contentRenderer();
+ RenderView* renderView = m_page->deprecatedLocalMainFrame()->contentRenderer();
if (!renderView)
return false;
return renderView->usesCompositing();
@@ -852,7 +864,7 @@ void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects");
ASSERT(touchHitTestingEnabled());
- Document* document = m_page->mainFrame()->document();
+ Document* document = m_page->deprecatedLocalMainFrame()->document();
if (!document || !document->view())
return;
@@ -883,7 +895,7 @@ void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView* frameView)
bool ScrollingCoordinator::isForMainFrame(ScrollableArea* scrollableArea) const
{
- return scrollableArea == m_page->mainFrame()->view();
+ return m_page->mainFrame()->isLocalFrame() ? scrollableArea == m_page->deprecatedLocalMainFrame()->view() : false;
}
void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
@@ -907,7 +919,7 @@ void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
if (!m_page)
return;
- FrameView* frameView = m_page->mainFrame()->view();
+ FrameView* frameView = m_page->deprecatedLocalMainFrame()->view();
if (!frameView)
return;
@@ -943,7 +955,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 = m_page->deprecatedLocalMainFrame()->view();
if (!frameView)
return static_cast<MainThreadScrollingReasons>(0);
@@ -975,13 +989,13 @@ String ScrollingCoordinator::mainThreadScrollingReasonsAsText(MainThreadScrollin
String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const
{
- ASSERT(m_page->mainFrame()->document()->lifecycle().state() >= DocumentLifecycle::CompositingClean);
+ ASSERT(m_page->deprecatedLocalMainFrame()->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() ? m_page->deprecatedLocalMainFrame()->view() : 0;
bool frameIsScrollable = frameView && frameView->isScrollable();
if (frameIsScrollable != m_wasFrameScrollable)
return true;
« no previous file with comments | « Source/core/page/SpatialNavigation.cpp ('k') | Source/core/plugins/DOMMimeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698