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/exported/WebViewBase.h" |
7 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
8 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
9 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
10 #include "core/input/EventHandler.h" | 11 #include "core/input/EventHandler.h" |
11 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
12 #include "core/style/ComputedStyle.h" | 13 #include "core/style/ComputedStyle.h" |
13 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
14 #include "platform/geometry/FloatRect.h" | 15 #include "platform/geometry/FloatRect.h" |
15 #include "platform/geometry/FloatSize.h" | 16 #include "platform/geometry/FloatSize.h" |
16 #include "platform/geometry/IntRect.h" | 17 #include "platform/geometry/IntRect.h" |
17 #include "platform/geometry/IntSize.h" | 18 #include "platform/geometry/IntSize.h" |
| 19 #include "platform/graphics/GraphicsLayer.h" |
18 #include "platform/loader/fetch/MemoryCache.h" | 20 #include "platform/loader/fetch/MemoryCache.h" |
19 #include "platform/wtf/PtrUtil.h" | 21 #include "platform/wtf/PtrUtil.h" |
20 #include "public/platform/WebLayerTreeView.h" | 22 #include "public/platform/WebLayerTreeView.h" |
21 #include "web/WebInputEventConversion.h" | 23 #include "web/WebInputEventConversion.h" |
22 #include "web/WebLocalFrameImpl.h" | 24 #include "web/WebLocalFrameImpl.h" |
23 #include "web/WebSettingsImpl.h" | 25 #include "web/WebSettingsImpl.h" |
24 #include "web/WebViewImpl.h" | |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 static float calculateDeviceScaleAdjustment(int width, | 29 static float calculateDeviceScaleAdjustment(int width, |
29 int height, | 30 int height, |
30 float deviceScaleFactor) { | 31 float deviceScaleFactor) { |
31 // Chromium on Android uses a device scale adjustment for fonts used in text | 32 // Chromium on Android uses a device scale adjustment for fonts used in text |
32 // autosizing for improved legibility. This function computes this adjusted | 33 // autosizing for improved legibility. This function computes this adjusted |
33 // value for text autosizing. | 34 // value for text autosizing. |
34 // For a description of the Android device scale adjustment algorithm, see: | 35 // For a description of the Android device scale adjustment algorithm, see: |
(...skipping 16 matching lines...) Expand all Loading... |
51 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. | 52 // The font scale multiplier varies linearly between kMinFSM and kMaxFSM. |
52 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / | 53 float ratio = static_cast<float>(minWidth - kWidthForMinFSM) / |
53 (kWidthForMaxFSM - kWidthForMinFSM); | 54 (kWidthForMaxFSM - kWidthForMinFSM); |
54 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; | 55 return ratio * (kMaxFSM - kMinFSM) + kMinFSM; |
55 } | 56 } |
56 | 57 |
57 } // namespace | 58 } // namespace |
58 | 59 |
59 namespace blink { | 60 namespace blink { |
60 | 61 |
61 DevToolsEmulator::DevToolsEmulator(WebViewImpl* web_view_impl) | 62 DevToolsEmulator::DevToolsEmulator(WebViewBase* web_view_impl) |
62 : web_view_impl_(web_view_impl), | 63 : web_view_impl_(web_view_impl), |
63 device_metrics_enabled_(false), | 64 device_metrics_enabled_(false), |
64 emulate_mobile_enabled_(false), | 65 emulate_mobile_enabled_(false), |
65 is_overlay_scrollbars_enabled_(false), | 66 is_overlay_scrollbars_enabled_(false), |
66 is_orientation_event_enabled_(false), | 67 is_orientation_event_enabled_(false), |
67 is_mobile_layout_theme_enabled_(false), | 68 is_mobile_layout_theme_enabled_(false), |
68 original_default_minimum_page_scale_factor_(0), | 69 original_default_minimum_page_scale_factor_(0), |
69 original_default_maximum_page_scale_factor_(0), | 70 original_default_maximum_page_scale_factor_(0), |
70 embedder_text_autosizing_enabled_( | 71 embedder_text_autosizing_enabled_( |
71 web_view_impl->GetPage()->GetSettings().TextAutosizingEnabled()), | 72 web_view_impl->GetPage()->GetSettings().TextAutosizingEnabled()), |
(...skipping 23 matching lines...) Expand all Loading... |
95 double_tap_to_zoom_enabled_(false), | 96 double_tap_to_zoom_enabled_(false), |
96 original_touch_event_feature_detection_enabled_(false), | 97 original_touch_event_feature_detection_enabled_(false), |
97 original_device_supports_touch_(false), | 98 original_device_supports_touch_(false), |
98 original_max_touch_points_(0), | 99 original_max_touch_points_(0), |
99 embedder_script_enabled_( | 100 embedder_script_enabled_( |
100 web_view_impl->GetPage()->GetSettings().GetScriptEnabled()), | 101 web_view_impl->GetPage()->GetSettings().GetScriptEnabled()), |
101 script_execution_disabled_(false) {} | 102 script_execution_disabled_(false) {} |
102 | 103 |
103 DevToolsEmulator::~DevToolsEmulator() {} | 104 DevToolsEmulator::~DevToolsEmulator() {} |
104 | 105 |
105 DevToolsEmulator* DevToolsEmulator::Create(WebViewImpl* web_view_impl) { | 106 DevToolsEmulator* DevToolsEmulator::Create(WebViewBase* web_view_base) { |
106 return new DevToolsEmulator(web_view_impl); | 107 return new DevToolsEmulator(web_view_base); |
107 } | 108 } |
108 | 109 |
109 DEFINE_TRACE(DevToolsEmulator) {} | 110 DEFINE_TRACE(DevToolsEmulator) {} |
110 | 111 |
111 void DevToolsEmulator::SetTextAutosizingEnabled(bool enabled) { | 112 void DevToolsEmulator::SetTextAutosizingEnabled(bool enabled) { |
112 embedder_text_autosizing_enabled_ = enabled; | 113 embedder_text_autosizing_enabled_ = enabled; |
113 bool emulate_mobile_enabled = | 114 bool emulate_mobile_enabled = |
114 device_metrics_enabled_ && emulate_mobile_enabled_; | 115 device_metrics_enabled_ && emulate_mobile_enabled_; |
115 if (!emulate_mobile_enabled) | 116 if (!emulate_mobile_enabled) |
116 web_view_impl_->GetPage()->GetSettings().SetTextAutosizingEnabled(enabled); | 117 web_view_impl_->GetPage()->GetSettings().SetTextAutosizingEnabled(enabled); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 last_pinch_anchor_css_.reset(); | 551 last_pinch_anchor_css_.reset(); |
551 last_pinch_anchor_dip_.reset(); | 552 last_pinch_anchor_dip_.reset(); |
552 } | 553 } |
553 return true; | 554 return true; |
554 } | 555 } |
555 | 556 |
556 return false; | 557 return false; |
557 } | 558 } |
558 | 559 |
559 } // namespace blink | 560 } // namespace blink |
OLD | NEW |