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

Side by Side Diff: Source/web/WebViewImpl.cpp

Issue 397023003: Preparing Blink for cross-process frame tree replication (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed extra blank line Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« Source/web/WebRemoteFrameImpl.cpp ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/editing/InputMethodController.h" 44 #include "core/editing/InputMethodController.h"
45 #include "core/editing/TextIterator.h" 45 #include "core/editing/TextIterator.h"
46 #include "core/editing/markup.h" 46 #include "core/editing/markup.h"
47 #include "core/events/KeyboardEvent.h" 47 #include "core/events/KeyboardEvent.h"
48 #include "core/events/WheelEvent.h" 48 #include "core/events/WheelEvent.h"
49 #include "core/frame/EventHandlerRegistry.h" 49 #include "core/frame/EventHandlerRegistry.h"
50 #include "core/frame/FrameHost.h" 50 #include "core/frame/FrameHost.h"
51 #include "core/frame/FrameView.h" 51 #include "core/frame/FrameView.h"
52 #include "core/frame/LocalFrame.h" 52 #include "core/frame/LocalFrame.h"
53 #include "core/frame/PinchViewport.h" 53 #include "core/frame/PinchViewport.h"
54 #include "core/frame/RemoteFrame.h"
54 #include "core/frame/Settings.h" 55 #include "core/frame/Settings.h"
55 #include "core/frame/SmartClip.h" 56 #include "core/frame/SmartClip.h"
56 #include "core/html/HTMLInputElement.h" 57 #include "core/html/HTMLInputElement.h"
57 #include "core/html/HTMLMediaElement.h" 58 #include "core/html/HTMLMediaElement.h"
58 #include "core/html/HTMLPlugInElement.h" 59 #include "core/html/HTMLPlugInElement.h"
59 #include "core/html/HTMLTextAreaElement.h" 60 #include "core/html/HTMLTextAreaElement.h"
60 #include "core/html/ime/InputMethodContext.h" 61 #include "core/html/ime/InputMethodContext.h"
61 #include "core/inspector/InspectorController.h" 62 #include "core/inspector/InspectorController.h"
62 #include "core/loader/DocumentLoader.h" 63 #include "core/loader/DocumentLoader.h"
63 #include "core/loader/FrameLoader.h" 64 #include "core/loader/FrameLoader.h"
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 } 1585 }
1585 1586
1586 void WebViewImpl::resizePinchViewport(const WebSize& newSize) 1587 void WebViewImpl::resizePinchViewport(const WebSize& newSize)
1587 { 1588 {
1588 if (!pinchVirtualViewportEnabled()) 1589 if (!pinchVirtualViewportEnabled())
1589 return; 1590 return;
1590 1591
1591 page()->frameHost().pinchViewport().setSize(newSize); 1592 page()->frameHost().pinchViewport().setSize(newSize);
1592 } 1593 }
1593 1594
1594 WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() 1595 WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() const
1595 { 1596 {
1596 // FIXME: This is a temporary method that finds the first localFrame in a tr aversal. 1597 // FIXME: This is a temporary method that finds the first localFrame in a tr aversal.
1597 // This is equivalent to mainFrame() if the mainFrame is in-process. We need to create 1598 // This is equivalent to mainFrame() if the mainFrame is in-process. We need to create
1598 // separate WebWidgets to be created by RenderWidgets, which are associated with *all* 1599 // separate WebWidgets to be created by RenderWidgets, which are associated with *all*
1599 // local frame roots, not just the first one in the tree. Until then, this l imits us 1600 // local frame roots, not just the first one in the tree. Until then, this l imits us
1600 // to having only one functioning connected LocalFrame subtree per process. 1601 // to having only one functioning connected LocalFrame subtree per process.
1601 for (WebCore::Frame* frame = page()->mainFrame(); frame; frame = frame->tree ().traverseNext()) { 1602 for (WebCore::Frame* frame = page()->mainFrame(); frame; frame = frame->tree ().traverseNext()) {
1602 if (frame->isLocalRoot()) 1603 if (frame->isLocalRoot())
1603 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame)); 1604 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
1604 } 1605 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 1643
1643 WebSize oldSize = m_size; 1644 WebSize oldSize = m_size;
1644 float oldPageScaleFactor = pageScaleFactor(); 1645 float oldPageScaleFactor = pageScaleFactor();
1645 int oldContentsWidth = contentsSize().width(); 1646 int oldContentsWidth = contentsSize().width();
1646 1647
1647 m_size = newSize; 1648 m_size = newSize;
1648 1649
1649 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges() 1650 bool shouldAnchorAndRescaleViewport = settings()->mainFrameResizesAreOrienta tionChanges()
1650 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen(); 1651 && oldSize.width && oldContentsWidth && newSize.width != oldSize.width & & !m_fullscreenController->isFullscreen();
1651 1652
1652 ViewportAnchor viewportAnchor(&mainFrameImpl()->frame()->eventHandler()); 1653 ViewportAnchor viewportAnchor(&localFrameRootTemporary()->frame()->eventHand ler());
1653 if (shouldAnchorAndRescaleViewport) { 1654 if (shouldAnchorAndRescaleViewport) {
1654 viewportAnchor.setAnchor(view->visibleContentRect(), 1655 viewportAnchor.setAnchor(view->visibleContentRect(),
1655 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); 1656 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord));
1656 } 1657 }
1657 1658
1658 // FIXME: FastTextAutosizer does not yet support out-of-process frames. 1659 // FIXME: FastTextAutosizer does not yet support out-of-process frames.
1659 if (mainFrameImpl()->frame()->isLocalFrame()) 1660 if (mainFrameImpl() && mainFrameImpl()->frame()->isLocalFrame())
1660 { 1661 {
1661 // Avoids unnecessary invalidations while various bits of state in FastT extAutosizer are updated. 1662 // Avoids unnecessary invalidations while various bits of state in FastT extAutosizer are updated.
1662 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); 1663 FastTextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page());
1663 performResize(); 1664 performResize();
1664 } else { 1665 } else {
1665 performResize(); 1666 performResize();
1666 } 1667 }
1667 1668
1668 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { 1669 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) {
1669 // Relayout immediately to recalculate the minimum scale limit. 1670 // Relayout immediately to recalculate the minimum scale limit.
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2152 return false; 2153 return false;
2153 *location = plainTextRange.start(); 2154 *location = plainTextRange.start();
2154 *length = plainTextRange.length(); 2155 *length = plainTextRange.length();
2155 return true; 2156 return true;
2156 } 2157 }
2157 2158
2158 WebTextInputInfo WebViewImpl::textInputInfo() 2159 WebTextInputInfo WebViewImpl::textInputInfo()
2159 { 2160 {
2160 WebTextInputInfo info; 2161 WebTextInputInfo info;
2161 2162
2162 LocalFrame* focused = toLocalFrame(focusedWebCoreFrame()); 2163 Frame* focusedFrame = focusedWebCoreFrame();
2164 if (!focusedFrame->isLocalFrame())
2165 return info;
2166
2167 LocalFrame* focused = toLocalFrame(focusedFrame);
2163 if (!focused) 2168 if (!focused)
2164 return info; 2169 return info;
2165 2170
2166 FrameSelection& selection = focused->selection(); 2171 FrameSelection& selection = focused->selection();
2167 Node* node = selection.selection().rootEditableElement(); 2172 Node* node = selection.selection().rootEditableElement();
2168 if (!node) 2173 if (!node)
2169 return info; 2174 return info;
2170 2175
2171 info.inputMode = inputModeOfFocusedElement(); 2176 info.inputMode = inputModeOfFocusedElement();
2172 2177
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 if (isHTMLTextAreaElement(*element)) { 2285 if (isHTMLTextAreaElement(*element)) {
2281 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element); 2286 const HTMLTextAreaElement& textarea = toHTMLTextAreaElement(*element);
2282 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower(); 2287 return textarea.fastGetAttribute(HTMLNames::inputmodeAttr).lower();
2283 } 2288 }
2284 2289
2285 return WebString(); 2290 return WebString();
2286 } 2291 }
2287 2292
2288 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const 2293 bool WebViewImpl::selectionBounds(WebRect& anchor, WebRect& focus) const
2289 { 2294 {
2290 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); 2295 const Frame* frame = focusedWebCoreFrame();
2291 if (!frame) 2296 if (!frame || !frame->isLocalFrame())
2292 return false; 2297 return false;
2293 FrameSelection& selection = frame->selection(); 2298
2299 const LocalFrame* localFrame = toLocalFrame(frame);
2300 if (!localFrame)
2301 return false;
2302 FrameSelection& selection = localFrame->selection();
2294 2303
2295 if (selection.isCaret()) { 2304 if (selection.isCaret()) {
2296 anchor = focus = selection.absoluteCaretBounds(); 2305 anchor = focus = selection.absoluteCaretBounds();
2297 } else { 2306 } else {
2298 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange(); 2307 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange();
2299 if (!selectedRange) 2308 if (!selectedRange)
2300 return false; 2309 return false;
2301 2310
2302 RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContai ner()->document(), 2311 RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContai ner()->document(),
2303 selectedRange->startContainer(), 2312 selectedRange->startContainer(),
2304 selectedRange->startOffset(), 2313 selectedRange->startOffset(),
2305 selectedRange->startContainer(), 2314 selectedRange->startContainer(),
2306 selectedRange->startOffset())); 2315 selectedRange->startOffset()));
2307 anchor = frame->editor().firstRectForRange(range.get()); 2316 anchor = localFrame->editor().firstRectForRange(range.get());
2308 2317
2309 range = Range::create(selectedRange->endContainer()->document(), 2318 range = Range::create(selectedRange->endContainer()->document(),
2310 selectedRange->endContainer(), 2319 selectedRange->endContainer(),
2311 selectedRange->endOffset(), 2320 selectedRange->endOffset(),
2312 selectedRange->endContainer(), 2321 selectedRange->endContainer(),
2313 selectedRange->endOffset()); 2322 selectedRange->endOffset());
2314 focus = frame->editor().firstRectForRange(range.get()); 2323 focus = localFrame->editor().firstRectForRange(range.get());
2315 } 2324 }
2316 2325
2317 IntRect scaledAnchor(frame->view()->contentsToWindow(anchor)); 2326 IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor));
2318 IntRect scaledFocus(frame->view()->contentsToWindow(focus)); 2327 IntRect scaledFocus(localFrame->view()->contentsToWindow(focus));
2319 2328
2320 if (pinchVirtualViewportEnabled()) { 2329 if (pinchVirtualViewportEnabled()) {
2321 // FIXME(http://crbug.com/371902) - We shouldn't have to do this 2330 // FIXME(http://crbug.com/371902) - We shouldn't have to do this
2322 // manually, the contentsToWindow methods above should be fixed to do 2331 // manually, the contentsToWindow methods above should be fixed to do
2323 // this. 2332 // this.
2324 IntPoint pinchViewportOffset = 2333 IntPoint pinchViewportOffset =
2325 roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().lo cation()); 2334 roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().lo cation());
2326 scaledAnchor.moveBy(-pinchViewportOffset); 2335 scaledAnchor.moveBy(-pinchViewportOffset);
2327 scaledFocus.moveBy(-pinchViewportOffset); 2336 scaledFocus.moveBy(-pinchViewportOffset);
2328 } 2337 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 relativeToFrame = mainFrame(); 2579 relativeToFrame = mainFrame();
2571 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame(); 2580 Frame* frame = toWebLocalFrameImpl(relativeToFrame)->frame();
2572 frame = frame->tree().find(name); 2581 frame = frame->tree().find(name);
2573 if (!frame || !frame->isLocalFrame()) 2582 if (!frame || !frame->isLocalFrame())
2574 return 0; 2583 return 0;
2575 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame)); 2584 return WebLocalFrameImpl::fromFrame(toLocalFrame(frame));
2576 } 2585 }
2577 2586
2578 WebFrame* WebViewImpl::focusedFrame() 2587 WebFrame* WebViewImpl::focusedFrame()
2579 { 2588 {
2580 return WebLocalFrameImpl::fromFrame(toLocalFrame(focusedWebCoreFrame())); 2589 return WebFrame::fromFrame(focusedWebCoreFrame());
2581 } 2590 }
2582 2591
2583 void WebViewImpl::setFocusedFrame(WebFrame* frame) 2592 void WebViewImpl::setFocusedFrame(WebFrame* frame)
2584 { 2593 {
2585 if (!frame) { 2594 if (!frame) {
2586 // Clears the focused frame if any. 2595 // Clears the focused frame if any.
2587 Frame* focusedFrame = focusedWebCoreFrame(); 2596 Frame* focusedFrame = focusedWebCoreFrame();
2588 if (focusedFrame && focusedFrame->isLocalFrame()) 2597 if (focusedFrame && focusedFrame->isLocalFrame())
2589 toLocalFrame(focusedFrame)->selection().setFocused(false); 2598 toLocalFrame(focusedFrame)->selection().setFocused(false);
2590 return; 2599 return;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 m_dragOperation = static_cast<WebDragOperation>(dropEffect); 3416 m_dragOperation = static_cast<WebDragOperation>(dropEffect);
3408 3417
3409 return m_dragOperation; 3418 return m_dragOperation;
3410 } 3419 }
3411 3420
3412 void WebViewImpl::sendResizeEventAndRepaint() 3421 void WebViewImpl::sendResizeEventAndRepaint()
3413 { 3422 {
3414 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent 3423 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent
3415 // as part of layout. Layout is also responsible for sending invalidations 3424 // as part of layout. Layout is also responsible for sending invalidations
3416 // to the embedder. This method and all callers may be wrong. -- eseidel. 3425 // to the embedder. This method and all callers may be wrong. -- eseidel.
3417 if (mainFrameImpl()->frameView()) { 3426 if (localFrameRootTemporary()->frameView()) {
3418 // Enqueues the resize event. 3427 // Enqueues the resize event.
3419 mainFrameImpl()->frame()->document()->enqueueResizeEvent(); 3428 localFrameRootTemporary()->frame()->document()->enqueueResizeEvent();
3420 } 3429 }
3421 3430
3422 if (m_client) { 3431 if (m_client) {
3423 if (isAcceleratedCompositingActive()) { 3432 if (isAcceleratedCompositingActive()) {
3424 updateLayerTreeViewport(); 3433 updateLayerTreeViewport();
3425 } else { 3434 } else {
3426 WebRect damagedRect(0, 0, m_size.width, m_size.height); 3435 WebRect damagedRect(0, 0, m_size.width, m_size.height);
3427 m_client->didInvalidateRect(damagedRect); 3436 m_client->didInvalidateRect(damagedRect);
3428 } 3437 }
3429 } 3438 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3712 { 3721 {
3713 if (m_layerTreeViewCommitsDeferred) { 3722 if (m_layerTreeViewCommitsDeferred) {
3714 if (m_layerTreeView) 3723 if (m_layerTreeView)
3715 m_layerTreeView->setDeferCommits(false); 3724 m_layerTreeView->setDeferCommits(false);
3716 m_layerTreeViewCommitsDeferred = false; 3725 m_layerTreeViewCommitsDeferred = false;
3717 } 3726 }
3718 } 3727 }
3719 3728
3720 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) 3729 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe)
3721 { 3730 {
3722 if (!m_client || webframe != mainFrameImpl()) 3731 if (!m_client || !webframe->frame()->isLocalRoot())
3723 return; 3732 return;
3724 3733
3725 // If we finished a layout while in deferred commit mode, 3734 // If we finished a layout while in deferred commit mode,
3726 // that means it's time to start producing frames again so un-defer. 3735 // that means it's time to start producing frames again so un-defer.
3727 resumeTreeViewCommits(); 3736 resumeTreeViewCommits();
3728 3737
3729 if (m_shouldAutoResize && mainFrameImpl()->frame() && mainFrameImpl()->frame ()->view()) { 3738 if (m_shouldAutoResize && webframe->frame() && webframe->frame()->view()) {
3730 WebSize frameSize = mainFrameImpl()->frame()->view()->frameRect().size() ; 3739 WebSize frameSize = webframe->frame()->view()->frameRect().size();
3731 if (frameSize != m_size) { 3740 if (frameSize != m_size) {
3732 m_size = frameSize; 3741 m_size = frameSize;
3733 3742
3734 page()->frameHost().pinchViewport().setSize(m_size); 3743 page()->frameHost().pinchViewport().setSize(m_size);
3735 m_pageScaleConstraintsSet.didChangeViewSize(m_size); 3744 m_pageScaleConstraintsSet.didChangeViewSize(m_size);
3736 3745
3737 m_client->didAutoResize(m_size); 3746 m_client->didAutoResize(m_size);
3738 sendResizeEventAndRepaint(); 3747 sendResizeEventAndRepaint();
3739 } 3748 }
3740 } 3749 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3937 m_client->didInvalidateRect(rect); 3946 m_client->didInvalidateRect(rect);
3938 } 3947 }
3939 3948
3940 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const 3949 WebCore::GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const
3941 { 3950 {
3942 return m_graphicsLayerFactory.get(); 3951 return m_graphicsLayerFactory.get();
3943 } 3952 }
3944 3953
3945 WebCore::RenderLayerCompositor* WebViewImpl::compositor() const 3954 WebCore::RenderLayerCompositor* WebViewImpl::compositor() const
3946 { 3955 {
3947 if (!page() 3956 if (!page() || !page()->mainFrame())
3948 || !page()->mainFrame()
3949 || !page()->mainFrame()->isLocalFrame()
3950 || !page()->deprecatedLocalMainFrame()->document()
3951 || !page()->deprecatedLocalMainFrame()->document()->renderView())
3952 return 0; 3957 return 0;
3958
3959 if (!page()->mainFrame()->isLocalFrame())
3960 return localFrameRootTemporary()->frame()->document()->renderView()->com positor();
3961
3962 if (!page()->deprecatedLocalMainFrame()->document() || !page()->deprecatedLo calMainFrame()->document()->renderView())
3963 return 0;
3964
3953 return page()->deprecatedLocalMainFrame()->document()->renderView()->composi tor(); 3965 return page()->deprecatedLocalMainFrame()->document()->renderView()->composi tor();
3954 } 3966 }
3955 3967
3956 void WebViewImpl::registerForAnimations(WebLayer* layer) 3968 void WebViewImpl::registerForAnimations(WebLayer* layer)
3957 { 3969 {
3958 if (m_layerTreeView) 3970 if (m_layerTreeView)
3959 m_layerTreeView->registerForAnimations(layer); 3971 m_layerTreeView->registerForAnimations(layer);
3960 } 3972 }
3961 3973
3962 WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer() 3974 WebCore::GraphicsLayer* WebViewImpl::rootGraphicsLayer()
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
4239 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); 4251 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints();
4240 4252
4241 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) 4253 if (!mainFrameImpl() || !mainFrameImpl()->frameView())
4242 return false; 4254 return false;
4243 4255
4244 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width 4256 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width
4245 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); 4257 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1);
4246 } 4258 }
4247 4259
4248 } // namespace blink 4260 } // namespace blink
OLDNEW
« Source/web/WebRemoteFrameImpl.cpp ('K') | « Source/web/WebViewImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698