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 "mojo/services/html_viewer/html_document_view.h" | 5 #include "mojo/services/html_viewer/html_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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 207 } |
208 | 208 |
209 void HTMLDocumentView::OnViewDestroyed(View* view) { | 209 void HTMLDocumentView::OnViewDestroyed(View* view) { |
210 DCHECK_EQ(view, root_); | 210 DCHECK_EQ(view, root_); |
211 view->RemoveObserver(this); | 211 view->RemoveObserver(this); |
212 root_ = NULL; | 212 root_ = NULL; |
213 } | 213 } |
214 | 214 |
215 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { | 215 void HTMLDocumentView::OnViewInputEvent(View* view, const EventPtr& event) { |
216 scoped_ptr<blink::WebInputEvent> web_event = | 216 scoped_ptr<blink::WebInputEvent> web_event = |
217 TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( | 217 event.To<scoped_ptr<blink::WebInputEvent> >(); |
218 event); | |
219 if (web_event) | 218 if (web_event) |
220 web_view_->handleInputEvent(*web_event); | 219 web_view_->handleInputEvent(*web_event); |
221 } | 220 } |
222 | 221 |
223 void HTMLDocumentView::Repaint() { | 222 void HTMLDocumentView::Repaint() { |
224 repaint_pending_ = false; | 223 repaint_pending_ = false; |
225 | 224 |
226 web_view_->animate(0.0); | 225 web_view_->animate(0.0); |
227 web_view_->layout(); | 226 web_view_->layout(); |
228 | 227 |
229 int width = web_view_->size().width; | 228 int width = web_view_->size().width; |
230 int height = web_view_->size().height; | 229 int height = web_view_->size().height; |
231 | 230 |
232 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( | 231 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( |
233 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); | 232 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); |
234 | 233 |
235 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); | 234 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); |
236 | 235 |
237 root_->SetContents(canvas->getDevice()->accessBitmap(false)); | 236 root_->SetContents(canvas->getDevice()->accessBitmap(false)); |
238 } | 237 } |
239 | 238 |
240 } // namespace mojo | 239 } // namespace mojo |
OLD | NEW |