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 #ifndef DevToolsEmulator_h | 5 #ifndef DevToolsEmulator_h |
6 #define DevToolsEmulator_h | 6 #define DevToolsEmulator_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "public/platform/PointerProperties.h" | 9 #include "public/platform/PointerProperties.h" |
| 10 #include "public/platform/WebFloatPoint.h" |
10 #include "public/platform/WebViewportStyle.h" | 11 #include "public/platform/WebViewportStyle.h" |
11 #include "public/web/WebDeviceEmulationParams.h" | 12 #include "public/web/WebDeviceEmulationParams.h" |
| 13 #include "web/WebExport.h" |
12 #include "wtf/Forward.h" | 14 #include "wtf/Forward.h" |
| 15 #include "wtf/Optional.h" |
13 #include <memory> | 16 #include <memory> |
14 | 17 |
15 namespace blink { | 18 namespace blink { |
16 | 19 |
17 class InspectorEmulationAgent; | 20 class InspectorEmulationAgent; |
18 class IntPoint; | 21 class IntPoint; |
| 22 class IntRect; |
| 23 class TransformationMatrix; |
19 class WebInputEvent; | 24 class WebInputEvent; |
20 class WebViewImpl; | 25 class WebViewImpl; |
21 | 26 |
22 class DevToolsEmulator final : public GarbageCollectedFinalized<DevToolsEmulator
> { | 27 class WEB_EXPORT DevToolsEmulator final : public GarbageCollectedFinalized<DevTo
olsEmulator> { |
23 public: | 28 public: |
24 ~DevToolsEmulator(); | 29 ~DevToolsEmulator(); |
25 static DevToolsEmulator* create(WebViewImpl*); | 30 static DevToolsEmulator* create(WebViewImpl*); |
26 DECLARE_TRACE(); | 31 DECLARE_TRACE(); |
27 | 32 |
28 // Settings overrides. | 33 // Settings overrides. |
29 void setTextAutosizingEnabled(bool); | 34 void setTextAutosizingEnabled(bool); |
30 void setDeviceScaleAdjustment(float); | 35 void setDeviceScaleAdjustment(float); |
31 void setPreferCompositingToLCDTextEnabled(bool); | 36 void setPreferCompositingToLCDTextEnabled(bool); |
32 void setViewportStyle(WebViewportStyle); | 37 void setViewportStyle(WebViewportStyle); |
33 void setPluginsEnabled(bool); | 38 void setPluginsEnabled(bool); |
34 void setScriptEnabled(bool); | 39 void setScriptEnabled(bool); |
35 void setDoubleTapToZoomEnabled(bool); | 40 void setDoubleTapToZoomEnabled(bool); |
36 bool doubleTapToZoomEnabled() const; | 41 bool doubleTapToZoomEnabled() const; |
37 void setAvailablePointerTypes(int); | 42 void setAvailablePointerTypes(int); |
38 void setPrimaryPointerType(PointerType); | 43 void setPrimaryPointerType(PointerType); |
39 void setAvailableHoverTypes(int); | 44 void setAvailableHoverTypes(int); |
40 void setPrimaryHoverType(HoverType); | 45 void setPrimaryHoverType(HoverType); |
41 void setMainFrameResizesAreOrientationChanges(bool); | 46 void setMainFrameResizesAreOrientationChanges(bool); |
42 bool mainFrameResizesAreOrientationChanges() const; | 47 bool mainFrameResizesAreOrientationChanges() const; |
43 | 48 |
44 // Emulation. | 49 // Emulation. |
45 void enableDeviceEmulation(const WebDeviceEmulationParams&); | 50 void enableDeviceEmulation(const WebDeviceEmulationParams&); |
46 void disableDeviceEmulation(); | 51 void disableDeviceEmulation(); |
| 52 // Position is given in CSS pixels, scale relative to a page scale of 1.0. |
| 53 void forceViewport(const WebFloatPoint& position, float scale); |
| 54 void resetViewport(); |
47 bool resizeIsDeviceSizeChange(); | 55 bool resizeIsDeviceSizeChange(); |
48 void setTouchEventEmulationEnabled(bool); | 56 void setTouchEventEmulationEnabled(bool); |
49 bool handleInputEvent(const WebInputEvent&); | 57 bool handleInputEvent(const WebInputEvent&); |
50 void setScriptExecutionDisabled(bool); | 58 void setScriptExecutionDisabled(bool); |
51 | 59 |
| 60 // Notify the DevToolsEmulator about a scroll or scale change of the main |
| 61 // frame. Updates the transform for a viewport override. |
| 62 void mainFrameScrollOrScaleChanged(); |
| 63 |
| 64 // Returns a custom visible content rect if a viewport override is active. |
| 65 // This ensures that all content inside the forced viewport is painted. |
| 66 WTF::Optional<IntRect> visibleContentRectForPainting() const; |
| 67 |
52 private: | 68 private: |
53 explicit DevToolsEmulator(WebViewImpl*); | 69 explicit DevToolsEmulator(WebViewImpl*); |
54 | 70 |
55 void enableMobileEmulation(); | 71 void enableMobileEmulation(); |
56 void disableMobileEmulation(); | 72 void disableMobileEmulation(); |
57 | 73 |
| 74 // Returns the original device scale factor when overridden by DevTools, or |
| 75 // deviceScaleFactor() otherwise. |
| 76 float compositorDeviceScaleFactor() const; |
| 77 |
| 78 void applyDeviceEmulationTransform(TransformationMatrix*); |
| 79 void applyViewportOverride(TransformationMatrix*); |
| 80 void updateRootLayerTransform(); |
| 81 |
58 WebViewImpl* m_webViewImpl; | 82 WebViewImpl* m_webViewImpl; |
59 | 83 |
60 bool m_deviceMetricsEnabled; | 84 bool m_deviceMetricsEnabled; |
61 bool m_emulateMobileEnabled; | 85 bool m_emulateMobileEnabled; |
62 WebDeviceEmulationParams m_emulationParams; | 86 WebDeviceEmulationParams m_emulationParams; |
63 | 87 |
| 88 struct ViewportOverride { |
| 89 WebFloatPoint position; |
| 90 double scale; |
| 91 bool originalVisualViewportMasking; |
| 92 }; |
| 93 WTF::Optional<ViewportOverride> m_viewportOverride; |
| 94 |
64 bool m_isOverlayScrollbarsEnabled; | 95 bool m_isOverlayScrollbarsEnabled; |
65 bool m_isOrientationEventEnabled; | 96 bool m_isOrientationEventEnabled; |
66 bool m_isMobileLayoutThemeEnabled; | 97 bool m_isMobileLayoutThemeEnabled; |
67 float m_originalDefaultMinimumPageScaleFactor; | 98 float m_originalDefaultMinimumPageScaleFactor; |
68 float m_originalDefaultMaximumPageScaleFactor; | 99 float m_originalDefaultMaximumPageScaleFactor; |
69 bool m_embedderTextAutosizingEnabled; | 100 bool m_embedderTextAutosizingEnabled; |
70 float m_embedderDeviceScaleAdjustment; | 101 float m_embedderDeviceScaleAdjustment; |
71 bool m_embedderPreferCompositingToLCDTextEnabled; | 102 bool m_embedderPreferCompositingToLCDTextEnabled; |
72 WebViewportStyle m_embedderViewportStyle; | 103 WebViewportStyle m_embedderViewportStyle; |
73 bool m_embedderPluginsEnabled; | 104 bool m_embedderPluginsEnabled; |
(...skipping 12 matching lines...) Expand all Loading... |
86 std::unique_ptr<IntPoint> m_lastPinchAnchorCss; | 117 std::unique_ptr<IntPoint> m_lastPinchAnchorCss; |
87 std::unique_ptr<IntPoint> m_lastPinchAnchorDip; | 118 std::unique_ptr<IntPoint> m_lastPinchAnchorDip; |
88 | 119 |
89 bool m_embedderScriptEnabled; | 120 bool m_embedderScriptEnabled; |
90 bool m_scriptExecutionDisabled; | 121 bool m_scriptExecutionDisabled; |
91 }; | 122 }; |
92 | 123 |
93 } // namespace blink | 124 } // namespace blink |
94 | 125 |
95 #endif | 126 #endif |
OLD | NEW |