Chromium Code Reviews| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) | 392 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) |
| 393 , m_savedPageScaleFactor(0) | 393 , m_savedPageScaleFactor(0) |
| 394 , m_doubleTapZoomPageScaleFactor(0) | 394 , m_doubleTapZoomPageScaleFactor(0) |
| 395 , m_doubleTapZoomPending(false) | 395 , m_doubleTapZoomPending(false) |
| 396 , m_enableFakePageScaleAnimationForTesting(false) | 396 , m_enableFakePageScaleAnimationForTesting(false) |
| 397 , m_fakePageScaleAnimationPageScaleFactor(0) | 397 , m_fakePageScaleAnimationPageScaleFactor(0) |
| 398 , m_fakePageScaleAnimationUseAnchor(false) | 398 , m_fakePageScaleAnimationUseAnchor(false) |
| 399 , m_contextMenuAllowed(false) | 399 , m_contextMenuAllowed(false) |
| 400 , m_doingDragAndDrop(false) | 400 , m_doingDragAndDrop(false) |
| 401 , m_ignoreInputEvents(false) | 401 , m_ignoreInputEvents(false) |
| 402 , m_emulatedDeviceScaleFactor(0) | |
| 403 , m_rootLayerScale(0) | |
|
aelias_OOO_until_Jul13
2013/10/01 08:08:51
Let's make rootLayerScale default to 1 instead.
dgozman
2013/10/01 15:26:34
Done.
| |
| 402 , m_suppressNextKeypressEvent(false) | 404 , m_suppressNextKeypressEvent(false) |
| 403 , m_imeAcceptEvents(true) | 405 , m_imeAcceptEvents(true) |
| 404 , m_operationsAllowed(WebDragOperationNone) | 406 , m_operationsAllowed(WebDragOperationNone) |
| 405 , m_dragOperation(WebDragOperationNone) | 407 , m_dragOperation(WebDragOperationNone) |
| 406 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) | 408 , m_featureSwitchClient(adoptPtr(new ContextFeaturesClientImpl())) |
| 407 , m_autofillPopupShowing(false) | 409 , m_autofillPopupShowing(false) |
| 408 , m_autofillPopup(0) | 410 , m_autofillPopup(0) |
| 409 , m_isTransparent(false) | 411 , m_isTransparent(false) |
| 410 , m_tabsToLinks(false) | 412 , m_tabsToLinks(false) |
| 411 , m_layerTreeView(0) | 413 , m_layerTreeView(0) |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1705 viewportAnchor.setAnchor(view->visibleContentRect(), | 1707 viewportAnchor.setAnchor(view->visibleContentRect(), |
| 1706 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); | 1708 FloatSize(viewportAnchorXCoord, viewportAnchorY Coord)); |
| 1707 } | 1709 } |
| 1708 | 1710 |
| 1709 // Set the fixed layout size from the viewport constraints before resizing. | 1711 // Set the fixed layout size from the viewport constraints before resizing. |
| 1710 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); | 1712 updatePageDefinedPageScaleConstraints(mainFrameImpl()->frame()->document()-> viewportArguments()); |
| 1711 | 1713 |
| 1712 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); | 1714 WebDevToolsAgentPrivate* agentPrivate = devToolsAgentPrivate(); |
| 1713 if (agentPrivate) | 1715 if (agentPrivate) |
| 1714 agentPrivate->webViewResized(newSize); | 1716 agentPrivate->webViewResized(newSize); |
| 1715 if (!agentPrivate || !agentPrivate->metricsOverridden()) { | 1717 WebFrameImpl* webFrame = mainFrameImpl(); |
| 1716 WebFrameImpl* webFrame = mainFrameImpl(); | 1718 if (webFrame->frameView()) { |
| 1717 if (webFrame->frameView()) { | 1719 webFrame->frameView()->resize(m_size); |
| 1718 webFrame->frameView()->resize(m_size); | 1720 if (m_pinchViewports) |
| 1719 if (m_pinchViewports) | 1721 m_pinchViewports->setViewportSize(m_size); |
| 1720 m_pinchViewports->setViewportSize(m_size); | |
| 1721 } | |
| 1722 } | 1722 } |
| 1723 | 1723 |
| 1724 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { | 1724 if (settings()->viewportEnabled() && !m_fixedLayoutSizeLock) { |
| 1725 // Relayout immediately to recalculate the minimum scale limit. | 1725 // Relayout immediately to recalculate the minimum scale limit. |
| 1726 if (view->needsLayout()) | 1726 if (view->needsLayout()) |
| 1727 view->layout(); | 1727 view->layout(); |
| 1728 | 1728 |
| 1729 if (shouldAnchorAndRescaleViewport) { | 1729 if (shouldAnchorAndRescaleViewport) { |
| 1730 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; | 1730 float viewportWidthRatio = static_cast<float>(newSize.width) / oldSi ze.width; |
| 1731 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; | 1731 float contentsWidthRatio = static_cast<float>(contentsSize().width() ) / oldContentsWidth; |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2905 } | 2905 } |
| 2906 | 2906 |
| 2907 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) | 2907 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) |
| 2908 { | 2908 { |
| 2909 if (!page()) | 2909 if (!page()) |
| 2910 return; | 2910 return; |
| 2911 | 2911 |
| 2912 page()->setDeviceScaleFactor(scaleFactor); | 2912 page()->setDeviceScaleFactor(scaleFactor); |
| 2913 | 2913 |
| 2914 if (m_layerTreeView) | 2914 if (m_layerTreeView) |
| 2915 m_layerTreeView->setDeviceScaleFactor(scaleFactor); | 2915 updateLayerTreeDeviceScaleFactor(); |
| 2916 } | 2916 } |
| 2917 | 2917 |
| 2918 bool WebViewImpl::isFixedLayoutModeEnabled() const | 2918 bool WebViewImpl::isFixedLayoutModeEnabled() const |
| 2919 { | 2919 { |
| 2920 if (!page()) | 2920 if (!page()) |
| 2921 return false; | 2921 return false; |
| 2922 | 2922 |
| 2923 Frame* frame = page()->mainFrame(); | 2923 Frame* frame = page()->mainFrame(); |
| 2924 if (!frame || !frame->view()) | 2924 if (!frame || !frame->view()) |
| 2925 return false; | 2925 return false; |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3755 m_newNavigationLoader = m_page->mainFrame()->loader()->documentLoader(); | 3755 m_newNavigationLoader = m_page->mainFrame()->loader()->documentLoader(); |
| 3756 #endif | 3756 #endif |
| 3757 } | 3757 } |
| 3758 | 3758 |
| 3759 void WebViewImpl::setIgnoreInputEvents(bool newValue) | 3759 void WebViewImpl::setIgnoreInputEvents(bool newValue) |
| 3760 { | 3760 { |
| 3761 ASSERT(m_ignoreInputEvents != newValue); | 3761 ASSERT(m_ignoreInputEvents != newValue); |
| 3762 m_ignoreInputEvents = newValue; | 3762 m_ignoreInputEvents = newValue; |
| 3763 } | 3763 } |
| 3764 | 3764 |
| 3765 void WebViewImpl::setDeviceEmulationParameters(bool enabled, float deviceScaleFa ctor, float rootLayerScale) | |
|
aelias_OOO_until_Jul13
2013/10/01 08:08:51
The other args are ignored when enabled = false wh
| |
| 3766 { | |
| 3767 m_emulatedDeviceScaleFactor = enabled ? deviceScaleFactor : 0; | |
| 3768 m_rootLayerScale = enabled ? rootLayerScale : 0; | |
| 3769 if (mainFrameImpl()) | |
| 3770 mainFrameImpl()->setInputEventsScaleFactorForEmulation(enabled ? rootLay erScale : 1); | |
| 3771 if (page() && m_layerTreeView) | |
| 3772 updateLayerTreeDeviceScaleFactor(); | |
| 3773 updateRootLayerTransform(); | |
| 3774 } | |
| 3775 | |
| 3765 void WebViewImpl::addPageOverlay(WebPageOverlay* overlay, int zOrder) | 3776 void WebViewImpl::addPageOverlay(WebPageOverlay* overlay, int zOrder) |
| 3766 { | 3777 { |
| 3767 if (!m_pageOverlays) | 3778 if (!m_pageOverlays) |
| 3768 m_pageOverlays = PageOverlayList::create(this); | 3779 m_pageOverlays = PageOverlayList::create(this); |
| 3769 | 3780 |
| 3770 m_pageOverlays->add(overlay, zOrder); | 3781 m_pageOverlays->add(overlay, zOrder); |
| 3771 } | 3782 } |
| 3772 | 3783 |
| 3773 void WebViewImpl::removePageOverlay(WebPageOverlay* overlay) | 3784 void WebViewImpl::removePageOverlay(WebPageOverlay* overlay) |
| 3774 { | 3785 { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3865 m_rootGraphicsLayer = 0; | 3876 m_rootGraphicsLayer = 0; |
| 3866 m_rootLayer = 0; | 3877 m_rootLayer = 0; |
| 3867 } | 3878 } |
| 3868 } else { | 3879 } else { |
| 3869 m_rootGraphicsLayer = layer; | 3880 m_rootGraphicsLayer = layer; |
| 3870 m_rootLayer = layer ? layer->platformLayer() : 0; | 3881 m_rootLayer = layer ? layer->platformLayer() : 0; |
| 3871 } | 3882 } |
| 3872 | 3883 |
| 3873 setIsAcceleratedCompositingActive(layer); | 3884 setIsAcceleratedCompositingActive(layer); |
| 3874 | 3885 |
| 3886 updateRootLayerTransform(); | |
| 3887 | |
| 3875 if (m_layerTreeView) { | 3888 if (m_layerTreeView) { |
| 3876 if (m_rootLayer) { | 3889 if (m_rootLayer) { |
| 3877 m_layerTreeView->setRootLayer(*m_rootLayer); | 3890 m_layerTreeView->setRootLayer(*m_rootLayer); |
| 3878 // We register viewport layers here since there may not be a layer | 3891 // We register viewport layers here since there may not be a layer |
| 3879 // tree view prior to this point. | 3892 // tree view prior to this point. |
| 3880 if (m_pinchViewports) { | 3893 if (m_pinchViewports) { |
| 3881 m_pinchViewports->registerViewportLayersWithTreeView(m_layerTree View); | 3894 m_pinchViewports->registerViewportLayersWithTreeView(m_layerTree View); |
| 3882 } else { | 3895 } else { |
| 3883 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); | 3896 GraphicsLayer* rootScrollLayer = compositor()->scrollLayer(); |
| 3884 ASSERT(rootScrollLayer); | 3897 ASSERT(rootScrollLayer); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3987 } else { | 4000 } else { |
| 3988 TRACE_EVENT0("webkit", "WebViewImpl::setIsAcceleratedCompositingActive(t rue)"); | 4001 TRACE_EVENT0("webkit", "WebViewImpl::setIsAcceleratedCompositingActive(t rue)"); |
| 3989 | 4002 |
| 3990 m_client->initializeLayerTreeView(); | 4003 m_client->initializeLayerTreeView(); |
| 3991 m_layerTreeView = m_client->layerTreeView(); | 4004 m_layerTreeView = m_client->layerTreeView(); |
| 3992 if (m_layerTreeView) { | 4005 if (m_layerTreeView) { |
| 3993 m_layerTreeView->setRootLayer(*m_rootLayer); | 4006 m_layerTreeView->setRootLayer(*m_rootLayer); |
| 3994 | 4007 |
| 3995 bool visible = page()->visibilityState() == PageVisibilityStateVisib le; | 4008 bool visible = page()->visibilityState() == PageVisibilityStateVisib le; |
| 3996 m_layerTreeView->setVisible(visible); | 4009 m_layerTreeView->setVisible(visible); |
| 3997 m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor()); | 4010 updateLayerTreeDeviceScaleFactor(); |
| 3998 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), mini mumPageScaleFactor(), maximumPageScaleFactor()); | 4011 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), mini mumPageScaleFactor(), maximumPageScaleFactor()); |
| 3999 m_layerTreeView->setBackgroundColor(backgroundColor()); | 4012 m_layerTreeView->setBackgroundColor(backgroundColor()); |
| 4000 m_layerTreeView->setHasTransparentBackground(isTransparent()); | 4013 m_layerTreeView->setHasTransparentBackground(isTransparent()); |
| 4001 updateLayerTreeViewport(); | 4014 updateLayerTreeViewport(); |
| 4002 m_client->didActivateCompositor(0); | 4015 m_client->didActivateCompositor(0); |
| 4003 m_isAcceleratedCompositingActive = true; | 4016 m_isAcceleratedCompositingActive = true; |
| 4004 m_compositorCreationFailed = false; | 4017 m_compositorCreationFailed = false; |
| 4005 if (m_pageOverlays) | 4018 if (m_pageOverlays) |
| 4006 m_pageOverlays->update(); | 4019 m_pageOverlays->update(); |
| 4007 m_layerTreeView->setShowFPSCounter(m_showFPSCounter); | 4020 m_layerTreeView->setShowFPSCounter(m_showFPSCounter); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4072 } | 4085 } |
| 4073 | 4086 |
| 4074 void WebViewImpl::updateLayerTreeViewport() | 4087 void WebViewImpl::updateLayerTreeViewport() |
| 4075 { | 4088 { |
| 4076 if (!page() || !m_layerTreeView) | 4089 if (!page() || !m_layerTreeView) |
| 4077 return; | 4090 return; |
| 4078 | 4091 |
| 4079 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageS caleFactor(), maximumPageScaleFactor()); | 4092 m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageS caleFactor(), maximumPageScaleFactor()); |
| 4080 } | 4093 } |
| 4081 | 4094 |
| 4095 void WebViewImpl::updateLayerTreeDeviceScaleFactor() | |
| 4096 { | |
| 4097 ASSERT(page()); | |
| 4098 ASSERT(m_layerTreeView); | |
| 4099 | |
| 4100 float deviceScaleFactor = m_emulatedDeviceScaleFactor ? m_emulatedDeviceScal eFactor : page()->deviceScaleFactor(); | |
| 4101 m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor); | |
| 4102 } | |
| 4103 | |
| 4104 void WebViewImpl::updateRootLayerTransform() | |
| 4105 { | |
| 4106 if (m_rootGraphicsLayer) { | |
| 4107 WebCore::TransformationMatrix transform; | |
| 4108 if (m_rootLayerScale) | |
| 4109 transform = transform.scale(m_rootLayerScale); | |
| 4110 m_rootGraphicsLayer->setChildrenTransform(transform); | |
| 4111 } | |
| 4112 } | |
| 4113 | |
| 4082 void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex) | 4114 void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex) |
| 4083 { | 4115 { |
| 4084 if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestio nsCount()) | 4116 if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestio nsCount()) |
| 4085 m_autofillPopupClient->valueChanged(listIndex); | 4117 m_autofillPopupClient->valueChanged(listIndex); |
| 4086 } | 4118 } |
| 4087 | 4119 |
| 4088 bool WebViewImpl::detectContentOnTouch(const WebPoint& position) | 4120 bool WebViewImpl::detectContentOnTouch(const WebPoint& position) |
| 4089 { | 4121 { |
| 4090 HitTestResult touchHit = hitTestResultForWindowPos(position); | 4122 HitTestResult touchHit = hitTestResultForWindowPos(position); |
| 4091 | 4123 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4184 // the initial viewport width. | 4216 // the initial viewport width. |
| 4185 // 2. The author has disabled viewport zoom. | 4217 // 2. The author has disabled viewport zoom. |
| 4186 | 4218 |
| 4187 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4219 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4188 | 4220 |
| 4189 return fixedLayoutSize().width == m_size.width | 4221 return fixedLayoutSize().width == m_size.width |
| 4190 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4222 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4191 } | 4223 } |
| 4192 | 4224 |
| 4193 } // namespace WebKit | 4225 } // namespace WebKit |
| OLD | NEW |