Chromium Code Reviews| 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 "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "mojo/public/cpp/application/connect.h" | 9 #include "mojo/public/cpp/application/connect.h" |
| 10 #include "sky/engine/public/platform/WebInputEvent.h" | 10 #include "sky/engine/public/platform/WebInputEvent.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 config_.gpu_task_runner->PostTask( | 120 config_.gpu_task_runner->PostTask( |
| 121 FROM_HERE, | 121 FROM_HERE, |
| 122 base::Bind(&GPUDelegate::OnOutputSurfaceDestroyed, config_.gpu_delegate)); | 122 base::Bind(&GPUDelegate::OnOutputSurfaceDestroyed, config_.gpu_delegate)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void Engine::OnViewportMetricsChanged(int width, int height, | 125 void Engine::OnViewportMetricsChanged(int width, int height, |
| 126 float device_pixel_ratio) { | 126 float device_pixel_ratio) { |
| 127 physical_size_.SetSize(width, height); | 127 physical_size_.SetSize(width, height); |
| 128 device_pixel_ratio_ = device_pixel_ratio; | 128 device_pixel_ratio_ = device_pixel_ratio; |
| 129 | 129 |
| 130 if (sky_view_) { | 130 if (sky_view_) |
| 131 blink::SkyDisplayMetrics metrics; | 131 UpdateSkyViewSize(); |
| 132 metrics.physical_size = physical_size_; | |
| 133 metrics.device_pixel_ratio = device_pixel_ratio_; | |
| 134 sky_view_->SetDisplayMetrics(metrics); | |
| 135 } | |
| 136 | 132 |
| 137 if (web_view_) | 133 if (web_view_) |
| 138 UpdateWebViewSize(); | 134 UpdateWebViewSize(); |
| 139 } | 135 } |
| 140 | 136 |
| 137 void Engine::UpdateSkyViewSize() | |
| 138 { | |
|
abarth-chromium
2015/06/04 23:46:42
These two lines should be merged.
| |
| 139 CHECK(sky_view_); | |
| 140 blink::SkyDisplayMetrics metrics; | |
| 141 metrics.physical_size = physical_size_; | |
| 142 metrics.device_pixel_ratio = device_pixel_ratio_; | |
| 143 sky_view_->SetDisplayMetrics(metrics); | |
| 144 } | |
| 145 | |
| 141 void Engine::UpdateWebViewSize() | 146 void Engine::UpdateWebViewSize() |
| 142 { | 147 { |
| 143 CHECK(web_view_); | 148 CHECK(web_view_); |
| 144 web_view_->setDeviceScaleFactor(device_pixel_ratio_); | 149 web_view_->setDeviceScaleFactor(device_pixel_ratio_); |
| 145 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_); | 150 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_); |
| 146 // FIXME: We should be able to set the size of the WebView in floating point | 151 // FIXME: We should be able to set the size of the WebView in floating point |
| 147 // because its in logical pixels. | 152 // because its in logical pixels. |
| 148 web_view_->resize(blink::WebSize(size.width(), size.height())); | 153 web_view_->resize(blink::WebSize(size.width(), size.height())); |
| 149 } | 154 } |
| 150 | 155 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 165 return; | 170 return; |
| 166 if (sky_view_) | 171 if (sky_view_) |
| 167 sky_view_->HandleInputEvent(*web_event); | 172 sky_view_->HandleInputEvent(*web_event); |
| 168 if (web_view_) | 173 if (web_view_) |
| 169 web_view_->handleInputEvent(*web_event); | 174 web_view_->handleInputEvent(*web_event); |
| 170 } | 175 } |
| 171 | 176 |
| 172 void Engine::LoadURL(const mojo::String& mojo_url) { | 177 void Engine::LoadURL(const mojo::String& mojo_url) { |
| 173 GURL url(mojo_url); | 178 GURL url(mojo_url); |
| 174 if (!blink::WebView::shouldUseWebView(url)) { | 179 if (!blink::WebView::shouldUseWebView(url)) { |
| 180 if (web_view_) { | |
| 181 web_view_->close(); | |
| 182 web_view_ = nullptr; | |
| 183 } | |
| 175 sky_view_ = blink::SkyView::Create(this); | 184 sky_view_ = blink::SkyView::Create(this); |
| 176 sky_view_->Load(url); | 185 sky_view_->Load(url); |
| 186 UpdateSkyViewSize(); | |
| 177 return; | 187 return; |
| 178 } | 188 } |
| 179 | 189 |
| 180 LOG(WARNING) << ".sky support is deprecated, please use .dart for main()"; | 190 LOG(WARNING) << ".sky support is deprecated, please use .dart for main()"; |
| 181 | 191 |
| 182 // Something bad happens if you try to call WebView::close and replace | 192 // Something bad happens if you try to call WebView::close and replace |
| 183 // the webview. So for now we just load into the existing one. :/ | 193 // the webview. So for now we just load into the existing one. :/ |
| 184 if (!web_view_) | 194 if (!web_view_) |
| 185 web_view_ = blink::WebView::create(this); | 195 web_view_ = blink::WebView::create(this); |
| 186 ConfigureSettings(web_view_->settings()); | 196 ConfigureSettings(web_view_->settings()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 | 243 |
| 234 void Engine::DidNavigateLocally(const mojo::String& url) { | 244 void Engine::DidNavigateLocally(const mojo::String& url) { |
| 235 } | 245 } |
| 236 | 246 |
| 237 void Engine::RequestNavigateHistory(int32_t delta) { | 247 void Engine::RequestNavigateHistory(int32_t delta) { |
| 238 NOTIMPLEMENTED(); | 248 NOTIMPLEMENTED(); |
| 239 } | 249 } |
| 240 | 250 |
| 241 } // namespace shell | 251 } // namespace shell |
| 242 } // namespace sky | 252 } // namespace sky |
| OLD | NEW |