| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 , m_spellCheckerClientImpl(this) | 143 , m_spellCheckerClientImpl(this) |
| 144 , m_fixedLayoutSizeLock(false) | 144 , m_fixedLayoutSizeLock(false) |
| 145 , m_doingDragAndDrop(false) | 145 , m_doingDragAndDrop(false) |
| 146 , m_ignoreInputEvents(false) | 146 , m_ignoreInputEvents(false) |
| 147 , m_compositorDeviceScaleFactorOverride(0) | 147 , m_compositorDeviceScaleFactorOverride(0) |
| 148 , m_rootLayerScale(1) | 148 , m_rootLayerScale(1) |
| 149 , m_suppressNextKeypressEvent(false) | 149 , m_suppressNextKeypressEvent(false) |
| 150 , m_imeAcceptEvents(true) | 150 , m_imeAcceptEvents(true) |
| 151 , m_isTransparent(false) | 151 , m_isTransparent(false) |
| 152 , m_tabsToLinks(false) | 152 , m_tabsToLinks(false) |
| 153 , m_layerTreeView(0) | |
| 154 , m_rootLayer(0) | 153 , m_rootLayer(0) |
| 155 , m_rootGraphicsLayer(0) | 154 , m_rootGraphicsLayer(0) |
| 156 , m_rootTransformLayer(0) | 155 , m_rootTransformLayer(0) |
| 157 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium(this))) | 156 , m_graphicsLayerFactory(adoptPtr(new GraphicsLayerFactoryChromium())) |
| 158 , m_isAcceleratedCompositingActive(false) | |
| 159 , m_layerTreeViewCommitsDeferred(false) | |
| 160 , m_layerTreeViewClosed(false) | |
| 161 , m_matchesHeuristicsForGpuRasterization(false) | 157 , m_matchesHeuristicsForGpuRasterization(false) |
| 162 , m_recreatingGraphicsContext(false) | 158 , m_recreatingGraphicsContext(false) |
| 163 , m_flingModifier(0) | 159 , m_flingModifier(0) |
| 164 , m_flingSourceDevice(false) | 160 , m_flingSourceDevice(false) |
| 165 , m_showFPSCounter(false) | 161 , m_showFPSCounter(false) |
| 166 , m_showPaintRects(false) | 162 , m_showPaintRects(false) |
| 167 , m_showDebugBorders(false) | 163 , m_showDebugBorders(false) |
| 168 , m_continuousPaintingEnabled(false) | 164 , m_continuousPaintingEnabled(false) |
| 169 , m_showScrollBottleneckRects(false) | 165 , m_showScrollBottleneckRects(false) |
| 170 , m_baseBackgroundColor(Color::white) | 166 , m_baseBackgroundColor(Color::white) |
| 171 , m_backgroundColorOverride(Color::transparent) | 167 , m_backgroundColorOverride(Color::transparent) |
| 172 , m_userGestureObserved(false) | 168 , m_userGestureObserved(false) |
| 173 { | 169 { |
| 174 Page::PageClients pageClients; | 170 Page::PageClients pageClients; |
| 175 pageClients.chromeClient = &m_chromeClientImpl; | 171 pageClients.chromeClient = &m_chromeClientImpl; |
| 176 pageClients.editorClient = &m_editorClientImpl; | 172 pageClients.editorClient = &m_editorClientImpl; |
| 177 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; | 173 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; |
| 178 | 174 |
| 179 m_page = adoptPtr(new Page(pageClients, m_client->services())); | 175 m_page = adoptPtr(new Page(pageClients, m_client->services())); |
| 180 | 176 |
| 181 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor); | 177 setDeviceScaleFactor(m_client->screenInfo().deviceScaleFactor); |
| 182 setVisibilityState(m_client->visibilityState(), true); | 178 setVisibilityState(m_client->visibilityState(), true); |
| 183 | 179 |
| 184 m_client->initializeLayerTreeView(); | 180 m_client->initializeLayerTreeView(); |
| 185 // FIXME(sky): Get rid of this member variable. It's unused. | |
| 186 m_layerTreeView = nullptr; | |
| 187 } | 181 } |
| 188 | 182 |
| 189 WebViewImpl::~WebViewImpl() | 183 WebViewImpl::~WebViewImpl() |
| 190 { | 184 { |
| 191 ASSERT(!m_page); | 185 ASSERT(!m_page); |
| 192 } | 186 } |
| 193 | 187 |
| 194 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() | 188 WebLocalFrameImpl* WebViewImpl::mainFrameImpl() |
| 195 { | 189 { |
| 196 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0; | 190 return m_page ? WebLocalFrameImpl::fromFrame(m_page->mainFrame()) : 0; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni
mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters
.cumulativeScroll)); | 408 OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAni
mationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters
.cumulativeScroll)); |
| 415 ASSERT(curve); | 409 ASSERT(curve); |
| 416 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r
elease(), this, parameters.startTime); | 410 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.r
elease(), this, parameters.startTime); |
| 417 scheduleAnimation(); | 411 scheduleAnimation(); |
| 418 } | 412 } |
| 419 | 413 |
| 420 bool WebViewImpl::endActiveFlingAnimation() | 414 bool WebViewImpl::endActiveFlingAnimation() |
| 421 { | 415 { |
| 422 if (m_gestureAnimation) { | 416 if (m_gestureAnimation) { |
| 423 m_gestureAnimation.clear(); | 417 m_gestureAnimation.clear(); |
| 424 if (m_layerTreeView) | |
| 425 m_layerTreeView->didStopFlinging(); | |
| 426 return true; | 418 return true; |
| 427 } | 419 } |
| 428 return false; | 420 return false; |
| 429 } | 421 } |
| 430 | 422 |
| 431 void WebViewImpl::setShowFPSCounter(bool show) | 423 void WebViewImpl::setShowFPSCounter(bool show) |
| 432 { | 424 { |
| 433 if (m_layerTreeView) { | |
| 434 TRACE_EVENT0("blink", "WebViewImpl::setShowFPSCounter"); | |
| 435 m_layerTreeView->setShowFPSCounter(show); | |
| 436 } | |
| 437 m_showFPSCounter = show; | 425 m_showFPSCounter = show; |
| 438 } | 426 } |
| 439 | 427 |
| 440 void WebViewImpl::setShowPaintRects(bool show) | 428 void WebViewImpl::setShowPaintRects(bool show) |
| 441 { | 429 { |
| 442 if (m_layerTreeView) { | |
| 443 TRACE_EVENT0("blink", "WebViewImpl::setShowPaintRects"); | |
| 444 m_layerTreeView->setShowPaintRects(show); | |
| 445 } | |
| 446 m_showPaintRects = show; | 430 m_showPaintRects = show; |
| 447 } | 431 } |
| 448 | 432 |
| 449 void WebViewImpl::setShowDebugBorders(bool show) | 433 void WebViewImpl::setShowDebugBorders(bool show) |
| 450 { | 434 { |
| 451 if (m_layerTreeView) | |
| 452 m_layerTreeView->setShowDebugBorders(show); | |
| 453 m_showDebugBorders = show; | 435 m_showDebugBorders = show; |
| 454 } | 436 } |
| 455 | 437 |
| 456 void WebViewImpl::setContinuousPaintingEnabled(bool enabled) | 438 void WebViewImpl::setContinuousPaintingEnabled(bool enabled) |
| 457 { | 439 { |
| 458 if (m_layerTreeView) { | |
| 459 TRACE_EVENT0("blink", "WebViewImpl::setContinuousPaintingEnabled"); | |
| 460 m_layerTreeView->setContinuousPaintingEnabled(enabled); | |
| 461 } | |
| 462 m_continuousPaintingEnabled = enabled; | 440 m_continuousPaintingEnabled = enabled; |
| 463 m_client->scheduleAnimation(); | 441 m_client->scheduleAnimation(); |
| 464 } | 442 } |
| 465 | 443 |
| 466 void WebViewImpl::setShowScrollBottleneckRects(bool show) | 444 void WebViewImpl::setShowScrollBottleneckRects(bool show) |
| 467 { | 445 { |
| 468 if (m_layerTreeView) | |
| 469 m_layerTreeView->setShowScrollBottleneckRects(show); | |
| 470 m_showScrollBottleneckRects = show; | 446 m_showScrollBottleneckRects = show; |
| 471 } | 447 } |
| 472 | 448 |
| 473 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const | 449 void WebViewImpl::getSelectionRootBounds(WebRect& bounds) const |
| 474 { | 450 { |
| 475 const LocalFrame* frame = focusedCoreFrame(); | 451 const LocalFrame* frame = focusedCoreFrame(); |
| 476 if (!frame) | 452 if (!frame) |
| 477 return; | 453 return; |
| 478 | 454 |
| 479 Element* root = frame->selection().rootEditableElementOrDocumentElement(); | 455 Element* root = frame->selection().rootEditableElementOrDocumentElement(); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 { | 917 { |
| 942 } | 918 } |
| 943 | 919 |
| 944 void WebViewImpl::layout() | 920 void WebViewImpl::layout() |
| 945 { | 921 { |
| 946 TRACE_EVENT0("blink", "WebViewImpl::layout"); | 922 TRACE_EVENT0("blink", "WebViewImpl::layout"); |
| 947 if (!localFrameRootTemporary()) | 923 if (!localFrameRootTemporary()) |
| 948 return; | 924 return; |
| 949 | 925 |
| 950 PageWidgetDelegate::layout(m_page.get(), localFrameRootTemporary()->frame())
; | 926 PageWidgetDelegate::layout(m_page.get(), localFrameRootTemporary()->frame())
; |
| 951 updateLayerTreeBackgroundColor(); | |
| 952 | 927 |
| 953 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 928 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 954 m_linkHighlights[i]->updateGeometry(); | 929 m_linkHighlights[i]->updateGeometry(); |
| 955 } | 930 } |
| 956 | 931 |
| 957 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) | 932 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| 958 { | 933 { |
| 959 // This should only be used when compositing is not being used for this | |
| 960 // WebView, and it is painting into the recording of its parent. | |
| 961 ASSERT(!isAcceleratedCompositingActive()); | |
| 962 | |
| 963 double paintStart = currentTime(); | 934 double paintStart = currentTime(); |
| 964 PageWidgetDelegate::paint(m_page.get(), canvas, rect, isTransparent() ? Page
WidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | 935 PageWidgetDelegate::paint(m_page.get(), canvas, rect, isTransparent() ? Page
WidgetDelegate::Translucent : PageWidgetDelegate::Opaque); |
| 965 double paintEnd = currentTime(); | 936 double paintEnd = currentTime(); |
| 966 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart); | 937 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart); |
| 967 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationM
S", (paintEnd - paintStart) * 1000, 0, 120, 30); | 938 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationM
S", (paintEnd - paintStart) * 1000, 0, 120, 30); |
| 968 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMegapixPe
rSecond", pixelsPerSec / 1000000, 10, 210, 30); | 939 Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMegapixPe
rSecond", pixelsPerSec / 1000000, 10, 210, 30); |
| 969 } | 940 } |
| 970 | 941 |
| 971 #if OS(ANDROID) | |
| 972 void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re
ct) | |
| 973 { | |
| 974 // Note: This method exists on OS(ANDROID) and will hopefully be | |
| 975 // removed once the link disambiguation feature renders using | |
| 976 // the compositor. | |
| 977 ASSERT(isAcceleratedCompositingActive()); | |
| 978 | |
| 979 FrameView* view = page()->mainFrame()->view(); | |
| 980 PaintBehavior oldPaintBehavior = view->paintBehavior(); | |
| 981 view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLay
ers); | |
| 982 | |
| 983 PageWidgetDelegate::paint(m_page.get(), canvas, rect, isTransparent() ? Page
WidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | |
| 984 | |
| 985 view->setPaintBehavior(oldPaintBehavior); | |
| 986 } | |
| 987 #endif | |
| 988 | |
| 989 void WebViewImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback
* callback) | |
| 990 { | |
| 991 ASSERT(isAcceleratedCompositingActive()); | |
| 992 m_layerTreeView->compositeAndReadbackAsync(callback); | |
| 993 } | |
| 994 | |
| 995 bool WebViewImpl::isTrackingRepaints() const | 942 bool WebViewImpl::isTrackingRepaints() const |
| 996 { | 943 { |
| 997 if (!page()) | 944 if (!page()) |
| 998 return false; | 945 return false; |
| 999 FrameView* view = page()->mainFrame()->view(); | 946 FrameView* view = page()->mainFrame()->view(); |
| 1000 return view->isTrackingPaintInvalidations(); | 947 return view->isTrackingPaintInvalidations(); |
| 1001 } | 948 } |
| 1002 | 949 |
| 1003 void WebViewImpl::themeChanged() | 950 void WebViewImpl::themeChanged() |
| 1004 { | 951 { |
| 1005 if (!page()) | 952 if (!page()) |
| 1006 return; | 953 return; |
| 1007 FrameView* view = page()->mainFrame()->view(); | 954 FrameView* view = page()->mainFrame()->view(); |
| 1008 | 955 |
| 1009 WebRect damagedRect(0, 0, m_size.width, m_size.height); | 956 WebRect damagedRect(0, 0, m_size.width, m_size.height); |
| 1010 view->invalidateRect(damagedRect); | 957 view->invalidateRect(damagedRect); |
| 1011 } | 958 } |
| 1012 | 959 |
| 1013 void WebViewImpl::clearCompositedSelectionBounds() | |
| 1014 { | |
| 1015 if (m_layerTreeView) | |
| 1016 m_layerTreeView->clearSelection(); | |
| 1017 } | |
| 1018 | |
| 1019 bool WebViewImpl::hasHorizontalScrollbar() | 960 bool WebViewImpl::hasHorizontalScrollbar() |
| 1020 { | 961 { |
| 1021 // FIXME(sky): Remove | 962 // FIXME(sky): Remove |
| 1022 return false; | 963 return false; |
| 1023 } | 964 } |
| 1024 | 965 |
| 1025 bool WebViewImpl::hasVerticalScrollbar() | 966 bool WebViewImpl::hasVerticalScrollbar() |
| 1026 { | 967 { |
| 1027 // FIXME(sky): Remove | 968 // FIXME(sky): Remove |
| 1028 return false; | 969 return false; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 case WebTextDirectionRightToLeft: | 1479 case WebTextDirectionRightToLeft: |
| 1539 editor.setBaseWritingDirection(RightToLeftWritingDirection); | 1480 editor.setBaseWritingDirection(RightToLeftWritingDirection); |
| 1540 break; | 1481 break; |
| 1541 | 1482 |
| 1542 default: | 1483 default: |
| 1543 notImplemented(); | 1484 notImplemented(); |
| 1544 break; | 1485 break; |
| 1545 } | 1486 } |
| 1546 } | 1487 } |
| 1547 | 1488 |
| 1548 bool WebViewImpl::isAcceleratedCompositingActive() const | |
| 1549 { | |
| 1550 return m_isAcceleratedCompositingActive; | |
| 1551 } | |
| 1552 | |
| 1553 void WebViewImpl::willCloseLayerTreeView() | |
| 1554 { | |
| 1555 setIsAcceleratedCompositingActive(false); | |
| 1556 m_layerTreeView = 0; | |
| 1557 m_layerTreeViewClosed = true; | |
| 1558 } | |
| 1559 | |
| 1560 // WebView -------------------------------------------------------------------- | 1489 // WebView -------------------------------------------------------------------- |
| 1561 | 1490 |
| 1562 WebSettingsImpl* WebViewImpl::settingsImpl() | 1491 WebSettingsImpl* WebViewImpl::settingsImpl() |
| 1563 { | 1492 { |
| 1564 if (!m_webSettings) | 1493 if (!m_webSettings) |
| 1565 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings())); | 1494 m_webSettings = adoptPtr(new WebSettingsImpl(&m_page->settings())); |
| 1566 ASSERT(m_webSettings); | 1495 ASSERT(m_webSettings); |
| 1567 return m_webSettings.get(); | 1496 return m_webSettings.get(); |
| 1568 } | 1497 } |
| 1569 | 1498 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 | 1628 |
| 1700 return page()->deviceScaleFactor(); | 1629 return page()->deviceScaleFactor(); |
| 1701 } | 1630 } |
| 1702 | 1631 |
| 1703 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 1632 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
| 1704 { | 1633 { |
| 1705 if (!page()) | 1634 if (!page()) |
| 1706 return; | 1635 return; |
| 1707 | 1636 |
| 1708 page()->setDeviceScaleFactor(scaleFactor); | 1637 page()->setDeviceScaleFactor(scaleFactor); |
| 1709 | |
| 1710 if (m_layerTreeView) | |
| 1711 updateLayerTreeDeviceScaleFactor(); | |
| 1712 } | 1638 } |
| 1713 | 1639 |
| 1714 void WebViewImpl::updateMainFrameLayoutSize() | 1640 void WebViewImpl::updateMainFrameLayoutSize() |
| 1715 { | 1641 { |
| 1716 if (m_fixedLayoutSizeLock || !mainFrameImpl()) | 1642 if (m_fixedLayoutSizeLock || !mainFrameImpl()) |
| 1717 return; | 1643 return; |
| 1718 | 1644 |
| 1719 RefPtr<FrameView> view = mainFrameImpl()->frameView(); | 1645 RefPtr<FrameView> view = mainFrameImpl()->frameView(); |
| 1720 if (!view) | 1646 if (!view) |
| 1721 return; | 1647 return; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 void WebViewImpl::sendResizeEventAndRepaint() | 1778 void WebViewImpl::sendResizeEventAndRepaint() |
| 1853 { | 1779 { |
| 1854 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent | 1780 // FIXME: This is wrong. The FrameView is responsible sending a resizeEvent |
| 1855 // as part of layout. Layout is also responsible for sending invalidations | 1781 // as part of layout. Layout is also responsible for sending invalidations |
| 1856 // to the embedder. This method and all callers may be wrong. -- eseidel. | 1782 // to the embedder. This method and all callers may be wrong. -- eseidel. |
| 1857 if (localFrameRootTemporary()->frameView()) { | 1783 if (localFrameRootTemporary()->frameView()) { |
| 1858 // Enqueues the resize event. | 1784 // Enqueues the resize event. |
| 1859 localFrameRootTemporary()->frame()->document()->enqueueResizeEvent(); | 1785 localFrameRootTemporary()->frame()->document()->enqueueResizeEvent(); |
| 1860 } | 1786 } |
| 1861 | 1787 |
| 1862 if (!isAcceleratedCompositingActive()) { | 1788 WebRect damagedRect(0, 0, m_size.width, m_size.height); |
| 1863 WebRect damagedRect(0, 0, m_size.width, m_size.height); | 1789 m_client->didInvalidateRect(damagedRect); |
| 1864 m_client->didInvalidateRect(damagedRect); | |
| 1865 } | |
| 1866 } | 1790 } |
| 1867 | 1791 |
| 1868 void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor
) | 1792 void WebViewImpl::setCompositorDeviceScaleFactorOverride(float deviceScaleFactor
) |
| 1869 { | 1793 { |
| 1870 if (m_compositorDeviceScaleFactorOverride == deviceScaleFactor) | |
| 1871 return; | |
| 1872 m_compositorDeviceScaleFactorOverride = deviceScaleFactor; | 1794 m_compositorDeviceScaleFactorOverride = deviceScaleFactor; |
| 1873 if (page() && m_layerTreeView) | |
| 1874 updateLayerTreeDeviceScaleFactor(); | |
| 1875 } | 1795 } |
| 1876 | 1796 |
| 1877 void WebViewImpl::setRootLayerTransform(const WebSize& rootLayerOffset, float ro
otLayerScale) | 1797 void WebViewImpl::setRootLayerTransform(const WebSize& rootLayerOffset, float ro
otLayerScale) |
| 1878 { | 1798 { |
| 1879 if (m_rootLayerScale == rootLayerScale && m_rootLayerOffset == rootLayerOffs
et) | 1799 if (m_rootLayerScale == rootLayerScale && m_rootLayerOffset == rootLayerOffs
et) |
| 1880 return; | 1800 return; |
| 1881 m_rootLayerScale = rootLayerScale; | 1801 m_rootLayerScale = rootLayerScale; |
| 1882 m_rootLayerOffset = rootLayerOffset; | 1802 m_rootLayerOffset = rootLayerOffset; |
| 1883 if (mainFrameImpl()) | 1803 if (mainFrameImpl()) |
| 1884 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset,
m_rootLayerScale); | 1804 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset,
m_rootLayerScale); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1896 | 1816 |
| 1897 // Future frames check this to know whether to be transparent. | 1817 // Future frames check this to know whether to be transparent. |
| 1898 m_isTransparent = isTransparent; | 1818 m_isTransparent = isTransparent; |
| 1899 } | 1819 } |
| 1900 | 1820 |
| 1901 bool WebViewImpl::isTransparent() const | 1821 bool WebViewImpl::isTransparent() const |
| 1902 { | 1822 { |
| 1903 return m_isTransparent; | 1823 return m_isTransparent; |
| 1904 } | 1824 } |
| 1905 | 1825 |
| 1826 // FIXME(sky): This is an android webview feature. Remove it. |
| 1906 void WebViewImpl::setBaseBackgroundColor(WebColor color) | 1827 void WebViewImpl::setBaseBackgroundColor(WebColor color) |
| 1907 { | 1828 { |
| 1908 layout(); | 1829 layout(); |
| 1909 | 1830 |
| 1910 if (m_baseBackgroundColor == color) | 1831 if (m_baseBackgroundColor == color) |
| 1911 return; | 1832 return; |
| 1912 | 1833 |
| 1913 m_baseBackgroundColor = color; | 1834 m_baseBackgroundColor = color; |
| 1914 | 1835 |
| 1915 if (m_page->mainFrame()) | 1836 if (m_page->mainFrame()) |
| 1916 m_page->mainFrame()->view()->setBaseBackgroundColor(color); | 1837 m_page->mainFrame()->view()->setBaseBackgroundColor(color); |
| 1917 | |
| 1918 updateLayerTreeBackgroundColor(); | |
| 1919 } | 1838 } |
| 1920 | 1839 |
| 1921 void WebViewImpl::setIsActive(bool active) | 1840 void WebViewImpl::setIsActive(bool active) |
| 1922 { | 1841 { |
| 1923 if (page()) | 1842 if (page()) |
| 1924 page()->focusController().setActive(active); | 1843 page()->focusController().setActive(active); |
| 1925 } | 1844 } |
| 1926 | 1845 |
| 1927 bool WebViewImpl::isActive() const | 1846 bool WebViewImpl::isActive() const |
| 1928 { | 1847 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1948 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag
e) | 1867 void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag
e) |
| 1949 { | 1868 { |
| 1950 // Make sure link highlight from previous page is cleared. | 1869 // Make sure link highlight from previous page is cleared. |
| 1951 m_linkHighlights.clear(); | 1870 m_linkHighlights.clear(); |
| 1952 endActiveFlingAnimation(); | 1871 endActiveFlingAnimation(); |
| 1953 m_userGestureObserved = false; | 1872 m_userGestureObserved = false; |
| 1954 if (!isNavigationWithinPage) | 1873 if (!isNavigationWithinPage) |
| 1955 UserGestureIndicator::clearProcessedUserGestureSinceLoad(); | 1874 UserGestureIndicator::clearProcessedUserGestureSinceLoad(); |
| 1956 } | 1875 } |
| 1957 | 1876 |
| 1958 void WebViewImpl::didRemoveAllPendingStylesheet(WebLocalFrameImpl* webframe) | |
| 1959 { | |
| 1960 if (webframe != mainFrameImpl()) | |
| 1961 return; | |
| 1962 | |
| 1963 // If we have no more stylesheets to load and we're past the body tag, | |
| 1964 // we should have something to paint and should start as soon as possible. | |
| 1965 // FIXME(sky): This logic is probably wrong now. | |
| 1966 resumeTreeViewCommits(); | |
| 1967 } | |
| 1968 | |
| 1969 void WebViewImpl::resumeTreeViewCommits() | |
| 1970 { | |
| 1971 if (m_layerTreeViewCommitsDeferred) { | |
| 1972 if (m_layerTreeView) | |
| 1973 m_layerTreeView->setDeferCommits(false); | |
| 1974 m_layerTreeViewCommitsDeferred = false; | |
| 1975 } | |
| 1976 } | |
| 1977 | |
| 1978 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) | 1877 void WebViewImpl::layoutUpdated(WebLocalFrameImpl* webframe) |
| 1979 { | 1878 { |
| 1980 if (!m_client) | 1879 if (!m_client) |
| 1981 return; | 1880 return; |
| 1982 | |
| 1983 // If we finished a layout while in deferred commit mode, | |
| 1984 // that means it's time to start producing frames again so un-defer. | |
| 1985 resumeTreeViewCommits(); | |
| 1986 | |
| 1987 m_client->didUpdateLayout(); | 1881 m_client->didUpdateLayout(); |
| 1988 } | 1882 } |
| 1989 | 1883 |
| 1990 void WebViewImpl::setIgnoreInputEvents(bool newValue) | 1884 void WebViewImpl::setIgnoreInputEvents(bool newValue) |
| 1991 { | 1885 { |
| 1992 ASSERT(m_ignoreInputEvents != newValue); | 1886 ASSERT(m_ignoreInputEvents != newValue); |
| 1993 m_ignoreInputEvents = newValue; | 1887 m_ignoreInputEvents = newValue; |
| 1994 } | 1888 } |
| 1995 | 1889 |
| 1996 void WebViewImpl::setBackgroundColorOverride(WebColor color) | 1890 void WebViewImpl::setBackgroundColorOverride(WebColor color) |
| 1997 { | 1891 { |
| 1998 m_backgroundColorOverride = color; | 1892 m_backgroundColorOverride = color; |
| 1999 updateLayerTreeBackgroundColor(); | |
| 2000 } | 1893 } |
| 2001 | 1894 |
| 2002 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) | 1895 void WebViewImpl::setOverlayLayer(GraphicsLayer* layer) |
| 2003 { | 1896 { |
| 2004 if (!m_rootGraphicsLayer) | 1897 if (!m_rootGraphicsLayer) |
| 2005 return; | 1898 return; |
| 2006 | 1899 |
| 2007 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. | 1900 // FIXME(bokan): This path goes away after virtual viewport pinch is enabled
everywhere. |
| 2008 if (!m_rootTransformLayer) | 1901 if (!m_rootTransformLayer) |
| 2009 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); | 1902 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos
itor()->ensureRootTransformLayer(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 } | 1943 } |
| 2051 | 1944 |
| 2052 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) | 1945 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) |
| 2053 { | 1946 { |
| 2054 suppressInvalidations(true); | 1947 suppressInvalidations(true); |
| 2055 | 1948 |
| 2056 m_rootGraphicsLayer = layer; | 1949 m_rootGraphicsLayer = layer; |
| 2057 m_rootLayer = layer ? layer->platformLayer() : 0; | 1950 m_rootLayer = layer ? layer->platformLayer() : 0; |
| 2058 m_rootTransformLayer = 0; | 1951 m_rootTransformLayer = 0; |
| 2059 | 1952 |
| 2060 setIsAcceleratedCompositingActive(layer != 0); | |
| 2061 | |
| 2062 updateRootLayerTransform(); | 1953 updateRootLayerTransform(); |
| 2063 | |
| 2064 if (m_layerTreeView) { | |
| 2065 if (m_rootLayer) { | |
| 2066 m_layerTreeView->setRootLayer(*m_rootLayer); | |
| 2067 // We register viewport layers here since there may not be a layer | |
| 2068 // tree view prior to this point. | |
| 2069 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); | |
| 2070 ASSERT(rootScrollLayer); | |
| 2071 WebLayer* pageScaleLayer = rootScrollLayer->parent() ? rootScrollLay
er->parent()->platformLayer() : 0; | |
| 2072 m_layerTreeView->registerViewportLayers(pageScaleLayer, rootScrollLa
yer->platformLayer(), 0); | |
| 2073 } else { | |
| 2074 m_layerTreeView->clearRootLayer(); | |
| 2075 m_layerTreeView->clearViewportLayers(); | |
| 2076 } | |
| 2077 } | |
| 2078 | |
| 2079 suppressInvalidations(false); | 1954 suppressInvalidations(false); |
| 2080 } | 1955 } |
| 2081 | 1956 |
| 2082 void WebViewImpl::scheduleCompositingLayerSync() | |
| 2083 { | |
| 2084 m_layerTreeView->setNeedsAnimate(); | |
| 2085 } | |
| 2086 | |
| 2087 void WebViewImpl::invalidateRect(const IntRect& rect) | 1957 void WebViewImpl::invalidateRect(const IntRect& rect) |
| 2088 { | 1958 { |
| 2089 if (!m_isAcceleratedCompositingActive) { | 1959 m_client->didInvalidateRect(rect); |
| 2090 m_client->didInvalidateRect(rect); | |
| 2091 } | |
| 2092 } | 1960 } |
| 2093 | 1961 |
| 2094 GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const | 1962 GraphicsLayerFactory* WebViewImpl::graphicsLayerFactory() const |
| 2095 { | 1963 { |
| 2096 return m_graphicsLayerFactory.get(); | 1964 return m_graphicsLayerFactory.get(); |
| 2097 } | 1965 } |
| 2098 | 1966 |
| 2099 RenderLayerCompositor* WebViewImpl::compositor() const | 1967 RenderLayerCompositor* WebViewImpl::compositor() const |
| 2100 { | 1968 { |
| 2101 if (!page() || !page()->mainFrame()) | 1969 if (!page() || !page()->mainFrame()) |
| 2102 return 0; | 1970 return 0; |
| 2103 | 1971 |
| 2104 if (!page()->mainFrame()->document() || !page()->mainFrame()->document()->re
nderView()) | 1972 if (!page()->mainFrame()->document() || !page()->mainFrame()->document()->re
nderView()) |
| 2105 return 0; | 1973 return 0; |
| 2106 | 1974 |
| 2107 return page()->mainFrame()->document()->renderView()->compositor(); | 1975 return page()->mainFrame()->document()->renderView()->compositor(); |
| 2108 } | 1976 } |
| 2109 | 1977 |
| 2110 void WebViewImpl::registerForAnimations(WebLayer* layer) | |
| 2111 { | |
| 2112 if (m_layerTreeView) | |
| 2113 m_layerTreeView->registerForAnimations(layer); | |
| 2114 } | |
| 2115 | |
| 2116 GraphicsLayer* WebViewImpl::rootGraphicsLayer() | 1978 GraphicsLayer* WebViewImpl::rootGraphicsLayer() |
| 2117 { | 1979 { |
| 2118 return m_rootGraphicsLayer; | 1980 return m_rootGraphicsLayer; |
| 2119 } | 1981 } |
| 2120 | 1982 |
| 2121 void WebViewImpl::scheduleAnimation() | 1983 void WebViewImpl::scheduleAnimation() |
| 2122 { | 1984 { |
| 2123 if (isAcceleratedCompositingActive()) { | |
| 2124 ASSERT(m_layerTreeView); | |
| 2125 m_layerTreeView->setNeedsAnimate(); | |
| 2126 return; | |
| 2127 } | |
| 2128 m_client->scheduleAnimation(); | 1985 m_client->scheduleAnimation(); |
| 2129 } | 1986 } |
| 2130 | 1987 |
| 2131 void WebViewImpl::setIsAcceleratedCompositingActive(bool active) | |
| 2132 { | |
| 2133 // In the middle of shutting down; don't try to spin back up a compositor. | |
| 2134 // FIXME: compositing startup/shutdown should be refactored so that it | |
| 2135 // turns on explicitly rather than lazily, which causes this awkwardness. | |
| 2136 if (m_layerTreeViewClosed) | |
| 2137 return; | |
| 2138 | |
| 2139 ASSERT(!active || m_layerTreeView); | |
| 2140 Platform::current()->histogramEnumeration("GPU.setIsAcceleratedCompositingAc
tive", active * 2 + m_isAcceleratedCompositingActive, 4); | |
| 2141 | |
| 2142 if (m_isAcceleratedCompositingActive == active) | |
| 2143 return; | |
| 2144 | |
| 2145 if (!m_client) | |
| 2146 return; | |
| 2147 | |
| 2148 if (!active) { | |
| 2149 m_isAcceleratedCompositingActive = false; | |
| 2150 if (!m_layerTreeViewCommitsDeferred) { | |
| 2151 ASSERT(m_layerTreeView); | |
| 2152 // This means that we're transitioning to a new page. Suppress commi
ts until WebKit generates invalidations so | |
| 2153 // we don't attempt to paint too early in the next page load. | |
| 2154 m_layerTreeView->setDeferCommits(true); | |
| 2155 m_layerTreeViewCommitsDeferred = true; | |
| 2156 } | |
| 2157 } else { | |
| 2158 TRACE_EVENT0("blink", "WebViewImpl::setIsAcceleratedCompositingActive(tr
ue)"); | |
| 2159 m_layerTreeView->setRootLayer(*m_rootLayer); | |
| 2160 | |
| 2161 bool visible = page()->visibilityState() == PageVisibilityStateVisible; | |
| 2162 m_layerTreeView->setVisible(visible); | |
| 2163 updateLayerTreeDeviceScaleFactor(); | |
| 2164 updateLayerTreeBackgroundColor(); | |
| 2165 m_layerTreeView->setHasTransparentBackground(isTransparent()); | |
| 2166 m_isAcceleratedCompositingActive = true; | |
| 2167 m_layerTreeView->setShowFPSCounter(m_showFPSCounter); | |
| 2168 m_layerTreeView->setShowPaintRects(m_showPaintRects); | |
| 2169 m_layerTreeView->setShowDebugBorders(m_showDebugBorders); | |
| 2170 m_layerTreeView->setContinuousPaintingEnabled(m_continuousPaintingEnable
d); | |
| 2171 m_layerTreeView->setShowScrollBottleneckRects(m_showScrollBottleneckRect
s); | |
| 2172 m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuristic
sForGpuRasterization); | |
| 2173 } | |
| 2174 } | |
| 2175 | |
| 2176 void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition,
bool programmaticScroll) | 1988 void WebViewImpl::updateMainFrameScrollPosition(const IntPoint& scrollPosition,
bool programmaticScroll) |
| 2177 { | 1989 { |
| 2178 // FIXME(sky): Remove | 1990 // FIXME(sky): Remove |
| 2179 } | 1991 } |
| 2180 | 1992 |
| 2181 void WebViewImpl::updateLayerTreeBackgroundColor() | |
| 2182 { | |
| 2183 if (!m_layerTreeView) | |
| 2184 return; | |
| 2185 | |
| 2186 m_layerTreeView->setBackgroundColor(alphaChannel(m_backgroundColorOverride)
? m_backgroundColorOverride : backgroundColor()); | |
| 2187 } | |
| 2188 | |
| 2189 void WebViewImpl::updateLayerTreeDeviceScaleFactor() | |
| 2190 { | |
| 2191 ASSERT(page()); | |
| 2192 ASSERT(m_layerTreeView); | |
| 2193 | |
| 2194 float deviceScaleFactor = m_compositorDeviceScaleFactorOverride ? m_composit
orDeviceScaleFactorOverride : page()->deviceScaleFactor(); | |
| 2195 m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); | |
| 2196 } | |
| 2197 | |
| 2198 void WebViewImpl::updateRootLayerTransform() | 1993 void WebViewImpl::updateRootLayerTransform() |
| 2199 { | 1994 { |
| 2200 // If we don't have a root graphics layer, we won't bother trying to find | 1995 // If we don't have a root graphics layer, we won't bother trying to find |
| 2201 // or update the transform layer. | 1996 // or update the transform layer. |
| 2202 if (!m_rootGraphicsLayer) | 1997 if (!m_rootGraphicsLayer) |
| 2203 return; | 1998 return; |
| 2204 | 1999 |
| 2205 // FIXME(bokan): m_rootTransformLayer is always set here in pinch virtual vi
ewport. This can go away once | 2000 // FIXME(bokan): m_rootTransformLayer is always set here in pinch virtual vi
ewport. This can go away once |
| 2206 // that's default everywhere. | 2001 // that's default everywhere. |
| 2207 if (!m_rootTransformLayer) | 2002 if (!m_rootTransformLayer) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 return true; | 2035 return true; |
| 2241 } | 2036 } |
| 2242 | 2037 |
| 2243 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, | 2038 void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, |
| 2244 bool isInitialState) { | 2039 bool isInitialState) { |
| 2245 if (!page()) | 2040 if (!page()) |
| 2246 return; | 2041 return; |
| 2247 | 2042 |
| 2248 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState =
= WebPageVisibilityStateHidden); | 2043 ASSERT(visibilityState == WebPageVisibilityStateVisible || visibilityState =
= WebPageVisibilityStateHidden); |
| 2249 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>
(visibilityState)), isInitialState); | 2044 m_page->setVisibilityState(static_cast<PageVisibilityState>(static_cast<int>
(visibilityState)), isInitialState); |
| 2250 | |
| 2251 if (m_layerTreeView) { | |
| 2252 bool visible = visibilityState == WebPageVisibilityStateVisible; | |
| 2253 m_layerTreeView->setVisible(visible); | |
| 2254 } | |
| 2255 } | 2045 } |
| 2256 | 2046 |
| 2257 bool WebViewImpl::shouldDisableDesktopWorkarounds() | 2047 bool WebViewImpl::shouldDisableDesktopWorkarounds() |
| 2258 { | 2048 { |
| 2259 return true; | 2049 return true; |
| 2260 } | 2050 } |
| 2261 | 2051 |
| 2262 } // namespace blink | 2052 } // namespace blink |
| OLD | NEW |