| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 WebDeviceEmulationParams_h | 5 #ifndef WebDeviceEmulationParams_h |
| 6 #define WebDeviceEmulationParams_h | 6 #define WebDeviceEmulationParams_h |
| 7 | 7 |
| 8 #include "../platform/WebFloatPoint.h" | 8 #include "../platform/WebFloatPoint.h" |
| 9 #include "../platform/WebPoint.h" |
| 9 #include "../platform/WebRect.h" | 10 #include "../platform/WebRect.h" |
| 10 #include "../platform/WebSize.h" | 11 #include "../platform/WebSize.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 // All sizes are measured in device independent pixels. | 15 // All sizes are measured in device independent pixels. |
| 15 struct WebDeviceEmulationParams { | 16 struct WebDeviceEmulationParams { |
| 16 // For mobile, screen has the same size as view, which is positioned at (0;0
). | 17 // For mobile, |screenSize| and |viewPosition| are used. |
| 17 // For desktop, screen size and view position are preserved. | 18 // For desktop, screen size and view position are preserved. |
| 18 enum ScreenPosition { | 19 enum ScreenPosition { |
| 19 Desktop, | 20 Desktop, |
| 20 Mobile, | 21 Mobile, |
| 21 ScreenPositionLast = Mobile | 22 ScreenPositionLast = Mobile |
| 22 }; | 23 }; |
| 23 | 24 |
| 24 ScreenPosition screenPosition; | 25 ScreenPosition screenPosition; |
| 25 | 26 |
| 27 // Emulated screen size. Used with |screenPosition == Mobile|. |
| 28 WebSize screenSize; |
| 29 |
| 30 // Position of view on the screen. Used with |screenPosition == Mobile|. |
| 31 WebPoint viewPosition; |
| 32 |
| 26 // If zero, the original device scale factor is preserved. | 33 // If zero, the original device scale factor is preserved. |
| 27 float deviceScaleFactor; | 34 float deviceScaleFactor; |
| 28 | 35 |
| 29 // Emulated view size. Empty size means no override. | 36 // Emulated view size. Empty size means no override. |
| 30 WebSize viewSize; | 37 WebSize viewSize; |
| 31 | 38 |
| 32 // Whether emulated view should be scaled down if necessary to fit into avai
lable space. | 39 // Whether emulated view should be scaled down if necessary to fit into avai
lable space. |
| 33 bool fitToView; | 40 bool fitToView; |
| 34 | 41 |
| 35 // Offset of emulated view inside available space, not in fit to view mode. | 42 // Offset of emulated view inside available space, not in fit to view mode. |
| 36 WebFloatPoint offset; | 43 WebFloatPoint offset; |
| 37 | 44 |
| 38 // Scale of emulated view inside available space, not in fit to view mode. | 45 // Scale of emulated view inside available space, not in fit to view mode. |
| 39 float scale; | 46 float scale; |
| 40 | 47 |
| 41 WebDeviceEmulationParams() | 48 WebDeviceEmulationParams() |
| 42 : screenPosition(Desktop) | 49 : screenPosition(Desktop) |
| 43 , deviceScaleFactor(0) | 50 , deviceScaleFactor(0) |
| 44 , fitToView(false) | 51 , fitToView(false) |
| 45 , scale(1) { } | 52 , scale(1) { } |
| 46 }; | 53 }; |
| 47 | 54 |
| 48 inline bool operator==(const WebDeviceEmulationParams& a, const WebDeviceEmulati
onParams& b) | 55 inline bool operator==(const WebDeviceEmulationParams& a, const WebDeviceEmulati
onParams& b) |
| 49 { | 56 { |
| 50 return a.screenPosition == b.screenPosition && a.deviceScaleFactor == b.devi
ceScaleFactor && a.viewSize == b.viewSize && a.fitToView == b.fitToView && a.off
set == b.offset && a.scale == b.scale; | 57 return a.screenPosition == b.screenPosition && a.screenSize == b.screenSize
&& a.viewPosition == b.viewPosition && a.deviceScaleFactor == b.deviceScaleFacto
r && a.viewSize == b.viewSize && a.fitToView == b.fitToView && a.offset == b.off
set && a.scale == b.scale; |
| 51 } | 58 } |
| 52 | 59 |
| 53 inline bool operator!=(const WebDeviceEmulationParams& a, const WebDeviceEmulati
onParams& b) | 60 inline bool operator!=(const WebDeviceEmulationParams& a, const WebDeviceEmulati
onParams& b) |
| 54 { | 61 { |
| 55 return !(a == b); | 62 return !(a == b); |
| 56 } | 63 } |
| 57 | 64 |
| 58 } // namespace blink | 65 } // namespace blink |
| 59 | 66 |
| 60 #endif | 67 #endif |
| OLD | NEW |