widget/cocoa/nsNativeThemeCocoa.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

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 #ifndef nsNativeThemeCocoa_h_
michael@0 7 #define nsNativeThemeCocoa_h_
michael@0 8
michael@0 9 #import <Carbon/Carbon.h>
michael@0 10 #import <Cocoa/Cocoa.h>
michael@0 11
michael@0 12 #include "nsITheme.h"
michael@0 13 #include "nsCOMPtr.h"
michael@0 14 #include "nsIAtom.h"
michael@0 15 #include "nsNativeTheme.h"
michael@0 16
michael@0 17 @class CellDrawView;
michael@0 18 @class NSProgressBarCell;
michael@0 19 @class ContextAwareSearchFieldCell;
michael@0 20 class nsDeviceContext;
michael@0 21 struct SegmentedControlRenderSettings;
michael@0 22
michael@0 23 namespace mozilla {
michael@0 24 class EventStates;
michael@0 25 } // namespace mozilla
michael@0 26
michael@0 27 class nsNativeThemeCocoa : private nsNativeTheme,
michael@0 28 public nsITheme
michael@0 29 {
michael@0 30 public:
michael@0 31 nsNativeThemeCocoa();
michael@0 32 virtual ~nsNativeThemeCocoa();
michael@0 33
michael@0 34 NS_DECL_ISUPPORTS_INHERITED
michael@0 35
michael@0 36 // The nsITheme interface.
michael@0 37 NS_IMETHOD DrawWidgetBackground(nsRenderingContext* aContext,
michael@0 38 nsIFrame* aFrame,
michael@0 39 uint8_t aWidgetType,
michael@0 40 const nsRect& aRect,
michael@0 41 const nsRect& aDirtyRect);
michael@0 42 NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
michael@0 43 nsIFrame* aFrame,
michael@0 44 uint8_t aWidgetType,
michael@0 45 nsIntMargin* aResult);
michael@0 46
michael@0 47 virtual bool GetWidgetPadding(nsDeviceContext* aContext,
michael@0 48 nsIFrame* aFrame,
michael@0 49 uint8_t aWidgetType,
michael@0 50 nsIntMargin* aResult);
michael@0 51
michael@0 52 virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
michael@0 53 uint8_t aWidgetType, nsRect* aOverflowRect);
michael@0 54
michael@0 55 NS_IMETHOD GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* aFrame,
michael@0 56 uint8_t aWidgetType,
michael@0 57 nsIntSize* aResult, bool* aIsOverridable);
michael@0 58 NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
michael@0 59 nsIAtom* aAttribute, bool* aShouldRepaint);
michael@0 60 NS_IMETHOD ThemeChanged();
michael@0 61 bool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, uint8_t aWidgetType);
michael@0 62 bool WidgetIsContainer(uint8_t aWidgetType);
michael@0 63 bool ThemeDrawsFocusForWidget(uint8_t aWidgetType) MOZ_OVERRIDE;
michael@0 64 bool ThemeNeedsComboboxDropmarker();
michael@0 65 virtual bool WidgetAppearanceDependsOnWindowFocus(uint8_t aWidgetType) MOZ_OVERRIDE;
michael@0 66 virtual Transparency GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType);
michael@0 67
michael@0 68 void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
michael@0 69 bool inIsIndeterminate, bool inIsHorizontal,
michael@0 70 double inValue, double inMaxValue, nsIFrame* aFrame);
michael@0 71
michael@0 72 protected:
michael@0 73
michael@0 74 nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
michael@0 75 nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
michael@0 76 CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
michael@0 77 nsIFrame* aCurrent, nsIFrame* aRight);
michael@0 78
michael@0 79 // HITheme drawing routines
michael@0 80 void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
michael@0 81 const HIRect& inBoxRect, bool inReadOnly,
michael@0 82 mozilla::EventStates inState);
michael@0 83 void DrawMeter(CGContextRef context, const HIRect& inBoxRect,
michael@0 84 nsIFrame* aFrame);
michael@0 85 void DrawSegment(CGContextRef cgContext, const HIRect& inBoxRect,
michael@0 86 mozilla::EventStates inState, nsIFrame* aFrame,
michael@0 87 const SegmentedControlRenderSettings& aSettings);
michael@0 88 void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
michael@0 89 void DrawScale(CGContextRef context, const HIRect& inBoxRect,
michael@0 90 mozilla::EventStates inState, bool inDirection,
michael@0 91 bool inIsReverse, int32_t inCurrentValue, int32_t inMinValue,
michael@0 92 int32_t inMaxValue, nsIFrame* aFrame);
michael@0 93 void DrawCheckboxOrRadio(CGContextRef cgContext, bool inCheckbox,
michael@0 94 const HIRect& inBoxRect, bool inSelected,
michael@0 95 mozilla::EventStates inState, nsIFrame* aFrame);
michael@0 96 void DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect,
michael@0 97 nsIFrame* aFrame, mozilla::EventStates inState);
michael@0 98 void DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
michael@0 99 mozilla::EventStates inState, uint8_t aWidgetType,
michael@0 100 nsIFrame* aFrame);
michael@0 101 void DrawButton(CGContextRef context, ThemeButtonKind inKind,
michael@0 102 const HIRect& inBoxRect, bool inIsDefault,
michael@0 103 ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
michael@0 104 mozilla::EventStates inState, nsIFrame* aFrame);
michael@0 105 void DrawDropdown(CGContextRef context, const HIRect& inBoxRect,
michael@0 106 mozilla::EventStates inState, uint8_t aWidgetType,
michael@0 107 nsIFrame* aFrame);
michael@0 108 void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind,
michael@0 109 const HIRect& inBoxRect, ThemeDrawState inDrawState,
michael@0 110 ThemeButtonAdornment inAdornment,
michael@0 111 mozilla::EventStates inState, nsIFrame* aFrame);
michael@0 112 void DrawSpinButton(CGContextRef context, ThemeButtonKind inKind,
michael@0 113 const HIRect& inBoxRect, ThemeDrawState inDrawState,
michael@0 114 ThemeButtonAdornment inAdornment,
michael@0 115 mozilla::EventStates inState,
michael@0 116 nsIFrame* aFrame, uint8_t aWidgetType);
michael@0 117 void DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect,
michael@0 118 NSWindow* aWindow);
michael@0 119 void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect,
michael@0 120 nsIFrame *aFrame);
michael@0 121 void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
michael@0 122 CGFloat aUnifiedHeight, BOOL aIsMain);
michael@0 123 void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame);
michael@0 124
michael@0 125 // Scrollbars
michael@0 126 void DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRect, nsIFrame *aFrame);
michael@0 127 void GetScrollbarPressStates(nsIFrame *aFrame,
michael@0 128 mozilla::EventStates aButtonStates[]);
michael@0 129 void GetScrollbarDrawInfo (HIThemeTrackDrawInfo& aTdi, nsIFrame *aFrame,
michael@0 130 const CGSize& aSize, bool aShouldGetButtonStates);
michael@0 131 nsIFrame* GetParentScrollbarFrame(nsIFrame *aFrame);
michael@0 132
michael@0 133 private:
michael@0 134 NSButtonCell* mHelpButtonCell;
michael@0 135 NSButtonCell* mPushButtonCell;
michael@0 136 NSButtonCell* mRadioButtonCell;
michael@0 137 NSButtonCell* mCheckboxCell;
michael@0 138 ContextAwareSearchFieldCell* mSearchFieldCell;
michael@0 139 NSPopUpButtonCell* mDropdownCell;
michael@0 140 NSComboBoxCell* mComboBoxCell;
michael@0 141 NSProgressBarCell* mProgressBarCell;
michael@0 142 NSLevelIndicatorCell* mMeterBarCell;
michael@0 143 CellDrawView* mCellDrawView;
michael@0 144 };
michael@0 145
michael@0 146 #endif // nsNativeThemeCocoa_h_

mercurial