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/examples/html_viewer/html_document_view.h" | 5 #include "mojo/examples/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/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 void HTMLDocumentView::AttachToNode(view_manager::Node* node) { | 96 void HTMLDocumentView::AttachToNode(view_manager::Node* node) { |
97 node->SetActiveView(view_); | 97 node->SetActiveView(view_); |
98 view_->SetColor(SK_ColorCYAN); // Dummy background color. | 98 view_->SetColor(SK_ColorCYAN); // Dummy background color. |
99 | 99 |
100 web_view_ = blink::WebView::create(this); | 100 web_view_ = blink::WebView::create(this); |
101 ConfigureSettings(web_view_->settings()); | 101 ConfigureSettings(web_view_->settings()); |
102 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); | 102 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
103 | 103 |
104 web_view_->resize(gfx::Size(node->bounds().size())); | 104 web_view_->resize(gfx::Size(node->bounds().size())); |
105 | |
106 node->AddObserver(this); | |
sky
2014/07/14 19:15:27
You need to remove this observer too.
hansmuller
2014/07/14 22:16:42
Done.
| |
105 } | 107 } |
106 | 108 |
107 void HTMLDocumentView::Load(URLResponsePtr response) { | 109 void HTMLDocumentView::Load(URLResponsePtr response) { |
108 DCHECK(web_view_); | 110 DCHECK(web_view_); |
109 | 111 |
110 GURL url(response->url); | 112 GURL url(response->url); |
111 | 113 |
112 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; | 114 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; |
113 extra_data->synthetic_response = response.Pass(); | 115 extra_data->synthetic_response = response.Pass(); |
114 | 116 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 | 179 |
178 void HTMLDocumentView::OnViewInputEvent(view_manager::View* view, | 180 void HTMLDocumentView::OnViewInputEvent(view_manager::View* view, |
179 const EventPtr& event) { | 181 const EventPtr& event) { |
180 scoped_ptr<blink::WebInputEvent> web_event = | 182 scoped_ptr<blink::WebInputEvent> web_event = |
181 TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( | 183 TypeConverter<EventPtr, scoped_ptr<blink::WebInputEvent> >::ConvertTo( |
182 event); | 184 event); |
183 if (web_event) | 185 if (web_event) |
184 web_view_->handleInputEvent(*web_event); | 186 web_view_->handleInputEvent(*web_event); |
185 } | 187 } |
186 | 188 |
189 void HTMLDocumentView::OnNodeBoundsChanged(view_manager::Node* node, | |
190 const gfx::Rect&, | |
191 const gfx::Rect&) { | |
192 web_view_->resize(gfx::Size(node->bounds().size())); | |
sky
2014/07/14 19:15:27
You don't need the gfx::Size here. node->bounds().
hansmuller
2014/07/14 22:16:42
Done.
| |
193 } | |
194 | |
187 void HTMLDocumentView::Repaint() { | 195 void HTMLDocumentView::Repaint() { |
188 repaint_pending_ = false; | 196 repaint_pending_ = false; |
189 | 197 |
190 web_view_->animate(0.0); | 198 web_view_->animate(0.0); |
191 web_view_->layout(); | 199 web_view_->layout(); |
192 | 200 |
193 int width = web_view_->size().width; | 201 int width = web_view_->size().width; |
194 int height = web_view_->size().height; | 202 int height = web_view_->size().height; |
195 | 203 |
196 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( | 204 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(SkCanvas::NewRaster( |
197 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); | 205 SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType))); |
198 | 206 |
199 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); | 207 web_view_->paint(canvas.get(), gfx::Rect(0, 0, width, height)); |
200 | 208 |
201 view_->SetContents(canvas->getDevice()->accessBitmap(false)); | 209 view_->SetContents(canvas->getDevice()->accessBitmap(false)); |
202 } | 210 } |
203 | 211 |
204 } // namespace examples | 212 } // namespace examples |
205 } // namespace mojo | 213 } // namespace mojo |
OLD | NEW |