File: direct_manipulation_test_helper_win.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (87 lines) | stat: -rw-r--r-- 3,333 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_DIRECT_MANIPULATION_TEST_HELPER_WIN_H_
#define CONTENT_BROWSER_RENDERER_HOST_DIRECT_MANIPULATION_TEST_HELPER_WIN_H_

#include <windows.h>

#include <directmanipulation.h>
#include <wrl.h>

#include <array>

namespace content {
class PrecisionTouchpadBrowserTest;

// Size of the |transforms_| array. The DirectManipulationContent API specifies
// that the size is always 6 for direct manipulation transforms.
inline constexpr int kTransformMatrixSize = 6;

// This class is used for setting up mock content to be used for testing direct
// manipulation and precision touchpad code paths. Most of its methods aren't
// used, and its only real purpose is to store, update, and provide the
// transforms scale, scroll_x, and scroll_y.
class MockDirectManipulationContent
    : public Microsoft::WRL::RuntimeClass<
          Microsoft::WRL::RuntimeClassFlags<
              Microsoft::WRL::RuntimeClassType::ClassicCom>,
          Microsoft::WRL::Implements<
              Microsoft::WRL::RuntimeClassFlags<
                  Microsoft::WRL::RuntimeClassType::ClassicCom>,
              Microsoft::WRL::FtmBase,
              IDirectManipulationContent>> {
 public:
  MockDirectManipulationContent();

  MockDirectManipulationContent(const MockDirectManipulationContent&) = delete;
  MockDirectManipulationContent& operator=(
      const MockDirectManipulationContent&) = delete;

  // IDirectManipulationContent:
  ~MockDirectManipulationContent() override;

  void SetContentTransform(float scale, float scroll_x, float scroll_y);

  // IDirectManipulationContent:
  HRESULT STDMETHODCALLTYPE GetContentTransform(float* transforms,
                                                DWORD point_count) override;

  // Other Overrides, also from IDirectManipulationContent
  HRESULT STDMETHODCALLTYPE GetContentRect(RECT* contentSize) override;

  HRESULT STDMETHODCALLTYPE SetContentRect(const RECT* contentSize) override;

  HRESULT STDMETHODCALLTYPE GetViewport(REFIID riid, void** object) override;

  HRESULT STDMETHODCALLTYPE GetTag(REFIID riid,
                                   void** object,
                                   UINT32* id) override;

  HRESULT STDMETHODCALLTYPE SetTag(IUnknown* object, UINT32 id) override;

  HRESULT STDMETHODCALLTYPE GetOutputTransform(float* matrix,
                                               DWORD point_count) override;

  HRESULT STDMETHODCALLTYPE SyncContentTransform(const float* matrix,
                                                 DWORD point_count) override;

 private:
  friend class PrecisionTouchpadBrowserTest;

  // IDirectManipulationContent provides a 3x2 transform matrix, written out
  // flatly as M = [(1,1), (1,2), (2,1), (2,2), (3,1), (3,2)].
  // Each element stores the following information:
  // (1,1) - x scale
  // (1,2) - y rotation (0 when rotation is not allowed, such as in Chromium)
  // (2,1) - x rotation (0 when rotation is not allowed)
  // (2,2) - y scale
  // (3,1) - x offset
  // (3,2) - y offset.
  std::array<float, kTransformMatrixSize> transforms_;
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_DIRECT_MANIPULATION_TEST_HELPER_WIN_H_