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