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

Unified Diff: Source/web/WebViewImpl.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/web/WebPageSerializer.cpp ('k') | Source/web/tests/MHTMLTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebViewImpl.cpp
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp
index c65c4c3bb1d731ef5044b342aae7e0270452eeba..cb9dffd1e206af266b3f435d6af72c157767036f 100644
--- a/Source/web/WebViewImpl.cpp
+++ b/Source/web/WebViewImpl.cpp
@@ -443,7 +443,7 @@ WebViewImpl::~WebViewImpl()
WebLocalFrameImpl* WebViewImpl::mainFrameImpl()
{
- return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0;
+ return m_page && m_page->mainFrame()->isLocalFrame() ? WebLocalFrameImpl::fromFrame(m_page->deprecatedLocalMainFrame()) : 0;
}
bool WebViewImpl::tabKeyCyclesThroughElements() const
@@ -485,9 +485,9 @@ void WebViewImpl::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& ev
// If the hit node is a plugin but a scrollbar is over it don't start mouse
// capture because it will interfere with the scrollbar receiving events.
IntPoint point(event.x, event.y);
- if (event.button == WebMouseEvent::ButtonLeft && !m_page->mainFrame()->view()->scrollbarAtPoint(point)) {
- point = m_page->mainFrame()->view()->windowToContents(point);
- HitTestResult result(m_page->mainFrame()->eventHandler().hitTestResultAtPoint(point));
+ if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLocalFrame() && !m_page->deprecatedLocalMainFrame()->view()->scrollbarAtPoint(point)) {
+ point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(point);
+ HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint(point));
Node* hitNode = result.innerNonSharedNode();
if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->renderer()->isEmbeddedObject()) {
@@ -597,8 +597,8 @@ bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
syntheticWheel.modifiers = m_flingModifier;
- if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
- return handleMouseWheel(*m_page->mainFrame(), syntheticWheel);
+ if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view())
+ return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel);
} else {
WebGestureEvent syntheticGestureEvent;
@@ -612,7 +612,7 @@ bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
syntheticGestureEvent.modifiers = m_flingModifier;
syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
- if (m_page && m_page->mainFrame() && m_page->mainFrame()->view())
+ if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view())
return handleGestureEvent(syntheticGestureEvent);
}
return false;
@@ -1171,16 +1171,16 @@ static bool invokesHandCursor(Node* node, LocalFrame* frame)
Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
{
- if (!m_page || !m_page->mainFrame())
+ if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame())
return 0;
Node* bestTouchNode = 0;
IntPoint touchEventLocation(tapEvent.position());
- m_page->mainFrame()->eventHandler().adjustGesturePosition(tapEvent, touchEventLocation);
+ m_page->deprecatedLocalMainFrame()->eventHandler().adjustGesturePosition(tapEvent, touchEventLocation);
- IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchEventLocation);
- HitTestResult result = m_page->mainFrame()->eventHandler().hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
+ IntPoint hitTestPoint = m_page->deprecatedLocalMainFrame()->view()->windowToContents(touchEventLocation);
+ HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
bestTouchNode = result.targetNode();
// We might hit something like an image map that has no renderer on it
@@ -1190,14 +1190,14 @@ Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent)
// Check if we're in the subtree of a node with a hand cursor
// this is the heuristic we use to determine if we show a highlight on tap
- while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->mainFrame()))
+ while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->deprecatedLocalMainFrame()))
bestTouchNode = bestTouchNode->parentNode();
if (!bestTouchNode)
return 0;
// We should pick the largest enclosing node with hand cursor set.
- while (bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), m_page->mainFrame()))
+ while (bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->parentNode(), toLocalFrame(m_page->mainFrame())))
bestTouchNode = bestTouchNode->parentNode();
return bestTouchNode;
@@ -1540,8 +1540,10 @@ void WebViewImpl::close()
if (m_page) {
// Initiate shutdown for the entire frameset. This will cause a lot of
// notifications to be sent.
- if (m_page->mainFrame())
- m_page->mainFrame()->loader().frameDetached();
+ // FIXME: This is redundant with willBeDestroyed()... is this really
+ // needed?
+ if (m_page->mainFrame()->isLocalFrame())
+ m_page->deprecatedLocalMainFrame()->loader().frameDetached();
m_page->willBeDestroyed();
m_page.clear();
@@ -1747,7 +1749,7 @@ void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re
// the compositor.
ASSERT(isAcceleratedCompositingActive());
- FrameView* view = page()->mainFrame()->view();
+ FrameView* view = page()->deprecatedLocalMainFrame()->view();
PaintBehavior oldPaintBehavior = view->paintBehavior();
view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
@@ -1767,7 +1769,9 @@ bool WebViewImpl::isTrackingRepaints() const
{
if (!page())
return false;
- FrameView* view = page()->mainFrame()->view();
+ if (!page()->mainFrame()->isLocalFrame())
+ return false;
+ FrameView* view = page()->deprecatedLocalMainFrame()->view();
return view->isTrackingPaintInvalidations();
}
@@ -1775,7 +1779,9 @@ void WebViewImpl::themeChanged()
{
if (!page())
return;
- FrameView* view = page()->mainFrame()->view();
+ if (!page()->mainFrame()->isLocalFrame())
+ return;
+ FrameView* view = page()->deprecatedLocalMainFrame()->view();
WebRect damagedRect(0, 0, m_size.width, m_size.height);
view->invalidateRect(damagedRect);
@@ -1967,7 +1973,8 @@ void WebViewImpl::setFocus(bool enable)
if (!m_page)
return;
- LocalFrame* frame = m_page->mainFrame();
+ LocalFrame* frame = m_page->mainFrame() && m_page->mainFrame()->isLocalFrame()
+ ? m_page->deprecatedLocalMainFrame() : 0;
if (!frame)
return;
@@ -2354,7 +2361,9 @@ WebColor WebViewImpl::backgroundColor() const
return m_baseBackgroundColor;
if (!m_page->mainFrame())
return m_baseBackgroundColor;
- FrameView* view = m_page->mainFrame()->view();
+ if (!m_page->mainFrame()->isLocalFrame())
+ return m_baseBackgroundColor;
+ FrameView* view = m_page->deprecatedLocalMainFrame()->view();
return view->documentBackgroundColor().rgb();
}
@@ -2461,11 +2470,14 @@ WebString WebViewImpl::pageEncoding() const
if (!m_page)
return WebString();
+ if (!m_page->mainFrame()->isLocalFrame())
+ return WebString();
+
// FIXME: Is this check needed?
- if (!m_page->mainFrame()->document()->loader())
+ if (!m_page->deprecatedLocalMainFrame()->document()->loader())
return WebString();
- return m_page->mainFrame()->document()->encodingName();
+ return m_page->deprecatedLocalMainFrame()->document()->encodingName();
}
void WebViewImpl::setPageEncoding(const WebString& encodingName)
@@ -2473,16 +2485,21 @@ void WebViewImpl::setPageEncoding(const WebString& encodingName)
if (!m_page)
return;
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+
// Only change override encoding, don't change default encoding.
// Note that the new encoding must be 0 if it isn't supposed to be set.
AtomicString newEncodingName;
if (!encodingName.isEmpty())
newEncodingName = encodingName;
- m_page->mainFrame()->loader().reload(NormalReload, KURL(), newEncodingName);
+ m_page->deprecatedLocalMainFrame()->loader().reload(NormalReload, KURL(), newEncodingName);
}
WebFrame* WebViewImpl::mainFrame()
{
+ // FIXME: This should be updated so it can return both WebLocalFrames and
+ // WebRemoteFrames. Right now, it only returns WebLocalFrames.
return mainFrameImpl();
}
@@ -2559,7 +2576,8 @@ void WebViewImpl::clearFocusedElement()
void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect)
{
- LocalFrame* frame = page()->mainFrame();
+ LocalFrame* frame = page()->mainFrame() && page()->mainFrame()->isLocalFrame()
+ ? page()->deprecatedLocalMainFrame() : 0;
Element* element = focusedElement();
if (!frame || !frame->view() || !element)
return;
@@ -2889,9 +2907,9 @@ void WebViewImpl::setIgnoreViewportTagScaleLimits(bool ignore)
void WebViewImpl::refreshPageScaleFactorAfterLayout()
{
- if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->view())
+ if (!mainFrame() || !page() || !page()->mainFrame() || !page()->mainFrame()->isLocalFrame() || !page()->deprecatedLocalMainFrame()->view())
return;
- FrameView* view = page()->mainFrame()->view();
+ FrameView* view = page()->deprecatedLocalMainFrame()->view();
updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->viewportDescription());
m_pageScaleConstraintsSet.computeFinalConstraints();
@@ -2923,10 +2941,10 @@ void WebViewImpl::refreshPageScaleFactorAfterLayout()
void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription& description)
{
- if (!settings()->viewportEnabled() || !page() || (!m_size.width && !m_size.height))
+ if (!settings()->viewportEnabled() || !page() || (!m_size.width && !m_size.height) || !page()->mainFrame()->isLocalFrame())
return;
- Document* document = page()->mainFrame()->document();
+ Document* document = page()->deprecatedLocalMainFrame()->document();
if (settingsImpl()->useExpandedHeuristicsForGpuRasterization()) {
m_matchesHeuristicsForGpuRasterization = description.maxWidth == Length(DeviceWidth)
@@ -2980,7 +2998,7 @@ void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription
updateMainFrameLayoutSize();
- if (LocalFrame* frame = page()->mainFrame()) {
+ if (LocalFrame* frame = page()->deprecatedLocalMainFrame()) {
if (FastTextAutosizer* textAutosizer = frame->document()->fastTextAutosizer())
textAutosizer->updatePageInfoInAllFrames();
}
@@ -3002,7 +3020,7 @@ void WebViewImpl::updateMainFrameLayoutSize()
bool textAutosizingEnabled = page()->settings().textAutosizingEnabled();
if (textAutosizingEnabled && layoutSize.width != view->layoutSize().width()) {
- if (TextAutosizer* textAutosizer = page()->mainFrame()->document()->textAutosizer())
+ if (TextAutosizer* textAutosizer = page()->deprecatedLocalMainFrame()->document()->textAutosizer())
textAutosizer->recalculateMultipliers();
}
}
@@ -3012,7 +3030,9 @@ void WebViewImpl::updateMainFrameLayoutSize()
IntSize WebViewImpl::contentsSize() const
{
- RenderView* root = page()->mainFrame()->contentRenderer();
+ if (!page()->mainFrame()->isLocalFrame())
+ return IntSize();
+ RenderView* root = page()->deprecatedLocalMainFrame()->contentRenderer();
if (!root)
return IntSize();
return root->documentRect().size();
@@ -3020,7 +3040,7 @@ IntSize WebViewImpl::contentsSize() const
WebSize WebViewImpl::contentsPreferredMinimumSize()
{
- Document* document = m_page->mainFrame()->document();
+ Document* document = m_page->mainFrame()->isLocalFrame() ? m_page->deprecatedLocalMainFrame()->document() : 0;
if (!document || !document->renderView() || !document->documentElement())
return WebSize();
@@ -3049,22 +3069,25 @@ void WebViewImpl::resetScrollAndScaleState()
updateMainFrameScrollPosition(IntPoint(), true);
page()->frameHost().pinchViewport().reset();
+ if (!page()->mainFrame()->isLocalFrame())
+ return;
+
// Clear out the values for the current history item. This will prevent the history item from clobbering the
// value determined during page scale initialization, which may be less than 1.
- page()->mainFrame()->loader().clearScrollPositionAndViewState();
+ page()->deprecatedLocalMainFrame()->loader().clearScrollPositionAndViewState();
m_pageScaleConstraintsSet.setNeedsReset(true);
// Clobber saved scales and scroll offsets.
- if (FrameView* view = page()->mainFrame()->document()->view())
+ if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view())
view->cacheCurrentScrollPosition();
}
void WebViewImpl::setFixedLayoutSize(const WebSize& layoutSize)
{
- if (!page())
+ if (!page() || !page()->mainFrame()->isLocalFrame())
return;
- LocalFrame* frame = page()->mainFrame();
+ LocalFrame* frame = page()->deprecatedLocalMainFrame();
if (!frame)
return;
@@ -3162,7 +3185,7 @@ void WebViewImpl::copyImageAt(const WebPoint& point)
return;
}
- m_page->mainFrame()->editor().copyImage(result);
+ m_page->deprecatedLocalMainFrame()->editor().copyImage(result);
}
void WebViewImpl::saveImageAt(const WebPoint& point)
@@ -3176,7 +3199,7 @@ void WebViewImpl::saveImageAt(const WebPoint& point)
return;
ResourceRequest request(url);
- m_page->mainFrame()->loader().client()->loadURLExternally(
+ m_page->deprecatedLocalMainFrame()->loader().client()->loadURLExternally(
request, NavigationPolicyDownloadTo, WebString());
}
@@ -3189,7 +3212,7 @@ void WebViewImpl::dragSourceEndedAt(
screenPoint,
LeftButton, PlatformEvent::MouseMoved, 0, false, false, false,
false, 0);
- m_page->mainFrame()->eventHandler().dragSourceEndedAt(pme,
+ m_page->deprecatedLocalMainFrame()->eventHandler().dragSourceEndedAt(pme,
static_cast<DragOperation>(operation));
}
@@ -3372,12 +3395,12 @@ void WebViewImpl::inspectElementAt(const WebPoint& point)
dummyEvent.type = WebInputEvent::MouseDown;
dummyEvent.x = point.x;
dummyEvent.y = point.y;
- IntPoint transformedPoint = PlatformMouseEventBuilder(m_page->mainFrame()->view(), dummyEvent).position();
- HitTestResult result(m_page->mainFrame()->view()->windowToContents(transformedPoint));
- m_page->mainFrame()->contentRenderer()->hitTest(request, result);
+ IntPoint transformedPoint = PlatformMouseEventBuilder(m_page->deprecatedLocalMainFrame()->view(), dummyEvent).position();
+ HitTestResult result(m_page->deprecatedLocalMainFrame()->view()->windowToContents(transformedPoint));
+ m_page->deprecatedLocalMainFrame()->contentRenderer()->hitTest(request, result);
Node* node = result.innerNode();
- if (!node && m_page->mainFrame()->document())
- node = m_page->mainFrame()->document()->documentElement();
+ if (!node && m_page->deprecatedLocalMainFrame()->document())
+ node = m_page->deprecatedLocalMainFrame()->document()->documentElement();
m_page->inspectorController().inspect(node);
}
}
@@ -3510,8 +3533,8 @@ void WebViewImpl::setBaseBackgroundColor(WebColor color)
m_baseBackgroundColor = color;
- if (m_page->mainFrame())
- m_page->mainFrame()->view()->setBaseBackgroundColor(color);
+ if (m_page->mainFrame() && m_page->mainFrame()->isLocalFrame())
+ m_page->deprecatedLocalMainFrame()->view()->setBaseBackgroundColor(color);
updateLayerTreeBackgroundColor();
}
@@ -3582,10 +3605,13 @@ void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe)
if (webframe != mainFrameImpl())
return;
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+
// If we get to the <body> tag and we have no pending stylesheet and import load, we
// can be fairly confident we'll have something sensible to paint soon and
// can turn off deferred commits.
- if (m_page->mainFrame()->document()->isRenderingReady())
+ if (m_page->deprecatedLocalMainFrame()->document()->isRenderingReady())
resumeTreeViewCommits();
}
@@ -3692,14 +3718,17 @@ void WebViewImpl::setOverlayLayer(WebCore::GraphicsLayer* layer)
if (!m_rootGraphicsLayer)
return;
+ if (!m_page->mainFrame()->isLocalFrame())
+ return;
+
if (pinchVirtualViewportEnabled()) {
- m_page->mainFrame()->view()->renderView()->compositor()->setOverlayLayer(layer);
+ m_page->deprecatedLocalMainFrame()->view()->renderView()->compositor()->setOverlayLayer(layer);
return;
}
// FIXME(bokan): This path goes away after virtual viewport pinch is enabled everywhere.
if (!m_rootTransformLayer)
- m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compositor()->ensureRootTransformLayer();
+ m_rootTransformLayer = m_page->deprecatedLocalMainFrame()->view()->renderView()->compositor()->ensureRootTransformLayer();
if (m_rootTransformLayer) {
if (layer->parent() != m_rootTransformLayer)
@@ -3722,8 +3751,10 @@ Element* WebViewImpl::focusedElement() const
HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos)
{
- IntPoint docPoint(m_page->mainFrame()->view()->windowToContents(pos));
- return m_page->mainFrame()->eventHandler().hitTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
+ if (!m_page->mainFrame()->isLocalFrame())
+ return HitTestResult();
+ IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->windowToContents(pos));
+ return m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::ConfusingAndOftenMisusedDisallowShadowContent);
}
void WebViewImpl::setTabsToLinks(bool enable)
@@ -3821,10 +3852,11 @@ WebCore::RenderLayerCompositor* WebViewImpl::compositor() const
{
if (!page()
|| !page()->mainFrame()
- || !page()->mainFrame()->document()
- || !page()->mainFrame()->document()->renderView())
+ || !page()->mainFrame()->isLocalFrame()
+ || !page()->deprecatedLocalMainFrame()->document()
+ || !page()->deprecatedLocalMainFrame()->document()->renderView())
return 0;
- return page()->mainFrame()->document()->renderView()->compositor();
+ return page()->deprecatedLocalMainFrame()->document()->renderView()->compositor();
}
void WebViewImpl::registerForAnimations(WebLayer* layer)
@@ -3915,13 +3947,16 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
m_page->updateAcceleratedCompositingSettings();
}
}
- if (page())
- page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositingActive);
+ if (page() && page()->mainFrame()->isLocalFrame())
+ page()->deprecatedLocalMainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositingActive);
}
void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition, bool programmaticScroll)
{
- FrameView* frameView = page()->mainFrame()->view();
+ if (!page()->mainFrame()->isLocalFrame())
+ return;
+
+ FrameView* frameView = page()->deprecatedLocalMainFrame()->view();
if (!frameView)
return;
@@ -4003,8 +4038,8 @@ void WebViewImpl::updateRootLayerTransform()
// FIXME(bokan): m_rootTransformLayer is always set here in pinch virtual viewport. This can go away once
// that's default everywhere.
- if (!m_rootTransformLayer)
- m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compositor()->ensureRootTransformLayer();
+ if (!m_rootTransformLayer && m_page->mainFrame()->isLocalFrame())
+ m_rootTransformLayer = m_page->deprecatedLocalMainFrame()->view()->renderView()->compositor()->ensureRootTransformLayer();
if (m_rootTransformLayer) {
WebCore::TransformationMatrix transform;
« no previous file with comments | « Source/web/WebPageSerializer.cpp ('k') | Source/web/tests/MHTMLTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698