dom/events/MouseEvent.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef mozilla_dom_MouseEvent_h_
     7 #define mozilla_dom_MouseEvent_h_
     9 #include "mozilla/dom/UIEvent.h"
    10 #include "mozilla/dom/MouseEventBinding.h"
    11 #include "mozilla/EventForwards.h"
    12 #include "nsIDOMMouseEvent.h"
    14 namespace mozilla {
    15 namespace dom {
    17 class MouseEvent : public UIEvent,
    18                    public nsIDOMMouseEvent
    19 {
    20 public:
    21   MouseEvent(EventTarget* aOwner,
    22              nsPresContext* aPresContext,
    23              WidgetMouseEventBase* aEvent);
    25   NS_DECL_ISUPPORTS_INHERITED
    27   // nsIDOMMouseEvent Interface
    28   NS_DECL_NSIDOMMOUSEEVENT
    30   // Forward to base class
    31   NS_FORWARD_TO_UIEVENT
    33   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
    34   {
    35     return MouseEventBinding::Wrap(aCx, this);
    36   }
    38   // Web IDL binding methods
    39   virtual uint32_t Which() MOZ_OVERRIDE
    40   {
    41     return Button() + 1;
    42   }
    44   int32_t ScreenX();
    45   int32_t ScreenY();
    46   int32_t ClientX();
    47   int32_t ClientY();
    48   bool CtrlKey();
    49   bool ShiftKey();
    50   bool AltKey();
    51   bool MetaKey();
    52   int16_t Button();
    53   uint16_t Buttons();
    54   already_AddRefed<EventTarget> GetRelatedTarget();
    55   void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
    56                       nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
    57                       int32_t aScreenY, int32_t aClientX, int32_t aClientY,
    58                       bool aCtrlKey, bool aAltKey, bool aShiftKey,
    59                       bool aMetaKey, uint16_t aButton,
    60                       EventTarget* aRelatedTarget, ErrorResult& aRv)
    61   {
    62     aRv = InitMouseEvent(aType, aCanBubble, aCancelable,
    63                          aView, aDetail, aScreenX, aScreenY,
    64                          aClientX, aClientY, aCtrlKey, aAltKey,
    65                          aShiftKey, aMetaKey, aButton,
    66                          aRelatedTarget);
    67   }
    68   bool GetModifierState(const nsAString& aKeyArg)
    69   {
    70     return GetModifierStateInternal(aKeyArg);
    71   }
    72   static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal,
    73                                                   const nsAString& aType,
    74                                                   const MouseEventInit& aParam,
    75                                                   ErrorResult& aRv);
    76   int32_t MozMovementX()
    77   {
    78     return GetMovementPoint().x;
    79   }
    80   int32_t MozMovementY()
    81   {
    82     return GetMovementPoint().y;
    83   }
    84   float MozPressure() const;
    85   uint16_t MozInputSource() const;
    86   void InitNSMouseEvent(const nsAString& aType,
    87                         bool aCanBubble, bool aCancelable,
    88                         nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
    89                         int32_t aScreenY, int32_t aClientX, int32_t aClientY,
    90                         bool aCtrlKey, bool aAltKey, bool aShiftKey,
    91                         bool aMetaKey, uint16_t aButton,
    92                         EventTarget* aRelatedTarget,
    93                         float aPressure, uint16_t aInputSource,
    94                         ErrorResult& aRv)
    95   {
    96     aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable,
    97                            aView, aDetail, aScreenX, aScreenY,
    98                            aClientX, aClientY, aCtrlKey, aAltKey,
    99                            aShiftKey, aMetaKey, aButton,
   100                            aRelatedTarget, aPressure, aInputSource);
   101   }
   103 protected:
   104   nsresult InitMouseEvent(const nsAString& aType,
   105                           bool aCanBubble,
   106                           bool aCancelable,
   107                           nsIDOMWindow* aView,
   108                           int32_t aDetail,
   109                           int32_t aScreenX,
   110                           int32_t aScreenY,
   111                           int32_t aClientX,
   112                           int32_t aClientY,
   113                           int16_t aButton,
   114                           nsIDOMEventTarget* aRelatedTarget,
   115                           const nsAString& aModifiersList);
   116 };
   118 } // namespace dom
   119 } // namespace mozilla
   121 #define NS_FORWARD_TO_MOUSEEVENT \
   122   NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \
   123   NS_FORWARD_TO_UIEVENT
   125 #endif // mozilla_dom_MouseEvent_h_

mercurial