Chromium Code Reviews| Index: mojo/examples/html_viewer/html_document_view.cc |
| diff --git a/mojo/examples/html_viewer/html_document_view.cc b/mojo/examples/html_viewer/html_document_view.cc |
| index 654161abd64e0fc51d93d9b056e341d985357cc0..b6d6df1cec62c0ccb305f4de39e50d5d8f58c8ff 100644 |
| --- a/mojo/examples/html_viewer/html_document_view.cc |
| +++ b/mojo/examples/html_viewer/html_document_view.cc |
| @@ -80,6 +80,7 @@ HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, |
| : view_manager_(view_manager), |
| view_(view_manager::View::Create(view_manager_)), |
| web_view_(NULL), |
| + root_(NULL), |
| repaint_pending_(false), |
| navigator_host_(service_provider), |
| weak_factory_(this) { |
| @@ -88,20 +89,23 @@ HTMLDocumentView::HTMLDocumentView(ServiceProvider* service_provider, |
| HTMLDocumentView::~HTMLDocumentView() { |
| view_->RemoveObserver(this); |
| - |
| if (web_view_) |
| web_view_->close(); |
| + if (root_) |
| + root_->RemoveObserver(this); |
| } |
| void HTMLDocumentView::AttachToNode(view_manager::Node* node) { |
| - node->SetActiveView(view_); |
| + root_ = node; |
| + root_->SetActiveView(view_); |
| view_->SetColor(SK_ColorCYAN); // Dummy background color. |
| web_view_ = blink::WebView::create(this); |
| ConfigureSettings(web_view_->settings()); |
| web_view_->setMainFrame(blink::WebLocalFrame::create(this)); |
| + web_view_->resize(root_->bounds().size()); |
| - web_view_->resize(gfx::Size(node->bounds().size())); |
| + root_->AddObserver(this); |
| } |
| void HTMLDocumentView::Load(URLResponsePtr response) { |
| @@ -184,6 +188,20 @@ void HTMLDocumentView::OnViewInputEvent(view_manager::View* view, |
| web_view_->handleInputEvent(*web_event); |
| } |
| +// Overridden from NodeObserver: |
|
sky
2014/07/15 00:07:49
Style guide says not to duplicate comments like th
hansmuller
2014/07/15 00:27:43
Done.
|
| +void HTMLDocumentView::OnNodeBoundsChanged(view_manager::Node* node, |
| + const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) { |
| + DCHECK_EQ(node, root_); |
| + web_view_->resize(node->bounds().size()); |
| +} |
| + |
| +// Overridden from NodeObserver: |
| +void HTMLDocumentView::OnNodeDestroying(view_manager::Node* node) { |
| + DCHECK_EQ(node, root_); |
| + node->RemoveObserver(this); |
|
sky
2014/07/15 00:07:49
Shouldn't you set root_ to NULL here too? This com
hansmuller
2014/07/15 00:27:43
That implies that other NodeObserver methods can't
sky
2014/07/15 04:08:37
By adding this override you're saying root_ may be
|
| +} |
| + |
| void HTMLDocumentView::Repaint() { |
| repaint_pending_ = false; |