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

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

Issue 2570733002: [Devtools] Fixed devtools altering srcset image after close (Closed)
Patch Set: changes 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/resources/square200.png ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 }
204 if (m_emulationParams.deviceScaleFactor != params.deviceScaleFactor ||
205 !m_deviceMetricsEnabled)
206 memoryCache()->evictResources();
203 207
204 m_emulationParams = params; 208 m_emulationParams = params;
205 209
206 if (!m_deviceMetricsEnabled) { 210 if (!m_deviceMetricsEnabled) {
207 m_deviceMetricsEnabled = true; 211 m_deviceMetricsEnabled = true;
208 if (params.viewSize.width || params.viewSize.height) 212 if (params.viewSize.width || params.viewSize.height)
209 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); 213 m_webViewImpl->setBackgroundColorOverride(Color::darkGray);
210 } 214 }
211 215
212 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( 216 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(
(...skipping 15 matching lines...) Expand all
228 if (Document* document = 232 if (Document* document =
229 m_webViewImpl->mainFrameImpl()->frame()->document()) 233 m_webViewImpl->mainFrameImpl()->frame()->document())
230 document->mediaQueryAffectingValueChanged(); 234 document->mediaQueryAffectingValueChanged();
231 } 235 }
232 } 236 }
233 237
234 void DevToolsEmulator::disableDeviceEmulation() { 238 void DevToolsEmulator::disableDeviceEmulation() {
235 if (!m_deviceMetricsEnabled) 239 if (!m_deviceMetricsEnabled)
236 return; 240 return;
237 241
242 memoryCache()->evictResources();
238 m_deviceMetricsEnabled = false; 243 m_deviceMetricsEnabled = false;
239 m_webViewImpl->setBackgroundColorOverride(Color::transparent); 244 m_webViewImpl->setBackgroundColorOverride(Color::transparent);
240 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( 245 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(
241 m_embedderDeviceScaleAdjustment); 246 m_embedderDeviceScaleAdjustment);
242 disableMobileEmulation(); 247 disableMobileEmulation();
243 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); 248 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f);
244 m_webViewImpl->setPageScaleFactor(1.f); 249 m_webViewImpl->setPageScaleFactor(1.f);
245 updateRootLayerTransform(); 250 updateRootLayerTransform();
246 // mainFrameImpl() could be null during cleanup or remote <-> local swap. 251 // mainFrameImpl() could be null during cleanup or remote <-> local swap.
247 if (m_webViewImpl->mainFrameImpl()) { 252 if (m_webViewImpl->mainFrameImpl()) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 m_lastPinchAnchorCss.reset(); 524 m_lastPinchAnchorCss.reset();
520 m_lastPinchAnchorDip.reset(); 525 m_lastPinchAnchorDip.reset();
521 } 526 }
522 return true; 527 return true;
523 } 528 }
524 529
525 return false; 530 return false;
526 } 531 }
527 532
528 } // namespace blink 533 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/resources/square200.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698