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
pdf / input_utils.cc [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "pdf/input_utils.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/common/input/web_pointer_properties.h"
namespace chrome_pdf {
blink::WebMouseEvent NormalizeMouseEvent(const blink::WebMouseEvent& event) {
blink::WebMouseEvent normalized_event = event;
#if BUILDFLAG(IS_MAC)
using Modifiers = blink::WebInputEvent::Modifiers;
if ((event.GetModifiers() & Modifiers::kControlKey) &&
event.button == blink::WebPointerProperties::Button::kLeft &&
event.GetType() == blink::WebInputEvent::Type::kMouseDown) {
constexpr int kUnsetModifiers =
Modifiers::kControlKey | Modifiers::kLeftButtonDown;
normalized_event.SetModifiers((event.GetModifiers() & ~kUnsetModifiers) |
Modifiers::kRightButtonDown);
normalized_event.button = blink::WebPointerProperties::Button::kRight;
}
#endif
return normalized_event;
}
} // namespace chrome_pdf