Skip to content

Commit fd0b57f

Browse files
authored
1 parent 1e50380 commit fd0b57f

File tree

3 files changed

+1095
-0
lines changed

3 files changed

+1095
-0
lines changed

patches/common/chromium/.patches

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,5 @@ fix_use_weakptr_to_detect_deletion.patch
8484
fix_disabling_compositor_recycling.patch
8585
allow_new_privileges_in_unsandboxed_child_processes.patch
8686
fix_add_more_checks_in_mojocdmservice.patch
87+
recreate_directmanipulationhelper_when_every_lrwhh_updateparent.patch
88+
notify_directmanipulationeventhandler_when_directmanipulationhelper.patch
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Siye Liu <siliu@microsoft.com>
3+
Date: Thu, 15 Aug 2019 02:30:05 +0000
4+
Subject: Notify DirectManipulationEventHandler when DirectManipulationHelper
5+
is destructed.
6+
7+
The crash report shows that DirectManipulation may call
8+
|DirectManipulationEventHandler::OnInteraction| after
9+
DirectManipulationHelper is destroyed. Since |OnInteraction| is relying
10+
on DirectManipulationHelper to add/remove animation observer, we should
11+
set the pointer to DirectManipulationHelper to nullptr after it is
12+
destroyed.
13+
14+
In this CL, we set the pointer to DirectManipulationHelper in separate
15+
function |SetDirectManipulationHelper| instead of passing the pointer
16+
during ctor of DirectManipulationEventHandler.
17+
18+
Bug: 993260
19+
Change-Id: Id781af047e72268532d861920a077a0c6b1650bb
20+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1753661
21+
Reviewed-by: Scott Violet <sky@chromium.org>
22+
Commit-Queue: Siye Liu <siliu@microsoft.com>
23+
Cr-Commit-Position: refs/heads/master@{#687125}
24+
25+
diff --git a/content/browser/renderer_host/direct_manipulation_event_handler_win.cc b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc
26+
index 33ce63d8d0f59573cb4764f146b4f88008cca4a8..bae879411fb253a810034eb2cb531a54530a4183 100644
27+
--- a/content/browser/renderer_host/direct_manipulation_event_handler_win.cc
28+
+++ b/content/browser/renderer_host/direct_manipulation_event_handler_win.cc
29+
@@ -28,9 +28,8 @@ bool FloatEquals(float f1, float f2) {
30+
} // namespace
31+
32+
DirectManipulationEventHandler::DirectManipulationEventHandler(
33+
- DirectManipulationHelper* helper,
34+
ui::WindowEventTarget* event_target)
35+
- : helper_(helper), event_target_(event_target) {}
36+
+ : event_target_(event_target) {}
37+
38+
bool DirectManipulationEventHandler::SetViewportSizeInPixels(
39+
const gfx::Size& viewport_size_in_pixels) {
40+
@@ -45,6 +44,11 @@ void DirectManipulationEventHandler::SetDeviceScaleFactor(
41+
device_scale_factor_ = device_scale_factor;
42+
}
43+
44+
+void DirectManipulationEventHandler::SetDirectManipulationHelper(
45+
+ DirectManipulationHelper* helper) {
46+
+ helper_ = helper;
47+
+}
48+
+
49+
DirectManipulationEventHandler::~DirectManipulationEventHandler() {}
50+
51+
void DirectManipulationEventHandler::TransitionToState(
52+
@@ -303,6 +307,9 @@ HRESULT DirectManipulationEventHandler::OnContentUpdated(
53+
HRESULT DirectManipulationEventHandler::OnInteraction(
54+
IDirectManipulationViewport2* viewport,
55+
DIRECTMANIPULATION_INTERACTION_TYPE interaction) {
56+
+ if (!helper_)
57+
+ return S_OK;
58+
+
59+
if (interaction == DIRECTMANIPULATION_INTERACTION_BEGIN) {
60+
DebugLogging("OnInteraction BEGIN.", S_OK);
61+
helper_->AddAnimationObserver();
62+
diff --git a/content/browser/renderer_host/direct_manipulation_event_handler_win.h b/content/browser/renderer_host/direct_manipulation_event_handler_win.h
63+
index f1902085032ffc95edb2d8dcd5224f1c5ecda3d2..e654c5f1a45da9e054d2c367df6f5115fa25862c 100644
64+
--- a/content/browser/renderer_host/direct_manipulation_event_handler_win.h
65+
+++ b/content/browser/renderer_host/direct_manipulation_event_handler_win.h
66+
@@ -38,14 +38,15 @@ class DirectManipulationEventHandler
67+
IDirectManipulationViewportEventHandler,
68+
IDirectManipulationInteractionEventHandler>> {
69+
public:
70+
- DirectManipulationEventHandler(DirectManipulationHelper* helper,
71+
- ui::WindowEventTarget* event_target);
72+
+ DirectManipulationEventHandler(ui::WindowEventTarget* event_target);
73+
74+
// Return true if viewport_size_in_pixels_ changed.
75+
bool SetViewportSizeInPixels(const gfx::Size& viewport_size_in_pixels);
76+
77+
void SetDeviceScaleFactor(float device_scale_factor);
78+
79+
+ void SetDirectManipulationHelper(DirectManipulationHelper* helper);
80+
+
81+
private:
82+
friend class DirectManipulationBrowserTest;
83+
friend DirectManipulationUnitTest;
84+
diff --git a/content/browser/renderer_host/direct_manipulation_helper_win.cc b/content/browser/renderer_host/direct_manipulation_helper_win.cc
85+
index 9401e7f8fb1fafd0532bb1e86035701c1df2ffda..6ce09b9f7b80e94c2adb582954c90afc95fc20e4 100644
86+
--- a/content/browser/renderer_host/direct_manipulation_helper_win.cc
87+
+++ b/content/browser/renderer_host/direct_manipulation_helper_win.cc
88+
@@ -78,8 +78,9 @@ DirectManipulationHelper::CreateInstanceForTesting(
89+
base::WrapUnique(new DirectManipulationHelper(0, nullptr));
90+
91+
instance->event_handler_ =
92+
- Microsoft::WRL::Make<DirectManipulationEventHandler>(instance.get(),
93+
- event_target);
94+
+ Microsoft::WRL::Make<DirectManipulationEventHandler>(event_target);
95+
+
96+
+ instance->event_handler_->SetDirectManipulationHelper(instance.get());
97+
98+
instance->viewport_ = viewport;
99+
100+
@@ -159,7 +160,9 @@ bool DirectManipulationHelper::Initialize(ui::WindowEventTarget* event_target) {
101+
}
102+
103+
event_handler_ =
104+
- Microsoft::WRL::Make<DirectManipulationEventHandler>(this, event_target);
105+
+ Microsoft::WRL::Make<DirectManipulationEventHandler>(event_target);
106+
+
107+
+ event_handler_->SetDirectManipulationHelper(this);
108+
109+
// We got Direct Manipulation transform from
110+
// IDirectManipulationViewportEventHandler.
111+
@@ -265,6 +268,7 @@ void DirectManipulationHelper::Destroy() {
112+
if (has_animation_observer_)
113+
RemoveAnimationObserver();
114+
compositor_ = nullptr;
115+
+ event_handler_->SetDirectManipulationHelper(nullptr);
116+
117+
HRESULT hr;
118+
if (viewport_) {

0 commit comments

Comments
 (0)