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: 2; 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 | #include "nsITheme.h" |
michael@0 | 7 | #include "nsCOMPtr.h" |
michael@0 | 8 | #include "nsIAtom.h" |
michael@0 | 9 | #include "nsIObserver.h" |
michael@0 | 10 | #include "nsNativeTheme.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <gtk/gtk.h> |
michael@0 | 13 | #include "gtkdrawing.h" |
michael@0 | 14 | |
michael@0 | 15 | class nsNativeThemeGTK: private nsNativeTheme, |
michael@0 | 16 | public nsITheme, |
michael@0 | 17 | public nsIObserver { |
michael@0 | 18 | public: |
michael@0 | 19 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 20 | |
michael@0 | 21 | NS_DECL_NSIOBSERVER |
michael@0 | 22 | |
michael@0 | 23 | // The nsITheme interface. |
michael@0 | 24 | NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext, |
michael@0 | 25 | nsIFrame* aFrame, uint8_t aWidgetType, |
michael@0 | 26 | const nsRect& aRect, |
michael@0 | 27 | const nsRect& aDirtyRect); |
michael@0 | 28 | |
michael@0 | 29 | NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame, |
michael@0 | 30 | uint8_t aWidgetType, nsIntMargin* aResult); |
michael@0 | 31 | |
michael@0 | 32 | virtual NS_HIDDEN_(bool) GetWidgetPadding(nsDeviceContext* aContext, |
michael@0 | 33 | nsIFrame* aFrame, |
michael@0 | 34 | uint8_t aWidgetType, |
michael@0 | 35 | nsIntMargin* aResult); |
michael@0 | 36 | |
michael@0 | 37 | virtual NS_HIDDEN_(bool) GetWidgetOverflow(nsDeviceContext* aContext, |
michael@0 | 38 | nsIFrame* aFrame, |
michael@0 | 39 | uint8_t aWidgetType, |
michael@0 | 40 | nsRect* aOverflowRect); |
michael@0 | 41 | |
michael@0 | 42 | NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, |
michael@0 | 43 | nsIFrame* aFrame, uint8_t aWidgetType, |
michael@0 | 44 | nsIntSize* aResult, bool* aIsOverridable); |
michael@0 | 45 | |
michael@0 | 46 | NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, |
michael@0 | 47 | nsIAtom* aAttribute, bool* aShouldRepaint); |
michael@0 | 48 | |
michael@0 | 49 | NS_IMETHOD ThemeChanged(); |
michael@0 | 50 | |
michael@0 | 51 | NS_IMETHOD_(bool) ThemeSupportsWidget(nsPresContext* aPresContext, |
michael@0 | 52 | nsIFrame* aFrame, |
michael@0 | 53 | uint8_t aWidgetType); |
michael@0 | 54 | |
michael@0 | 55 | NS_IMETHOD_(bool) WidgetIsContainer(uint8_t aWidgetType); |
michael@0 | 56 | |
michael@0 | 57 | NS_IMETHOD_(bool) ThemeDrawsFocusForWidget(uint8_t aWidgetType) MOZ_OVERRIDE; |
michael@0 | 58 | |
michael@0 | 59 | bool ThemeNeedsComboboxDropmarker(); |
michael@0 | 60 | |
michael@0 | 61 | virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, |
michael@0 | 62 | uint8_t aWidgetType); |
michael@0 | 63 | |
michael@0 | 64 | nsNativeThemeGTK(); |
michael@0 | 65 | virtual ~nsNativeThemeGTK(); |
michael@0 | 66 | |
michael@0 | 67 | private: |
michael@0 | 68 | gint GetTabMarginPixels(nsIFrame* aFrame); |
michael@0 | 69 | bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame, |
michael@0 | 70 | GtkThemeWidgetType& aGtkWidgetType, |
michael@0 | 71 | GtkWidgetState* aState, gint* aWidgetFlags); |
michael@0 | 72 | bool GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType, |
michael@0 | 73 | nsIntMargin* aExtra); |
michael@0 | 74 | |
michael@0 | 75 | void RefreshWidgetWindow(nsIFrame* aFrame); |
michael@0 | 76 | |
michael@0 | 77 | uint8_t mDisabledWidgetTypes[32]; |
michael@0 | 78 | uint8_t mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget |
michael@0 | 79 | static const char* sDisabledEngines[]; |
michael@0 | 80 | }; |