Bug 332115 - hide a bunch of symbols when building libxul, fix the thebes symbols so that they are exported/imported sanely, and some other graphics-related linking/visibility fixups, r=darin+vlad

This commit is contained in:
benjamin%smedbergs.us 2006-04-27 14:41:11 +00:00
Родитель 876f09528d
Коммит ddc19fa107
40 изменённых файлов: 183 добавлений и 267 удалений

Просмотреть файл

@ -45,7 +45,9 @@ include $(DEPTH)/config/autoconf.mk
SUBMAKEFILES += cairo-features.h
ifndef MOZ_ENABLE_LIBXUL
VISIBILITY_FLAGS =
endif
MODULE = cairo
LIBRARY_NAME = mozcairo

Просмотреть файл

@ -37,7 +37,21 @@
#ifndef CAIRO_PLATFORM_H
#define CAIRO_PLATFORM_H
#if defined(XP_WIN)
#if defined(MOZ_ENABLE_LIBXUL)
#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE
#define CVISIBILITY_HIDDEN __attribute__((visibility("hidden")))
#else
#define CVISIBILITY_HIDDEN
#endif
// In libxul builds we don't ever want to export cairo symbols
#define cairo_public extern CVISIBILITY_HIDDEN
#define CCALLBACK
#define CCALLBACK_DECL
#define CSTATIC_CALLBACK(__x) static __x
#elif defined(XP_WIN)
#define cairo_public extern __declspec(dllexport)
#define CCALLBACK
@ -67,7 +81,7 @@
#else /* Unix */
#ifdef HAVE_VISIBILITY_PRAGMA
#ifdef HAVE_VISIBILITY_ATTRIBUTE
#define CVISIBILITY_DEFAULT __attribute__((visibility("default")))
#else
#define CVISIBILITY_DEFAULT

Просмотреть файл

@ -43,12 +43,14 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
VISIBILITY_FLAGS =
MODULE = libpixman
LIBRARY_NAME = mozlibpixman
LIBXUL_LIBRARY = 1
ifndef MOZ_ENABLE_LIBXUL
VISIBILITY_FLAGS =
endif
CSRCS = \
fbcompose.c \
fbedge.c \

Просмотреть файл

@ -78,8 +78,9 @@ protected:
// ownership is implied. MMP.
};
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
// inherit visibility from the NS_GFX class declaration
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY
class NS_GFX DeviceContextImpl : public nsIDeviceContext,
public nsIObserver,
@ -169,7 +170,7 @@ public:
#endif
};
#undef IMETHOD_VISIBILITY
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
#endif /* nsDeviceContext_h___ */

Просмотреть файл

@ -50,9 +50,6 @@ typedef struct {
int i; // edge number: edge i goes from mPointList[i] to mPointList[i+1]
} Edge;
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
class nsRenderingContextImpl : public nsIRenderingContext
{
@ -203,7 +200,4 @@ private:
};
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
#endif /* nsRenderingContextImpl */

Просмотреть файл

@ -48,7 +48,7 @@
* A surface is something you can draw on. Instantiate a subclass of this
* abstract class, and use gfxContext to draw on this surface.
*/
class NS_EXPORT gfxASurface {
class THEBES_API gfxASurface {
THEBES_DECL_REFCOUNTING_ABSTRACT
public:
@ -148,7 +148,7 @@ private:
/**
* An Unknown surface; used to wrap unknown cairo_surface_t returns from cairo
*/
class NS_EXPORT gfxUnknownSurface : public gfxASurface {
class THEBES_API gfxUnknownSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -72,7 +72,7 @@ protected:
gfxFont::Metrics mMetrics;
};
class NS_EXPORT gfxAtsuiFontGroup : public gfxFontGroup {
class THEBES_API gfxAtsuiFontGroup : public gfxFontGroup {
public:
gfxAtsuiFontGroup(const nsAString& families,
const gfxFontStyle *aStyle);
@ -97,7 +97,7 @@ protected:
ATSUFontFallbacks mFallbacks;
};
class NS_EXPORT gfxAtsuiTextRun : public gfxTextRun {
class THEBES_API gfxAtsuiTextRun : public gfxTextRun {
THEBES_DECL_ISUPPORTS_INHERITED
public:
gfxAtsuiTextRun(const nsAString& aString, gfxAtsuiFontGroup *aFontGroup);

Просмотреть файл

@ -49,7 +49,7 @@
* XXX should this use doubles (instead of gfxFloat), for consistency with
* cairo?
*/
struct NS_EXPORT gfxRGBA {
struct THEBES_API gfxRGBA {
gfxFloat r, g, b, a;
gfxRGBA() { }

Просмотреть файл

@ -64,7 +64,7 @@ class gfxTextRun;
* When a path is drawn (stroked or filled), it is filled/stroked with a
* pattern set by SetPattern, SetColor or SetSource.
*/
class NS_EXPORT gfxContext {
class THEBES_API gfxContext {
THEBES_DECL_REFCOUNTING
public:

Просмотреть файл

@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** 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 Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
*
* 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 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 ***** */
#ifndef GFX_FILTER_H
#define GFX_FILTER_H
#include "gfxTypes.h"
/**
* A filter.
*
* @see gfxContext::PushFilter, gfxContext::PopFilter
*/
class NS_EXPORT gfxFilter {
static gfxFilter* CreateOpacityFilter(gfxFloat alpha);
// CreateGaussianFilter, etc
};
#endif /* GFX_FILTER_H */

Просмотреть файл

@ -64,7 +64,7 @@ class gfxTextRun;
class gfxFontGroup;
struct NS_EXPORT gfxFontStyle {
struct THEBES_API gfxFontStyle {
gfxFontStyle(PRUint8 aStyle, PRUint8 aVariant,
PRUint16 aWeight, PRUint8 aDecoration, gfxFloat aSize,
const nsACString& aLangGroup,
@ -119,7 +119,7 @@ struct NS_EXPORT gfxFontStyle {
/* a SPECIFIC single font family */
class NS_EXPORT gfxFont {
class THEBES_API gfxFont {
THEBES_DECL_REFCOUNTING_ABSTRACT
public:
@ -162,7 +162,7 @@ protected:
};
class NS_EXPORT gfxFontGroup {
class THEBES_API gfxFontGroup {
public:
gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyle);
@ -198,7 +198,7 @@ protected:
// these do not copy the text
class NS_EXPORT gfxTextRun {
class THEBES_API gfxTextRun {
THEBES_DECL_REFCOUNTING_ABSTRACT
public:

Просмотреть файл

@ -45,7 +45,7 @@
/**
* A surface that wraps a glitz surface.
*/
class NS_EXPORT gfxGlitzSurface : public gfxASurface {
class THEBES_API gfxGlitzSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -48,7 +48,7 @@
* purpose is for storing read-only images and using it as a source surface,
* but it can also be drawn to.
*/
class NS_EXPORT gfxImageSurface : public gfxASurface {
class THEBES_API gfxImageSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -64,7 +64,7 @@
* \ tx ty 1 / \ 1 /
*
*/
class NS_EXPORT gfxMatrix {
class THEBES_API gfxMatrix {
protected:
cairo_matrix_t mat;

Просмотреть файл

@ -40,7 +40,7 @@
#include "gfxASurface.h"
class NS_EXPORT gfxPDFSurface : public gfxASurface {
class THEBES_API gfxPDFSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -40,7 +40,7 @@
#include "gfxASurface.h"
class NS_EXPORT gfxPSSurface : public gfxASurface {
class THEBES_API gfxPSSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -67,7 +67,7 @@ protected:
void GetSize(const char *aString, PRUint32 aLength, gfxSize& inkSize, gfxSize& logSize);
};
class NS_EXPORT gfxPangoFontGroup : public gfxFontGroup {
class THEBES_API gfxPangoFontGroup : public gfxFontGroup {
public:
gfxPangoFontGroup (const nsAString& families,
const gfxFontStyle *aStyle);
@ -89,7 +89,7 @@ protected:
void *closure);
};
class NS_EXPORT gfxPangoTextRun : public gfxTextRun {
class THEBES_API gfxPangoTextRun : public gfxTextRun {
THEBES_DECL_ISUPPORTS_INHERITED
public:
gfxPangoTextRun(const nsAString& aString, gfxPangoFontGroup *aFontGroup);

Просмотреть файл

@ -47,7 +47,7 @@
class gfxContext;
class NS_EXPORT gfxPattern {
class THEBES_API gfxPattern {
friend class gfxContext;
THEBES_DECL_REFCOUNTING

Просмотреть файл

@ -46,7 +46,7 @@
class gfxImageSurface;
class NS_EXPORT gfxPlatform {
class THEBES_API gfxPlatform {
public:
/**
* Return a pointer to the current active platform.

Просмотреть файл

@ -42,7 +42,7 @@
#include "gfxPlatform.h"
class NS_EXPORT gfxPlatformGtk : public gfxPlatform {
class THEBES_API gfxPlatformGtk : public gfxPlatform {
public:
gfxPlatformGtk();

Просмотреть файл

@ -40,7 +40,7 @@
#include "gfxPlatform.h"
class NS_EXPORT gfxPlatformMac : public gfxPlatform {
class THEBES_API gfxPlatformMac : public gfxPlatform {
public:
gfxPlatformMac();

Просмотреть файл

@ -42,7 +42,7 @@
#include "gfxTypes.h"
struct NS_EXPORT gfxSize {
struct THEBES_API gfxSize {
gfxFloat width, height;
gfxSize() {}
@ -71,7 +71,7 @@ struct NS_EXPORT gfxSize {
}
};
struct NS_EXPORT gfxPoint {
struct THEBES_API gfxPoint {
gfxFloat x, y;
gfxPoint() { }

Просмотреть файл

@ -43,7 +43,7 @@
#include <Carbon/Carbon.h>
class NS_EXPORT gfxQuartzSurface : public gfxASurface {
class THEBES_API gfxQuartzSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -41,7 +41,7 @@
#include "gfxTypes.h"
#include "gfxPoint.h"
struct NS_EXPORT gfxRect {
struct THEBES_API gfxRect {
// pt? point?
gfxPoint pos;
gfxSize size;

Просмотреть файл

@ -1,80 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** 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 Oracle Corporation code.
*
* The Initial Developer of the Original Code is Oracle Corporation.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@pavlov.net>
*
* 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 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 ***** */
/*
* *********************************************************
* This file is under construction. Ignore it for a while.
* *********************************************************
*/
class NS_EXPORT gfxRegion {
public:
gfxRegion(const gfxRegion& r);
gfxRegion(const gfxRect& r);
gfxRegion& operator=(const gfxRegion& r);
gfxRegion& operator=(const gfxRect& r);
int operator==(const gfxRegion& r) const;
int operator!=(const gfxRegion& r) const;
gfxPoint& operator+=(const gfxRegion& r); // Union
gfxPoint& operator+=(const gfxRect& r); // Union
gfxPoint& operator-=(const gfxRegion& r); // Subtract
gfxPoint& operator-=(const gfxRect& r); // Subtract
void SetTo(const nsIRegion &aRegion);
void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Intersect(const nsIRegion &aRegion);
void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Union(const nsIRegion &aRegion);
void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Subtract(const nsIRegion &aRegion);
void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
PRBool IsEmpty(void);
PRBool IsEqual(const nsIRegion &aRegion);
void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void GetRects(nsRegionRectSet **aRects);
void FreeRects(nsRegionRectSet *aRects);
void GetNativeRegion(void *&aRegion) const;
void GetRegionComplexity(nsRegionComplexity &aComplexity) const;
void GetNumRects(PRUint32 *aRects) const;
};

Просмотреть файл

@ -39,13 +39,20 @@
#define GFX_TYPES_H
#include "prtypes.h"
/**
* Currently needs to be 'double' for Cairo compatibility. Could
* become 'float', perhaps, in some configurations.
*/
typedef double gfxFloat;
#if defined(MOZ_ENABLE_LIBXUL)
#define THEBES_API
#elif defined(IMPL_THEBES)
#define THEBES_API NS_EXPORT
#else
#define THEBES_API NS_IMPORT
#endif
/**
* Define refcounting for Thebes. For now use the stuff from nsISupportsImpl

Просмотреть файл

@ -101,7 +101,7 @@ private:
*
**********************************************************************/
class NS_EXPORT gfxWindowsFontGroup : public gfxFontGroup {
class THEBES_API gfxWindowsFontGroup : public gfxFontGroup {
public:
gfxWindowsFontGroup(const nsAString& aFamilies, const gfxFontStyle* aStyle);
@ -128,7 +128,7 @@ private:
*
**********************************************************************/
class NS_EXPORT gfxWindowsTextRun : public gfxTextRun {
class THEBES_API gfxWindowsTextRun : public gfxTextRun {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -46,7 +46,7 @@
#include <windows.h>
#include <mlang.h>
class NS_EXPORT gfxWindowsPlatform : public gfxPlatform {
class THEBES_API gfxWindowsPlatform : public gfxPlatform {
public:
gfxWindowsPlatform();
virtual ~gfxWindowsPlatform();

Просмотреть файл

@ -42,7 +42,7 @@
#include <windows.h>
class NS_EXPORT gfxWindowsSurface : public gfxASurface {
class THEBES_API gfxWindowsSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -50,7 +50,7 @@ class gfxContext;
* override NativeDraw, and then call Draw(). The drawing will be subjected
* to all Thebes transformations, clipping etc.
*/
class NS_EXPORT gfxXlibNativeRenderer {
class THEBES_API gfxXlibNativeRenderer {
public:
/**
* Perform the native drawing.

Просмотреть файл

@ -44,7 +44,7 @@
#include <cairo-xlib.h>
#include <cairo-xlib-xrender.h>
class NS_EXPORT gfxXlibSurface : public gfxASurface {
class THEBES_API gfxXlibSurface : public gfxASurface {
THEBES_DECL_ISUPPORTS_INHERITED
public:

Просмотреть файл

@ -29,6 +29,8 @@ CPPSRCS = \
gfxPlatform.cpp \
$(NULL)
DEFINES += -DIMPL_THEBES
ifdef MOZ_TREE_CAIRO
SHARED_LIBRARY_LIBS += \
$(DEPTH)/gfx/cairo/cairo/src/$(LIB_PREFIX)mozcairo.$(LIB_SUFFIX) \

Просмотреть файл

@ -208,11 +208,17 @@ typedef unsigned int JDIMENSION;
#define METHODDEF(type) static type PR_CALLBACK
/* a function used only in its module: */
#define LOCAL(type) static type
PR_BEGIN_EXTERN_C
#ifdef MOZ_ENABLE_LIBXUL
#define GLOBAL(type) type
#define EXTERN(type) extern type
#else
/* a function referenced thru EXTERNs: */
#define GLOBAL(type) PR_IMPLEMENT(type)
/* a reference to a GLOBAL function: */
PR_BEGIN_EXTERN_C
#define EXTERN(type) PR_EXTERN(type)
#endif
PR_END_EXTERN_C

Просмотреть файл

@ -44,11 +44,8 @@ include $(DEPTH)/config/autoconf.mk
MODULE = imgicon
LIBRARY_NAME = imgicon
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsIconDecoderModule
GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
PACKAGE_FILE = imgicon.pkg
@ -56,9 +53,9 @@ ifdef MOZ_ENABLE_GNOMEUI
EXTRA_DSO_LDOPTS = $(MOZ_GNOMEUI_LIBS)
PLATFORM = gtk
FORCE_SHARED_LIB = 1
EXPORT_LIBRARY =
else
LIBXUL_LIBRARY = 1
EXPORT_LIBRARY = 1
endif
ifeq ($(OS_ARCH),WINNT)
@ -107,10 +104,17 @@ XPIDLSRCS = nsIIconURI.idl
SHARED_LIBRARY_LIBS = $(PLATFORM)/$(LIB_PREFIX)imgicon$(PLATFORM)_s.$(LIB_SUFFIX)
ifdef LIBXUL_LIBRARY
EXTRA_DSO_LDOPTS += \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
else
EXTRA_DSO_LDOPTS += \
$(XPCOM_GLUE_LDOPTS) \
$(NSPR_LIBS) \
$(NULL)
endif
LOCAL_INCLUDES = -I$(srcdir)/$(PLATFORM)

Просмотреть файл

@ -44,7 +44,6 @@ include $(DEPTH)/config/autoconf.mk
MODULE = imgicon
LIBRARY_NAME = imgicongtk_s
LIBXUL_LIBRARY = 1
REQUIRES = xpcom \
string \

Просмотреть файл

@ -60,10 +60,8 @@ extern "C" {
#include "nsIStringBundle.h"
#include "nsEscape.h"
#include "nsNetUtil.h"
#include "nsIURL.h"
#include "nsStringStream.h"
#include "nsIconChannel.h"
@ -116,9 +114,11 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPixbuf, nsIURI *aURI,
"size miscalculation");
nsresult rv;
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewByteInputStream(getter_AddRefs(stream), (char*)buf, buf_size,
NS_ASSIGNMENT_ADOPT);
nsCOMPtr<nsIStringInputStream> stream =
do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = stream->AdoptData((char*)buf, buf_size);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewInputStreamChannel(aChannel, aURI, stream,
@ -199,14 +199,14 @@ nsIconChannel::InitWithGnome(nsIMozIconURI *aIconURI)
nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
getter_AddRefs(bundle));
nsXPIDLString appName;
nsAutoString appName;
if (bundle) {
bundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
getter_Copies(appName));
} else {
NS_WARNING("brand.properties not present, using default application name");
appName.AssignLiteral("Gecko");
appName.Assign(NS_LITERAL_STRING("Gecko"));
}
char* empty[] = { "" };

Просмотреть файл

@ -45,6 +45,7 @@
#include "nspr.h"
#include "nsIComponentManager.h"
#include "nsRect.h"
#include "nsComponentManagerUtils.h"
NS_IMPL_THREADSAFE_ADDREF(nsIconDecoder)
NS_IMPL_THREADSAFE_RELEASE(nsIconDecoder)

Просмотреть файл

@ -41,42 +41,53 @@
#include "nsNetUtil.h"
#include "nsIIOService.h"
#include "nsIURL.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
#include "nsPrintfCString.h"
#include "nsIAtom.h"
#include "nsStaticAtom.h"
#include "nsIAtomService.h"
#include "prprf.h"
#include "plstr.h"
#include <stdlib.h>
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#define DEFAULT_IMAGE_SIZE 16
// helper function for parsing out attributes like size, and contentType
// from the icon url.
static void extractAttributeValue(const char * searchString, const char * attributeName, char ** result);
static void extractAttributeValue(const char * searchString, const char * attributeName, nsCString& aResult);
static nsIAtom *sStockSizeButton = nsnull;
static nsIAtom *sStockSizeToolbar = nsnull;
static nsIAtom *sStockSizeToolbarsmall = nsnull;
static nsIAtom *sStockSizeMenu = nsnull;
static nsIAtom *sStockSizeDialog = nsnull;
static nsIAtom *sStockStateNormal = nsnull;
static nsIAtom *sStockStateDisabled = nsnull;
/* static */ const nsStaticAtom nsMozIconURI::sSizeAtoms[] =
{
{ "button", &sStockSizeButton },
{ "toolbar", &sStockSizeToolbar },
{ "toolbarsmall", &sStockSizeToolbarsmall },
{ "menu", &sStockSizeMenu },
{ "dialog", &sStockSizeDialog }
struct AtomStruct {
const char *string;
nsIAtom *atom;
};
/* static */ const nsStaticAtom nsMozIconURI::sStateAtoms[] =
static AtomStruct gSizeAtoms[] =
{
{ "normal", &sStockStateNormal },
{ "disabled", &sStockStateDisabled }
{ "button", nsnull },
{ "toolbar", nsnull },
{ "toolbarsmall", nsnull },
{ "menu", nsnull },
{ "dialog", nsnull }
};
static AtomStruct gStateAtoms[] =
{
{ "normal", nsnull },
{ "disabled", nsnull }
};
static void
FillAtoms(AtomStruct* atoms, PRUint32 length)
{
nsCOMPtr<nsIAtomService> as(do_GetService(NS_ATOMSERVICE_CONTRACTID));
if (!as)
return;
while (length) {
--length;
as->GetPermanentAtomUTF8(atoms[length].string,
&atoms[length].atom);
}
}
////////////////////////////////////////////////////////////////////////////////
nsMozIconURI::nsMozIconURI()
@ -92,8 +103,8 @@ nsMozIconURI::~nsMozIconURI()
/* static */ void
nsMozIconURI::InitAtoms()
{
NS_RegisterStaticAtoms(sSizeAtoms, NS_ARRAY_LENGTH(sSizeAtoms));
NS_RegisterStaticAtoms(sStateAtoms, NS_ARRAY_LENGTH(sStateAtoms));
FillAtoms(gSizeAtoms, NS_ARRAY_LENGTH(gSizeAtoms));
FillAtoms(gStateAtoms, NS_ARRAY_LENGTH(gStateAtoms));
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsMozIconURI, nsIMozIconURI, nsIURI)
@ -138,7 +149,10 @@ nsMozIconURI::FormatSpec(nsACString &spec)
{
spec += NS_MOZ_ICON_DELIMITER;
spec += "size=";
spec.Append(nsPrintfCString("%d", mSize));
char buf[20];
PR_snprintf(buf, sizeof(buf), "%d", mSize);
spec.Append(buf);
}
if (mIconState) {
@ -170,30 +184,30 @@ nsMozIconURI::GetSpec(nsACString &aSpec)
// containing just the attribute value. i.e you could pass in this string with
// an attribute name of 'size=', this will return 32
// Assumption: attribute pairs in the string are separated by '&'.
void extractAttributeValue(const char * searchString, const char * attributeName, char ** result)
void extractAttributeValue(const char * searchString, const char * attributeName, nsCString& result)
{
//NS_ENSURE_ARG_POINTER(extractAttributeValue);
char * attributeValue = nsnull;
if (searchString && attributeName)
{
// search the string for attributeName
PRUint32 attributeNameSize = strlen(attributeName);
const char * startOfAttribute = PL_strcasestr(searchString, attributeName);
if (startOfAttribute)
{
startOfAttribute += attributeNameSize; // skip over the attributeName
if (*startOfAttribute) // is there something after the attribute name
{
const char * endofAttribute = strchr(startOfAttribute, '&');
attributeValue = endofAttribute // is there text after attribute value ?
? PL_strndup(startOfAttribute, endofAttribute - startOfAttribute)
: PL_strdup(startOfAttribute);
} // if we have a attribute value
} // if we have a attribute name
} // if we got non-null search string and attribute name values
result.Truncate();
*result = attributeValue; // passing ownership of attributeValue into result...no need to
if (searchString && attributeName)
{
// search the string for attributeName
PRUint32 attributeNameSize = strlen(attributeName);
const char * startOfAttribute = PL_strcasestr(searchString, attributeName);
if (startOfAttribute)
{
startOfAttribute += attributeNameSize; // skip over the attributeName
if (*startOfAttribute) // is there something after the attribute name
{
const char * endofAttribute = strchr(startOfAttribute, '&');
if (endofAttribute)
result.Assign(Substring(startOfAttribute, endofAttribute));
else
result.Assign(startOfAttribute);
} // if we have a attribute value
} // if we have a attribute name
} // if we got non-null search string and attribute name values
}
NS_IMETHODIMP
@ -210,33 +224,37 @@ nsMozIconURI::SetSpec(const nsACString &aSpec)
if (strcmp("moz-icon", scheme.get()) != 0)
return NS_ERROR_MALFORMED_URI;
nsXPIDLCString sizeString;
nsXPIDLCString stateString;
nsCAutoString sizeString;
nsCAutoString stateString;
nsCAutoString mozIconPath(aSpec);
PRInt32 endPos = mozIconPath.FindChar(':') + 1; // guaranteed to exist!
PRInt32 pos = mozIconPath.FindChar(NS_MOZ_ICON_DELIMITER);
if (pos == -1) // no size or content type specified
// guaranteed to exist!
const char *path = strchr(mozIconPath.get(), ':') + 1;
const char *question = strchr(mozIconPath.get(), NS_MOZ_ICON_DELIMITER);
if (!question) // no size or content type specified
{
mozIconPath.Right(mDummyFilePath, mozIconPath.Length() - endPos);
mDummyFilePath.Assign(path);
}
else
{
mozIconPath.Mid(mDummyFilePath, endPos, pos - endPos);
mDummyFilePath.Assign(Substring(path, question));
// fill in any size and content type values...
nsXPIDLCString contentTypeString;
extractAttributeValue(mozIconPath.get() + pos, "size=", getter_Copies(sizeString));
extractAttributeValue(mozIconPath.get() + pos, "state=", getter_Copies(stateString));
extractAttributeValue(mozIconPath.get() + pos, "contentType=", getter_Copies(contentTypeString));
mContentType = contentTypeString;
extractAttributeValue(question, "size=", sizeString);
extractAttributeValue(question, "state=", stateString);
extractAttributeValue(question, "contentType=", mContentType);
}
if (!sizeString.IsEmpty())
{
nsCOMPtr<nsIAtom> atom = do_GetAtom(sizeString);
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sSizeAtoms); i++)
nsCOMPtr<nsIAtomService> atoms(do_GetService(NS_ATOMSERVICE_CONTRACTID));
nsCOMPtr<nsIAtom> atom;
atoms->GetAtomUTF8(sizeString.get(),
getter_AddRefs(atom));
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gSizeAtoms); i++)
{
if (atom == *(sSizeAtoms[i].mAtom))
if (atom == gSizeAtoms[i].atom)
{
mIconSize = atom;
break;
@ -246,10 +264,13 @@ nsMozIconURI::SetSpec(const nsACString &aSpec)
if (!stateString.IsEmpty())
{
nsCOMPtr<nsIAtom> atom = do_GetAtom(stateString);
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(sStateAtoms); i++)
nsCOMPtr<nsIAtomService> atoms(do_GetService(NS_ATOMSERVICE_CONTRACTID));
nsCOMPtr<nsIAtom> atom;
atoms->GetAtomUTF8(sizeString.get(),
getter_AddRefs(atom));
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(gStateAtoms); i++)
{
if (atom == *(sStateAtoms[i].mAtom))
if (atom == gStateAtoms[i].atom)
{
mIconState = atom;
break;
@ -284,7 +305,7 @@ nsMozIconURI::SetSpec(const nsACString &aSpec)
}
if (!sizeString.IsEmpty())
{
PRInt32 sizeValue = atoi(sizeString);
PRInt32 sizeValue = atoi(sizeString.get());
// if the size value we got back is > 0 then use it
if (sizeValue)
mSize = sizeValue;
@ -413,7 +434,7 @@ nsMozIconURI::Equals(nsIURI *other, PRBool *result)
other->GetSpec(spec2);
GetSpec(spec1);
if (!nsCRT::strcasecmp(spec1.get(), spec2.get()))
if (!PL_strcasecmp(spec1.get(), spec2.get()))
*result = PR_TRUE;
else
*result = PR_FALSE;
@ -546,7 +567,8 @@ nsMozIconURI::GetFileExtension(nsACString &aFileExtension)
{
// unfortunately, this code doesn't give us the required '.' in front of the extension
// so we have to do it ourselves..
aFileExtension = NS_LITERAL_CSTRING(".") + fileExt;
aFileExtension.Assign('.');
aFileExtension.Append(fileExt);
return NS_OK;
}
}
@ -564,7 +586,7 @@ nsMozIconURI::GetFileExtension(nsACString &aFileExtension)
const char * fileExt = strrchr(chFileName, '.');
if (!fileExt) return NS_ERROR_FAILURE; // no file extension to work from.
aFileExtension = nsDependentCString(fileExt);
aFileExtension.Assign(fileExt);
return NS_OK;
}

Просмотреть файл

@ -42,7 +42,7 @@
#include "nsIIconURI.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsStringGlue.h"
struct nsStaticAtom;
class nsIAtom;
@ -77,9 +77,6 @@ protected:
nsCOMPtr<nsIAtom> mIconSize;
nsCOMPtr<nsIAtom> mIconState;
static const nsStaticAtom sSizeAtoms[];
static const nsStaticAtom sStateAtoms[];
nsresult FormatSpec(nsACString &result);
};

Просмотреть файл

@ -37,11 +37,9 @@
#ifndef MOZZCONF_H
#define MOZZCONF_H
#if defined(XP_WIN) && defined(ZLIB_DLL) && !defined(MOZ_ENABLE_LIBXUL)
#ifdef MOZ_ENABLE_LIBXUL
#undef ZLIB_DLL
#endif
#ifdef HAVE_VISIBILITY_ATTRIBUTE
#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
#define ZEXTERN __attribute__((visibility ("default"))) extern
#endif