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

Unified Diff: Source/web/WebViewImpl.cpp

Issue 23187005: [DevTools] Use device metrics emulation implemented in content. (Closed) Base URL: svn://svn.chromium.org/blink/trunk/
Patch Set: Created 7 years, 3 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
Index: Source/web/WebViewImpl.cpp
===================================================================
--- Source/web/WebViewImpl.cpp (revision 157211)
+++ Source/web/WebViewImpl.cpp (working copy)
@@ -396,6 +396,7 @@
, m_contextMenuAllowed(false)
, m_doingDragAndDrop(false)
, m_ignoreInputEvents(false)
+ , m_emulatingDeviceScales(false)
pfeldman 2013/09/19 12:46:05 Initialize floats too.
dgozman 2013/09/19 13:59:38 Done.
, m_suppressNextKeypressEvent(false)
, m_imeAcceptEvents(true)
, m_operationsAllowed(WebDragOperationNone)
@@ -2864,8 +2865,7 @@
page()->setDeviceScaleFactor(scaleFactor);
- if (m_layerTreeView)
- m_layerTreeView->setDeviceScaleFactor(scaleFactor);
+ updateLayerTreeDeviceScaleFactor();
}
bool WebViewImpl::isFixedLayoutModeEnabled() const
@@ -3703,6 +3703,15 @@
m_ignoreInputEvents = newValue;
}
+void WebViewImpl::setDeviceEmulationScales(bool enabled, float deviceScaleFactor, float rootLayerScale)
+{
+ m_emulatingDeviceScales = enabled;
+ m_emulatedDeviceScaleFactor = deviceScaleFactor;
+ m_rootLayerScale = rootLayerScale;
+ updateLayerTreeDeviceScaleFactor();
+ updateRootLayerTransform();
+}
+
void WebViewImpl::addPageOverlay(WebPageOverlay* overlay, int zOrder)
{
if (!m_pageOverlays)
@@ -3817,6 +3826,8 @@
setIsAcceleratedCompositingActive(layer);
+ updateRootLayerTransform();
pfeldman 2013/09/19 12:46:05 Will this work?: if (m_emulatingDeviceScales)
dgozman 2013/09/19 13:59:38 What if root layer has transform left from previou
+
if (m_layerTreeView) {
if (m_rootLayer)
m_layerTreeView->setRootLayer(*m_rootLayer);
@@ -3924,7 +3935,7 @@
bool visible = page()->visibilityState() == PageVisibilityStateVisible;
m_layerTreeView->setVisible(visible);
- m_layerTreeView->setDeviceScaleFactor(page()->deviceScaleFactor());
+ updateLayerTreeDeviceScaleFactor();
m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor());
m_layerTreeView->setBackgroundColor(backgroundColor());
m_layerTreeView->setHasTransparentBackground(isTransparent());
@@ -4009,6 +4020,27 @@
m_layerTreeView->setPageScaleFactorAndLimits(pageScaleFactor(), minimumPageScaleFactor(), maximumPageScaleFactor());
}
+void WebViewImpl::updateLayerTreeDeviceScaleFactor()
+{
+ if (!page() || !m_layerTreeView)
pfeldman 2013/09/19 12:46:05 Assert these exist instead.
dgozman 2013/09/19 13:59:38 Done.
+ return;
+
+ float deviceScaleFactor = page()->deviceScaleFactor();
+ if (m_emulatingDeviceScales)
apavlov 2013/09/19 12:47:57 float deviceScaleFactor = m_emulatingDeviceScales
dgozman 2013/09/19 13:59:38 Done.
+ deviceScaleFactor = m_emulatedDeviceScaleFactor;
+ m_layerTreeView->setDeviceScaleFactor(deviceScaleFactor);
+}
+
+void WebViewImpl::updateRootLayerTransform()
+{
+ if (m_rootGraphicsLayer) {
+ WebCore::TransformationMatrix transform;
+ if (m_emulatingDeviceScales)
+ transform = transform.scale(m_rootLayerScale);
+ m_rootGraphicsLayer->setTransform(transform);
+ }
+}
+
void WebViewImpl::selectAutofillSuggestionAtIndex(unsigned listIndex)
{
if (m_autofillPopupClient && listIndex < m_autofillPopupClient->getSuggestionsCount())

Powered by Google App Engine
This is Rietveld 408576698