Skip to content

Commit

Permalink
[Merge to M110] Tooltip: Set parent_window_ null on hiding tooltip
Browse files Browse the repository at this point in the history
This CL resets `parent_window_` in TooltipLacros on Hide().
This aims to fix the crash on GetHost.
Without this CL, `parent_window_` stays non-null when the window is
destructed, so we sets it null on Hide() which is called when the window
is destroyed via TooltipController::OnWindowDestroyed().

(cherry picked from commit 6af0784)

Bug: 1404163
Change-Id: I14c2a0d238b3d88f35d03664e6ac11a8ee28b7b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4150449
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Eriko Kurimoto <elkurin@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1091022}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4159631
Auto-Submit: Eriko Kurimoto <elkurin@chromium.org>
Cr-Commit-Position: refs/branch-heads/5481@{#257}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
elkurin authored and Chromium LUCI CQ committed Jan 13, 2023
1 parent ccf6f1c commit 8ed154c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ui/views/corewm/tooltip_lacros.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ void TooltipLacros::Hide() {
if (platform_window) {
platform_window->HideTooltip();
}

parent_window_ = nullptr;
}

bool TooltipLacros::IsVisible() {
Expand Down
11 changes: 7 additions & 4 deletions ui/wm/public/tooltip_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ class WM_PUBLIC_EXPORT TooltipObserver : public base::CheckedObserver {
public:
~TooltipObserver() override = default;

// Called when tooltip whose parent window's toplevel window is `target` is
// shown. `bounds` is relative to `target` position.
// Called when tooltip is shown.
// `target` is a target window of show tooltip. This may be null if the target
// window is already destroyed,
// `bounds` is relative to the target window position.
// TODO(crbug.com/1385219): Use tooltip's parent window for `target`.
virtual void OnTooltipShown(aura::Window* target,
const std::u16string& text,
const gfx::Rect& bounds) = 0;

// Called when tooltip whose parent window's toplevel window is `target` is
// hidden.
// Called when tooltip is hidden.
// `target` is a target window of show tooltip. This may be null if the target
// window is already destroyed,
// TODO(crbug.com/1385219): Use tooltip's parent window for `target`.
virtual void OnTooltipHidden(aura::Window* target) = 0;
};
Expand Down

0 comments on commit 8ed154c

Please sign in to comment.