Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e94d531

Browse files
committed
[Windows] Mark move-only classes as such
Applies the FML_DISALLOW_COPY_AND_ASSIGN to non-POD types in the Windows embedder. No new tests since no semantic change. Only has the compile-time effect of preventing copying of classes intended to be move-only.
1 parent e7fde3f commit e94d531

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+223
-101
lines changed

shell/platform/windows/accessibility_bridge_windows.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_WINDOWS_H_
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_ACCESSIBILITY_BRIDGE_WINDOWS_H_
77

8+
#include "flutter/fml/macros.h"
89
#include "flutter/shell/platform/common/accessibility_bridge.h"
910
#include "flutter/third_party/accessibility/ax/platform/ax_fragment_root_delegate_win.h"
1011

@@ -71,6 +72,8 @@ class AccessibilityBridgeWindows : public AccessibilityBridge,
7172
private:
7273
FlutterWindowsEngine* engine_;
7374
FlutterWindowsView* view_;
75+
76+
FML_DISALLOW_COPY_AND_ASSIGN(AccessibilityBridgeWindows);
7477
};
7578

7679
} // namespace flutter

shell/platform/windows/accessibility_bridge_windows_unittests.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <vector>
1212

13+
#include "flutter/fml/macros.h"
1314
#include "flutter/shell/platform/embedder/embedder.h"
1415
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
1516
#include "flutter/shell/platform/windows/flutter_platform_node_delegate_windows.h"
@@ -66,6 +67,8 @@ class AccessibilityBridgeWindowsSpy : public AccessibilityBridgeWindows {
6667
private:
6768
std::vector<MsaaEvent> dispatched_events_;
6869
std::vector<int32_t> focused_nodes_;
70+
71+
FML_DISALLOW_COPY_AND_ASSIGN(AccessibilityBridgeWindowsSpy);
6972
};
7073

7174
// A FlutterWindowsEngine whose accessibility bridge is a
@@ -81,6 +84,9 @@ class FlutterWindowsEngineSpy : public FlutterWindowsEngine {
8184
FlutterWindowsView* view) override {
8285
return std::make_shared<AccessibilityBridgeWindowsSpy>(engine, view);
8386
}
87+
88+
private:
89+
FML_DISALLOW_COPY_AND_ASSIGN(FlutterWindowsEngineSpy);
8490
};
8591

8692
// Returns an engine instance configured with dummy project path values, and

shell/platform/windows/angle_surface_manager.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#include <wrl/client.h>
1919
#include <memory>
2020

21-
#include "window_binding_handler.h"
21+
#include "flutter/fml/macros.h"
22+
#include "flutter/shell/platform/windows/window_binding_handler.h"
2223

2324
namespace flutter {
2425

@@ -29,10 +30,6 @@ class AngleSurfaceManager {
2930
static std::unique_ptr<AngleSurfaceManager> Create();
3031
~AngleSurfaceManager();
3132

32-
// Disallow copy/move.
33-
AngleSurfaceManager(const AngleSurfaceManager&) = delete;
34-
AngleSurfaceManager& operator=(const AngleSurfaceManager&) = delete;
35-
3633
// Creates an EGLSurface wrapper and backing DirectX 11 SwapChain
3734
// associated with window, in the appropriate format for display.
3835
// Target represents the visual entity to bind to. Width and
@@ -125,6 +122,8 @@ class AngleSurfaceManager {
125122

126123
// Number of active instances of AngleSurfaceManager
127124
static int instance_count_;
125+
126+
FML_DISALLOW_COPY_AND_ASSIGN(AngleSurfaceManager);
128127
};
129128

130129
} // namespace flutter

shell/platform/windows/cursor_handler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <unordered_map>
99

10+
#include "flutter/fml/macros.h"
1011
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
1112
#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h"
1213
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h"
@@ -37,6 +38,8 @@ class CursorHandler {
3738

3839
// The cache map for custom cursors.
3940
std::unordered_map<std::string, HCURSOR> custom_cursors_;
41+
42+
FML_DISALLOW_COPY_AND_ASSIGN(CursorHandler);
4043
};
4144

4245
// Create a cursor from a rawBGRA buffer and the cursor info.

shell/platform/windows/cursor_handler_unittests.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <memory>
77
#include <vector>
88

9+
#include "flutter/fml/macros.h"
910
#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_result_functions.h"
1011
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
1112
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h"
@@ -53,6 +54,10 @@ void SimulateCursorMessage(TestBinaryMessenger* messenger,
5354
} // namespace
5455

5556
class CursorHandlerTest : public WindowsTest {
57+
public:
58+
CursorHandlerTest() = default;
59+
virtual ~CursorHandlerTest() = default;
60+
5661
protected:
5762
FlutterWindowsEngine* engine() { return engine_.get(); }
5863
FlutterWindowsView* view() { return view_.get(); }
@@ -83,6 +88,8 @@ class CursorHandlerTest : public WindowsTest {
8388
std::unique_ptr<FlutterWindowsEngine> engine_;
8489
std::unique_ptr<FlutterWindowsView> view_;
8590
MockWindowBindingHandler* window_;
91+
92+
FML_DISALLOW_COPY_AND_ASSIGN(CursorHandlerTest);
8693
};
8794

8895
TEST_F(CursorHandlerTest, ActivateSystemCursor) {

shell/platform/windows/direct_manipulation_unittests.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// found in the LICENSE file.
44

55
#include "flutter/shell/platform/windows/direct_manipulation.h"
6-
#include "flutter/shell/platform/windows/testing/mock_window_binding_handler_delegate.h"
76

7+
#include "flutter/fml/macros.h"
8+
#include "flutter/shell/platform/windows/testing/mock_window_binding_handler_delegate.h"
89
#include "gtest/gtest.h"
910

1011
using testing::_;
@@ -16,11 +17,6 @@ class MockIDirectManipulationViewport : public IDirectManipulationViewport {
1617
public:
1718
MockIDirectManipulationViewport() {}
1819

19-
// Prevent copying.
20-
MockIDirectManipulationViewport(MockIDirectManipulationViewport const&) =
21-
delete;
22-
MockIDirectManipulationViewport& operator=(
23-
MockIDirectManipulationViewport const&) = delete;
2420
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, AddRef, ULONG());
2521
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Release, ULONG());
2622
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE,
@@ -101,17 +97,15 @@ class MockIDirectManipulationViewport : public IDirectManipulationViewport {
10197
STDMETHODCALLTYPE,
10298
ZoomToRect,
10399
HRESULT(const float, const float, const float, const float, BOOL));
100+
101+
private:
102+
FML_DISALLOW_COPY_AND_ASSIGN(MockIDirectManipulationViewport);
104103
};
105104

106105
class MockIDirectManipulationContent : public IDirectManipulationContent {
107106
public:
108107
MockIDirectManipulationContent() {}
109108

110-
// Prevent copying.
111-
MockIDirectManipulationContent(MockIDirectManipulationContent const&) =
112-
delete;
113-
MockIDirectManipulationContent& operator=(
114-
MockIDirectManipulationContent const&) = delete;
115109
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, AddRef, ULONG());
116110
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Release, ULONG());
117111
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE,
@@ -139,6 +133,9 @@ class MockIDirectManipulationContent : public IDirectManipulationContent {
139133
MOCK_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE,
140134
SyncContentTransform,
141135
HRESULT(const float*, DWORD));
136+
137+
private:
138+
FML_DISALLOW_COPY_AND_ASSIGN(MockIDirectManipulationContent);
142139
};
143140

144141
TEST(DirectManipulationTest, TestGesture) {

shell/platform/windows/dpi_utils.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "dpi_utils.h"
66

7+
#include "flutter/fml/macros.h"
8+
79
namespace flutter {
810

911
namespace {
@@ -58,6 +60,8 @@ class DpiHelper {
5860
HMODULE shlib_module_ = nullptr;
5961
bool dpi_for_window_supported_ = false;
6062
bool dpi_for_monitor_supported_ = false;
63+
64+
FML_DISALLOW_COPY_AND_ASSIGN(DpiHelper);
6165
};
6266

6367
DpiHelper::DpiHelper() {

shell/platform/windows/event_watcher.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include <functional>
1111

12+
#include "flutter/fml/macros.h"
13+
1214
namespace flutter {
1315

1416
// A win32 `HANDLE` wrapper for use as a one-time callback.
@@ -28,8 +30,7 @@ class EventWatcher {
2830
HANDLE handle_;
2931
HANDLE handle_for_wait_;
3032

31-
EventWatcher(const EventWatcher&) = delete;
32-
EventWatcher& operator=(const EventWatcher&) = delete;
33+
FML_DISALLOW_COPY_AND_ASSIGN(EventWatcher);
3334
};
3435

3536
} // namespace flutter

shell/platform/windows/external_texture_d3d.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_D3D_H_
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_D3D_H_
77

8+
#include "flutter/fml/macros.h"
89
#include "flutter/shell/platform/windows/angle_surface_manager.h"
910
#include "flutter/shell/platform/windows/external_texture.h"
1011

@@ -42,6 +43,8 @@ class ExternalTextureD3d : public ExternalTexture {
4243
GLuint gl_texture_ = 0;
4344
EGLSurface egl_surface_ = EGL_NO_SURFACE;
4445
void* last_surface_handle_ = nullptr;
46+
47+
FML_DISALLOW_COPY_AND_ASSIGN(ExternalTextureD3d);
4548
};
4649

4750
} // namespace flutter

shell/platform/windows/external_texture_pixelbuffer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_PIXELBUFFER_H_
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_PIXELBUFFER_H_
77

8+
#include "flutter/fml/macros.h"
89
#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
910
#include "flutter/shell/platform/windows/external_texture.h"
1011

@@ -38,6 +39,8 @@ class ExternalTexturePixelBuffer : public ExternalTexture {
3839
void* const user_data_ = nullptr;
3940
const GlProcs& gl_;
4041
GLuint gl_texture_ = 0;
42+
43+
FML_DISALLOW_COPY_AND_ASSIGN(ExternalTexturePixelBuffer);
4144
};
4245

4346
} // namespace flutter

0 commit comments

Comments
 (0)