Commit 72d99358 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[VizHitTesting] Update cc::Layer hit_testable logic in ui::Layer

Prior to crrev.com/c/1452790, a cc::Layer created by ui::Layer was
hit testable if its type_ != LAYER_NOT_DRAWN. That patch updated the
logic with new hit testable critia but it missed the initial assignment.
This patch addresses that issue and defines a helper function to check
hit testability to avoid breakage in the future.

Bug: 924294
Change-Id: I6957539cbfddc12ae24a35c451186c21ff85246c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1785080Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696029}
parent 2645895e
......@@ -651,7 +651,7 @@ void Layer::SetAcceptEvents(bool accept_events) {
if (accept_events_ == accept_events)
return;
accept_events_ = accept_events;
cc_layer_->SetHitTestable(visible_ && accept_events_);
cc_layer_->SetHitTestable(IsHitTestableForCC());
}
bool Layer::GetTargetVisibility() const {
......@@ -776,7 +776,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
cc_layer_->SetTransformOrigin(gfx::Point3F());
cc_layer_->SetContentsOpaque(fills_bounds_opaquely_);
cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
cc_layer_->SetHitTestable(visible_ && accept_events_);
cc_layer_->SetHitTestable(IsHitTestableForCC());
cc_layer_->SetHideLayerAndSubtree(!visible_);
cc_layer_->SetBackdropFilterQuality(backdrop_filter_quality_);
cc_layer_->SetElementId(cc::ElementId(cc_layer_->id()));
......@@ -1416,7 +1416,7 @@ void Layer::SetVisibilityFromAnimation(bool visible,
visible_ = visible;
cc_layer_->SetHideLayerAndSubtree(!visible_);
cc_layer_->SetHitTestable(visible_ && accept_events_);
cc_layer_->SetHitTestable(IsHitTestableForCC());
}
void Layer::SetBrightnessFromAnimation(float brightness,
......@@ -1544,9 +1544,7 @@ void Layer::CreateCcLayer() {
cc_layer_->SetContentsOpaque(true);
cc_layer_->SetSafeOpaqueBackgroundColor(SK_ColorWHITE);
cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
// TODO(sunxd): Allow ui::Layers to set if they accept events or not. See
// https://crbug.com/924294.
cc_layer_->SetHitTestable(type_ != LAYER_NOT_DRAWN);
cc_layer_->SetHitTestable(IsHitTestableForCC());
cc_layer_->SetLayerClient(weak_ptr_factory_.GetWeakPtr());
cc_layer_->SetElementId(cc::ElementId(cc_layer_->id()));
RecomputePosition();
......
......@@ -603,6 +603,8 @@ class COMPOSITOR_EXPORT Layer : public LayerAnimationDelegate,
// |subtree_reflecting_layers_| list accordingly.
void ResetSubtreeReflectedLayer();
bool IsHitTestableForCC() const { return visible_ && accept_events_; }
const LayerType type_;
Compositor* compositor_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment