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

Side by Side Diff: third_party/WebKit/Source/web/DevToolsEmulator.cpp

Issue 2570733002: [Devtools] Fixed devtools altering srcset image after close (Closed)
Patch Set: added test Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "web/DevToolsEmulator.h" 5 #include "web/DevToolsEmulator.h"
6 6
7 #include "core/fetch/MemoryCache.h"
7 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
8 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
10 #include "core/frame/VisualViewport.h" 11 #include "core/frame/VisualViewport.h"
11 #include "core/page/Page.h" 12 #include "core/page/Page.h"
12 #include "core/style/ComputedStyle.h" 13 #include "core/style/ComputedStyle.h"
13 #include "platform/RuntimeEnabledFeatures.h" 14 #include "platform/RuntimeEnabledFeatures.h"
14 #include "platform/geometry/FloatRect.h" 15 #include "platform/geometry/FloatRect.h"
15 #include "platform/geometry/FloatSize.h" 16 #include "platform/geometry/FloatSize.h"
16 #include "platform/geometry/IntRect.h" 17 #include "platform/geometry/IntRect.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 void DevToolsEmulator::enableDeviceEmulation( 195 void DevToolsEmulator::enableDeviceEmulation(
195 const WebDeviceEmulationParams& params) { 196 const WebDeviceEmulationParams& params) {
196 if (m_deviceMetricsEnabled && m_emulationParams.viewSize == params.viewSize && 197 if (m_deviceMetricsEnabled && m_emulationParams.viewSize == params.viewSize &&
197 m_emulationParams.screenPosition == params.screenPosition && 198 m_emulationParams.screenPosition == params.screenPosition &&
198 m_emulationParams.deviceScaleFactor == params.deviceScaleFactor && 199 m_emulationParams.deviceScaleFactor == params.deviceScaleFactor &&
199 m_emulationParams.offset == params.offset && 200 m_emulationParams.offset == params.offset &&
200 m_emulationParams.scale == params.scale) { 201 m_emulationParams.scale == params.scale) {
201 return; 202 return;
202 } 203 }
203 204 memoryCache()->evictResources();
dgozman 2016/12/13 20:56:11 Let's only do this when necessary, e.g. deviceScal
allada 2016/12/14 19:50:47 Done. I moved it into blink instead.
204 m_emulationParams = params; 205 m_emulationParams = params;
205 206
206 if (!m_deviceMetricsEnabled) { 207 if (!m_deviceMetricsEnabled) {
207 m_deviceMetricsEnabled = true; 208 m_deviceMetricsEnabled = true;
208 if (params.viewSize.width || params.viewSize.height) 209 if (params.viewSize.width || params.viewSize.height)
209 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); 210 m_webViewImpl->setBackgroundColorOverride(Color::darkGray);
210 } 211 }
211 212
212 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( 213 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(
213 calculateDeviceScaleAdjustment(params.viewSize.width, 214 calculateDeviceScaleAdjustment(params.viewSize.width,
(...skipping 13 matching lines...) Expand all
227 if (m_webViewImpl->mainFrameImpl()) { 228 if (m_webViewImpl->mainFrameImpl()) {
228 if (Document* document = 229 if (Document* document =
229 m_webViewImpl->mainFrameImpl()->frame()->document()) 230 m_webViewImpl->mainFrameImpl()->frame()->document())
230 document->mediaQueryAffectingValueChanged(); 231 document->mediaQueryAffectingValueChanged();
231 } 232 }
232 } 233 }
233 234
234 void DevToolsEmulator::disableDeviceEmulation() { 235 void DevToolsEmulator::disableDeviceEmulation() {
235 if (!m_deviceMetricsEnabled) 236 if (!m_deviceMetricsEnabled)
236 return; 237 return;
237 238 memoryCache()->evictResources();
238 m_deviceMetricsEnabled = false; 239 m_deviceMetricsEnabled = false;
239 m_webViewImpl->setBackgroundColorOverride(Color::transparent); 240 m_webViewImpl->setBackgroundColorOverride(Color::transparent);
240 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( 241 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(
241 m_embedderDeviceScaleAdjustment); 242 m_embedderDeviceScaleAdjustment);
242 disableMobileEmulation(); 243 disableMobileEmulation();
243 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); 244 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f);
244 m_webViewImpl->setPageScaleFactor(1.f); 245 m_webViewImpl->setPageScaleFactor(1.f);
245 updateRootLayerTransform(); 246 updateRootLayerTransform();
246 // mainFrameImpl() could be null during cleanup or remote <-> local swap. 247 // mainFrameImpl() could be null during cleanup or remote <-> local swap.
247 if (m_webViewImpl->mainFrameImpl()) { 248 if (m_webViewImpl->mainFrameImpl()) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 m_lastPinchAnchorCss.reset(); 519 m_lastPinchAnchorCss.reset();
519 m_lastPinchAnchorDip.reset(); 520 m_lastPinchAnchorDip.reset();
520 } 521 }
521 return true; 522 return true;
522 } 523 }
523 524
524 return false; 525 return false;
525 } 526 }
526 527
527 } // namespace blink 528 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698