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 "sky/shell/ui/engine.h" | 5 #include "sky/shell/ui/engine.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "sky/engine/public/platform/WebInputEvent.h" | 8 #include "sky/engine/public/platform/WebInputEvent.h" |
9 #include "sky/engine/public/web/Sky.h" | 9 #include "sky/engine/public/web/Sky.h" |
10 #include "sky/engine/public/web/WebLocalFrame.h" | 10 #include "sky/engine/public/web/WebLocalFrame.h" |
11 #include "sky/engine/public/web/WebSettings.h" | |
11 #include "sky/engine/public/web/WebView.h" | 12 #include "sky/engine/public/web/WebView.h" |
12 #include "sky/shell/ui/animator.h" | 13 #include "sky/shell/ui/animator.h" |
13 #include "sky/shell/ui/input_event_converter.h" | 14 #include "sky/shell/ui/input_event_converter.h" |
14 #include "sky/shell/ui/platform_impl.h" | 15 #include "sky/shell/ui/platform_impl.h" |
15 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
16 #include "third_party/skia/include/core/SkPictureRecorder.h" | 17 #include "third_party/skia/include/core/SkPictureRecorder.h" |
17 | 18 |
18 namespace sky { | 19 namespace sky { |
19 namespace shell { | 20 namespace shell { |
20 | 21 |
22 void ConfigureSettings(blink::WebSettings* settings) { | |
abarth-chromium
2015/02/20 22:54:11
Can you wrap this in an anonymous namespace or mar
| |
23 settings->setDefaultFixedFontSize(13); | |
24 settings->setDefaultFontSize(16); | |
25 settings->setLoadsImagesAutomatically(true); | |
26 } | |
27 | |
21 Engine::Engine(const Config& config) | 28 Engine::Engine(const Config& config) |
22 : animator_(new Animator(config, this)), | 29 : animator_(new Animator(config, this)), |
23 web_view_(nullptr), | 30 web_view_(nullptr), |
24 device_pixel_ratio_(1.0f), | 31 device_pixel_ratio_(1.0f), |
25 viewport_observer_binding_(this), | 32 viewport_observer_binding_(this), |
26 weak_factory_(this) { | 33 weak_factory_(this) { |
27 } | 34 } |
28 | 35 |
29 Engine::~Engine() { | 36 Engine::~Engine() { |
30 if (web_view_) | 37 if (web_view_) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 void Engine::UpdateWebViewSize() | 85 void Engine::UpdateWebViewSize() |
79 { | 86 { |
80 DCHECK(web_view_); | 87 DCHECK(web_view_); |
81 web_view_->setDeviceScaleFactor(device_pixel_ratio_); | 88 web_view_->setDeviceScaleFactor(device_pixel_ratio_); |
82 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_); | 89 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_); |
83 // FIXME: We should be able to set the size of the WebView in floating point | 90 // FIXME: We should be able to set the size of the WebView in floating point |
84 // because its in logical pixels. | 91 // because its in logical pixels. |
85 web_view_->resize(blink::WebSize(size.width(), size.height())); | 92 web_view_->resize(blink::WebSize(size.width(), size.height())); |
86 } | 93 } |
87 | 94 |
95 // TODO(eseidel): This is likely not needed anymore. | |
96 blink::WebScreenInfo Engine::screenInfo() { | |
97 blink::WebScreenInfo screen; | |
98 screen.rect = blink::WebRect(gfx::Rect(physical_size_)); | |
99 screen.availableRect = screen.rect; | |
100 screen.deviceScaleFactor = device_pixel_ratio_; | |
101 return screen; | |
102 } | |
103 | |
88 void Engine::OnInputEvent(InputEventPtr event) { | 104 void Engine::OnInputEvent(InputEventPtr event) { |
89 scoped_ptr<blink::WebInputEvent> web_event = | 105 scoped_ptr<blink::WebInputEvent> web_event = |
90 ConvertEvent(event, device_pixel_ratio_); | 106 ConvertEvent(event, device_pixel_ratio_); |
91 if (!web_event) | 107 if (!web_event) |
92 return; | 108 return; |
93 web_view_->handleInputEvent(*web_event); | 109 web_view_->handleInputEvent(*web_event); |
94 } | 110 } |
95 | 111 |
96 void Engine::LoadURL(const mojo::String& url) { | 112 void Engine::LoadURL(const mojo::String& url) { |
97 web_view_ = blink::WebView::create(this); | 113 web_view_ = blink::WebView::create(this); |
114 ConfigureSettings(web_view_->settings()); | |
98 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 115 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
99 UpdateWebViewSize(); | 116 UpdateWebViewSize(); |
100 web_view_->mainFrame()->load(GURL(url)); | 117 web_view_->mainFrame()->load(GURL(url)); |
101 } | 118 } |
102 | 119 |
103 void Engine::initializeLayerTreeView() { | 120 void Engine::initializeLayerTreeView() { |
104 } | 121 } |
105 | 122 |
106 void Engine::scheduleVisualUpdate() { | 123 void Engine::scheduleVisualUpdate() { |
107 animator_->RequestFrame(); | 124 animator_->RequestFrame(); |
108 } | 125 } |
109 | 126 |
110 } // namespace shell | 127 } // namespace shell |
111 } // namespace sky | 128 } // namespace sky |
OLD | NEW |