Chromium Code Reviews| 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 #include "sky/viewer/document_view.h" | 5 #include "sky/viewer/document_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 shell_->ConnectToApplication("mojo:native_viewport_service", | 144 shell_->ConnectToApplication("mojo:native_viewport_service", |
| 145 mojo::GetProxy(&gpu_service_provider)); | 145 mojo::GetProxy(&gpu_service_provider)); |
| 146 mojo::InterfacePtr<mojo::Gpu> gpu_service; | 146 mojo::InterfacePtr<mojo::Gpu> gpu_service; |
| 147 mojo::ConnectToService(gpu_service_provider.get(), &gpu_service); | 147 mojo::ConnectToService(gpu_service_provider.get(), &gpu_service); |
| 148 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( | 148 web_layer_tree_view_impl_.reset(new WebLayerTreeViewImpl( |
| 149 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); | 149 compositor_thread_, surfaces_service.Pass(), gpu_service.Pass())); |
| 150 | 150 |
| 151 return web_layer_tree_view_impl_.get(); | 151 return web_layer_tree_view_impl_.get(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DocumentView::createChildView(const blink::WebURL& url) { | 154 uint32_t DocumentView::createChildFrame(const blink::WebURL& url) { |
| 155 if (!root_) | 155 if (!root_) |
| 156 return; | 156 return static_cast<uint32_t>(-1); |
|
esprehn
2014/11/07 21:22:15
It seems wrong to continuously cast -1 to a uint f
Matt Perry
2014/11/10 23:00:56
Switched to using objects instead of IDs.
| |
| 157 | 157 |
| 158 mojo::View* child = mojo::View::Create(root_->view_manager()); | 158 mojo::View* child = mojo::View::Create(root_->view_manager()); |
| 159 root_->AddChild(child); | 159 root_->AddChild(child); |
| 160 // TODO(mpcomplete): actual bounds. | 160 child->Embed(mojo::String::From(url.string().utf8())); |
| 161 | |
| 162 return child->id(); | |
|
abarth-chromium
2014/11/07 21:25:50
Why not just return |child| from this function? T
Matt Perry
2014/11/10 23:00:56
I wasn't sure about the layering rules, but that's
| |
| 163 } | |
| 164 | |
| 165 void DocumentView::initializeChildFrame(uint32_t frame_id, const blink::WebRect& bounds) { | |
| 166 if (!root_) | |
| 167 return; | |
| 168 mojo::View* child = root_->GetChildById(frame_id); | |
| 169 if (!child) | |
| 170 return; | |
| 171 | |
| 161 mojo::Rect mojo_bounds; | 172 mojo::Rect mojo_bounds; |
| 162 mojo_bounds.x = 0; | 173 mojo_bounds.x = bounds.x; |
| 163 mojo_bounds.y = 50; | 174 mojo_bounds.y = bounds.y; |
| 164 mojo_bounds.width = 300; | 175 mojo_bounds.width = bounds.width; |
| 165 mojo_bounds.height = 100; | 176 mojo_bounds.height = bounds.height; |
| 166 child->SetBounds(mojo_bounds); | 177 child->SetBounds(mojo_bounds); |
| 167 child->Embed(mojo::String::From(url.string().utf8())); | |
| 168 } | 178 } |
| 169 | 179 |
| 170 void DocumentView::frameDetached(blink::WebFrame* frame) { | 180 void DocumentView::frameDetached(blink::WebFrame* frame) { |
| 171 // |frame| is invalid after here. | 181 // |frame| is invalid after here. |
| 172 frame->close(); | 182 frame->close(); |
| 173 } | 183 } |
| 174 | 184 |
| 175 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( | 185 blink::WebNavigationPolicy DocumentView::decidePolicyForNavigation( |
| 176 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 186 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
| 177 | 187 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 | 241 |
| 232 void DocumentView::OnViewInputEvent( | 242 void DocumentView::OnViewInputEvent( |
| 233 mojo::View* view, const mojo::EventPtr& event) { | 243 mojo::View* view, const mojo::EventPtr& event) { |
| 234 scoped_ptr<blink::WebInputEvent> web_event = | 244 scoped_ptr<blink::WebInputEvent> web_event = |
| 235 event.To<scoped_ptr<blink::WebInputEvent> >(); | 245 event.To<scoped_ptr<blink::WebInputEvent> >(); |
| 236 if (web_event) | 246 if (web_event) |
| 237 web_view_->handleInputEvent(*web_event); | 247 web_view_->handleInputEvent(*web_event); |
| 238 } | 248 } |
| 239 | 249 |
| 240 } // namespace sky | 250 } // namespace sky |
| OLD | NEW |