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> { |
dgozman
2016/08/29 20:45:36
What are we exporting this for?
Eric Seckler
2016/09/12 13:58:00
So we can call force/resetViewport on it from WebV
| |
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 void applyDeviceEmulationTransform(TransformationMatrix*); | |
75 void applyViewportOverride(TransformationMatrix*); | |
76 void updateRootLayerTransform(); | |
77 | |
58 WebViewImpl* m_webViewImpl; | 78 WebViewImpl* m_webViewImpl; |
59 | 79 |
60 bool m_deviceMetricsEnabled; | 80 bool m_deviceMetricsEnabled; |
61 bool m_emulateMobileEnabled; | 81 bool m_emulateMobileEnabled; |
62 WebDeviceEmulationParams m_emulationParams; | 82 WebDeviceEmulationParams m_emulationParams; |
63 | 83 |
84 struct ViewportOverride { | |
85 WebFloatPoint position; | |
86 double scale; | |
87 bool originalVisualViewportMasking; | |
88 }; | |
89 WTF::Optional<ViewportOverride> m_viewportOverride; | |
90 | |
64 bool m_isOverlayScrollbarsEnabled; | 91 bool m_isOverlayScrollbarsEnabled; |
65 bool m_isOrientationEventEnabled; | 92 bool m_isOrientationEventEnabled; |
66 bool m_isMobileLayoutThemeEnabled; | 93 bool m_isMobileLayoutThemeEnabled; |
67 float m_originalDefaultMinimumPageScaleFactor; | 94 float m_originalDefaultMinimumPageScaleFactor; |
68 float m_originalDefaultMaximumPageScaleFactor; | 95 float m_originalDefaultMaximumPageScaleFactor; |
69 bool m_embedderTextAutosizingEnabled; | 96 bool m_embedderTextAutosizingEnabled; |
70 float m_embedderDeviceScaleAdjustment; | 97 float m_embedderDeviceScaleAdjustment; |
71 bool m_embedderPreferCompositingToLCDTextEnabled; | 98 bool m_embedderPreferCompositingToLCDTextEnabled; |
72 WebViewportStyle m_embedderViewportStyle; | 99 WebViewportStyle m_embedderViewportStyle; |
73 bool m_embedderPluginsEnabled; | 100 bool m_embedderPluginsEnabled; |
(...skipping 12 matching lines...) Expand all Loading... | |
86 std::unique_ptr<IntPoint> m_lastPinchAnchorCss; | 113 std::unique_ptr<IntPoint> m_lastPinchAnchorCss; |
87 std::unique_ptr<IntPoint> m_lastPinchAnchorDip; | 114 std::unique_ptr<IntPoint> m_lastPinchAnchorDip; |
88 | 115 |
89 bool m_embedderScriptEnabled; | 116 bool m_embedderScriptEnabled; |
90 bool m_scriptExecutionDisabled; | 117 bool m_scriptExecutionDisabled; |
91 }; | 118 }; |
92 | 119 |
93 } // namespace blink | 120 } // namespace blink |
94 | 121 |
95 #endif | 122 #endif |
OLD | NEW |