mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
b=348645, part of cocoa-cairo native theme stuff, just enough to get cairo builds working, r=me
This commit is contained in:
parent
079f0ade3d
commit
0b0af5db8b
@ -100,10 +100,12 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += $(MOZ_CAIRO_CFLAGS) $(TK_CFLAGS)
|
||||
|
||||
ifndef MOZ_ENABLE_CAIRO_GFX
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT)))
|
||||
# needed for nsDrawingSurfaceMac.h
|
||||
CXXFLAGS += -I$(topsrcdir)/gfx/src/mac
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT), os2)
|
||||
# needed for nsDrawingSurfaceOS2.h
|
||||
|
@ -117,6 +117,10 @@ CPPSRCS = \
|
||||
$(MAC_LCPPSRCS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_CAIRO_GFX
|
||||
CPPSRCS += nsNativeThemeCocoa.cpp
|
||||
endif
|
||||
|
||||
CMMSRCS = \
|
||||
nsMenuX.mm \
|
||||
nsMenuBarX.mm \
|
||||
@ -200,6 +204,7 @@ LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../mac \
|
||||
-I/System/Library/Frameworks/Carbon.Framework/Headers \
|
||||
-I/System/Library/Frameworks/Cocoa.Framework/Headers \
|
||||
-I/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers \
|
||||
$(NULL)
|
||||
|
||||
LDFLAGS += \
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#import "mozView.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsBaseWidget.h"
|
||||
#include "nsIPluginWidget.h"
|
||||
@ -302,6 +303,10 @@ protected:
|
||||
PRPackedBool mTempRenderingContextMadeHere;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
nsRefPtr<gfxASurface> mTempThebesSurface;
|
||||
#endif
|
||||
|
||||
PRPackedBool mDestructorCalled;
|
||||
PRPackedBool mVisible;
|
||||
|
||||
|
@ -65,6 +65,15 @@
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
#include "gfxContext.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
||||
extern "C" {
|
||||
CG_EXTERN void CGContextResetCTM (CGContextRef);
|
||||
CG_EXTERN void CGContextSetCTM (CGContextRef, CGAffineTransform);
|
||||
CG_EXTERN void CGContextResetClip (CGContextRef);
|
||||
}
|
||||
|
||||
#undef DEBUG_UPDATE
|
||||
|
||||
#else
|
||||
#include "nsGfxUtils.h" // for StPortSetter
|
||||
#endif
|
||||
@ -875,7 +884,6 @@ NS_IMETHODIMP nsChildView::MoveWithRepaintOption(PRInt32 aX, PRInt32 aY, PRBool
|
||||
if (mVisible && aRepaint)
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
|
||||
// Report the event
|
||||
ReportMoveEvent();
|
||||
}
|
||||
@ -1385,9 +1393,6 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
|
||||
if (! mVisible)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_vladimir
|
||||
fprintf(stderr, "nsChildView[%p]::UpdateWidget called!\n", this);
|
||||
#else
|
||||
// For updating widgets, we _always_ want to use the NSQuickDrawView's port,
|
||||
// since that's the correct port for gecko to use to make rendering contexts.
|
||||
// The plugin is the only thing that uses the plugin port.
|
||||
@ -1416,7 +1421,6 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext)
|
||||
Flash(paintEvent);
|
||||
}
|
||||
EndDraw();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2042,11 +2046,14 @@ nsChildView::Idle()
|
||||
gfxASurface*
|
||||
nsChildView::GetThebesSurface()
|
||||
{
|
||||
#ifdef DEBUG_vladimir
|
||||
fprintf (stderr, "nsChildView[%p]::GetThebesSurface\n", this);
|
||||
#endif
|
||||
|
||||
return new gfxQuartzSurface(gfxASurface::ImageFormatARGB32, 1, 1);
|
||||
if (!mTempThebesSurface) {
|
||||
mTempThebesSurface = new gfxQuartzSurface(gfxASurface::ImageFormatARGB32, 1, 1);
|
||||
}
|
||||
|
||||
gfxASurface *surf = mTempThebesSurface.get();
|
||||
NS_ADDREF(surf);
|
||||
return surf;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2402,13 +2409,20 @@ nsChildView::GetThebesSurface()
|
||||
CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
nsRect geckoBounds;
|
||||
mGeckoChild->GetBounds(geckoBounds);
|
||||
nsRefPtr<gfxQuartzSurface> targetSurface =
|
||||
new gfxQuartzSurface(cgContext, geckoBounds.width, geckoBounds.height, PR_FALSE);
|
||||
|
||||
//fprintf (stderr, "Update[%p] [%f %f %f %f] cgc: %p gecko bounds: [%d %d %d %d]\n", mGeckoChild, aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height, cgContext, geckoBounds.x, geckoBounds.y, geckoBounds.width, geckoBounds.height);
|
||||
NSRect bounds = [self bounds];
|
||||
nsRefPtr<gfxQuartzSurface> targetSurface =
|
||||
new gfxQuartzSurface(cgContext, bounds.size.width, bounds.size.height, PR_TRUE);
|
||||
|
||||
#ifdef DEBUG_UPDATE
|
||||
fprintf (stderr, "---- Update[%p][%p] [%f %f %f %f] cgc: %p\n gecko bounds: [%d %d %d %d]\n",
|
||||
self, mGeckoChild,
|
||||
aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height, cgContext,
|
||||
geckoBounds.x, geckoBounds.y, geckoBounds.width, geckoBounds.height);
|
||||
|
||||
CGAffineTransform xform = CGContextGetCTM(cgContext);
|
||||
//fprintf (stderr, " context xform: t: %f %f xx: %f xy: %f yx: %f yy: %f\n", xform.tx, xform.ty, xform.a, xform.b, xform.c, xform.d);
|
||||
fprintf (stderr, " xform in: [%f %f %f %f %f %f]\n", xform.a, xform.b, xform.c, xform.d, xform.tx, xform.ty);
|
||||
#endif
|
||||
|
||||
nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
|
||||
|
||||
@ -2421,7 +2435,6 @@ nsChildView::GetThebesSurface()
|
||||
int count, i;
|
||||
[self getRectsBeingDrawn:&rects count:&count];
|
||||
for (i = 0; i < count; ++i) {
|
||||
//fprintf (stderr, " Clip rect[%d]: %f %f %f %f\n", i, rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height);
|
||||
targetContext->Rectangle(gfxRect(rects[i].origin.x, rects[i].origin.y,
|
||||
rects[i].size.width, rects[i].size.height));
|
||||
}
|
||||
@ -2439,8 +2452,6 @@ nsChildView::GetThebesSurface()
|
||||
mGeckoChild->LocalToWindowCoordinate(tr);
|
||||
//targetContext->Translate(gfxPoint(tr.x, tr.y));
|
||||
|
||||
//fprintf (stderr, " window coords: [%d %d %d %d]\n", tr.x, tr.y, tr.width, tr.height);
|
||||
|
||||
nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, mGeckoChild);
|
||||
paintEvent.renderingContext = rc;
|
||||
paintEvent.rect = &r;
|
||||
@ -2450,9 +2461,28 @@ nsChildView::GetThebesSurface()
|
||||
|
||||
paintEvent.renderingContext = nsnull;
|
||||
|
||||
//fprintf (stderr, "---- update done ----\n");
|
||||
targetContext = nsnull;
|
||||
targetSurface = nsnull;
|
||||
|
||||
#else /* MOZ_CAIRO_GFX */
|
||||
// note that the cairo surface *MUST* be destroyed at this point,
|
||||
// or bad things will happen (since we can't keep the cgContext around
|
||||
// beyond this drawRect message handler)
|
||||
|
||||
#ifdef DEBUG_UPDATE
|
||||
fprintf (stderr, " window coords: [%d %d %d %d]\n", tr.x, tr.y, tr.width, tr.height);
|
||||
fprintf (stderr, "---- update done ----\n");
|
||||
|
||||
CGContextSetRGBStrokeColor (cgContext,
|
||||
((((unsigned long)self) & 0xff)) / 255.0,
|
||||
((((unsigned long)self) & 0xff00) >> 8) / 255.0,
|
||||
((((unsigned long)self) & 0xff0000) >> 16) / 255.0,
|
||||
0.5);
|
||||
CGContextSetLineWidth (cgContext, 4.0);
|
||||
CGContextStrokeRect (cgContext,
|
||||
CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height));
|
||||
#endif
|
||||
|
||||
#else
|
||||
// tell gecko to paint.
|
||||
const NSRect *rects;
|
||||
int count, i;
|
||||
|
1062
widget/src/cocoa/nsNativeThemeCocoa.cpp
Normal file
1062
widget/src/cocoa/nsNativeThemeCocoa.cpp
Normal file
File diff suppressed because it is too large
Load Diff
125
widget/src/cocoa/nsNativeThemeCocoa.h
Normal file
125
widget/src/cocoa/nsNativeThemeCocoa.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mike Pinkerton (pinkerton@netscape.com).
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <Appearance.h>
|
||||
|
||||
#include "nsITheme.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsNativeTheme.h"
|
||||
|
||||
class nsNativeThemeCocoa : private nsNativeTheme,
|
||||
public nsITheme
|
||||
{
|
||||
public:
|
||||
nsNativeThemeCocoa();
|
||||
virtual ~nsNativeThemeCocoa();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// The nsITheme interface.
|
||||
NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
const nsRect& aRect,
|
||||
const nsRect& aClipRect);
|
||||
NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsMargin* aResult);
|
||||
|
||||
virtual PRBool GetWidgetPadding(nsIDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsMargin* aResult);
|
||||
|
||||
NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsSize* aResult, PRBool* aIsOverridable);
|
||||
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
nsIAtom* aAttribute, PRBool* aShouldRepaint);
|
||||
NS_IMETHOD ThemeChanged();
|
||||
PRBool ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, PRUint8 aWidgetType);
|
||||
PRBool WidgetIsContainer(PRUint8 aWidgetType);
|
||||
|
||||
protected:
|
||||
|
||||
// Some widths and margins. You'd think there would be metrics for these, but no.
|
||||
enum {
|
||||
kAquaPushButtonEndcaps = 14,
|
||||
kAquaPushButtonTopBottom = 2,
|
||||
kAquaSmallPushButtonEndcaps = 10,
|
||||
|
||||
kAquaDropdownLeftEndcap = 9,
|
||||
kAquaDropwdonRightEndcap = 20 // wider on right to encompass the button
|
||||
};
|
||||
|
||||
nsresult GetSystemColor(PRUint8 aWidgetType, nsILookAndFeel::nsColorID& aColorID);
|
||||
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
|
||||
|
||||
|
||||
// HITheme drawing routines
|
||||
void DrawFrame (CGContextRef context, HIThemeFrameKind inKind,
|
||||
const HIRect& inBoxRect, PRBool inIsDisabled,
|
||||
PRInt32 inState);
|
||||
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
|
||||
PRBool inIsDisabled, PRBool inIsIndeterminate,
|
||||
PRBool inIsHorizontal, PRInt32 inValue);
|
||||
void DrawTab (CGContextRef context, const HIRect& inBoxRect,
|
||||
PRBool inIsDisabled, PRBool inIsFrontmost,
|
||||
PRBool inIsHorizontal, PRBool inTabBottom,
|
||||
PRInt32 inPosition, PRInt32 inState);
|
||||
void DrawTabPanel (CGContextRef context, const HIRect& inBoxRect,
|
||||
PRBool inIsDisabled);
|
||||
void DrawScale (CGContextRef context, const HIRect& inBoxRect,
|
||||
PRBool inIsDisabled, PRInt32 inState,
|
||||
PRBool inDirection, PRInt32 inCurrentValue,
|
||||
PRInt32 inMinValue, PRInt32 inMaxValue);
|
||||
void DrawButton (CGContextRef context, ThemeButtonKind inKind,
|
||||
const HIRect& inBoxRect, PRBool inIsDefault,
|
||||
PRBool inDisabled, ThemeButtonValue inValue,
|
||||
ThemeButtonAdornment inAdornment, PRInt32 inState);
|
||||
void DrawSpinButtons (CGContextRef context, ThemeButtonKind inKind,
|
||||
const HIRect& inBoxRect,
|
||||
PRBool inDisabled, ThemeDrawState inDrawState,
|
||||
ThemeButtonAdornment inAdornment, PRInt32 inState);
|
||||
void DrawCheckboxRadio (CGContextRef context, ThemeButtonKind inKind,
|
||||
const HIRect& inBoxRect, PRBool inChecked,
|
||||
PRBool inDisabled, PRInt32 inState);
|
||||
};
|
@ -96,8 +96,13 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSessionX, Init)
|
||||
#include "nsBidiKeyboard.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
#include "nsNativeThemeCocoa.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeCocoa)
|
||||
#else
|
||||
#include "nsNativeThemeMac.h"
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeMac)
|
||||
#endif
|
||||
|
||||
static const nsModuleComponentInfo gComponents[] =
|
||||
{
|
||||
@ -179,7 +184,12 @@ static const nsModuleComponentInfo gComponents[] =
|
||||
NS_NATIVESCROLLBAR_CID,
|
||||
"@mozilla.org/widget/nativescrollbar;1",
|
||||
nsNativeScrollbarConstructor },
|
||||
#ifndef MOZ_CAIRO_GFX
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
{ "Native Theme Renderer",
|
||||
NS_THEMERENDERER_CID,
|
||||
"@mozilla.org/chrome/chrome-native-theme;1",
|
||||
nsNativeThemeCocoaConstructor },
|
||||
#else
|
||||
{ "Native Theme Renderer",
|
||||
NS_THEMERENDERER_CID,
|
||||
"@mozilla.org/chrome/chrome-native-theme;1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user