Commit e5cbef5a authored by karandeepb's avatar karandeepb Committed by Commit bot

MacViews: Trigger shadow invalidation when a translucent window is shown.

Currently, invalidate_shadow_on_frame_swap_ is not set when a MacViews window is
shown. It is only set when the layer is created, changed or the window resized.
This causes translucent windows like the "Restore Pages" bubble and Find-In-Page
window to not have a shadow, when they are shown after being hidden.

This CL modifies BridgedNativeWidget::OnVisibilityChanged() to trigger shadow
invalidation while showing translucent windows. This fixes the shadow for the
"Restore Pages" bubble and also of the Find-In-Page window on tab switching. A
unit test is also added which demonstrates the problem.

Note that this does not fix the shadow for the Find-In-Page window when it is
displayed initially on pressing Cmd+F.

BUG=636707, 646734

Review-Url: https://codereview.chromium.org/2336983002
Cr-Commit-Position: refs/heads/master@{#418803}
parent 514b86d0
...@@ -839,6 +839,11 @@ void BridgedNativeWidget::OnVisibilityChanged() { ...@@ -839,6 +839,11 @@ void BridgedNativeWidget::OnVisibilityChanged() {
if (layer()) { if (layer()) {
layer()->SetVisible(window_visible_); layer()->SetVisible(window_visible_);
layer()->SchedulePaint(gfx::Rect(GetClientAreaSize())); layer()->SchedulePaint(gfx::Rect(GetClientAreaSize()));
// For translucent windows which are made visible, recalculate shadow when
// the frame from the compositor arrives.
if (![window_ isOpaque])
invalidate_shadow_on_frame_swap_ = window_visible_;
} }
NotifyVisibilityChangeDown(); NotifyVisibilityChangeDown();
......
...@@ -1376,6 +1376,17 @@ TEST_F(NativeWidgetMacTest, InvalidateShadow) { ...@@ -1376,6 +1376,17 @@ TEST_F(NativeWidgetMacTest, InvalidateShadow) {
test_api.SimulateFrameSwap(gfx::Size(123, 456)); test_api.SimulateFrameSwap(gfx::Size(123, 456));
EXPECT_EQ(2, [window invalidateShadowCount]); EXPECT_EQ(2, [window invalidateShadowCount]);
// Hiding the window does not require shadow invalidation.
widget->Hide();
test_api.SimulateFrameSwap(gfx::Size(123, 456));
EXPECT_EQ(2, [window invalidateShadowCount]);
// Showing a translucent window after hiding it, should trigger shadow
// invalidation.
widget->Show();
test_api.SimulateFrameSwap(gfx::Size(123, 456));
EXPECT_EQ(3, [window invalidateShadowCount]);
widget->CloseNow(); widget->CloseNow();
} }
......
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