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

Side by Side Diff: third_party/WebKit/Source/core/inspector/DevToolsHost.cpp

Issue 1737733002: [DevTools] Handle emulated device scale factor and original device scale factor properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 m_client = 0; 157 m_client = 0;
158 if (m_menuProvider) { 158 if (m_menuProvider) {
159 m_menuProvider->disconnect(); 159 m_menuProvider->disconnect();
160 m_menuProvider = nullptr; 160 m_menuProvider = nullptr;
161 } 161 }
162 m_frontendFrame = nullptr; 162 m_frontendFrame = nullptr;
163 } 163 }
164 164
165 float DevToolsHost::zoomFactor() 165 float DevToolsHost::zoomFactor()
166 { 166 {
167 return m_frontendFrame ? m_frontendFrame->pageZoomFactor() : 1; 167 float zoomFactor = m_frontendFrame->pageZoomFactor();
tkent 2016/03/03 13:05:55 The original code implies m_fontendFrame can be nu
oshima 2016/03/03 14:20:55 Good point. Done.
168 } 168 // Cancel the device scale factor applied to the zoom factor in
169 169 // use-zoom-for-dsf mode.
170 float DevToolsHost::convertLengthForEmbedder(float length)
171 {
172 if (!m_frontendFrame)
173 return length;
174 const HostWindow* hostWindow = m_frontendFrame->view()->hostWindow(); 170 const HostWindow* hostWindow = m_frontendFrame->view()->hostWindow();
175 IntRect screen = hostWindow->viewportToScreen(IntRect(0, 0, length, 0)); 171 float windowToViewportRatio = hostWindow->windowToViewportScalar(1.0f);
176 return screen.width(); 172 return zoomFactor / windowToViewportRatio;
177 } 173 }
178 174
179 void DevToolsHost::setInjectedScriptForOrigin(const String& origin, const String & script) 175 void DevToolsHost::setInjectedScriptForOrigin(const String& origin, const String & script)
180 { 176 {
181 if (m_client) 177 if (m_client)
182 m_client->setInjectedScriptForOrigin(origin, script); 178 m_client->setInjectedScriptForOrigin(origin, script);
183 } 179 }
184 180
185 void DevToolsHost::copyText(const String& text) 181 void DevToolsHost::copyText(const String& text)
186 { 182 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 { 238 {
243 return m_client && m_client->isUnderTest(); 239 return m_client && m_client->isUnderTest();
244 } 240 }
245 241
246 bool DevToolsHost::isHostedMode() 242 bool DevToolsHost::isHostedMode()
247 { 243 {
248 return false; 244 return false;
249 } 245 }
250 246
251 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698