-bool ViewManagerServiceImpl::ShouldNotifyOnHierarchyChange(
- const Node* node,
- const Node** new_parent,
- const Node** old_parent,
- std::vector<const Node*>* to_send) {
- // If the node is not in |roots_| or was never known to this connection then
- // don't notify the client about it.
- if (node->id().connection_id != id_ &&
- known_nodes_.count(NodeIdToTransportId(node->id())) == 0 &&
- !IsNodeDescendantOfRoots(node)) {
- return false;
- }
- if (!IsNodeDescendantOfRoots(*new_parent))
- *new_parent = NULL;
- if (!IsNodeDescendantOfRoots(*old_parent))
- *old_parent = NULL;
-
- if (*new_parent) {
- // On getting a new parent we may need to communicate new nodes to the
- // client. We do that in the following cases:
- // . New parent is a descendant of the roots. In this case the client
- // already knows all ancestors, so we only have to communicate descendants
- // of node the client doesn't know about.
- // . If the client knew about the parent, we have to do the same.
- // . If the client knows about the node and is added to a tree the client
- // doesn't know about we have to communicate from the root down (the
- // client is learning about a new root).
- if (root_node_manager_->root()->Contains(*new_parent) ||
- known_nodes_.count(NodeIdToTransportId((*new_parent)->id()))) {
- GetUnknownNodesFrom(node, to_send);
- return true;
- }
- // If parent wasn't known we have to communicate from the root down.
- if (known_nodes_.count(NodeIdToTransportId(node->id()))) {
- // No need to check against |roots_| as client should always know it's
- // |roots_|.
- GetUnknownNodesFrom((*new_parent)->GetRoot(), to_send);
- return true;
- }
- }
- // Otherwise only communicate the change if the node was known. We shouldn't
- // need to communicate any nodes on a remove.
- return known_nodes_.count(NodeIdToTransportId(node->id())) > 0;
+void ViewManagerServiceImpl::RemoveChildrenAsPartOfEmbed(
+ const NodeId& node_id) {
+ Node* node = GetNode(node_id);
+ CHECK(node);
+ CHECK(node->id().connection_id == node_id.connection_id);
+ std::vector<Node*> children = node->GetChildren();
+ for (size_t i = 0; i < children.size(); ++i)
+ node->Remove(children[i]);