diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index 9e7c7a43335..e80436d3f9a 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -1583,7 +1583,12 @@ sub BuildLayoutProjects() BuildProject(":mozilla:expat:macbuild:expat.mcp", "expat$D.o"); BuildOneProject(":mozilla:htmlparser:macbuild:htmlparser.mcp", "htmlparser$D.$S", 1, $main::ALIAS_SYM_FILES, 1); - BuildOneProjectWithOutput(":mozilla:gfx:macbuild:gfx.mcp", "gfx$C$D.$S", "gfx$D.$S", 1, $main::ALIAS_SYM_FILES, 0); + + BuildOneProject(":mozilla:gfx:macbuild:gfx.mcp", "gfx$D.shlb", 1, $main::ALIAS_SYM_FILES, 0); + + my($dbg) = $main::DEBUG ? "Dbg" : ""; + BuildOneProjectWithOutput(":mozilla:gfx:macbuild:gfxComponent.mcp", "gfxComponent$C$dbg.$S", "gfxComponent$D.$S", 1, $main::ALIAS_SYM_FILES, 1); + BuildOneProject(":mozilla:dom:macbuild:dom.mcp", "dom$D.$S", 1, $main::ALIAS_SYM_FILES, 1); BuildOneProject(":mozilla:modules:plugin:base:macbuild:plugin.mcp", "plugin$D.$S", 1, $main::ALIAS_SYM_FILES, 1); @@ -1610,9 +1615,9 @@ sub BuildLayoutProjects() } BuildOneProject(":mozilla:layout:macbuild:layout.mcp", "layout$D.$S", 1, $main::ALIAS_SYM_FILES, 1); BuildOneProject(":mozilla:view:macbuild:view.mcp", "view$D.$S", 1, $main::ALIAS_SYM_FILES, 1); - BuildOneProjectWithOutput(":mozilla:widget:macbuild:widget.mcp", "widget$C$D.$S", "widget$D.$S", 1, $main::ALIAS_SYM_FILES, 0); + BuildOneProject(":mozilla:widget:macbuild:WidgetSupport.mcp", "WidgetSupport$D.shlb", 1, $main::ALIAS_SYM_FILES, 0); + BuildOneProjectWithOutput(":mozilla:widget:macbuild:widget.mcp", "widget$C$D.$S", "widget$D.$S", 1, $main::ALIAS_SYM_FILES, 1); BuildOneProject(":mozilla:docshell:macbuild:docshell.mcp", "docshell$D.$S", 1, $main::ALIAS_SYM_FILES, 1); - BuildOneProject(":mozilla:webshell:embed:mac:RaptorShell.mcp", "RaptorShell$D.$S", 1, $main::ALIAS_SYM_FILES, 0); BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "RDFLibrary$D.$S", 1, $main::ALIAS_SYM_FILES, 1); diff --git a/mozilla/embedding/browser/powerplant/PPBrowser.mcp b/mozilla/embedding/browser/powerplant/PPBrowser.mcp index bcc8b29063f..f36d11efabc 100755 Binary files a/mozilla/embedding/browser/powerplant/PPBrowser.mcp and b/mozilla/embedding/browser/powerplant/PPBrowser.mcp differ diff --git a/mozilla/gfx/macbuild/GFXComponentConfig.h b/mozilla/gfx/macbuild/GFXComponentConfig.h new file mode 100644 index 00000000000..580d1353ab3 --- /dev/null +++ b/mozilla/gfx/macbuild/GFXComponentConfig.h @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +#if TARGET_CARBON +// we can't use the carbon printing session APIs +#define PM_USE_SESSION_APIS 0 +#endif diff --git a/mozilla/gfx/macbuild/GFXStaticDebugPrefix.h b/mozilla/gfx/macbuild/GFXComponentDebugPrefix.h similarity index 93% rename from mozilla/gfx/macbuild/GFXStaticDebugPrefix.h rename to mozilla/gfx/macbuild/GFXComponentDebugPrefix.h index 47b0c7b213d..92940500ea6 100644 --- a/mozilla/gfx/macbuild/GFXStaticDebugPrefix.h +++ b/mozilla/gfx/macbuild/GFXComponentDebugPrefix.h @@ -20,6 +20,5 @@ * Contributor(s): */ -#define GFX_STATIC 1 - -#include "MacPrefix_debug.h" \ No newline at end of file +#include "MacPrefix_debug.h" +#include "GFXComponentConfig.h" diff --git a/mozilla/gfx/macbuild/GFXStaticPrefix.h b/mozilla/gfx/macbuild/GFXComponentPrefix.h similarity index 93% rename from mozilla/gfx/macbuild/GFXStaticPrefix.h rename to mozilla/gfx/macbuild/GFXComponentPrefix.h index 534230b32a0..36f1600e168 100644 --- a/mozilla/gfx/macbuild/GFXStaticPrefix.h +++ b/mozilla/gfx/macbuild/GFXComponentPrefix.h @@ -20,6 +20,5 @@ * Contributor(s): */ -#define GFX_STATIC 1 - -#include "MacPrefix.h" \ No newline at end of file +#include "MacSharedPrefix.h" +#include "GFXComponentConfig.h" diff --git a/mozilla/gfx/macbuild/GFXConfig.h b/mozilla/gfx/macbuild/GFXConfig.h index 986e2341897..d035d288112 100644 --- a/mozilla/gfx/macbuild/GFXConfig.h +++ b/mozilla/gfx/macbuild/GFXConfig.h @@ -21,8 +21,3 @@ */ #define _IMPL_NS_GFX 1 - -#if TARGET_CARBON -// we can't use the carbon printing session APIs -#define PM_USE_SESSION_APIS 0 -#endif diff --git a/mozilla/gfx/macbuild/GFXSharedPrefix.h b/mozilla/gfx/macbuild/GFXPrefix.h similarity index 96% rename from mozilla/gfx/macbuild/GFXSharedPrefix.h rename to mozilla/gfx/macbuild/GFXPrefix.h index 2b179c42244..09ef46a9596 100644 --- a/mozilla/gfx/macbuild/GFXSharedPrefix.h +++ b/mozilla/gfx/macbuild/GFXPrefix.h @@ -20,5 +20,5 @@ * Contributor(s): */ -#include "MacSharedPrefix.h" #include "GFXConfig.h" +#include "MacPrefix.h" diff --git a/mozilla/gfx/macbuild/GFXSharedDebugPrefix.h b/mozilla/gfx/macbuild/GFXPrefixDebug.h similarity index 99% rename from mozilla/gfx/macbuild/GFXSharedDebugPrefix.h rename to mozilla/gfx/macbuild/GFXPrefixDebug.h index a685fa8cfb4..f793340fa85 100644 --- a/mozilla/gfx/macbuild/GFXSharedDebugPrefix.h +++ b/mozilla/gfx/macbuild/GFXPrefixDebug.h @@ -20,5 +20,6 @@ * Contributor(s): */ -#include "MacPrefix_debug.h" + #include "GFXConfig.h" +#include "MacPrefix_debug.h" diff --git a/mozilla/gfx/macbuild/gfx.mcp b/mozilla/gfx/macbuild/gfx.mcp index a21dcfa8ab7..da7dc2b4b4c 100644 Binary files a/mozilla/gfx/macbuild/gfx.mcp and b/mozilla/gfx/macbuild/gfx.mcp differ diff --git a/mozilla/gfx/macbuild/gfxComponent.mcp b/mozilla/gfx/macbuild/gfxComponent.mcp new file mode 100644 index 00000000000..dedeba48b36 Binary files /dev/null and b/mozilla/gfx/macbuild/gfxComponent.mcp differ diff --git a/mozilla/gfx/public/nsRepeater.h b/mozilla/gfx/public/nsRepeater.h index 9b0213ea4df..758725e8e45 100644 --- a/mozilla/gfx/public/nsRepeater.h +++ b/mozilla/gfx/public/nsRepeater.h @@ -43,7 +43,7 @@ class EventRecord; -class NS_NET Repeater +class NS_WIDGET Repeater { public: diff --git a/mozilla/gfx/src/Makefile.in b/mozilla/gfx/src/Makefile.in index 451b8e015c9..160be098e42 100644 --- a/mozilla/gfx/src/Makefile.in +++ b/mozilla/gfx/src/Makefile.in @@ -19,105 +19,117 @@ # Contributor(s): # -DEPTH = ../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ +DEPTH = ../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -MODULE = gfx +MODULE = gfx EXPORTS = nsFontList.h -LIBRARY_NAME = gkgfx +LIBRARY_NAME = gkgfx EXPORT_LIBRARY = 1 -REQUIRES = xpcom \ - string \ - widget \ - locale \ - view \ - pref \ - gfx2 \ - imglib2 \ - uconv \ - unicharutil \ - $(NULL) +REQUIRES = xpcom \ + string \ + widget \ + locale \ + view \ + pref \ + gfx2 \ + imglib2 \ + uconv \ + unicharutil \ + $(NULL) ifeq ($(MOZ_WIDGET_TOOLKIT),os2) -DIRS = +DIRS = else -DIRS = ps +DIRS = ps endif ifneq (,$(filter beos os2 mac,$(MOZ_GFX_TOOLKIT))) -DIRS += $(MOZ_GFX_TOOLKIT) +DIRS += $(MOZ_GFX_TOOLKIT) endif # Build xlibrgb only for X toolkits and/or Xprint ifneq (,$(filter xlib,$(MOZ_WIDGET_TOOLKIT))$(MOZ_ENABLE_XLIB)$(MOZ_ENABLE_XPRINT)) -DIRS += xlibrgb +DIRS += xlibrgb endif ifdef MOZ_ENABLE_GTK -DIRS += gtk +DIRS += gtk endif ifdef MOZ_ENABLE_GTK2 -DIRS += gtk2 +DIRS += gtk2 endif ifdef MOZ_ENABLE_QT -DIRS += qt +DIRS += qt endif ifdef MOZ_ENABLE_XLIB -DIRS += xlib +DIRS += xlib endif ifdef MOZ_ENABLE_PHOTON -DIRS += photon +DIRS += photon endif ifdef MOZ_ENABLE_XPRINT -DIRS += xprint +DIRS += xprint endif -CPPSRCS = \ - nsBlender.cpp \ - nsColor.cpp \ - nsColorNames.cpp \ - nsCompressedCharMap.cpp \ - nsDeviceContext.cpp \ - nsFont.cpp \ - nsFontList.cpp \ - nsRenderingContextImpl.cpp \ - nsRect.cpp \ - nsTransform2D.cpp \ - nsScriptableRegion.cpp \ - nsGraphicsImpl.cpp \ - nsPrintOptionsImpl.cpp \ - $(NULL) +CPPSRCS = \ + nsBlender.cpp \ + nsColor.cpp \ + nsColorNames.cpp \ + nsCompressedCharMap.cpp \ + nsDeviceContext.cpp \ + nsFont.cpp \ + nsFontList.cpp \ + nsRenderingContextImpl.cpp \ + nsRect.cpp \ + nsTransform2D.cpp \ + nsScriptableRegion.cpp \ + nsGraphicsImpl.cpp \ + nsPrintOptionsImpl.cpp \ + $(NULL) ifneq (,$(filter gtk xlib os2,$(MOZ_WIDGET_TOOLKIT))) -CPPSRCS += \ - nsRegion.cpp \ - nsRegionImpl.cpp \ - $(NULL) +CPPSRCS += \ + nsRegion.cpp \ + nsRegionImpl.cpp \ + $(NULL) endif ifneq (,$(filter gtk xlib beos,$(MOZ_WIDGET_TOOLKIT))) -CPPSRCS += imgScaler.cpp +CPPSRCS += imgScaler.cpp +endif + +ifeq (mac, $(MOZ_WIDGET_TOOLKIT)) +CPPSRCS += \ + mac/nsRegionPool.cpp \ + $(NULL) endif SHARED_LIBRARY_LIBS = \ - $(DIST)/lib/libmozutil_s.$(LIB_SUFFIX) \ - $(NULL) + $(DIST)/lib/libmozutil_s.$(LIB_SUFFIX) \ + $(NULL) EXTRA_DSO_LDOPTS = \ - $(MOZ_UNICHARUTIL_LIBS) \ - $(MOZ_COMPONENT_LIBS) \ - $(NULL) + $(MOZ_UNICHARUTIL_LIBS) \ + $(MOZ_COMPONENT_LIBS) \ + $(NULL) + +ifeq (mac, $(MOZ_WIDGET_TOOLKIT)) +EXTRA_DSO_LDOPTS += \ + $(TK_LIBS) \ + $(NULL) +endif include $(topsrcdir)/config/rules.mk -DEFINES += -D_IMPL_NS_GFX +DEFINES += -D_IMPL_NS_GFX install:: icon_0.gif icon_1.gif - $(INSTALL) -m 555 $^ $(DIST)/bin/res/gfx + $(INSTALL) -m 555 $^ $(DIST)/bin/res/gfx diff --git a/mozilla/gfx/src/mac/Makefile.in b/mozilla/gfx/src/mac/Makefile.in index 421a2207bd3..eddee4a6ed3 100644 --- a/mozilla/gfx/src/mac/Makefile.in +++ b/mozilla/gfx/src/mac/Makefile.in @@ -15,70 +15,72 @@ # Reserved. # -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -LIBRARY_NAME = gfx_mac -EXPORT_LIBRARY = 1 -MODULE = gfx -IS_COMPONENT = 1 -MODULE_NAME = nsGfxMacModule -REQUIRES = xpcom \ - string \ - img \ - widget \ - view \ - util \ - dom \ - pref \ - js \ - uconv \ - necko \ - unicharutil \ - gfx2 \ - mozcomps \ - windowwatcher \ - $(NULL) +LIBRARY_NAME = gfx_mac +EXPORT_LIBRARY = 1 +MODULE = gfx +IS_COMPONENT = 1 +MODULE_NAME = nsGfxMacModule + +REQUIRES = xpcom \ + string \ + img \ + widget \ + view \ + util \ + dom \ + pref \ + js \ + uconv \ + necko \ + unicharutil \ + gfx2 \ + mozcomps \ + windowwatcher \ + $(NULL) CPPSRCS = \ - nsATSUIUtils.cpp \ - nsDeviceContextMac.cpp \ - nsDeviceContextSpecFactoryM.cpp \ - nsDeviceContextSpecX.cpp \ - nsDrawingSurfaceMac.cpp \ - nsFontMetricsMac.cpp \ - nsGfxFactoryMac.cpp \ - nsGraphicState.cpp \ - nsImageMac.cpp \ - nsRegionMac.cpp \ - nsRenderingContextMac.cpp \ - nsMacUnicodeFontInfo.cpp \ - nsUnicodeFontMappingMac.cpp \ - nsUnicodeMappingUtil.cpp \ - nsUnicodeRenderingToolkit.cpp \ - nsScreenMac.cpp \ - nsScreenManagerMac.cpp \ - nsPrintOptionsX.cpp \ - $(NULL) + nsATSUIUtils.cpp \ + nsDeviceContextMac.cpp \ + nsDeviceContextSpecFactoryM.cpp \ + nsDeviceContextSpecX.cpp \ + nsDrawingSurfaceMac.cpp \ + nsFontMetricsMac.cpp \ + nsGfxFactoryMac.cpp \ + nsGraphicState.cpp \ + nsImageMac.cpp \ + nsRegionMac.cpp \ + nsRenderingContextMac.cpp \ + nsMacUnicodeFontInfo.cpp \ + nsUnicodeFontMappingMac.cpp \ + nsUnicodeMappingUtil.cpp \ + nsUnicodeRenderingToolkit.cpp \ + nsScreenMac.cpp \ + nsScreenManagerMac.cpp \ + nsPrintOptionsX.cpp \ + nsFontUtils.cpp \ + $(NULL) -# $(DIST)/lib/libimg_s.a \ +# $(DIST)/lib/libimg_s.a \ EXTRA_DSO_LDOPTS = \ - $(MKSHLIB_FORCE_ALL) \ - $(DIST)/lib/libmozutil_s.a \ - -lgkgfx \ - $(MKSHLIB_UNFORCE_ALL) \ - $(TK_LIBS) \ - $(MOZ_COMPONENT_LIBS) \ - $(NULL) + $(MKSHLIB_FORCE_ALL) \ + $(DIST)/lib/libmozutil_s.a \ + -lgkgfx \ + $(MKSHLIB_UNFORCE_ALL) \ + $(TK_LIBS) \ + $(MOZ_COMPONENT_LIBS) \ + $(NULL) include $(topsrcdir)/config/rules.mk -CXXFLAGS += $(TK_CFLAGS) -CFLAGS += $(TK_CFLAGS) -INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. +CXXFLAGS += $(TK_CFLAGS) +CFLAGS += $(TK_CFLAGS) +INCLUDES += $(TK_CFLAGS) -I$(srcdir)/.. diff --git a/mozilla/gfx/src/mac/nsATSUIUtils.cpp b/mozilla/gfx/src/mac/nsATSUIUtils.cpp index dc66720bc1b..48bb4fde728 100644 --- a/mozilla/gfx/src/mac/nsATSUIUtils.cpp +++ b/mozilla/gfx/src/mac/nsATSUIUtils.cpp @@ -42,6 +42,8 @@ #include "nsDeviceContextMac.h" #include "nsTransform2D.h" #include "plhash.h" +#include "nsFontUtils.h" + #include #include @@ -304,7 +306,7 @@ ATSUTextLayout nsATSUIToolkit::GetTextLayout(short aFontNum, short aSize, PRBool mContext->GetDevUnitsToAppUnits(dev2app); // Fixed size = FloatToFixed( roundf(float(fontsize) / dev2app)); Fixed size = FloatToFixed( (float) rint(float(fontsize) / dev2app)); - if( FixRound ( size ) < 9 && !nsDeviceContextMac::DisplayVerySmallFonts()) + if( FixRound ( size ) < 9 && !nsFontUtils::DisplayVerySmallFonts()) size = X2Fix(9); theTag[1] = kATSUSizeTag; diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index 62a72953378..4cc5beaaadb 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -69,7 +69,6 @@ PRUint32 nsDeviceContextMac::mPixelsPerInch = 96; -PRBool nsDeviceContextMac::mDisplayVerySmallFonts = true; PRUint32 nsDeviceContextMac::sNumberOfScreens = 0; @@ -969,25 +968,6 @@ PRUint32 nsDeviceContextMac::GetScreenResolution() return mPixelsPerInch; } -PRBool nsDeviceContextMac::DisplayVerySmallFonts() -{ - static PRBool initialized = PR_FALSE; - if (initialized) - return mDisplayVerySmallFonts; - initialized = PR_TRUE; - - nsresult rv; - nsCOMPtr prefs(do_GetService(kPrefCID, &rv)); - if (NS_SUCCEEDED(rv) && prefs) { - PRBool boolVal; - if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display_very_small_fonts", &boolVal))) { - mDisplayVerySmallFonts = boolVal; - } - } - - return mDisplayVerySmallFonts; -} - #pragma mark - //------------------------------------------------------------------------ diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.h b/mozilla/gfx/src/mac/nsDeviceContextMac.h index 760540a667f..8808d001375 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.h +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.h @@ -111,11 +111,9 @@ public: private: static PRUint32 mPixelsPerInch; - static PRBool mDisplayVerySmallFonts; static PRUint32 sNumberOfScreens; // how many screens we have. public: static PRUint32 GetScreenResolution(); - static PRBool DisplayVerySmallFonts(); }; diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp index e97c42ff8c4..cb6a5f071b2 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp @@ -387,7 +387,8 @@ NS_IMETHODIMP nsDeviceContextSpecMac::Init(PRBool aQuiet) // standard print dialog, if true print nsWatchTask::GetTask().Suspend(); - + ::InitCursor(); + // put up the print dialog if (::PrDlgMain(hPrintRec, theInitProcPtr)) { diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp index 7dc17d8c3cf..5e7c934fd58 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp @@ -116,6 +116,8 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(PRBool aQuiet) if (! aQuiet) { + ::InitCursor(); + Boolean accepted = false; status = ::PMPrintDialog(mPrintSettings, mPageFormat, &accepted); if (! accepted) diff --git a/mozilla/gfx/src/mac/nsFontMetricsMac.cpp b/mozilla/gfx/src/mac/nsFontMetricsMac.cpp index 5724f029e86..253260210ec 100644 --- a/mozilla/gfx/src/mac/nsFontMetricsMac.cpp +++ b/mozilla/gfx/src/mac/nsFontMetricsMac.cpp @@ -43,6 +43,7 @@ #include "nsUnicodeFontMappingMac.h" #include "nsUnicodeMappingUtil.h" #include "nsGfxUtils.h" +#include "nsFontUtils.h" #define BAD_FONT_NUM -1 @@ -79,7 +80,7 @@ NS_IMETHODIMP nsFontMetricsMac::Init(const nsFont& aFont, nsIAtom* aLangGroup, n RealizeFont(); TextStyle theStyle; - nsFontMetricsMac::GetNativeTextStyle(*this, *mContext, theStyle); + nsFontUtils::GetNativeTextStyle(*this, *mContext, theStyle); StTextStyleSetter styleSetter(theStyle); @@ -399,68 +400,3 @@ NS_IMETHODIMP nsFontMetricsMac :: GetFontHandle(nsFontHandle &aHandle) return NS_OK; } -// A utility routine to the the text style in a convenient manner. -// This is static, which is unfortunate, because it introduces link -// dependencies between libraries that should not exist. -NS_EXPORT void nsFontMetricsMac::GetNativeTextStyle(nsIFontMetrics& inMetrics, - const nsIDeviceContext& inDevContext, TextStyle &outStyle) -{ - - const nsFont *aFont; - inMetrics.GetFont(aFont); - - nsFontHandle fontNum; - inMetrics.GetFontHandle(fontNum); - - float dev2app; - inDevContext.GetDevUnitsToAppUnits(dev2app); - short textSize = float(aFont->size) / dev2app; - - if (textSize < 9 && !nsDeviceContextMac::DisplayVerySmallFonts()) - textSize = 9; - - Style textFace = normal; - switch (aFont->style) - { - case NS_FONT_STYLE_NORMAL: break; - case NS_FONT_STYLE_ITALIC: textFace |= italic; break; - case NS_FONT_STYLE_OBLIQUE: textFace |= italic; break; //XXX - } -#if 0 - switch (aFont->variant) - { - case NS_FONT_VARIANT_NORMAL: break; - case NS_FONT_VARIANT_SMALL_CAPS: break; - } -#endif - PRInt32 offset = aFont->weight % 100; - PRInt32 baseWeight = aFont->weight / 100; - NS_ASSERTION((offset < 10) || (offset > 90), "Invalid bolder or lighter value"); - if (offset == 0) { - if (aFont->weight >= NS_FONT_WEIGHT_BOLD) - textFace |= bold; - } else { - if (offset < 10) - textFace |= bold; - } - - if ( aFont->decorations & NS_FONT_DECORATION_UNDERLINE ) - textFace |= underline; - if ( aFont->decorations & NS_FONT_DECORATION_OVERLINE ) - textFace |= underline; // THIS IS WRONG, BUT HERE FOR COMPLETENESS - if ( aFont->decorations & NS_FONT_DECORATION_LINE_THROUGH ) - textFace |= underline; // THIS IS WRONG, BUT HERE FOR COMPLETENESS - - RGBColor black = {0}; - - float textZoom = 1.0; - inDevContext.GetTextZoom(textZoom); - textSize *= textZoom; - - outStyle.tsFont = (short)fontNum; - outStyle.tsFace = textFace; - outStyle.tsSize = textSize; - outStyle.tsColor = black; -} - - diff --git a/mozilla/gfx/src/mac/nsFontMetricsMac.h b/mozilla/gfx/src/mac/nsFontMetricsMac.h index bffa1fd0596..87c33bc692c 100644 --- a/mozilla/gfx/src/mac/nsFontMetricsMac.h +++ b/mozilla/gfx/src/mac/nsFontMetricsMac.h @@ -84,10 +84,6 @@ public: NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup); NS_IMETHOD GetFontHandle(nsFontHandle& aHandle); NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth); - // fill a native TextStyle record with the font, size and style (not color) - static void GetNativeTextStyle(nsIFontMetrics& inMetrics, - const nsIDeviceContext& inDevContext, TextStyle &outStyle); - nsUnicodeFontMappingMac* GetUnicodeFontMapping(); diff --git a/mozilla/gfx/src/mac/nsFontUtils.cpp b/mozilla/gfx/src/mac/nsFontUtils.cpp new file mode 100644 index 00000000000..9faa3c7268d --- /dev/null +++ b/mozilla/gfx/src/mac/nsFontUtils.cpp @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + + +#include "nsIPref.h" +#include "nsIServiceManager.h" + +#include "nsFont.h" +#include "nsDeviceContextMac.h" + +#include "nsFontUtils.h" + +PRBool nsFontUtils::sDisplayVerySmallFonts = true; + + +PRBool +nsFontUtils::DisplayVerySmallFonts() +{ + static PRBool sInitialized = PR_FALSE; + if (sInitialized) + return sDisplayVerySmallFonts; + + sInitialized = PR_TRUE; + + nsresult rv; + nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && prefs) { + PRBool boolVal; + if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display_very_small_fonts", &boolVal))) { + sDisplayVerySmallFonts = boolVal; + } + } + + return sDisplayVerySmallFonts; +} + + +// A utility routine to the the text style in a convenient manner. +// This is static, which is unfortunate, because it introduces link +// dependencies between libraries that should not exist. +void +nsFontUtils::GetNativeTextStyle(nsIFontMetrics& inMetrics, + const nsIDeviceContext& inDevContext, TextStyle &outStyle) +{ + + const nsFont *aFont; + inMetrics.GetFont(aFont); + + nsFontHandle fontNum; + inMetrics.GetFontHandle(fontNum); + + float dev2app; + inDevContext.GetDevUnitsToAppUnits(dev2app); + short textSize = float(aFont->size) / dev2app; + + if (textSize < 9 && !nsFontUtils::DisplayVerySmallFonts()) + textSize = 9; + + Style textFace = normal; + switch (aFont->style) + { + case NS_FONT_STYLE_NORMAL: break; + case NS_FONT_STYLE_ITALIC: textFace |= italic; break; + case NS_FONT_STYLE_OBLIQUE: textFace |= italic; break; //XXX + } +#if 0 + switch (aFont->variant) + { + case NS_FONT_VARIANT_NORMAL: break; + case NS_FONT_VARIANT_SMALL_CAPS: break; + } +#endif + PRInt32 offset = aFont->weight % 100; + PRInt32 baseWeight = aFont->weight / 100; + NS_ASSERTION((offset < 10) || (offset > 90), "Invalid bolder or lighter value"); + if (offset == 0) { + if (aFont->weight >= NS_FONT_WEIGHT_BOLD) + textFace |= bold; + } else { + if (offset < 10) + textFace |= bold; + } + + if ( aFont->decorations & NS_FONT_DECORATION_UNDERLINE ) + textFace |= underline; + if ( aFont->decorations & NS_FONT_DECORATION_OVERLINE ) + textFace |= underline; // THIS IS WRONG, BUT HERE FOR COMPLETENESS + if ( aFont->decorations & NS_FONT_DECORATION_LINE_THROUGH ) + textFace |= underline; // THIS IS WRONG, BUT HERE FOR COMPLETENESS + + RGBColor black = {0}; + + outStyle.tsFont = (short)fontNum; + outStyle.tsFace = textFace; + outStyle.tsSize = textSize; + outStyle.tsColor = black; +} + diff --git a/mozilla/widget/macbuild/WidgetSharedDebugPrefix.h b/mozilla/gfx/src/mac/nsFontUtils.h similarity index 67% rename from mozilla/widget/macbuild/WidgetSharedDebugPrefix.h rename to mozilla/gfx/src/mac/nsFontUtils.h index 89305e6639e..717c57aadc3 100644 --- a/mozilla/widget/macbuild/WidgetSharedDebugPrefix.h +++ b/mozilla/gfx/src/mac/nsFontUtils.h @@ -20,12 +20,27 @@ * Contributor(s): */ -#define MAC_SHARED 1 -#define _IMPL_NS_WIDGET 1 +#ifndef nsFontUtils_h_ +#define nsFontUtils_h_ -#include "WidgetDebug.prefix" +#include -#if !TARGET_CARBON -#define USE_MENUSELECT 1 -#endif +#include "nsIFontMetrics.h" +#include "nsIDeviceContext.h" +class NS_GFX nsFontUtils +{ +public: + + static void GetNativeTextStyle(nsIFontMetrics& inMetrics, const nsIDeviceContext& inDevContext, TextStyle &outStyle); + static PRBool DisplayVerySmallFonts(); + +protected: + + static PRBool sDisplayVerySmallFonts; + +}; + + + +#endif // nsFontUtils_h_ diff --git a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp index 9e8b549fb29..bf4678fcb45 100644 --- a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp +++ b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp @@ -61,11 +61,8 @@ #include "nsCOMPtr.h" #include "nsPrintOptionsMac.h" -#ifdef XP_MACOSX - #include "nsIGenericFactory.h" -// XXX Implement the GFX module using NS_GENERIC_FACTORY_CONSTRUCTOR / NS_IMPL_NSGETMODULE NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextMac) @@ -74,8 +71,13 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceMac) +#if TARGET_CARBON NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX) NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsX) +#else +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsMac) +#endif NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList) @@ -116,6 +118,10 @@ static nsModuleComponentInfo components[] = NS_REGION_CID, "@mozilla.org/gfx/unscriptable-region;1", nsRegionMacConstructor }, + { "nsScriptableRegion", + NS_SCRIPTABLE_REGION_CID, + "@mozilla.org/gfx/region;1", + nsScriptableRegionConstructor }, { "nsBlender", NS_BLENDER_CID, "@mozilla.org/gfx/blender;1", @@ -124,22 +130,32 @@ static nsModuleComponentInfo components[] = NS_DRAWING_SURFACE_CID, "@mozilla.org/gfx/drawing-surface;1", nsDrawingSurfaceMacConstructor }, +#if TARGET_CARBON { "nsDeviceContextSpec", NS_DEVICE_CONTEXT_SPEC_CID, "@mozilla.org/gfx/devicecontextspec;1", nsDeviceContextSpecXConstructor }, +#else + { "nsDeviceContextSpec", + NS_DEVICE_CONTEXT_SPEC_CID, + "@mozilla.org/gfx/devicecontextspec;1", + nsDeviceContextSpecMacConstructor }, +#endif { "nsDeviceContextSpecFactory", NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, "@mozilla.org/gfx/devicecontextspecfactory;1", nsDeviceContextSpecFactoryMacConstructor }, - { "nsScriptableRegion", - NS_SCRIPTABLE_REGION_CID, - "@mozilla.org/gfx/region;1", - nsScriptableRegionConstructor }, +#if TARGET_CARBON { "nsPrintOptions", NS_PRINTOPTIONS_CID, "@mozilla.org/gfx/printoptions;1", nsPrintOptionsXConstructor }, +#else + { "Print Options", + NS_PRINTOPTIONS_CID, + "@mozilla.org/gfx/printoptions;1", + nsPrintOptionsMacConstructor }, +#endif { "nsFontEnumerator", NS_FONT_ENUMERATOR_CID, "@mozilla.org/gfx/fontenumerator;1", @@ -156,158 +172,4 @@ static nsModuleComponentInfo components[] = NS_IMPL_NSGETMODULE(nsGfxModule, components) -#else -static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID); -static NS_DEFINE_IID(kCFontEnumerator, NS_FONT_ENUMERATOR_CID); -static NS_DEFINE_IID(kCFontList, NS_FONTLIST_CID); -static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID); -static NS_DEFINE_IID(kCImage, NS_IMAGE_CID); -static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID); -static NS_DEFINE_IID(kCRegion, NS_REGION_CID); -static NS_DEFINE_IID(kCScriptableRegion, NS_SCRIPTABLE_REGION_CID); -static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID); -static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID); -static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID); -static NS_DEFINE_IID(kCScreenManager, NS_SCREENMANAGER_CID); -static NS_DEFINE_IID(kCPrintOptions, NS_PRINTOPTIONS_CID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); - -class nsGfxFactoryMac : public nsIFactory { -public: - // nsISupports methods - NS_DECL_ISUPPORTS - - // nsIFactory methods - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - - nsGfxFactoryMac(const nsCID &aClass); - ~nsGfxFactoryMac(); - -private: - nsCID mClassID; -}; - -nsGfxFactoryMac::nsGfxFactoryMac(const nsCID &aClass) -{ - NS_INIT_ISUPPORTS(); - mClassID = aClass; -} - -nsGfxFactoryMac::~nsGfxFactoryMac() -{ -} - -NS_IMPL_ISUPPORTS1(nsGfxFactoryMac, nsIFactory) - -nsresult nsGfxFactoryMac::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - - *aResult = NULL; - - nsCOMPtr inst; - - if (mClassID.Equals(kCFontMetrics)) { - NS_NEWXPCOM(inst, nsFontMetricsMac); - } - else if (mClassID.Equals(kCDeviceContext)) { - NS_NEWXPCOM(inst, nsDeviceContextMac); - } - else if (mClassID.Equals(kCRenderingContext)) { - NS_NEWXPCOM(inst, nsRenderingContextMac); - } - else if (mClassID.Equals(kCImage)) { - inst = NS_STATIC_CAST(nsIImage*, new nsImageMac()); - } - else if (mClassID.Equals(kCRegion)) { - NS_NEWXPCOM(inst, nsRegionMac); - } - else if (mClassID.Equals(kCBlender)) { - NS_NEWXPCOM(inst, nsBlender); - } - else if (mClassID.Equals(kCScriptableRegion)) { - nsCOMPtr rgn; - NS_NEWXPCOM(rgn, nsRegionMac); - if (rgn != nsnull) { - nsCOMPtr scriptableRgn = new nsScriptableRegion(rgn); - inst = scriptableRgn; - } - } - else if (mClassID.Equals(kCDeviceContextSpec)) { - nsCOMPtr dcSpec; -#if TARGET_CARBON - NS_NEWXPCOM(dcSpec, nsDeviceContextSpecX); -#else - NS_NEWXPCOM(dcSpec, nsDeviceContextSpecMac); -#endif - inst = dcSpec; - } - else if (mClassID.Equals(kCPrintOptions)) { -#if TARGET_CARBON - NS_NEWXPCOM(inst, nsPrintOptionsX); -#else - NS_NEWXPCOM(inst, nsPrintOptionsMac); -#endif - } - else if (mClassID.Equals(kCDeviceContextSpecFactory)) { - NS_NEWXPCOM(inst, nsDeviceContextSpecFactoryMac); - } - else if (mClassID.Equals(kCFontEnumerator)) { - nsFontEnumeratorMac* fe; - NS_NEWXPCOM(fe, nsFontEnumeratorMac); - inst = (nsISupports *)fe; - } - else if (mClassID.Equals(kCFontList)) { - nsFontList* fl; - NS_NEWXPCOM(fl, nsFontList); - inst = (nsISupports *)fl; - } - else if (mClassID.Equals(kCScreenManager)) { - NS_NEWXPCOM(inst, nsScreenManagerMac); - } - - - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return inst->QueryInterface(aIID, aResult); -} - -nsresult nsGfxFactoryMac::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -// return the proper factory to the caller - -extern "C" NS_GFX nsresult NSGetFactory(nsISupports* servMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - nsCOMPtr factory = new nsGfxFactoryMac(aClass); - if (nsnull == factory) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return factory->QueryInterface(kIFactoryIID, (void**)aFactory); -} - -#endif diff --git a/mozilla/gfx/src/mac/nsGraphicState.cpp b/mozilla/gfx/src/mac/nsGraphicState.cpp index 4abf762b8d2..208f027a977 100644 --- a/mozilla/gfx/src/mac/nsGraphicState.cpp +++ b/mozilla/gfx/src/mac/nsGraphicState.cpp @@ -41,6 +41,7 @@ #include "nsRegionMac.h" #include "nsIFontMetrics.h" #include "nsCarbonHelpers.h" +#include "nsRegionPool.h" nsGraphicStatePool sGraphicStatePool; diff --git a/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp b/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp index 2929d2378d9..4e924817c19 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp +++ b/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp @@ -104,6 +104,7 @@ nsPrintOptionsMac::ShowNativeDialog(void) NS_ASSERTION(::PrError() == noErr, "Printing error"); nsWatchTask::GetTask().Suspend(); + ::InitCursor(); Boolean dialogOK = ::PrStlDialog(mPrintRecord); // open up and process the style record nsWatchTask::GetTask().Resume(); diff --git a/mozilla/gfx/src/mac/nsPrintOptionsX.cpp b/mozilla/gfx/src/mac/nsPrintOptionsX.cpp index 01cbcf64cab..c13ee0c9106 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsX.cpp +++ b/mozilla/gfx/src/mac/nsPrintOptionsX.cpp @@ -98,6 +98,8 @@ nsPrintOptionsX::ShowNativeDialog(void) Boolean validated; ::PMValidatePageFormat(mPageFormat, &validated); + ::InitCursor(); + Boolean accepted = false; status = ::PMPageSetupDialog(mPageFormat, &accepted); diff --git a/mozilla/gfx/src/mac/nsRegionMac.cpp b/mozilla/gfx/src/mac/nsRegionMac.cpp index dae650b4c13..fc96c239a13 100644 --- a/mozilla/gfx/src/mac/nsRegionMac.cpp +++ b/mozilla/gfx/src/mac/nsRegionMac.cpp @@ -40,91 +40,7 @@ #include "prmem.h" #include "nsCarbonHelpers.h" -NS_EXPORT nsNativeRegionPool sNativeRegionPool; - -//------------------------------------------------------------------------ - -nsNativeRegionPool::nsNativeRegionPool() -{ - mRegionSlots = nsnull; - mEmptySlots = nsnull; -} - -//------------------------------------------------------------------------ - -nsNativeRegionPool::~nsNativeRegionPool() -{ - // Release all of the regions. - if (mRegionSlots != nsnull) { - nsRegionSlot* slot = mRegionSlots; - while (slot != nsnull) { - ::DisposeRgn(slot->mRegion); - nsRegionSlot* next = slot->mNext; - delete slot; - slot = next; - } - } - - // Release all empty slots. - if (mEmptySlots != nsnull) { - nsRegionSlot* slot = mEmptySlots; - while (slot != nsnull) { - nsRegionSlot* next = slot->mNext; - delete slot; - slot = next; - } - } -} - -//------------------------------------------------------------------------ - -RgnHandle nsNativeRegionPool::GetNewRegion() -{ - nsRegionSlot* slot = mRegionSlots; - if (slot != nsnull) { - RgnHandle region = slot->mRegion; - - // remove this slot from the free list. - mRegionSlots = slot->mNext; - - // transfer this slot to the empty slot list for reuse. - slot->mRegion = nsnull; - slot->mNext = mEmptySlots; - mEmptySlots = slot; - - // initialize the region. - ::SetEmptyRgn(region); - return region; - } - - // return a fresh new region. a slot will be created to hold it - // if and when the region is released. - return (::NewRgn()); -} - -//------------------------------------------------------------------------ - -void nsNativeRegionPool::ReleaseRegion(RgnHandle aRgnHandle) -{ - nsRegionSlot* slot = mEmptySlots; - if (slot != nsnull) - mEmptySlots = slot->mNext; - else - slot = new nsRegionSlot; - - if (slot != nsnull) { - // put this region on the region list. - slot->mRegion = aRgnHandle; - slot->mNext = mRegionSlots; - mRegionSlots = slot; - } else { - // couldn't allocate a slot, toss the region. - ::DisposeRgn(aRgnHandle); - } -} - - -#pragma mark - +#include "nsRegionPool.h" //--------------------------------------------------------------------- diff --git a/mozilla/gfx/src/mac/nsRegionMac.h b/mozilla/gfx/src/mac/nsRegionMac.h index 6c6e30d1e15..51a28dd0f68 100644 --- a/mozilla/gfx/src/mac/nsRegionMac.h +++ b/mozilla/gfx/src/mac/nsRegionMac.h @@ -40,58 +40,7 @@ #define nsRegionMac_h___ #include "nsIRegion.h" -#include - -//------------------------------------------------------------------------ - - -class NS_EXPORT nsNativeRegionPool -{ -public: - nsNativeRegionPool(); - ~nsNativeRegionPool(); - - RgnHandle GetNewRegion(); - void ReleaseRegion(RgnHandle aRgnHandle); - -private: - struct nsRegionSlot { - RgnHandle mRegion; - nsRegionSlot* mNext; - }; - - nsRegionSlot* mRegionSlots; - nsRegionSlot* mEmptySlots; -}; - -//------------------------------------------------------------------------ - -extern nsNativeRegionPool sNativeRegionPool; - -//------------------------------------------------------------------------ - -class StRegionFromPool -{ -public: - StRegionFromPool() - { - mRegionH = sNativeRegionPool.GetNewRegion(); - } - - ~StRegionFromPool() - { - if ( mRegionH ) - sNativeRegionPool.ReleaseRegion(mRegionH); - } - - operator RgnHandle() const - { - return mRegionH; - } - - private: - RgnHandle mRegionH; -}; +#include //------------------------------------------------------------------------ diff --git a/mozilla/gfx/src/mac/nsRegionPool.cpp b/mozilla/gfx/src/mac/nsRegionPool.cpp new file mode 100644 index 00000000000..06c6063a877 --- /dev/null +++ b/mozilla/gfx/src/mac/nsRegionPool.cpp @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either 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 NPL, 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsRegionPool.h" + + +NS_EXPORT nsNativeRegionPool sNativeRegionPool; + +//------------------------------------------------------------------------ + +nsNativeRegionPool::nsNativeRegionPool() +{ + mRegionSlots = nsnull; + mEmptySlots = nsnull; +} + +//------------------------------------------------------------------------ + +nsNativeRegionPool::~nsNativeRegionPool() +{ + // Release all of the regions. + if (mRegionSlots != nsnull) { + nsRegionSlot* slot = mRegionSlots; + while (slot != nsnull) { + ::DisposeRgn(slot->mRegion); + nsRegionSlot* next = slot->mNext; + delete slot; + slot = next; + } + } + + // Release all empty slots. + if (mEmptySlots != nsnull) { + nsRegionSlot* slot = mEmptySlots; + while (slot != nsnull) { + nsRegionSlot* next = slot->mNext; + delete slot; + slot = next; + } + } +} + +//------------------------------------------------------------------------ + +RgnHandle nsNativeRegionPool::GetNewRegion() +{ + nsRegionSlot* slot = mRegionSlots; + if (slot != nsnull) { + RgnHandle region = slot->mRegion; + + // remove this slot from the free list. + mRegionSlots = slot->mNext; + + // transfer this slot to the empty slot list for reuse. + slot->mRegion = nsnull; + slot->mNext = mEmptySlots; + mEmptySlots = slot; + + // initialize the region. + ::SetEmptyRgn(region); + return region; + } + + // return a fresh new region. a slot will be created to hold it + // if and when the region is released. + return (::NewRgn()); +} + +//------------------------------------------------------------------------ + +void nsNativeRegionPool::ReleaseRegion(RgnHandle aRgnHandle) +{ + nsRegionSlot* slot = mEmptySlots; + if (slot != nsnull) + mEmptySlots = slot->mNext; + else + slot = new nsRegionSlot; + + if (slot != nsnull) { + // put this region on the region list. + slot->mRegion = aRgnHandle; + slot->mNext = mRegionSlots; + mRegionSlots = slot; + } else { + // couldn't allocate a slot, toss the region. + ::DisposeRgn(aRgnHandle); + } +} + diff --git a/mozilla/gfx/src/mac/nsRegionPool.h b/mozilla/gfx/src/mac/nsRegionPool.h new file mode 100644 index 00000000000..762b9081b82 --- /dev/null +++ b/mozilla/gfx/src/mac/nsRegionPool.h @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either 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 NPL, 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 NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsRegionPool_h___ +#define nsRegionPool_h___ + +#include "nscore.h" +#include + + +class NS_EXPORT nsNativeRegionPool +{ +public: + nsNativeRegionPool(); + ~nsNativeRegionPool(); + + RgnHandle GetNewRegion(); + void ReleaseRegion(RgnHandle aRgnHandle); + +private: + struct nsRegionSlot { + RgnHandle mRegion; + nsRegionSlot* mNext; + }; + + nsRegionSlot* mRegionSlots; + nsRegionSlot* mEmptySlots; +}; + +//------------------------------------------------------------------------ + +extern nsNativeRegionPool sNativeRegionPool; + +//------------------------------------------------------------------------ + +class StRegionFromPool +{ +public: + StRegionFromPool() + { + mRegionH = sNativeRegionPool.GetNewRegion(); + } + + ~StRegionFromPool() + { + if ( mRegionH ) + sNativeRegionPool.ReleaseRegion(mRegionH); + } + + operator RgnHandle() const + { + return mRegionH; + } + + private: + RgnHandle mRegionH; +}; + + + +#endif // nsRegionPool_h___ diff --git a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp index ed4d0ebe108..e9f055eb087 100644 --- a/mozilla/gfx/src/mac/nsRenderingContextMac.cpp +++ b/mozilla/gfx/src/mac/nsRenderingContextMac.cpp @@ -58,10 +58,14 @@ #include #include -#include +#include + +#include "nsRegionPool.h" +#include "nsFontUtils.h" + #include "nsCarbonHelpers.h" -#define STACK_TREASHOLD 1000 +#define STACK_THRESHOLD 1000 //------------------------------------------------------------------------ @@ -272,7 +276,7 @@ NS_IMETHODIMP nsRenderingContextMac::SetPortTextState() return NS_ERROR_NULL_POINTER; TextStyle theStyle; - nsFontMetricsMac::GetNativeTextStyle(*mGS->mFontMetrics, *mContext, theStyle); + nsFontUtils::GetNativeTextStyle(*mGS->mFontMetrics, *mContext, theStyle); ::TextFont(theStyle.tsFont); ::TextSize(theStyle.tsSize); @@ -1336,8 +1340,8 @@ NS_IMETHODIMP nsRenderingContextMac::DrawString(const char *aString, PRUint32 aL ::DrawText(aString,0,aLength); else { - int buffer[STACK_TREASHOLD]; - int* spacing = (aLength <= STACK_TREASHOLD ? buffer : new int[aLength]); + int buffer[STACK_THRESHOLD]; + int* spacing = (aLength <= STACK_THRESHOLD ? buffer : new int[aLength]); if (spacing) { mGS->mTMatrix.ScaleXCoords(aSpacing, aLength, spacing); diff --git a/mozilla/webshell/tests/viewer/mac/viewer.mcp b/mozilla/webshell/tests/viewer/mac/viewer.mcp index 70bb01b461d..890fdf7f2f4 100644 Binary files a/mozilla/webshell/tests/viewer/mac/viewer.mcp and b/mozilla/webshell/tests/viewer/mac/viewer.mcp differ diff --git a/mozilla/widget/macbuild/Widget.prefix b/mozilla/widget/macbuild/WidgetComponentConfig.h similarity index 51% rename from mozilla/widget/macbuild/Widget.prefix rename to mozilla/widget/macbuild/WidgetComponentConfig.h index 1264cc03657..22e062a9f20 100644 --- a/mozilla/widget/macbuild/Widget.prefix +++ b/mozilla/widget/macbuild/WidgetComponentConfig.h @@ -1,13 +1,11 @@ -// -// Widget.Prefix -// -// Global prefix file for the Widget project. -// - -#include "MacPrefix.h" #include #include #include #define USE_TLS_FOR_TOOLKIT 1 + +#if !TARGET_CARBON +#define USE_MENUSELECT 1 +#endif + diff --git a/mozilla/widget/macbuild/WidgetSharedPrefix.h b/mozilla/widget/macbuild/WidgetComponentDebugPrefix.h similarity index 92% rename from mozilla/widget/macbuild/WidgetSharedPrefix.h rename to mozilla/widget/macbuild/WidgetComponentDebugPrefix.h index f82754fc890..577757a03f3 100644 --- a/mozilla/widget/macbuild/WidgetSharedPrefix.h +++ b/mozilla/widget/macbuild/WidgetComponentDebugPrefix.h @@ -20,11 +20,10 @@ * Contributor(s): */ -#define MAC_SHARED 1 -#define _IMPL_NS_WIDGET 1 - -#include "Widget.prefix" +#include "WidgetComponentConfig.h" +#include "MacPrefix_debug.h" #if !TARGET_CARBON #define USE_MENUSELECT 1 #endif + diff --git a/mozilla/widget/macbuild/WidgetStaticDebugPrefix.h b/mozilla/widget/macbuild/WidgetComponentPrefix.h similarity index 93% rename from mozilla/widget/macbuild/WidgetStaticDebugPrefix.h rename to mozilla/widget/macbuild/WidgetComponentPrefix.h index 63ea04b350e..722e8863628 100644 --- a/mozilla/widget/macbuild/WidgetStaticDebugPrefix.h +++ b/mozilla/widget/macbuild/WidgetComponentPrefix.h @@ -20,6 +20,6 @@ * Contributor(s): */ -#define MAC_STATIC 1 +#include "WidgetComponentConfig.h" +#include "MacPrefix.h" -#include "WidgetDebug.prefix" \ No newline at end of file diff --git a/mozilla/widget/macbuild/WidgetStaticPrefix.h b/mozilla/widget/macbuild/WidgetStaticPrefix.h deleted file mode 100644 index b51e631322c..00000000000 --- a/mozilla/widget/macbuild/WidgetStaticPrefix.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape 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/NPL/ - * - * 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 Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -#define MAC_STATIC 1 - -#include "Widget.prefix" \ No newline at end of file diff --git a/mozilla/widget/macbuild/WidgetSupport.mcp b/mozilla/widget/macbuild/WidgetSupport.mcp new file mode 100644 index 00000000000..ff26171743b Binary files /dev/null and b/mozilla/widget/macbuild/WidgetSupport.mcp differ diff --git a/mozilla/widget/macbuild/WidgetSupport.prefix b/mozilla/widget/macbuild/WidgetSupport.prefix new file mode 100644 index 00000000000..ec8be42c82a --- /dev/null +++ b/mozilla/widget/macbuild/WidgetSupport.prefix @@ -0,0 +1,8 @@ +// +// Widget.Prefix +// +// Global prefix file for the Widget project. +// + +#include "WidgetSupportConfig.h" +#include "MacPrefix.h" diff --git a/mozilla/widget/macbuild/WidgetSupportConfig.h b/mozilla/widget/macbuild/WidgetSupportConfig.h new file mode 100644 index 00000000000..c05110cb831 --- /dev/null +++ b/mozilla/widget/macbuild/WidgetSupportConfig.h @@ -0,0 +1,3 @@ + + +#define _IMPL_NS_WIDGET 1 diff --git a/mozilla/widget/macbuild/WidgetDebug.prefix b/mozilla/widget/macbuild/WidgetSupportDebug.prefix similarity index 53% rename from mozilla/widget/macbuild/WidgetDebug.prefix rename to mozilla/widget/macbuild/WidgetSupportDebug.prefix index 4a8671ab071..0591bbaeddb 100644 --- a/mozilla/widget/macbuild/WidgetDebug.prefix +++ b/mozilla/widget/macbuild/WidgetSupportDebug.prefix @@ -4,10 +4,5 @@ // Global prefix file for the debug Widget project. // +#include "WidgetSupportConfig.h" #include "MacPrefix_debug.h" - -#include -#include -#include - -#define USE_TLS_FOR_TOOLKIT 1 diff --git a/mozilla/widget/macbuild/widget.mcp b/mozilla/widget/macbuild/widget.mcp index 4d8908c4c6d..f78eea50476 100644 Binary files a/mozilla/widget/macbuild/widget.mcp and b/mozilla/widget/macbuild/widget.mcp differ diff --git a/mozilla/widget/src/mac/nsChildWindow.cpp b/mozilla/widget/src/mac/nsChildWindow.cpp index 183994ce4d6..8260a7b6fac 100644 --- a/mozilla/widget/src/mac/nsChildWindow.cpp +++ b/mozilla/widget/src/mac/nsChildWindow.cpp @@ -38,6 +38,7 @@ #include "nsChildWindow.h" #include "nsCOMPtr.h" #include "nsRegionMac.h" +#include "nsRegionPool.h" //------------------------------------------------------------------------- // diff --git a/mozilla/widget/src/mac/nsMacControl.cpp b/mozilla/widget/src/mac/nsMacControl.cpp index 0b5befd3d1e..3e374f601a1 100644 --- a/mozilla/widget/src/mac/nsMacControl.cpp +++ b/mozilla/widget/src/mac/nsMacControl.cpp @@ -38,6 +38,7 @@ #include "nsIFontMetrics.h" #include "nsIDeviceContext.h" #include "nsFont.h" +#include "nsFontUtils.h" #include "nsToolkit.h" #include "nsMacControl.h" @@ -382,7 +383,7 @@ void nsMacControl::SetupMacControlFont() TextStyle theStyle; #if !TARGET_CARBON - nsFontMetricsMac::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); + nsFontUtils::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); #endif // if needed, impose a min size of 9pt on the control font if (theStyle.tsSize < 9) @@ -510,7 +511,7 @@ void nsMacControl::NSStringSetControlTitle(ControlHandle theControl, nsString ti // determine the script of the font that the control is supposed to be drawn in // #if !TARGET_CARBON - nsFontMetricsMac::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); + nsFontUtils::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); #endif fontScript = ::FontToScript(theStyle.tsFont); @@ -592,7 +593,7 @@ void nsMacControl::SetupMacControlFontForScript(short theScript) NS_PRECONDITION(mFontMetrics != nsnull, "No font metrics in SetupMacControlFont"); NS_PRECONDITION(mContext != nsnull, "No context metrics in SetupMacControlFont"); #if !TARGET_CARBON - nsFontMetricsMac::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); + nsFontUtils::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); #endif // diff --git a/mozilla/widget/src/mac/nsMacMessageSink.cpp b/mozilla/widget/src/mac/nsMacMessageSink.cpp index 18d9a5447b3..feee7e0c13d 100644 --- a/mozilla/widget/src/mac/nsMacMessageSink.cpp +++ b/mozilla/widget/src/mac/nsMacMessageSink.cpp @@ -46,7 +46,7 @@ // Return PR_TRUE if the event was handled // //------------------------------------------------------------------------- -NS_EXPORT PRBool nsMacMessageSink::DispatchOSEvent( +PRBool nsMacMessageSink::DispatchOSEvent( EventRecord &anEvent, WindowPtr aWindow) { @@ -70,7 +70,7 @@ NS_EXPORT PRBool nsMacMessageSink::DispatchOSEvent( // DispatchMenuCommand // //------------------------------------------------------------------------- -NS_EXPORT PRBool nsMacMessageSink::DispatchMenuCommand( +PRBool nsMacMessageSink::DispatchMenuCommand( EventRecord &anEvent, long menuResult, WindowPtr aWindow) @@ -96,7 +96,7 @@ NS_EXPORT PRBool nsMacMessageSink::DispatchMenuCommand( // GetNSWindowFromWindow // //------------------------------------------------------------------------- -NS_EXPORT nsMacWindow *nsMacMessageSink::GetNSWindowFromMacWindow(WindowPtr inWindow) +nsMacWindow *nsMacMessageSink::GetNSWindowFromMacWindow(WindowPtr inWindow) { if (!inWindow) return nsnull; @@ -122,7 +122,7 @@ NS_EXPORT nsMacWindow *nsMacMessageSink::GetNSWindowFromMacWindow(WindowPtr inWi // IsRaptorWindow // //------------------------------------------------------------------------- -NS_EXPORT PRBool nsMacMessageSink::IsRaptorWindow(WindowPtr inWindow) +PRBool nsMacMessageSink::IsRaptorWindow(WindowPtr inWindow) { if (!inWindow) return PR_FALSE; return (GetRaptorWindowList()[inWindow] != nsnull); diff --git a/mozilla/widget/src/mac/nsMacMessageSink.h b/mozilla/widget/src/mac/nsMacMessageSink.h index af74b569ea4..ceaa1c03743 100644 --- a/mozilla/widget/src/mac/nsMacMessageSink.h +++ b/mozilla/widget/src/mac/nsMacMessageSink.h @@ -39,6 +39,7 @@ #define nsMacMessageSink_h__ #include "prtypes.h" +#include "nscore.h" #include @@ -66,7 +67,7 @@ to a nsMacWindow *. ================================================*/ // Macintosh Message Sink Class -class nsMacMessageSink +class NS_WIDGET nsMacMessageSink { private: diff --git a/mozilla/widget/src/mac/nsScrollbar.h b/mozilla/widget/src/mac/nsScrollbar.h index d7a48268552..c91f5296bf4 100644 --- a/mozilla/widget/src/mac/nsScrollbar.h +++ b/mozilla/widget/src/mac/nsScrollbar.h @@ -120,4 +120,19 @@ private: static ControlActionUPP sControlActionProc; // we only need one of these }; + + +class nsHorizScrollbar : public nsScrollbar +{ +public: + nsHorizScrollbar() : nsScrollbar(PR_FALSE) {} +}; + +class nsVertScrollbar : public nsScrollbar +{ +public: + nsVertScrollbar() : nsScrollbar(PR_TRUE) {} +}; + + #endif // nsScrollbar_ diff --git a/mozilla/widget/src/mac/nsWidgetFactory.cpp b/mozilla/widget/src/mac/nsWidgetFactory.cpp index c382c4647d2..38d3e00439a 100644 --- a/mozilla/widget/src/mac/nsWidgetFactory.cpp +++ b/mozilla/widget/src/mac/nsWidgetFactory.cpp @@ -88,8 +88,6 @@ #include "nsBidiKeyboard.h" #endif -#ifdef XP_MACOSX - #include "nsIGenericFactory.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl) @@ -97,7 +95,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) #if USE_NATIVE_VERSION NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsComboBox) @@ -105,7 +102,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRadioButton) NS_GENERIC_FACTORY_CONSTRUCTOR(nsListBox) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextAreaWidget) #endif -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHorizScrollbar) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsVertScrollbar) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) // used by Viewer? NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) @@ -114,32 +113,15 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuBar) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenu) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuItem) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) #endif - -#define NS_GENERIC_SCROLLBAR_CONSTRUCTOR(type, isVertical) \ -static NS_IMETHODIMP \ -type ## ScrollbarConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) \ -{ \ - if (aOuter) return NS_ERROR_NO_AGGREGATION; \ - if (!aResult) return NS_ERROR_NULL_POINTER; \ - *aResult = NULL; \ - nsCOMPtr scrollbar = new nsScrollbar(isVertical); \ - if (!scrollbar) return NS_ERROR_OUT_OF_MEMORY; \ - return scrollbar->QueryInterface(aIID, aResult); \ -} - -NS_GENERIC_SCROLLBAR_CONSTRUCTOR(Vertical, PR_TRUE) -NS_GENERIC_SCROLLBAR_CONSTRUCTOR(Horizontal, PR_FALSE) - static nsModuleComponentInfo components[] = { { "Timer", @@ -156,7 +138,7 @@ static nsModuleComponentInfo components[] = nsMacWindowConstructor }, { "Child nsWindow", NS_CHILD_CID, - "@mozilla.org/widgets/childwindow/mac;1", + "@mozilla.org/widgets/child_window/mac;1", ChildWindowConstructor }, { "Button", NS_BUTTON_CID, @@ -169,14 +151,14 @@ static nsModuleComponentInfo components[] = { "Horiz Scrollbar", NS_HORZSCROLLBAR_CID, "@mozilla.org/widgets/horizscroll/mac;1", - HorizontalScrollbarConstructor }, + nsHorizScrollbarConstructor }, { "Vert Scrollbar", NS_VERTSCROLLBAR_CID, "@mozilla.org/widgets/vertscroll/mac;1", - VerticalScrollbarConstructor }, + nsVertScrollbarConstructor }, { "Text Field", NS_TEXTFIELD_CID, - "@mozilla.org/widgets/textfield/mac;1", + "@mozilla.org/widgets/textwidget/mac;1", nsTextWidgetConstructor }, { "AppShell", NS_APPSHELL_CID, @@ -231,7 +213,7 @@ static nsModuleComponentInfo components[] = "@mozilla.org/widget/dragservice;1", nsDragServiceConstructor }, #ifdef IBMBIDI - { "Gtk Bidi Keyboard", + { "Gtk Bidi Keyboard", NS_BIDIKEYBOARD_CID, "@mozilla.org/widget/bidikeyboard;1", nsBidiKeyboardConstructor }, @@ -240,237 +222,3 @@ static nsModuleComponentInfo components[] = NS_IMPL_NSGETMODULE(nsWidgetModule, components) -#else - -// NOTE the following does not match MAC_STATIC actually used below in this file! -#define MACSTATIC - -static NS_DEFINE_CID(kCWindow, NS_WINDOW_CID); -static NS_DEFINE_IID(kCTimer, NS_TIMER_CID); -static NS_DEFINE_CID(kCPopUp, NS_POPUP_CID); -static NS_DEFINE_CID(kCChild, NS_CHILD_CID); -static NS_DEFINE_CID(kCButton, NS_BUTTON_CID); -static NS_DEFINE_CID(kCCheckButton, NS_CHECKBUTTON_CID); -static NS_DEFINE_CID(kCFilePicker, NS_FILEPICKER_CID); -static NS_DEFINE_CID(kCHorzScrollbar, NS_HORZSCROLLBAR_CID); -static NS_DEFINE_CID(kCVertScrollbar, NS_VERTSCROLLBAR_CID); -static NS_DEFINE_CID(kCTextField, NS_TEXTFIELD_CID); -static NS_DEFINE_CID(kCAppShell, NS_APPSHELL_CID); -static NS_DEFINE_CID(kCToolkit, NS_TOOLKIT_CID); -static NS_DEFINE_CID(kCLookAndFeel, NS_LOOKANDFEEL_CID); -static NS_DEFINE_CID(kCLabel, NS_LABEL_CID); -static NS_DEFINE_CID(kCMenuBar, NS_MENUBAR_CID); -static NS_DEFINE_CID(kCMenu, NS_MENU_CID); -static NS_DEFINE_CID(kCMenuItem, NS_MENUITEM_CID); -static NS_DEFINE_CID(kCPopUpMenu, NS_POPUPMENU_CID); - -// Drag and Drop/Clipboard -static NS_DEFINE_CID(kCDataFlavor, NS_DATAFLAVOR_CID); -static NS_DEFINE_CID(kCClipboard, NS_CLIPBOARD_CID); -static NS_DEFINE_CID(kCClipboardHelper, NS_CLIPBOARDHELPER_CID); -static NS_DEFINE_CID(kCTransferable, NS_TRANSFERABLE_CID); -static NS_DEFINE_CID(kCHTMLFormatConverter, NS_HTMLFORMATCONVERTER_CID); -static NS_DEFINE_CID(kCDragService, NS_DRAGSERVICE_CID); - -// Sound services (just Beep for now) -static NS_DEFINE_CID(kCSound, NS_SOUND_CID); - -#ifdef IBMBIDI -static NS_DEFINE_CID(kCBidiKeyboard, NS_BIDIKEYBOARD_CID); -#endif -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -class nsWidgetFactory : public nsIFactory -{ -public: - - NS_DECL_ISUPPORTS - - // nsIFactory methods - NS_IMETHOD CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); - - nsWidgetFactory(const nsCID &aClass); - virtual ~nsWidgetFactory(); -private: - nsCID mClassID; - -}; - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -nsWidgetFactory::nsWidgetFactory(const nsCID &aClass) -{ - NS_INIT_REFCNT(); - mClassID = aClass; -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -nsWidgetFactory::~nsWidgetFactory() -{ -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS1(nsWidgetFactory, nsIFactory) - -//------------------------------------------------------------------------- -// -// ***IMPORTANT*** -// On all platforms, we are assuming in places that the implementation of |nsIWidget| -// is really |nsWindow| and then calling methods specific to nsWindow to finish the job. -// This is by design and the assumption is safe because an nsIWidget can only be created through -// our Widget factory where all our widgets, including the XP widgets, inherit from nsWindow. -// A similar warning is in nsWindow.cpp. -//------------------------------------------------------------------------- -nsresult nsWidgetFactory::CreateInstance(nsISupports *aOuter, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) { - return NS_ERROR_NULL_POINTER; - } - *aResult = NULL; - if (nsnull != aOuter) { - return NS_ERROR_NO_AGGREGATION; - } - - nsISupports *inst = nsnull; - - if (mClassID.Equals(kCTimer)) { - inst = (nsISupports*)new nsTimerImpl(); - } - else if (mClassID.Equals(kCWindow)) { - inst = (nsISupports*)(nsBaseWidget*)new nsMacWindow(); - } - else if (mClassID.Equals(kCPopUp)) { - inst = (nsISupports*)(nsBaseWidget*)new nsMacWindow(); - } - else if (mClassID.Equals(kCChild)) { - inst = (nsISupports*)(nsBaseWidget*)new ChildWindow(); - } - else if (mClassID.Equals(kCButton)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsButton(); - } - else if (mClassID.Equals(kCFilePicker)) { - inst = (nsISupports*)(nsBaseFilePicker*)new nsFilePicker(); - } -#if USE_NATIVE_VERSION - else if (mClassID.Equals(kCCheckButton)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsCheckButton(); - } -#endif - else if (mClassID.Equals(kCHorzScrollbar)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_FALSE); - } - else if (mClassID.Equals(kCVertScrollbar)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsScrollbar(PR_TRUE); - } - else if (mClassID.Equals(kCTextField)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsTextWidget(); - } - else if (mClassID.Equals(kCAppShell)) { - inst = (nsISupports*)new nsAppShell(); - } - else if (mClassID.Equals(kCToolkit)) { - inst = (nsISupports*)new nsToolkit(); - } - else if (mClassID.Equals(kCLookAndFeel)) { - inst = (nsISupports*)new nsLookAndFeel(); - } - else if (mClassID.Equals(kCLabel)) { - inst = (nsISupports*)(nsBaseWidget*)(nsWindow*)new nsLabel(); - } - else if (mClassID.Equals(kCMenuBar)) { - inst = (nsISupports*)(nsIMenuBar*) new nsMenuBar(); - } - else if (mClassID.Equals(kCMenu)) { - inst = (nsISupports*)(nsIMenu*) new nsMenu(); - } - else if (mClassID.Equals(kCMenuItem)) { - inst = (nsISupports*)(nsIMenuItem*) new nsMenuItem(); - } - else if (mClassID.Equals(kCPopUpMenu)) { - // inst = (nsISupports*)new nsPopUpMenu(); - NS_NOTYETIMPLEMENTED("nsPopUpMenu"); - } - else if (mClassID.Equals(kCSound)) { - inst = (nsISupports*)(nsISound*) new nsSound(); - } - else if (mClassID.Equals(kCTransferable)) - inst = (nsISupports*)new nsTransferable(); - else if (mClassID.Equals(kCHTMLFormatConverter)) - inst = (nsISupports*)new nsHTMLFormatConverter(); - else if (mClassID.Equals(kCClipboard)) - inst = (nsISupports*)new nsClipboard(); - else if (mClassID.Equals(kCClipboardHelper)) - inst = (nsISupports*)new nsClipboardHelper(); - else if (mClassID.Equals(kCDragService)) - inst = (nsISupports*)NS_STATIC_CAST(nsIDragService*, new nsDragService()); -#ifdef IBMBIDI - else if (mClassID.Equals(kCBidiKeyboard)) - inst = (nsISupports*)(nsIBidiKeyboard*) new nsBidiKeyboard(); -#endif // IBMBIDI - - if (inst == NULL) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(inst); - nsresult res = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return res; -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -nsresult nsWidgetFactory::LockFactory(PRBool aLock) -{ - // Not implemented in simplest case. - return NS_OK; -} - -//------------------------------------------------------------------------- -// -//------------------------------------------------------------------------- -// return the proper factory to the caller -#if defined(XP_MAC) && defined(MAC_STATIC) -extern "C" NS_WIDGET nsresult -NSGetFactory_WIDGET_DLL(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -#else -extern "C" NS_WIDGET nsresult -NSGetFactory(nsISupports* serviceMgr, - const nsCID &aClass, - const char *aClassName, - const char *aContractID, - nsIFactory **aFactory) -#endif -{ - if (nsnull == aFactory) { - return NS_ERROR_NULL_POINTER; - } - - *aFactory = new nsWidgetFactory(aClass); - - if (nsnull == aFactory) { - return NS_ERROR_OUT_OF_MEMORY; - } - - return (*aFactory)->QueryInterface(NS_GET_IID(nsIFactory), (void**)aFactory); -} - -#endif diff --git a/mozilla/widget/src/mac/nsWindow.cpp b/mozilla/widget/src/mac/nsWindow.cpp index 9270e34c501..1014a6b1398 100644 --- a/mozilla/widget/src/mac/nsWindow.cpp +++ b/mozilla/widget/src/mac/nsWindow.cpp @@ -66,6 +66,7 @@ #include "nsCarbonHelpers.h" #include "nsGfxUtils.h" +#include "nsRegionPool.h" #if PINK_PROFILING #include "profilerutils.h" diff --git a/mozilla/xpfe/bootstrap/macbuild/apprunner.mcp b/mozilla/xpfe/bootstrap/macbuild/apprunner.mcp index 772c542a627..a941bc6ae83 100644 Binary files a/mozilla/xpfe/bootstrap/macbuild/apprunner.mcp and b/mozilla/xpfe/bootstrap/macbuild/apprunner.mcp differ