Bug 1708422: part 14) Extend documentation of `mozInlineSpellChecker::SpellCheckerTim...
[gecko.git] / dom / events / WheelEvent.h
blob502bc4ef2759d30ae1a0ed961f362e46976a8cac
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_WheelEvent_h_
8 #define mozilla_dom_WheelEvent_h_
10 #include "mozilla/dom/MouseEvent.h"
11 #include "mozilla/dom/WheelEventBinding.h"
12 #include "mozilla/EventForwards.h"
14 namespace mozilla {
15 namespace dom {
17 class WheelEvent : public MouseEvent {
18 public:
19 WheelEvent(EventTarget* aOwner, nsPresContext* aPresContext,
20 WidgetWheelEvent* aWheelEvent);
22 NS_INLINE_DECL_REFCOUNTING_INHERITED(WheelEvent, MouseEvent)
24 static already_AddRefed<WheelEvent> Constructor(const GlobalObject& aGlobal,
25 const nsAString& aType,
26 const WheelEventInit& aParam);
28 virtual JSObject* WrapObjectInternal(
29 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override {
30 return WheelEvent_Binding::Wrap(aCx, this, aGivenProto);
33 double DevToCssPixels(double aDevPxValue) const {
34 if (!mAppUnitsPerDevPixel) {
35 return aDevPxValue;
37 return aDevPxValue * mAppUnitsPerDevPixel / AppUnitsPerCSSPixel();
40 // NOTE: DeltaX(), DeltaY() and DeltaZ() return CSS pixels when deltaMode is
41 // DOM_DELTA_PIXEL. (The internal event's delta values are device pixels
42 // if it's dispatched by widget)
43 double DeltaX(CallerType);
44 double DeltaY(CallerType);
45 double DeltaZ(CallerType);
46 uint32_t DeltaMode(CallerType);
48 int32_t WheelDelta(CallerType aCallerType) {
49 int32_t y = WheelDeltaY(aCallerType);
50 return y ? y : WheelDeltaX(aCallerType);
53 static constexpr int32_t kNativeTicksToWheelDelta = 120;
54 static constexpr double kTrustedDeltaToWheelDelta = 3.0;
56 int32_t WheelDeltaX(CallerType);
57 int32_t WheelDeltaY(CallerType);
59 void InitWheelEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
60 nsGlobalWindowInner* aView, int32_t aDetail,
61 int32_t aScreenX, int32_t aScreenY, int32_t aClientX,
62 int32_t aClientY, uint16_t aButton,
63 EventTarget* aRelatedTarget,
64 const nsAString& aModifiersList, double aDeltaX,
65 double aDeltaY, double aDeltaZ, uint32_t aDeltaMode);
67 protected:
68 ~WheelEvent() = default;
70 double ToWebExposedDelta(WidgetWheelEvent&, double aDelta,
71 nscoord aLineOrPageAmount, CallerType);
73 private:
74 int32_t mAppUnitsPerDevPixel;
77 } // namespace dom
78 } // namespace mozilla
80 already_AddRefed<mozilla::dom::WheelEvent> NS_NewDOMWheelEvent(
81 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
82 mozilla::WidgetWheelEvent* aEvent);
84 #endif // mozilla_dom_WheelEvent_h_