| Index: cc/trees/layer_tree_impl.cc
|
| diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
|
| index 175c9a4f49f218506549699fdcf7e447153ab0aa..e878c84e746312f9ebcc121312f9dfc7603f3b1d 100644
|
| --- a/cc/trees/layer_tree_impl.cc
|
| +++ b/cc/trees/layer_tree_impl.cc
|
| @@ -1659,8 +1659,14 @@ void LayerTreeImpl::RegisterScrollbar(ScrollbarLayerImplBase* scrollbar_layer) {
|
| if (!scroll_element_id)
|
| return;
|
|
|
| - element_id_to_scrollbar_layer_ids_.insert(
|
| - std::pair<ElementId, int>(scroll_element_id, scrollbar_layer->id()));
|
| + if (scrollbar_layer->orientation() == HORIZONTAL) {
|
| + element_id_to_scrollbar_layer_ids_[scroll_element_id].horizontal =
|
| + scrollbar_layer->id();
|
| + } else {
|
| + element_id_to_scrollbar_layer_ids_[scroll_element_id].vertical =
|
| + scrollbar_layer->id();
|
| + }
|
| +
|
| if (IsActiveTree() && scrollbar_layer->is_overlay_scrollbar()) {
|
| layer_tree_host_impl_->RegisterScrollbarAnimationController(
|
| scroll_element_id, scrollbar_layer->Opacity());
|
| @@ -1677,27 +1683,37 @@ void LayerTreeImpl::UnregisterScrollbar(
|
| if (!scroll_element_id)
|
| return;
|
|
|
| - auto scrollbar_range =
|
| - element_id_to_scrollbar_layer_ids_.equal_range(scroll_element_id);
|
| - for (auto i = scrollbar_range.first; i != scrollbar_range.second; ++i)
|
| - if (i->second == scrollbar_layer->id()) {
|
| - element_id_to_scrollbar_layer_ids_.erase(i);
|
| - break;
|
| - }
|
| + bool no_remaining_scrollbars = false;
|
| + auto& scrollbar_ids = element_id_to_scrollbar_layer_ids_[scroll_element_id];
|
| + if (scrollbar_layer->orientation() == HORIZONTAL) {
|
| + scrollbar_ids.horizontal = Layer::INVALID_ID;
|
| + if (scrollbar_ids.vertical == Layer::INVALID_ID)
|
| + no_remaining_scrollbars = true;
|
| + } else {
|
| + scrollbar_ids.vertical = Layer::INVALID_ID;
|
| + if (scrollbar_ids.horizontal == Layer::INVALID_ID)
|
| + no_remaining_scrollbars = true;
|
| + }
|
|
|
| - if (IsActiveTree() &&
|
| - element_id_to_scrollbar_layer_ids_.count(scroll_element_id) == 0) {
|
| - layer_tree_host_impl_->UnregisterScrollbarAnimationController(
|
| - scroll_element_id);
|
| + if (no_remaining_scrollbars) {
|
| + element_id_to_scrollbar_layer_ids_.erase(scroll_element_id);
|
| + if (IsActiveTree()) {
|
| + layer_tree_host_impl_->UnregisterScrollbarAnimationController(
|
| + scroll_element_id);
|
| + }
|
| }
|
| }
|
|
|
| ScrollbarSet LayerTreeImpl::ScrollbarsFor(ElementId scroll_element_id) const {
|
| ScrollbarSet scrollbars;
|
| - auto scrollbar_range =
|
| - element_id_to_scrollbar_layer_ids_.equal_range(scroll_element_id);
|
| - for (auto i = scrollbar_range.first; i != scrollbar_range.second; ++i)
|
| - scrollbars.insert(LayerById(i->second)->ToScrollbarLayer());
|
| + auto it = element_id_to_scrollbar_layer_ids_.find(scroll_element_id);
|
| + if (it != element_id_to_scrollbar_layer_ids_.end()) {
|
| + const ScrollbarLayerIds& layer_ids = it->second;
|
| + if (layer_ids.horizontal != Layer::INVALID_ID)
|
| + scrollbars.insert(LayerById(layer_ids.horizontal)->ToScrollbarLayer());
|
| + if (layer_ids.vertical != Layer::INVALID_ID)
|
| + scrollbars.insert(LayerById(layer_ids.vertical)->ToScrollbarLayer());
|
| + }
|
| return scrollbars;
|
| }
|
|
|
|
|