Commit 8e2c9408 authored by sangseok.jang's avatar sangseok.jang Committed by Commit Bot

Change the order of handling inkdrop and mouse event

 InkDrop is handled before View::OnMouseEvent() in OnMouseEvent().
So, If I want to override the functions associated with InkDrop(ex : CreateInkDropHighlight()),
there is a problem with not getting the something appropriate(ex. Button::STATE).

 But, changing the order of handling inkdrop and mouse event causes crashes on windows.
(See, http:://www.crbug.org/902279.)
The cause of this crashes is calling views::OnMouseEvent() might delete "this".
So We Check if it's being detroyed to avoid crashes.


Bug: none
Change-Id: I2051ddbff9d674418c42e8fd81fcd9a4ab47a984
Reviewed-on: https://chromium-review.googlesource.com/c/1335068Reviewed-by: default avatarMohsen Izadi <mohsen@chromium.org>
Commit-Queue: Mohsen Izadi <mohsen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611513}
parent a403b514
......@@ -230,6 +230,12 @@ void InkDropHostView::OnBlur() {
}
void InkDropHostView::OnMouseEvent(ui::MouseEvent* event) {
auto weak_ptr = weak_factory_.GetWeakPtr();
View::OnMouseEvent(event);
if (!weak_ptr) {
// Calling View::OnMouseEvent() might destroy |this|.
return;
}
switch (event->type()) {
case ui::ET_MOUSE_ENTERED:
GetInkDrop()->SetHovered(true);
......@@ -243,7 +249,6 @@ void InkDropHostView::OnMouseEvent(ui::MouseEvent* event) {
default:
break;
}
View::OnMouseEvent(event);
}
std::unique_ptr<InkDropImpl> InkDropHostView::CreateDefaultInkDropImpl() {
......
......@@ -205,6 +205,8 @@ class VIEWS_EXPORT InkDropHostView : public View {
std::unique_ptr<views::InkDropMask> ink_drop_mask_;
base::WeakPtrFactory<InkDropHostView> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(InkDropHostView);
};
......
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