dom/xbl/nsXBLEventHandler.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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 nsXBLEventHandler_h__
     7 #define nsXBLEventHandler_h__
     9 #include "mozilla/Attributes.h"
    10 #include "nsCOMPtr.h"
    11 #include "nsIDOMEventListener.h"
    12 #include "nsTArray.h"
    14 class nsIAtom;
    15 class nsIDOMKeyEvent;
    16 class nsXBLPrototypeHandler;
    18 class nsXBLEventHandler : public nsIDOMEventListener
    19 {
    20 public:
    21   nsXBLEventHandler(nsXBLPrototypeHandler* aHandler);
    22   virtual ~nsXBLEventHandler();
    24   NS_DECL_ISUPPORTS
    26   NS_DECL_NSIDOMEVENTLISTENER
    28 protected:
    29   nsXBLPrototypeHandler* mProtoHandler;
    31 private:
    32   nsXBLEventHandler();
    33   virtual bool EventMatched(nsIDOMEvent* aEvent)
    34   {
    35     return true;
    36   }
    37 };
    39 class nsXBLMouseEventHandler : public nsXBLEventHandler
    40 {
    41 public:
    42   nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler);
    43   virtual ~nsXBLMouseEventHandler();
    45 private:
    46   bool EventMatched(nsIDOMEvent* aEvent) MOZ_OVERRIDE;
    47 };
    49 class nsXBLKeyEventHandler : public nsIDOMEventListener
    50 {
    51 public:
    52   nsXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType);
    53   virtual ~nsXBLKeyEventHandler();
    55   NS_DECL_ISUPPORTS
    57   NS_DECL_NSIDOMEVENTLISTENER
    59   void AddProtoHandler(nsXBLPrototypeHandler* aProtoHandler)
    60   {
    61     mProtoHandlers.AppendElement(aProtoHandler);
    62   }
    64   bool Matches(nsIAtom* aEventType, uint8_t aPhase, uint8_t aType) const
    65   {
    66     return (mEventType == aEventType && mPhase == aPhase && mType == aType);
    67   }
    69   void GetEventName(nsAString& aString) const
    70   {
    71     mEventType->ToString(aString);
    72   }
    74   uint8_t GetPhase() const
    75   {
    76     return mPhase;
    77   }
    79   uint8_t GetType() const
    80   {
    81     return mType;
    82   }
    84   void SetIsBoundToChrome(bool aIsBoundToChrome)
    85   {
    86     mIsBoundToChrome = aIsBoundToChrome;
    87   }
    89   void SetUsingXBLScope(bool aUsingXBLScope)
    90   {
    91     mUsingXBLScope = aUsingXBLScope;
    92   }
    94 private:
    95   nsXBLKeyEventHandler();
    96   bool ExecuteMatchedHandlers(nsIDOMKeyEvent* aEvent, uint32_t aCharCode,
    97                                 bool aIgnoreShiftKey);
    99   nsTArray<nsXBLPrototypeHandler*> mProtoHandlers;
   100   nsCOMPtr<nsIAtom> mEventType;
   101   uint8_t mPhase;
   102   uint8_t mType;
   103   bool mIsBoundToChrome;
   104   bool mUsingXBLScope;
   105 };
   107 nsresult
   108 NS_NewXBLEventHandler(nsXBLPrototypeHandler* aHandler,
   109                       nsIAtom* aEventType,
   110                       nsXBLEventHandler** aResult);
   112 nsresult
   113 NS_NewXBLKeyEventHandler(nsIAtom* aEventType, uint8_t aPhase,
   114                          uint8_t aType, nsXBLKeyEventHandler** aResult);
   116 #endif

mercurial