| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "core/editing/HTMLInterchange.h" | 42 #include "core/editing/HTMLInterchange.h" |
| 43 #include "core/editing/InputMethodController.h" | 43 #include "core/editing/InputMethodController.h" |
| 44 #include "core/editing/TextIterator.h" | 44 #include "core/editing/TextIterator.h" |
| 45 #include "core/editing/markup.h" | 45 #include "core/editing/markup.h" |
| 46 #include "core/events/KeyboardEvent.h" | 46 #include "core/events/KeyboardEvent.h" |
| 47 #include "core/events/WheelEvent.h" | 47 #include "core/events/WheelEvent.h" |
| 48 #include "core/frame/EventHandlerRegistry.h" | 48 #include "core/frame/EventHandlerRegistry.h" |
| 49 #include "core/frame/FrameHost.h" | 49 #include "core/frame/FrameHost.h" |
| 50 #include "core/frame/FrameView.h" | 50 #include "core/frame/FrameView.h" |
| 51 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/PinchViewport.h" | |
| 53 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 54 #include "core/html/HTMLMediaElement.h" | 53 #include "core/html/HTMLMediaElement.h" |
| 55 #include "core/html/ime/InputMethodContext.h" | 54 #include "core/html/ime/InputMethodContext.h" |
| 56 #include "core/loader/FrameLoader.h" | 55 #include "core/loader/FrameLoader.h" |
| 57 #include "core/loader/UniqueIdentifier.h" | 56 #include "core/loader/UniqueIdentifier.h" |
| 58 #include "core/page/Chrome.h" | 57 #include "core/page/Chrome.h" |
| 59 #include "core/page/EventHandler.h" | 58 #include "core/page/EventHandler.h" |
| 60 #include "core/page/EventWithHitTestResults.h" | 59 #include "core/page/EventWithHitTestResults.h" |
| 61 #include "core/page/FocusController.h" | 60 #include "core/page/FocusController.h" |
| 62 #include "core/page/Page.h" | 61 #include "core/page/Page.h" |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 void WebViewImpl::willStartLiveResize() | 935 void WebViewImpl::willStartLiveResize() |
| 937 { | 936 { |
| 938 // FIXME(sky): Remove | 937 // FIXME(sky): Remove |
| 939 } | 938 } |
| 940 | 939 |
| 941 WebSize WebViewImpl::size() | 940 WebSize WebViewImpl::size() |
| 942 { | 941 { |
| 943 return m_size; | 942 return m_size; |
| 944 } | 943 } |
| 945 | 944 |
| 946 void WebViewImpl::resizePinchViewport(const WebSize& newSize) | |
| 947 { | |
| 948 if (!pinchVirtualViewportEnabled()) | |
| 949 return; | |
| 950 | |
| 951 page()->frameHost().pinchViewport().setSize(newSize); | |
| 952 } | |
| 953 | |
| 954 WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() const | 945 WebLocalFrameImpl* WebViewImpl::localFrameRootTemporary() const |
| 955 { | 946 { |
| 956 // FIXME(sky): remove | 947 // FIXME(sky): remove |
| 957 return WebLocalFrameImpl::fromFrame(page()->mainFrame()); | 948 return WebLocalFrameImpl::fromFrame(page()->mainFrame()); |
| 958 } | 949 } |
| 959 | 950 |
| 960 void WebViewImpl::performResize() | 951 void WebViewImpl::performResize() |
| 961 { | 952 { |
| 962 updatePageDefinedViewportConstraints(localFrameRootTemporary()->frame()->doc
ument()->viewportDescription()); | 953 updatePageDefinedViewportConstraints(localFrameRootTemporary()->frame()->doc
ument()->viewportDescription()); |
| 963 updateMainFrameLayoutSize(); | 954 updateMainFrameLayoutSize(); |
| 964 | 955 |
| 965 // If the virtual viewport pinch mode is enabled, the main frame will be res
ized | 956 // If the virtual viewport pinch mode is enabled, the main frame will be res
ized |
| 966 // after layout so it can be sized to the contentsSize. | 957 // after layout so it can be sized to the contentsSize. |
| 967 if (!pinchVirtualViewportEnabled() && localFrameRootTemporary()->frameView()
) | 958 if (localFrameRootTemporary()->frameView()) |
| 968 localFrameRootTemporary()->frameView()->resize(m_size); | 959 localFrameRootTemporary()->frameView()->resize(m_size); |
| 969 | |
| 970 if (pinchVirtualViewportEnabled()) | |
| 971 page()->frameHost().pinchViewport().setSize(m_size); | |
| 972 } | 960 } |
| 973 | 961 |
| 974 void WebViewImpl::resize(const WebSize& newSize) | 962 void WebViewImpl::resize(const WebSize& newSize) |
| 975 { | 963 { |
| 976 if (m_size == newSize) | 964 if (m_size == newSize) |
| 977 return; | 965 return; |
| 978 | 966 |
| 979 FrameView* view = localFrameRootTemporary()->frameView(); | 967 FrameView* view = localFrameRootTemporary()->frameView(); |
| 980 if (!view) | 968 if (!view) |
| 981 return; | 969 return; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 selectedRange->endContainer(), | 1479 selectedRange->endContainer(), |
| 1492 selectedRange->endOffset(), | 1480 selectedRange->endOffset(), |
| 1493 selectedRange->endContainer(), | 1481 selectedRange->endContainer(), |
| 1494 selectedRange->endOffset()); | 1482 selectedRange->endOffset()); |
| 1495 focus = localFrame->editor().firstRectForRange(range.get()); | 1483 focus = localFrame->editor().firstRectForRange(range.get()); |
| 1496 } | 1484 } |
| 1497 | 1485 |
| 1498 IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor)); | 1486 IntRect scaledAnchor(localFrame->view()->contentsToWindow(anchor)); |
| 1499 IntRect scaledFocus(localFrame->view()->contentsToWindow(focus)); | 1487 IntRect scaledFocus(localFrame->view()->contentsToWindow(focus)); |
| 1500 | 1488 |
| 1501 if (pinchVirtualViewportEnabled()) { | |
| 1502 // FIXME(http://crbug.com/371902) - We shouldn't have to do this | |
| 1503 // manually, the contentsToWindow methods above should be fixed to do | |
| 1504 // this. | |
| 1505 IntPoint pinchViewportOffset = | |
| 1506 roundedIntPoint(page()->frameHost().pinchViewport().visibleRect().lo
cation()); | |
| 1507 scaledAnchor.moveBy(-pinchViewportOffset); | |
| 1508 scaledFocus.moveBy(-pinchViewportOffset); | |
| 1509 } | |
| 1510 | |
| 1511 anchor = scaledAnchor; | 1489 anchor = scaledAnchor; |
| 1512 focus = scaledFocus; | 1490 focus = scaledFocus; |
| 1513 | 1491 |
| 1514 if (!selection.selection().isBaseFirst()) | 1492 if (!selection.selection().isBaseFirst()) |
| 1515 std::swap(anchor, focus); | 1493 std::swap(anchor, focus); |
| 1516 return true; | 1494 return true; |
| 1517 } | 1495 } |
| 1518 | 1496 |
| 1519 InputMethodContext* WebViewImpl::inputMethodContext() | 1497 InputMethodContext* WebViewImpl::inputMethodContext() |
| 1520 { | 1498 { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 localFrame->selection().clear(); | 1722 localFrame->selection().clear(); |
| 1745 } | 1723 } |
| 1746 | 1724 |
| 1747 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) | 1725 void WebViewImpl::scrollFocusedNodeIntoRect(const WebRect& rect) |
| 1748 { | 1726 { |
| 1749 LocalFrame* frame = page()->mainFrame(); | 1727 LocalFrame* frame = page()->mainFrame(); |
| 1750 Element* element = focusedElement(); | 1728 Element* element = focusedElement(); |
| 1751 if (!frame || !frame->view() || !element) | 1729 if (!frame || !frame->view() || !element) |
| 1752 return; | 1730 return; |
| 1753 | 1731 |
| 1754 if (!m_webSettings->autoZoomFocusedNodeToLegibleScale()) { | |
| 1755 frame->view()->scrollElementToRect(element, IntRect(rect.x, rect.y, rect
.width, rect.height)); | |
| 1756 return; | |
| 1757 } | |
| 1758 | |
| 1759 float scale; | 1732 float scale; |
| 1760 IntPoint scroll; | 1733 IntPoint scroll; |
| 1761 bool needAnimation; | 1734 bool needAnimation; |
| 1762 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); | 1735 computeScaleAndScrollForFocusedNode(element, scale, scroll, needAnimation); |
| 1763 } | 1736 } |
| 1764 | 1737 |
| 1765 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) | 1738 void WebViewImpl::computeScaleAndScrollForFocusedNode(Node* focusedNode, float&
newScale, IntPoint& newScroll, bool& needAnimation) |
| 1766 { | 1739 { |
| 1767 //FIXME(sky) | 1740 //FIXME(sky) |
| 1768 } | 1741 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 | 1799 |
| 1827 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) | 1800 IntPoint WebViewImpl::clampOffsetAtScale(const IntPoint& offset, float scale) |
| 1828 { | 1801 { |
| 1829 FrameView* view = mainFrameImpl()->frameView(); | 1802 FrameView* view = mainFrameImpl()->frameView(); |
| 1830 if (!view) | 1803 if (!view) |
| 1831 return offset; | 1804 return offset; |
| 1832 | 1805 |
| 1833 return view->clampOffsetAtScale(offset, scale); | 1806 return view->clampOffsetAtScale(offset, scale); |
| 1834 } | 1807 } |
| 1835 | 1808 |
| 1836 bool WebViewImpl::pinchVirtualViewportEnabled() const | |
| 1837 { | |
| 1838 ASSERT(page()); | |
| 1839 return page()->settings().pinchVirtualViewportEnabled(); | |
| 1840 } | |
| 1841 | |
| 1842 void WebViewImpl::setPinchViewportOffset(const WebFloatPoint& offset) | |
| 1843 { | |
| 1844 ASSERT(page()); | |
| 1845 | |
| 1846 if (!pinchVirtualViewportEnabled()) | |
| 1847 return; | |
| 1848 | |
| 1849 page()->frameHost().pinchViewport().setLocation(offset); | |
| 1850 } | |
| 1851 | |
| 1852 WebFloatPoint WebViewImpl::pinchViewportOffset() const | |
| 1853 { | |
| 1854 ASSERT(page()); | |
| 1855 | |
| 1856 if (!pinchVirtualViewportEnabled()) | |
| 1857 return WebFloatPoint(); | |
| 1858 | |
| 1859 return page()->frameHost().pinchViewport().visibleRect().location(); | |
| 1860 } | |
| 1861 | |
| 1862 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) | 1809 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin) |
| 1863 { | 1810 { |
| 1864 updateMainFrameScrollPosition(origin, false); | 1811 updateMainFrameScrollPosition(origin, false); |
| 1865 } | 1812 } |
| 1866 | 1813 |
| 1867 float WebViewImpl::deviceScaleFactor() const | 1814 float WebViewImpl::deviceScaleFactor() const |
| 1868 { | 1815 { |
| 1869 if (!page()) | 1816 if (!page()) |
| 1870 return 1; | 1817 return 1; |
| 1871 | 1818 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 { | 2191 { |
| 2245 if (m_pageOverlays && m_pageOverlays->remove(overlay) && m_pageOverlays->emp
ty()) | 2192 if (m_pageOverlays && m_pageOverlays->remove(overlay) && m_pageOverlays->emp
ty()) |
| 2246 m_pageOverlays = nullptr; | 2193 m_pageOverlays = nullptr; |
| 2247 } | 2194 } |
| 2248 | 2195 |
| 2249 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) | 2196 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) |
| 2250 { | 2197 { |
| 2251 if (!m_rootGraphicsLayer) | 2198 if (!m_rootGraphicsLayer) |
| 2252 return; | 2199 return; |
| 2253 | 2200 |
| 2254 if (pinchVirtualViewportEnabled()) { | |
| 2255 m_page->mainFrame()->view()->renderView()->compositor()->setOverlayLayer
(layer); | |
| 2256 return; | |
| 2257 } | |
| 2258 | |
| 2259 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. | 2201 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. |
| 2260 if (!m_rootTransformLayer) | 2202 if (!m_rootTransformLayer) |
| 2261 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); | 2203 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); |
| 2262 | 2204 |
| 2263 if (m_rootTransformLayer) { | 2205 if (m_rootTransformLayer) { |
| 2264 if (layer->parent() != m_rootTransformLayer) | 2206 if (layer->parent() != m_rootTransformLayer) |
| 2265 m_rootTransformLayer->addChild(layer); | 2207 m_rootTransformLayer->addChild(layer); |
| 2266 } | 2208 } |
| 2267 } | 2209 } |
| 2268 | 2210 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2298 | 2240 |
| 2299 void WebViewImpl::suppressInvalidations(bool enable) | 2241 void WebViewImpl::suppressInvalidations(bool enable) |
| 2300 { | 2242 { |
| 2301 m_client->suppressCompositorScheduling(enable); | 2243 m_client->suppressCompositorScheduling(enable); |
| 2302 } | 2244 } |
| 2303 | 2245 |
| 2304 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) | 2246 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) |
| 2305 { | 2247 { |
| 2306 suppressInvalidations(true); | 2248 suppressInvalidations(true); |
| 2307 | 2249 |
| 2308 if (pinchVirtualViewportEnabled()) { | 2250 m_rootGraphicsLayer = layer; |
| 2309 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); | 2251 m_rootLayer = layer ? layer->platformLayer() : 0; |
| 2310 pinchViewport.attachToLayerTree(layer, graphicsLayerFactory()); | 2252 m_rootTransformLayer = 0; |
| 2311 if (layer) { | |
| 2312 m_rootGraphicsLayer = pinchViewport.rootGraphicsLayer(); | |
| 2313 m_rootLayer = pinchViewport.rootGraphicsLayer()->platformLayer(); | |
| 2314 m_rootTransformLayer = pinchViewport.rootGraphicsLayer(); | |
| 2315 } else { | |
| 2316 m_rootGraphicsLayer = 0; | |
| 2317 m_rootLayer = 0; | |
| 2318 m_rootTransformLayer = 0; | |
| 2319 } | |
| 2320 } else { | |
| 2321 m_rootGraphicsLayer = layer; | |
| 2322 m_rootLayer = layer ? layer->platformLayer() : 0; | |
| 2323 m_rootTransformLayer = 0; | |
| 2324 } | |
| 2325 | 2253 |
| 2326 setIsAcceleratedCompositingActive(layer != 0); | 2254 setIsAcceleratedCompositingActive(layer != 0); |
| 2327 | 2255 |
| 2328 updateRootLayerTransform(); | 2256 updateRootLayerTransform(); |
| 2329 | 2257 |
| 2330 if (m_layerTreeView) { | 2258 if (m_layerTreeView) { |
| 2331 if (m_rootLayer) { | 2259 if (m_rootLayer) { |
| 2332 m_layerTreeView->setRootLayer(*m_rootLayer); | 2260 m_layerTreeView->setRootLayer(*m_rootLayer); |
| 2333 // We register viewport layers here since there may not be a layer | 2261 // We register viewport layers here since there may not be a layer |
| 2334 // tree view prior to this point. | 2262 // tree view prior to this point. |
| 2335 if (pinchVirtualViewportEnabled()) { | 2263 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); |
| 2336 page()->frameHost().pinchViewport().registerLayersWithTreeView(m
_layerTreeView); | 2264 ASSERT(rootScrollLayer); |
| 2337 } else { | 2265 WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrollLay
er->parent()->platformLayer() : 0; |
| 2338 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); | 2266 m_layerTreeView->registerViewportLayers(pageScaleLayer, rootScrollLa
yer->platformLayer(), 0); |
| 2339 ASSERT(rootScrollLayer); | |
| 2340 WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrol
lLayer->parent()->platformLayer() : 0; | |
| 2341 m_layerTreeView->registerViewportLayers(pageScaleLayer, rootScro
llLayer->platformLayer(), 0); | |
| 2342 } | |
| 2343 } else { | 2267 } else { |
| 2344 m_layerTreeView->clearRootLayer(); | 2268 m_layerTreeView->clearRootLayer(); |
| 2345 if (pinchVirtualViewportEnabled()) | 2269 m_layerTreeView->clearViewportLayers(); |
| 2346 page()->frameHost().pinchViewport().clearLayersForTreeView(m_lay
erTreeView); | |
| 2347 else | |
| 2348 m_layerTreeView->clearViewportLayers(); | |
| 2349 } | 2270 } |
| 2350 } | 2271 } |
| 2351 | 2272 |
| 2352 suppressInvalidations(false); | 2273 suppressInvalidations(false); |
| 2353 } | 2274 } |
| 2354 | 2275 |
| 2355 void WebViewImpl::scheduleCompositingLayerSync() | 2276 void WebViewImpl::scheduleCompositingLayerSync() |
| 2356 { | 2277 { |
| 2357 m_layerTreeView->setNeedsAnimate(); | 2278 m_layerTreeView->setNeedsAnimate(); |
| 2358 } | 2279 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2541 m_layerTreeView->setVisible(visible); | 2462 m_layerTreeView->setVisible(visible); |
| 2542 } | 2463 } |
| 2543 } | 2464 } |
| 2544 | 2465 |
| 2545 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 2466 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 2546 { | 2467 { |
| 2547 return true; | 2468 return true; |
| 2548 } | 2469 } |
| 2549 | 2470 |
| 2550 } // namespace blink | 2471 } // namespace blink |
| OLD | NEW |