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.

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

mercurial