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

Side by Side Diff: sky/viewer/document_view.cc

Issue 716223003: Fix contenteditable (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/viewer/document_view.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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 root_ = root; 108 root_ = root;
109 imported_services_ = imported_services.Pass(); 109 imported_services_ = imported_services.Pass();
110 navigator_host_.set_service_provider(imported_services_.get()); 110 navigator_host_.set_service_provider(imported_services_.get());
111 exported_services->AddService(&inspector_service_factory_); 111 exported_services->AddService(&inspector_service_factory_);
112 112
113 Load(response_.Pass()); 113 Load(response_.Pass());
114 114
115 gfx::Size size = root_->bounds().To<gfx::Rect>().size(); 115 gfx::Size size = root_->bounds().To<gfx::Rect>().size();
116 web_view_->resize(size); 116 web_view_->resize(size);
117 // TODO(abarth): We should ask the view whether it is focused instead of
118 // assuming that we're focused.
119 web_view_->setFocus(true);
117 web_layer_tree_view_impl_->setViewportSize(size); 120 web_layer_tree_view_impl_->setViewportSize(size);
118 web_layer_tree_view_impl_->set_view(root_); 121 web_layer_tree_view_impl_->set_view(root_);
119 root_->AddObserver(this); 122 root_->AddObserver(this);
120 } 123 }
121 124
122 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { 125 void DocumentView::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {
123 // TODO(aa): Need to figure out how shutdown works. 126 // TODO(aa): Need to figure out how shutdown works.
124 } 127 }
125 128
126 void DocumentView::Load(mojo::URLResponsePtr response) { 129 void DocumentView::Load(mojo::URLResponsePtr response) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 211
209 void DocumentView::OnViewBoundsChanged(mojo::View* view, 212 void DocumentView::OnViewBoundsChanged(mojo::View* view,
210 const mojo::Rect& old_bounds, 213 const mojo::Rect& old_bounds,
211 const mojo::Rect& new_bounds) { 214 const mojo::Rect& new_bounds) {
212 DCHECK_EQ(view, root_); 215 DCHECK_EQ(view, root_);
213 gfx::Size size = new_bounds.To<gfx::Rect>().size(); 216 gfx::Size size = new_bounds.To<gfx::Rect>().size();
214 web_view_->resize(size); 217 web_view_->resize(size);
215 web_layer_tree_view_impl_->setViewportSize(size); 218 web_layer_tree_view_impl_->setViewportSize(size);
216 } 219 }
217 220
221 void DocumentView::OnViewFocusChanged(mojo::View* gained_focus,
222 mojo::View* lost_focus) {
223 if (root_ == lost_focus) {
224 web_view_->setFocus(false);
225 } else if (root_ == gained_focus) {
226 web_view_->setFocus(true);
227 }
228 }
229
218 void DocumentView::OnViewDestroyed(mojo::View* view) { 230 void DocumentView::OnViewDestroyed(mojo::View* view) {
219 DCHECK_EQ(view, root_); 231 DCHECK_EQ(view, root_);
220 232
221 for (auto& child : root_->children()) 233 for (auto& child : root_->children())
222 child->Destroy(); 234 child->Destroy();
223 235
224 delete this; 236 delete this;
225 } 237 }
226 238
227 void DocumentView::OnViewInputEvent( 239 void DocumentView::OnViewInputEvent(
228 mojo::View* view, const mojo::EventPtr& event) { 240 mojo::View* view, const mojo::EventPtr& event) {
229 scoped_ptr<blink::WebInputEvent> web_event = 241 scoped_ptr<blink::WebInputEvent> web_event =
230 event.To<scoped_ptr<blink::WebInputEvent> >(); 242 event.To<scoped_ptr<blink::WebInputEvent> >();
231 if (web_event) 243 if (web_event)
232 web_view_->handleInputEvent(*web_event); 244 web_view_->handleInputEvent(*web_event);
233 } 245 }
234 246
235 } // namespace sky 247 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/document_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698