Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsWindowBase_h_ |
michael@0 | 7 | #define nsWindowBase_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/EventForwards.h" |
michael@0 | 10 | #include "nsBaseWidget.h" |
michael@0 | 11 | #include "nsClassHashtable.h" |
michael@0 | 12 | |
michael@0 | 13 | #include <windows.h> |
michael@0 | 14 | #include "touchinjection_sdk80.h" |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | * nsWindowBase - Base class of common methods other classes need to access |
michael@0 | 18 | * in both win32 and winrt window classes. |
michael@0 | 19 | */ |
michael@0 | 20 | class nsWindowBase : public nsBaseWidget |
michael@0 | 21 | { |
michael@0 | 22 | public: |
michael@0 | 23 | /* |
michael@0 | 24 | * Return the HWND or null for this widget. |
michael@0 | 25 | */ |
michael@0 | 26 | virtual HWND GetWindowHandle() MOZ_FINAL { |
michael@0 | 27 | return static_cast<HWND>(GetNativeData(NS_NATIVE_WINDOW)); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | /* |
michael@0 | 31 | * Return the parent window, if it exists. |
michael@0 | 32 | */ |
michael@0 | 33 | virtual nsWindowBase* GetParentWindowBase(bool aIncludeOwner) = 0; |
michael@0 | 34 | |
michael@0 | 35 | /* |
michael@0 | 36 | * Return true if this is a top level widget. |
michael@0 | 37 | */ |
michael@0 | 38 | virtual bool IsTopLevelWidget() = 0; |
michael@0 | 39 | |
michael@0 | 40 | /* |
michael@0 | 41 | * Init a standard gecko event for this widget. |
michael@0 | 42 | * @param aEvent the event to initialize. |
michael@0 | 43 | * @param aPoint message position in physical coordinates. |
michael@0 | 44 | */ |
michael@0 | 45 | virtual void InitEvent(mozilla::WidgetGUIEvent& aEvent, |
michael@0 | 46 | nsIntPoint* aPoint = nullptr) = 0; |
michael@0 | 47 | |
michael@0 | 48 | /* |
michael@0 | 49 | * Dispatch a gecko event for this widget. |
michael@0 | 50 | * Returns true if it's consumed. Otherwise, false. |
michael@0 | 51 | */ |
michael@0 | 52 | virtual bool DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent) = 0; |
michael@0 | 53 | |
michael@0 | 54 | /* |
michael@0 | 55 | * Dispatch a gecko keyboard event for this widget. This |
michael@0 | 56 | * is called by KeyboardLayout to dispatch gecko events. |
michael@0 | 57 | * Returns true if it's consumed. Otherwise, false. |
michael@0 | 58 | */ |
michael@0 | 59 | virtual bool DispatchKeyboardEvent(mozilla::WidgetGUIEvent* aEvent) = 0; |
michael@0 | 60 | |
michael@0 | 61 | /* |
michael@0 | 62 | * Dispatch a gecko scroll event for this widget. This |
michael@0 | 63 | * is called by ScrollHandler to dispatch gecko events. |
michael@0 | 64 | * Returns true if it's consumed. Otherwise, false. |
michael@0 | 65 | */ |
michael@0 | 66 | virtual bool DispatchScrollEvent(mozilla::WidgetGUIEvent* aEvent) = 0; |
michael@0 | 67 | |
michael@0 | 68 | /* |
michael@0 | 69 | * Default dispatch of a plugin event. |
michael@0 | 70 | */ |
michael@0 | 71 | virtual bool DispatchPluginEvent(const MSG& aMsg); |
michael@0 | 72 | |
michael@0 | 73 | /* |
michael@0 | 74 | * Returns true if a plugin has focus on this widget. Otherwise, false. |
michael@0 | 75 | */ |
michael@0 | 76 | virtual bool PluginHasFocus() const MOZ_FINAL |
michael@0 | 77 | { |
michael@0 | 78 | return (mInputContext.mIMEState.mEnabled == IMEState::PLUGIN); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | /* |
michael@0 | 82 | * Touch input injection apis |
michael@0 | 83 | */ |
michael@0 | 84 | virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId, |
michael@0 | 85 | TouchPointerState aPointerState, |
michael@0 | 86 | nsIntPoint aPointerScreenPoint, |
michael@0 | 87 | double aPointerPressure, |
michael@0 | 88 | uint32_t aPointerOrientation); |
michael@0 | 89 | virtual nsresult ClearNativeTouchSequence(); |
michael@0 | 90 | |
michael@0 | 91 | /* |
michael@0 | 92 | * WM_APPCOMMAND common handler. Sends events via DispatchWindowEvent. |
michael@0 | 93 | */ |
michael@0 | 94 | virtual bool HandleAppCommandMsg(WPARAM aWParam, |
michael@0 | 95 | LPARAM aLParam, |
michael@0 | 96 | LRESULT *aRetValue); |
michael@0 | 97 | |
michael@0 | 98 | protected: |
michael@0 | 99 | bool DispatchCommandEvent(uint32_t aEventCommand); |
michael@0 | 100 | static bool InitTouchInjection(); |
michael@0 | 101 | bool InjectTouchPoint(uint32_t aId, nsIntPoint& aPointerScreenPoint, |
michael@0 | 102 | POINTER_FLAGS aFlags, uint32_t aPressure = 1024, |
michael@0 | 103 | uint32_t aOrientation = 90); |
michael@0 | 104 | |
michael@0 | 105 | class PointerInfo |
michael@0 | 106 | { |
michael@0 | 107 | public: |
michael@0 | 108 | PointerInfo(int32_t aPointerId, nsIntPoint& aPoint) : |
michael@0 | 109 | mPointerId(aPointerId), |
michael@0 | 110 | mPosition(aPoint) |
michael@0 | 111 | { |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | int32_t mPointerId; |
michael@0 | 115 | nsIntPoint mPosition; |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | static PLDHashOperator CancelTouchPoints(const unsigned int& aPointerId, nsAutoPtr<PointerInfo>& aInfo, void* aUserArg); |
michael@0 | 119 | |
michael@0 | 120 | nsClassHashtable<nsUint32HashKey, PointerInfo> mActivePointers; |
michael@0 | 121 | static bool sTouchInjectInitialized; |
michael@0 | 122 | static InjectTouchInputPtr sInjectTouchFuncPtr; |
michael@0 | 123 | |
michael@0 | 124 | protected: |
michael@0 | 125 | InputContext mInputContext; |
michael@0 | 126 | }; |
michael@0 | 127 | |
michael@0 | 128 | #endif // nsWindowBase_h_ |