Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: sky/shell/ui/engine.cc

Issue 1165003006: Various fixes in preparation for deploying (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove game changes Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698