OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/html_viewer/html_frame_tree_manager.h" | 5 #include "components/html_viewer/html_frame_tree_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(ChangeIdAdvancedNotifier); | 62 DISALLOW_COPY_AND_ASSIGN(ChangeIdAdvancedNotifier); |
63 }; | 63 }; |
64 | 64 |
65 // static | 65 // static |
66 HTMLFrameTreeManager::TreeMap* HTMLFrameTreeManager::instances_ = nullptr; | 66 HTMLFrameTreeManager::TreeMap* HTMLFrameTreeManager::instances_ = nullptr; |
67 | 67 |
68 // static | 68 // static |
69 HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree( | 69 HTMLFrame* HTMLFrameTreeManager::CreateFrameAndAttachToTree( |
70 GlobalState* global_state, | 70 GlobalState* global_state, |
71 mus::View* view, | 71 mojo::View* view, |
72 scoped_ptr<DocumentResourceWaiter> resource_waiter, | 72 scoped_ptr<DocumentResourceWaiter> resource_waiter, |
73 HTMLFrameDelegate* delegate) { | 73 HTMLFrameDelegate* delegate) { |
74 if (!instances_) | 74 if (!instances_) |
75 instances_ = new TreeMap; | 75 instances_ = new TreeMap; |
76 | 76 |
77 mojo::InterfaceRequest<web_view::FrameTreeClient> frame_tree_client_request; | 77 mojo::InterfaceRequest<web_view::FrameTreeClient> frame_tree_client_request; |
78 web_view::FrameTreeServerPtr frame_tree_server; | 78 web_view::FrameTreeServerPtr frame_tree_server; |
79 mojo::Array<web_view::FrameDataPtr> frame_data; | 79 mojo::Array<web_view::FrameDataPtr> frame_data; |
80 uint32_t change_id; | 80 uint32_t change_id; |
81 uint32_t view_id; | 81 uint32_t view_id; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 HTMLFrameTreeManager::~HTMLFrameTreeManager() { | 202 HTMLFrameTreeManager::~HTMLFrameTreeManager() { |
203 DCHECK(!root_ || !local_root_); | 203 DCHECK(!root_ || !local_root_); |
204 RemoveFromInstances(); | 204 RemoveFromInstances(); |
205 | 205 |
206 FOR_EACH_OBSERVER(HTMLFrameTreeManagerObserver, observers_, | 206 FOR_EACH_OBSERVER(HTMLFrameTreeManagerObserver, observers_, |
207 OnHTMLFrameTreeManagerDestroyed()); | 207 OnHTMLFrameTreeManagerDestroyed()); |
208 } | 208 } |
209 | 209 |
210 void HTMLFrameTreeManager::Init( | 210 void HTMLFrameTreeManager::Init( |
211 HTMLFrameDelegate* delegate, | 211 HTMLFrameDelegate* delegate, |
212 mus::View* local_view, | 212 mojo::View* local_view, |
213 const mojo::Array<web_view::FrameDataPtr>& frame_data, | 213 const mojo::Array<web_view::FrameDataPtr>& frame_data, |
214 uint32_t change_id) { | 214 uint32_t change_id) { |
215 change_id_ = change_id; | 215 change_id_ = change_id; |
216 root_ = BuildFrameTree(delegate, frame_data, local_view->id(), local_view); | 216 root_ = BuildFrameTree(delegate, frame_data, local_view->id(), local_view); |
217 local_root_ = root_->FindFrame(local_view->id()); | 217 local_root_ = root_->FindFrame(local_view->id()); |
218 CHECK(local_root_); | 218 CHECK(local_root_); |
219 local_root_->UpdateFocus(); | 219 local_root_->UpdateFocus(); |
220 } | 220 } |
221 | 221 |
222 HTMLFrame* HTMLFrameTreeManager::BuildFrameTree( | 222 HTMLFrame* HTMLFrameTreeManager::BuildFrameTree( |
223 HTMLFrameDelegate* delegate, | 223 HTMLFrameDelegate* delegate, |
224 const mojo::Array<web_view::FrameDataPtr>& frame_data, | 224 const mojo::Array<web_view::FrameDataPtr>& frame_data, |
225 uint32_t local_frame_id, | 225 uint32_t local_frame_id, |
226 mus::View* local_view) { | 226 mojo::View* local_view) { |
227 std::vector<HTMLFrame*> parents; | 227 std::vector<HTMLFrame*> parents; |
228 HTMLFrame* root = nullptr; | 228 HTMLFrame* root = nullptr; |
229 HTMLFrame* last_frame = nullptr; | 229 HTMLFrame* last_frame = nullptr; |
230 for (size_t i = 0; i < frame_data.size(); ++i) { | 230 for (size_t i = 0; i < frame_data.size(); ++i) { |
231 if (last_frame && frame_data[i]->parent_id == last_frame->id()) { | 231 if (last_frame && frame_data[i]->parent_id == last_frame->id()) { |
232 parents.push_back(last_frame); | 232 parents.push_back(last_frame); |
233 } else if (!parents.empty()) { | 233 } else if (!parents.empty()) { |
234 while (parents.back()->id() != frame_data[i]->parent_id) | 234 while (parents.back()->id() != frame_data[i]->parent_id) |
235 parents.pop_back(); | 235 parents.pop_back(); |
236 } | 236 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 mojo::Array<uint8_t> new_data) { | 355 mojo::Array<uint8_t> new_data) { |
356 if (source != local_root_) | 356 if (source != local_root_) |
357 return; | 357 return; |
358 | 358 |
359 HTMLFrame* frame = root_->FindFrame(frame_id); | 359 HTMLFrame* frame = root_->FindFrame(frame_id); |
360 if (frame) | 360 if (frame) |
361 frame->SetValueFromClientProperty(name, new_data.Pass()); | 361 frame->SetValueFromClientProperty(name, new_data.Pass()); |
362 } | 362 } |
363 | 363 |
364 } // namespace mojo | 364 } // namespace mojo |
OLD | NEW |