Tue, 06 Jan 2015 21:39:09 +0100
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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* service providing platform-specific native rendering for widgets */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef nsITheme_h_ |
michael@0 | 10 | #define nsITheme_h_ |
michael@0 | 11 | |
michael@0 | 12 | #include "nsISupports.h" |
michael@0 | 13 | #include "nsCOMPtr.h" |
michael@0 | 14 | #include "nsColor.h" |
michael@0 | 15 | |
michael@0 | 16 | struct nsRect; |
michael@0 | 17 | struct nsIntRect; |
michael@0 | 18 | struct nsIntSize; |
michael@0 | 19 | class nsIntRegion; |
michael@0 | 20 | struct nsFont; |
michael@0 | 21 | struct nsIntMargin; |
michael@0 | 22 | class nsPresContext; |
michael@0 | 23 | class nsRenderingContext; |
michael@0 | 24 | class nsDeviceContext; |
michael@0 | 25 | class nsIFrame; |
michael@0 | 26 | class nsIContent; |
michael@0 | 27 | class nsIAtom; |
michael@0 | 28 | class nsIWidget; |
michael@0 | 29 | |
michael@0 | 30 | // IID for the nsITheme interface |
michael@0 | 31 | // {b0f3efe9-0bd4-4f6b-8daa-0ec7f6006822} |
michael@0 | 32 | #define NS_ITHEME_IID \ |
michael@0 | 33 | { 0x4440b5c7, 0xd8bd, 0x4d9c, \ |
michael@0 | 34 | { 0x9c, 0x3e, 0xa5, 0xe6, 0x26, 0x81, 0x10, 0xa0 } } |
michael@0 | 35 | // {D930E29B-6909-44e5-AB4B-AF10D6923705} |
michael@0 | 36 | #define NS_THEMERENDERER_CID \ |
michael@0 | 37 | { 0x9020805b, 0x14a3, 0x4125, \ |
michael@0 | 38 | { 0xa5, 0x63, 0x4a, 0x8c, 0x5d, 0xe0, 0xa9, 0xa3 } } |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * nsITheme is a service that provides platform-specific native |
michael@0 | 42 | * rendering for widgets. In other words, it provides the necessary |
michael@0 | 43 | * operations to draw a rendering object (an nsIFrame) as a native |
michael@0 | 44 | * widget. |
michael@0 | 45 | * |
michael@0 | 46 | * All the methods on nsITheme take a rendering context or device |
michael@0 | 47 | * context, a frame (the rendering object), and a widget type (one of |
michael@0 | 48 | * the constants in nsThemeConstants.h). |
michael@0 | 49 | */ |
michael@0 | 50 | class nsITheme: public nsISupports { |
michael@0 | 51 | public: |
michael@0 | 52 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID) |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Draw the actual theme background. |
michael@0 | 56 | * @param aContext the context to draw into |
michael@0 | 57 | * @param aFrame the frame for the widget that we're drawing |
michael@0 | 58 | * @param aWidgetType the -moz-appearance value to draw |
michael@0 | 59 | * @param aRect the rectangle defining the area occupied by the widget |
michael@0 | 60 | * @param aDirtyRect the rectangle that needs to be drawn |
michael@0 | 61 | */ |
michael@0 | 62 | NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext, |
michael@0 | 63 | nsIFrame* aFrame, |
michael@0 | 64 | uint8_t aWidgetType, |
michael@0 | 65 | const nsRect& aRect, |
michael@0 | 66 | const nsRect& aDirtyRect) = 0; |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Get the computed CSS border for the widget, in pixels. |
michael@0 | 70 | */ |
michael@0 | 71 | NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, |
michael@0 | 72 | nsIFrame* aFrame, |
michael@0 | 73 | uint8_t aWidgetType, |
michael@0 | 74 | nsIntMargin* aResult)=0; |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * This method can return false to indicate that the CSS padding |
michael@0 | 78 | * value should be used. Otherwise, it will fill in aResult with the |
michael@0 | 79 | * computed padding, in pixels, and return true. |
michael@0 | 80 | * |
michael@0 | 81 | * XXXldb This ought to be required to return true for non-containers |
michael@0 | 82 | * so that we don't let specified padding that has no effect change |
michael@0 | 83 | * the computed padding and potentially the size. |
michael@0 | 84 | */ |
michael@0 | 85 | virtual bool GetWidgetPadding(nsDeviceContext* aContext, |
michael@0 | 86 | nsIFrame* aFrame, |
michael@0 | 87 | uint8_t aWidgetType, |
michael@0 | 88 | nsIntMargin* aResult) = 0; |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * On entry, *aResult is positioned at 0,0 and sized to the new size |
michael@0 | 92 | * of aFrame (aFrame->GetSize() may be stale and should not be used). |
michael@0 | 93 | * This method can return false to indicate that no special |
michael@0 | 94 | * overflow area is required by the native widget. Otherwise it will |
michael@0 | 95 | * fill in aResult with the desired overflow area, in appunits, relative |
michael@0 | 96 | * to the frame origin, and return true. |
michael@0 | 97 | * |
michael@0 | 98 | * This overflow area is used to determine what area needs to be |
michael@0 | 99 | * repainted when the widget changes. However, it does not affect the |
michael@0 | 100 | * widget's size or what area is reachable by scrollbars. (In other |
michael@0 | 101 | * words, in layout terms, it affects visual overflow but not |
michael@0 | 102 | * scrollable overflow.) |
michael@0 | 103 | */ |
michael@0 | 104 | virtual bool GetWidgetOverflow(nsDeviceContext* aContext, |
michael@0 | 105 | nsIFrame* aFrame, |
michael@0 | 106 | uint8_t aWidgetType, |
michael@0 | 107 | /*INOUT*/ nsRect* aOverflowRect) |
michael@0 | 108 | { return false; } |
michael@0 | 109 | |
michael@0 | 110 | /** |
michael@0 | 111 | * Get the minimum border-box size of a widget, in *pixels* (in |
michael@0 | 112 | * |aResult|). If |aIsOverridable| is set to true, this size is a |
michael@0 | 113 | * minimum size; if false, this size is the only valid size for the |
michael@0 | 114 | * widget. |
michael@0 | 115 | */ |
michael@0 | 116 | NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, |
michael@0 | 117 | nsIFrame* aFrame, |
michael@0 | 118 | uint8_t aWidgetType, |
michael@0 | 119 | nsIntSize* aResult, |
michael@0 | 120 | bool* aIsOverridable)=0; |
michael@0 | 121 | |
michael@0 | 122 | |
michael@0 | 123 | enum Transparency { |
michael@0 | 124 | eOpaque = 0, |
michael@0 | 125 | eTransparent, |
michael@0 | 126 | eUnknownTransparency |
michael@0 | 127 | }; |
michael@0 | 128 | |
michael@0 | 129 | /** |
michael@0 | 130 | * Returns what we know about the transparency of the widget. |
michael@0 | 131 | */ |
michael@0 | 132 | virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType) |
michael@0 | 133 | { return eUnknownTransparency; } |
michael@0 | 134 | |
michael@0 | 135 | NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, |
michael@0 | 136 | nsIAtom* aAttribute, bool* aShouldRepaint)=0; |
michael@0 | 137 | |
michael@0 | 138 | NS_IMETHOD ThemeChanged()=0; |
michael@0 | 139 | |
michael@0 | 140 | virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) |
michael@0 | 141 | { return false; } |
michael@0 | 142 | |
michael@0 | 143 | /** |
michael@0 | 144 | * Can the nsITheme implementation handle this widget? |
michael@0 | 145 | */ |
michael@0 | 146 | virtual bool ThemeSupportsWidget(nsPresContext* aPresContext, |
michael@0 | 147 | nsIFrame* aFrame, |
michael@0 | 148 | uint8_t aWidgetType)=0; |
michael@0 | 149 | |
michael@0 | 150 | virtual bool WidgetIsContainer(uint8_t aWidgetType)=0; |
michael@0 | 151 | |
michael@0 | 152 | /** |
michael@0 | 153 | * Does the nsITheme implementation draw its own focus ring for this widget? |
michael@0 | 154 | */ |
michael@0 | 155 | virtual bool ThemeDrawsFocusForWidget(uint8_t aWidgetType)=0; |
michael@0 | 156 | |
michael@0 | 157 | /** |
michael@0 | 158 | * Should we insert a dropmarker inside of combobox button? |
michael@0 | 159 | */ |
michael@0 | 160 | virtual bool ThemeNeedsComboboxDropmarker()=0; |
michael@0 | 161 | |
michael@0 | 162 | /** |
michael@0 | 163 | * Should we hide scrollbars? |
michael@0 | 164 | */ |
michael@0 | 165 | virtual bool ShouldHideScrollbars() |
michael@0 | 166 | { return false; } |
michael@0 | 167 | }; |
michael@0 | 168 | |
michael@0 | 169 | NS_DEFINE_STATIC_IID_ACCESSOR(nsITheme, NS_ITHEME_IID) |
michael@0 | 170 | |
michael@0 | 171 | // Creator function |
michael@0 | 172 | extern nsresult NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult); |
michael@0 | 173 | |
michael@0 | 174 | #endif |