OLD | NEW |
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/frame/FrameHost.h" | 7 #include "core/frame/FrameHost.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
10 #include "core/page/Page.h" | 10 #include "core/page/Page.h" |
11 #include "platform/RuntimeEnabledFeatures.h" | 11 #include "platform/RuntimeEnabledFeatures.h" |
12 #include "public/platform/WebLayerTreeView.h" | 12 #include "public/platform/WebLayerTreeView.h" |
13 #include "web/InspectorEmulationAgent.h" | |
14 #include "web/WebInputEventConversion.h" | 13 #include "web/WebInputEventConversion.h" |
15 #include "web/WebLocalFrameImpl.h" | 14 #include "web/WebLocalFrameImpl.h" |
16 #include "web/WebSettingsImpl.h" | 15 #include "web/WebSettingsImpl.h" |
17 #include "web/WebViewImpl.h" | 16 #include "web/WebViewImpl.h" |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 static float calculateDeviceScaleAdjustment(int width, int height, float deviceS
caleFactor) | 20 static float calculateDeviceScaleAdjustment(int width, int height, float deviceS
caleFactor) |
22 { | 21 { |
23 // Chromium on Android uses a device scale adjustment for fonts used in text
autosizing for | 22 // Chromium on Android uses a device scale adjustment for fonts used in text
autosizing for |
(...skipping 18 matching lines...) Expand all Loading... |
42 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / (kWidthForMax
FSM - kWidthForMinFSM); | 41 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / (kWidthForMax
FSM - kWidthForMinFSM); |
43 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; | 42 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
44 } | 43 } |
45 | 44 |
46 } // namespace | 45 } // namespace |
47 | 46 |
48 namespace blink { | 47 namespace blink { |
49 | 48 |
50 DevToolsEmulator::DevToolsEmulator(WebViewImpl* webViewImpl) | 49 DevToolsEmulator::DevToolsEmulator(WebViewImpl* webViewImpl) |
51 : m_webViewImpl(webViewImpl) | 50 : m_webViewImpl(webViewImpl) |
52 , m_emulationAgent(nullptr) | |
53 , m_deviceMetricsEnabled(false) | 51 , m_deviceMetricsEnabled(false) |
54 , m_emulateMobileEnabled(false) | 52 , m_emulateMobileEnabled(false) |
55 , m_isOverlayScrollbarsEnabled(false) | 53 , m_isOverlayScrollbarsEnabled(false) |
56 , m_originalDefaultMinimumPageScaleFactor(0) | 54 , m_originalDefaultMinimumPageScaleFactor(0) |
57 , m_originalDefaultMaximumPageScaleFactor(0) | 55 , m_originalDefaultMaximumPageScaleFactor(0) |
58 , m_embedderTextAutosizingEnabled(webViewImpl->page()->settings().textAutosi
zingEnabled()) | 56 , m_embedderTextAutosizingEnabled(webViewImpl->page()->settings().textAutosi
zingEnabled()) |
59 , m_embedderDeviceScaleAdjustment(webViewImpl->page()->settings().deviceScal
eAdjustment()) | 57 , m_embedderDeviceScaleAdjustment(webViewImpl->page()->settings().deviceScal
eAdjustment()) |
60 , m_embedderPreferCompositingToLCDTextEnabled(webViewImpl->page()->settings(
).preferCompositingToLCDTextEnabled()) | 58 , m_embedderPreferCompositingToLCDTextEnabled(webViewImpl->page()->settings(
).preferCompositingToLCDTextEnabled()) |
61 , m_embedderUseMobileViewport(webViewImpl->page()->settings().useMobileViewp
ortStyle()) | 59 , m_embedderUseMobileViewport(webViewImpl->page()->settings().useMobileViewp
ortStyle()) |
62 , m_embedderPluginsEnabled(webViewImpl->page()->settings().pluginsEnabled()) | 60 , m_embedderPluginsEnabled(webViewImpl->page()->settings().pluginsEnabled()) |
(...skipping 16 matching lines...) Expand all Loading... |
79 { | 77 { |
80 } | 78 } |
81 | 79 |
82 PassOwnPtrWillBeRawPtr<DevToolsEmulator> DevToolsEmulator::create(WebViewImpl* w
ebViewImpl) | 80 PassOwnPtrWillBeRawPtr<DevToolsEmulator> DevToolsEmulator::create(WebViewImpl* w
ebViewImpl) |
83 { | 81 { |
84 return adoptPtrWillBeNoop(new DevToolsEmulator(webViewImpl)); | 82 return adoptPtrWillBeNoop(new DevToolsEmulator(webViewImpl)); |
85 } | 83 } |
86 | 84 |
87 DEFINE_TRACE(DevToolsEmulator) | 85 DEFINE_TRACE(DevToolsEmulator) |
88 { | 86 { |
89 visitor->trace(m_emulationAgent); | |
90 } | |
91 | |
92 void DevToolsEmulator::setEmulationAgent(InspectorEmulationAgent* agent) | |
93 { | |
94 m_emulationAgent = agent; | |
95 } | |
96 | |
97 void DevToolsEmulator::viewportChanged() | |
98 { | |
99 if (m_emulationAgent) | |
100 m_emulationAgent->viewportChanged(); | |
101 } | 87 } |
102 | 88 |
103 void DevToolsEmulator::setTextAutosizingEnabled(bool enabled) | 89 void DevToolsEmulator::setTextAutosizingEnabled(bool enabled) |
104 { | 90 { |
105 m_embedderTextAutosizingEnabled = enabled; | 91 m_embedderTextAutosizingEnabled = enabled; |
106 bool emulateMobileEnabled = m_deviceMetricsEnabled && m_emulateMobileEnabled
; | 92 bool emulateMobileEnabled = m_deviceMetricsEnabled && m_emulateMobileEnabled
; |
107 if (!emulateMobileEnabled) | 93 if (!emulateMobileEnabled) |
108 m_webViewImpl->page()->settings().setTextAutosizingEnabled(enabled); | 94 m_webViewImpl->page()->settings().setTextAutosizingEnabled(enabled); |
109 } | 95 } |
110 | 96 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 m_lastPinchAnchorCss.clear(); | 351 m_lastPinchAnchorCss.clear(); |
366 m_lastPinchAnchorDip.clear(); | 352 m_lastPinchAnchorDip.clear(); |
367 } | 353 } |
368 return true; | 354 return true; |
369 } | 355 } |
370 | 356 |
371 return false; | 357 return false; |
372 } | 358 } |
373 | 359 |
374 } // namespace blink | 360 } // namespace blink |
OLD | NEW |