| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 1652 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 1653 DCHECK(it != picture_layers_.end()); | 1653 DCHECK(it != picture_layers_.end()); |
| 1654 picture_layers_.erase(it); | 1654 picture_layers_.erase(it); |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 void LayerTreeImpl::RegisterScrollbar(ScrollbarLayerImplBase* scrollbar_layer) { | 1657 void LayerTreeImpl::RegisterScrollbar(ScrollbarLayerImplBase* scrollbar_layer) { |
| 1658 ElementId scroll_element_id = scrollbar_layer->scroll_element_id(); | 1658 ElementId scroll_element_id = scrollbar_layer->scroll_element_id(); |
| 1659 if (!scroll_element_id) | 1659 if (!scroll_element_id) |
| 1660 return; | 1660 return; |
| 1661 | 1661 |
| 1662 element_id_to_scrollbar_layer_ids_.insert( | 1662 if (scrollbar_layer->orientation() == HORIZONTAL) { |
| 1663 std::pair<ElementId, int>(scroll_element_id, scrollbar_layer->id())); | 1663 element_id_to_scrollbar_layer_ids_[scroll_element_id].horizontal = |
| 1664 scrollbar_layer->id(); |
| 1665 } else { |
| 1666 element_id_to_scrollbar_layer_ids_[scroll_element_id].vertical = |
| 1667 scrollbar_layer->id(); |
| 1668 } |
| 1669 |
| 1664 if (IsActiveTree() && scrollbar_layer->is_overlay_scrollbar()) { | 1670 if (IsActiveTree() && scrollbar_layer->is_overlay_scrollbar()) { |
| 1665 layer_tree_host_impl_->RegisterScrollbarAnimationController( | 1671 layer_tree_host_impl_->RegisterScrollbarAnimationController( |
| 1666 scroll_element_id, scrollbar_layer->Opacity()); | 1672 scroll_element_id, scrollbar_layer->Opacity()); |
| 1667 } | 1673 } |
| 1668 | 1674 |
| 1669 // TODO(pdr): Refactor DidUpdateScrollState to use ElementIds instead of | 1675 // TODO(pdr): Refactor DidUpdateScrollState to use ElementIds instead of |
| 1670 // layer ids and remove this use of LayerIdByElementId. | 1676 // layer ids and remove this use of LayerIdByElementId. |
| 1671 DidUpdateScrollState(LayerIdByElementId(scroll_element_id)); | 1677 DidUpdateScrollState(LayerIdByElementId(scroll_element_id)); |
| 1672 } | 1678 } |
| 1673 | 1679 |
| 1674 void LayerTreeImpl::UnregisterScrollbar( | 1680 void LayerTreeImpl::UnregisterScrollbar( |
| 1675 ScrollbarLayerImplBase* scrollbar_layer) { | 1681 ScrollbarLayerImplBase* scrollbar_layer) { |
| 1676 ElementId scroll_element_id = scrollbar_layer->scroll_element_id(); | 1682 ElementId scroll_element_id = scrollbar_layer->scroll_element_id(); |
| 1677 if (!scroll_element_id) | 1683 if (!scroll_element_id) |
| 1678 return; | 1684 return; |
| 1679 | 1685 |
| 1680 auto scrollbar_range = | 1686 bool no_remaining_scrollbars = false; |
| 1681 element_id_to_scrollbar_layer_ids_.equal_range(scroll_element_id); | 1687 auto& scrollbar_ids = element_id_to_scrollbar_layer_ids_[scroll_element_id]; |
| 1682 for (auto i = scrollbar_range.first; i != scrollbar_range.second; ++i) | 1688 if (scrollbar_layer->orientation() == HORIZONTAL) { |
| 1683 if (i->second == scrollbar_layer->id()) { | 1689 scrollbar_ids.horizontal = Layer::INVALID_ID; |
| 1684 element_id_to_scrollbar_layer_ids_.erase(i); | 1690 if (scrollbar_ids.vertical == Layer::INVALID_ID) |
| 1685 break; | 1691 no_remaining_scrollbars = true; |
| 1692 } else { |
| 1693 scrollbar_ids.vertical = Layer::INVALID_ID; |
| 1694 if (scrollbar_ids.horizontal == Layer::INVALID_ID) |
| 1695 no_remaining_scrollbars = true; |
| 1696 } |
| 1697 |
| 1698 if (no_remaining_scrollbars) { |
| 1699 element_id_to_scrollbar_layer_ids_.erase(scroll_element_id); |
| 1700 if (IsActiveTree()) { |
| 1701 layer_tree_host_impl_->UnregisterScrollbarAnimationController( |
| 1702 scroll_element_id); |
| 1686 } | 1703 } |
| 1687 | |
| 1688 if (IsActiveTree() && | |
| 1689 element_id_to_scrollbar_layer_ids_.count(scroll_element_id) == 0) { | |
| 1690 layer_tree_host_impl_->UnregisterScrollbarAnimationController( | |
| 1691 scroll_element_id); | |
| 1692 } | 1704 } |
| 1693 } | 1705 } |
| 1694 | 1706 |
| 1695 ScrollbarSet LayerTreeImpl::ScrollbarsFor(ElementId scroll_element_id) const { | 1707 ScrollbarSet LayerTreeImpl::ScrollbarsFor(ElementId scroll_element_id) const { |
| 1696 ScrollbarSet scrollbars; | 1708 ScrollbarSet scrollbars; |
| 1697 auto scrollbar_range = | 1709 auto it = element_id_to_scrollbar_layer_ids_.find(scroll_element_id); |
| 1698 element_id_to_scrollbar_layer_ids_.equal_range(scroll_element_id); | 1710 if (it != element_id_to_scrollbar_layer_ids_.end()) { |
| 1699 for (auto i = scrollbar_range.first; i != scrollbar_range.second; ++i) | 1711 const ScrollbarLayerIds& layer_ids = it->second; |
| 1700 scrollbars.insert(LayerById(i->second)->ToScrollbarLayer()); | 1712 if (layer_ids.horizontal != Layer::INVALID_ID) |
| 1713 scrollbars.insert(LayerById(layer_ids.horizontal)->ToScrollbarLayer()); |
| 1714 if (layer_ids.vertical != Layer::INVALID_ID) |
| 1715 scrollbars.insert(LayerById(layer_ids.vertical)->ToScrollbarLayer()); |
| 1716 } |
| 1701 return scrollbars; | 1717 return scrollbars; |
| 1702 } | 1718 } |
| 1703 | 1719 |
| 1704 void LayerTreeImpl::RegisterScrollLayer(LayerImpl* layer) { | 1720 void LayerTreeImpl::RegisterScrollLayer(LayerImpl* layer) { |
| 1705 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID) | 1721 if (layer->scroll_clip_layer_id() == Layer::INVALID_ID) |
| 1706 return; | 1722 return; |
| 1707 | 1723 |
| 1708 clip_scroll_map_.insert( | 1724 clip_scroll_map_.insert( |
| 1709 std::pair<int, int>(layer->scroll_clip_layer_id(), layer->id())); | 1725 std::pair<int, int>(layer->scroll_clip_layer_id(), layer->id())); |
| 1710 | 1726 |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 | 2117 |
| 2102 void LayerTreeImpl::ResetAllChangeTracking() { | 2118 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2103 layers_that_should_push_properties_.clear(); | 2119 layers_that_should_push_properties_.clear(); |
| 2104 // Iterate over all layers, including masks. | 2120 // Iterate over all layers, including masks. |
| 2105 for (auto& layer : *layers_) | 2121 for (auto& layer : *layers_) |
| 2106 layer->ResetChangeTracking(); | 2122 layer->ResetChangeTracking(); |
| 2107 property_trees_.ResetAllChangeTracking(); | 2123 property_trees_.ResetAllChangeTracking(); |
| 2108 } | 2124 } |
| 2109 | 2125 |
| 2110 } // namespace cc | 2126 } // namespace cc |
| OLD | NEW |