Bug 266236 part 2: Merge nsIRenderingContext with nsThebesRenderingContext (the sole implementation) and remove XPCOM vestiges. Non-mechanical fixups. DOES NOT COMPILE without part 3.

--HG--
rename : gfx/src/nsThebesRenderingContext.cpp => gfx/src/nsRenderingContext.cpp
rename : gfx/src/nsThebesRenderingContext.h => gfx/src/nsRenderingContext.h
extra : rebase_source : 9e149d30da5222d072071043d30d83033fec9787
This commit is contained in:
Jan Küchler 2011-04-07 18:04:39 -07:00
parent ebb2f0c7ec
commit cbabd3ce0f
23 changed files with 725 additions and 1430 deletions

View File

@ -72,7 +72,7 @@ EXPORTS = \
nsSize.h \
nsMargin.h \
nsTransform2D.h \
nsIRenderingContext.h \
nsRenderingContext.h \
nsIFontMetrics.h \
nsIDeviceContext.h \
nsGfxCIID.h \
@ -99,7 +99,7 @@ CPPSRCS = \
nsThebesDeviceContext.cpp \
nsThebesRegion.cpp \
nsThebesGfxFactory.cpp \
nsThebesRenderingContext.cpp \
nsRenderingContext.cpp \
nsThebesFontMetrics.cpp \
nsThebesFontEnumerator.cpp \
$(NULL)

View File

@ -46,10 +46,6 @@
{ 0x6049b260, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_RENDERING_CONTEXT_CID \
{ 0x6049b261, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_CID \
{ 0x6049b262, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }

View File

@ -42,9 +42,8 @@
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsRect.h"
#include "nsIRenderingContext.h"
// XXX we need only gfxTypes.h, but we cannot include it directly.
#include "gfxPoint.h"
#include "gfxTypes.h"
#include "nsStringFwd.h"
class nsIView;
class nsIFontMetrics;
@ -52,6 +51,7 @@ class nsIWidget;
class nsIDeviceContextSpec;
class nsIAtom;
class gfxUserFontSet;
class nsRenderingContext;
struct nsFont;

View File

@ -1,830 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Leon Sha <leon.sha@sun.com>
* Boris Zbarsky <bzbarsky@mit.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIRenderingContext_h___
#define nsIRenderingContext_h___
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsColor.h"
#include "nsCoord.h"
#include "nsRect.h"
#include "nsPoint.h"
#include "nsSize.h"
#include <stdio.h>
class nsIWidget;
class nsIFontMetrics;
class nsTransform2D;
class nsString;
class nsIDeviceContext;
class nsIntRegion;
class nsIAtom;
struct nsFont;
struct nsTextDimensions;
class gfxUserFontSet;
#ifdef MOZ_MATHML
struct nsBoundingMetrics;
#endif
class gfxASurface;
class gfxContext;
/* gfx2 */
class imgIContainer;
//cliprect/region combination methods
typedef enum
{
nsClipCombine_kIntersect = 0,
nsClipCombine_kUnion = 1,
nsClipCombine_kSubtract = 2,
nsClipCombine_kReplace = 3
} nsClipCombine;
//linestyles
typedef enum
{
nsLineStyle_kNone = 0,
nsLineStyle_kSolid = 1,
nsLineStyle_kDashed = 2,
nsLineStyle_kDotted = 3
} nsLineStyle;
typedef enum
{
nsPenMode_kNone = 0,
nsPenMode_kInvert = 1
} nsPenMode;
// IID for the nsIRenderingContext interface
#define NS_IRENDERING_CONTEXT_IID \
{ 0xefbfeb6c, 0x937e, 0x4889, \
{ 0x92, 0x46, 0x16, 0xc0, 0xe8, 0x4b, 0xfa, 0xae } }
//----------------------------------------------------------------------
// RenderingContext interface
class nsIRenderingContext : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRENDERING_CONTEXT_IID)
//TBD: bind/unbind, transformation of scalars (hacky),
//potential drawmode for selection, polygons. MMP
/**
* Initialize the RenderingContext
* @param aContext the device context to use.
* @param aWidget the widget to hook up to
* @result The result of the initialization, NS_Ok if no errors
*/
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget) = 0;
/**
* Initialize the RenderingContext
* @param aContext the device context to use for the drawing.
* @param aThebesSurface the Thebes gfxASurface to which to draw
* @result The result of the initialization, NS_Ok if no errors
*/
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxASurface* aThebesSurface) = 0;
/**
* Initialize the RenderingContext
* @param aContext the device context to use for the drawing.
* @param aThebesContext an existing thebes context to use for the drawing
* @result The result of the initialization, NS_Ok if no errors
*/
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxContext* aThebesContext) = 0;
/**
* Get the DeviceContext that this RenderingContext was initialized
* with.
* @result the device context
*/
virtual already_AddRefed<nsIDeviceContext> GetDeviceContext() = 0;
/**
* Save a graphical state onto a stack.
*/
NS_IMETHOD PushState(void) = 0;
/**
* Get and and set RenderingContext to this graphical state
*/
NS_IMETHOD PopState(void) = 0;
// XXX temporary
NS_IMETHOD PushFilter(const nsRect& aRect, PRBool aAreaIsOpaque, float aOpacity)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD PopFilter()
{ return NS_ERROR_NOT_IMPLEMENTED; }
/**
* Sets the clipping for the RenderingContext to the passed in rectangle.
* The rectangle is in app units!
* @param aRect The rectangle to set the clipping rectangle to
* @param aCombine how to combine this rect with the current clip region.
* see the bottom of nsIRenderingContext.h
*/
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine) = 0;
/**
* Sets the line style for the RenderingContext
* @param aLineStyle The line style
* @return NS_OK if the line style is correctly set
*/
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle) = 0;
/**
* Sets the clipping for the RenderingContext to the passed in region.
* The region is in device coordinates!
* @param aRegion The region to set the clipping area to, IN DEVICE COORDINATES
* @param aCombine how to combine this region with the current clip region.
* see the bottom of nsIRenderingContext.h
*/
NS_IMETHOD SetClipRegion(const nsIntRegion& aRegion, nsClipCombine aCombine) = 0;
/**
* Sets the forground color for the RenderingContext
* @param aColor The color to set the RenderingContext to
*/
NS_IMETHOD SetColor(nscolor aColor) = 0;
/**
* Get the forground color for the RenderingContext
* @return The current forground color of the RenderingContext
*/
NS_IMETHOD GetColor(nscolor &aColor) const = 0;
/**
* Sets the font for the RenderingContext
* @param aFont The font to use in the RenderingContext
*/
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLanguage,
gfxUserFontSet *aUserFontSet) = 0;
/**
* Sets the font for the RenderingContext, without language info
* @param aFont The font to use in the RenderingContext
*/
NS_IMETHOD SetFont(const nsFont& aFont,
gfxUserFontSet *aUserFontSet) = 0;
/**
* Sets the font for the RenderingContext
* @param aFontMetric The font metrics representing the
* font to use in the RenderingContext
*/
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics) = 0;
/**
* Get the current fontmetrics for the RenderingContext
* @return The current font of the RenderingContext
*/
virtual already_AddRefed<nsIFontMetrics> GetFontMetrics() = 0;
/**
* Add in a translate to the RenderingContext's transformation matrix
* @param aPt The point to translate to
*/
NS_IMETHOD Translate(const nsPoint& aPt) = 0;
/**
* Set the translation compoennt of the current transformation matrix.
* Useful to set it to a known pixel value without incurring roundoff
* errors.
*/
NS_IMETHOD SetTranslation(const nsPoint& aPt) = 0;
/**
* Add in a scale to the RenderingContext's transformation matrix
* @param aX The horizontal scale
* @param aY The vertical scale
*/
NS_IMETHOD Scale(float aSx, float aSy) = 0;
struct PushedTranslation {
float mSavedX, mSavedY;
};
class AutoPushTranslation {
nsIRenderingContext* mCtx;
PushedTranslation mPushed;
public:
AutoPushTranslation(nsIRenderingContext* aCtx, const nsPoint& aPt)
: mCtx(aCtx) {
mCtx->PushTranslation(&mPushed);
mCtx->Translate(aPt);
}
~AutoPushTranslation() {
mCtx->PopTranslation(&mPushed);
}
};
NS_IMETHOD PushTranslation(PushedTranslation* aState) = 0;
NS_IMETHOD PopTranslation(PushedTranslation* aState) = 0;
/**
* Get the current transformation matrix for the RenderingContext
* @return The transformation matrix for the RenderingContext
*/
virtual nsTransform2D* GetCurrentTransform() = 0;
/**
* Draw a line
* @param aStartPt starting point
* @param aEndPt ending point
*/
NS_IMETHOD DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt) = 0;
/**
* Draw a line
* @param aX0 starting horizontal coord in twips
* @param aY0 starting vertical coord in twips
* @param aX1 end horiztonal coord in twips
* @param aY1 end vertical coord in twips
*/
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
/**
* Draw a rectangle
* @param aRect The rectangle to draw
*/
NS_IMETHOD DrawRect(const nsRect& aRect) = 0;
/**
* Draw a rectangle
* @param aX Horizontal left Coordinate in twips
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of rectangle in twips
* @param aHeight Height of rectangle in twips
*/
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Fill a rectangle in the current foreground color
* @param aRect The rectangle to draw
*/
NS_IMETHOD FillRect(const nsRect& aRect) = 0;
/**
* Fill a rectangle in the current foreground color
* @param aX Horizontal left Coordinate in twips
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of rectangle in twips
* @param aHeight Height of rectangle in twips
*/
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* XOR Invert a rectangle in the current foreground color
* @param aRect The rectangle to draw
*/
NS_IMETHOD InvertRect(const nsRect& aRect) = 0;
/**
* XOR Invert a rectangle in the current foreground color
* @param aX Horizontal left Coordinate in twips
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of rectangle in twips
* @param aHeight Height of rectangle in twips
*/
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Fill a poly in the current foreground color
* @param aPoints points to use for the drawing, last must equal first
* @param aNumPonts number of points in the polygon
*/
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
/**
* Draw an ellipse in the current foreground color
* @param aRect The rectangle define bounds of ellipse to draw
*/
NS_IMETHOD DrawEllipse(const nsRect& aRect) = 0;
/**
* Draw an ellipse in the current foreground color
* @param aX Horizontal left Coordinate in twips
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
*/
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Fill an ellipse in the current foreground color
* @param aRect The rectangle define bounds of ellipse to draw
*/
NS_IMETHOD FillEllipse(const nsRect& aRect) = 0;
/**
* Fill an ellipse in the current foreground color
* @param aX Horizontal left Coordinate in twips
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
*/
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Returns the width (in app units) of an 8-bit character
* If no font has been Set, the results are undefined.
* @param aC character to measure
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
/**
* Returns the width (in app units) of a unicode character
* If no font has been Set, the results are undefined.
* @param aC character to measure
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID = nsnull) = 0;
/**
* Returns the width (in app units) of an nsString
* If no font has been Set, the results are undefined.
* @param aString string to measure
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull) = 0;
/**
* Returns the width (in app units) of an 8-bit character string
* If no font has been Set, the results are undefined.
* @param aString string to measure
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
/**
* Returns the width (in app units) of an 8-bit character string
* If no font has been Set, the results are undefined.
* @param aString string to measure
* @param aLength number of characters in string
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth) = 0;
/**
* Returns the width (in app units) of a Unicode character string
* If no font has been Set, the results are undefined.
* @param aString string to measure
* @param aLength number of characters in string
* @param aWidth out parameter for width
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull) = 0;
/**
* Returns the dimensions of a string, i.e., the overall extent of a string
* whose rendering may involve switching between different fonts that have
* different metrics.
* @param aString string to measure
* @param aLength number of characters in string
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed measurements
* @return aDimensions struct that contains the extent of the string (see below)
*/
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions) = 0;
NS_IMETHOD GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull) = 0;
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11)
/**
* Given an available width and an array of break points,
* returns the dimensions (in app units) of the text that fit and
* the number of characters that fit. The number of characters
* corresponds to an entry in the break array.
* If no font has been set, the results are undefined.
* @param aString, string to measure
* @param aLength, number of characters in string
* @param aAvailWidth, the available space in which the text must fit
* @param aBreaks, array of places to break. Specified as offsets from the
* start of the string
* @param aNumBreaks, the number of entries in the break array. The last
* entry in the break array must equal the length of the string
* @param aDimensions, out parameter for the dimensions, the ascent and descent
* of the last word are left out to allow possible line-breaking before
* the last word. However, the width of the last word is included.
* @param aNumCharsFit, the number of characters that fit in the available space
* @param aLastWordDimensions, dimensions of the last word, the width field,
* dimensions.width, should be -1 for an unknown width. But the
* ascent and descent are expected to be known.
* @param aFontID, an optional out parameter used to store a
* font identifier that can be passed into the DrawString()
* methods to speed rendering
* @return error status
*/
NS_IMETHOD GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull) = 0;
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull) = 0;
#endif
/**
* Draw a string in the RenderingContext
* @param aString The string to draw
* @param aLength The length of the aString
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull) = 0;
/**
* Draw a string in the RenderingContext
* @param aString A PRUnichar of the string
* @param aLength The length of the aString
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aFontID an optional parameter used to speed font
* selection for complex unicode strings. the value
* passed is returned by the DrawString() methods.
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull) = 0;
/**
* Draw a string in the RenderingContext
* @param aString A nsString of the string
* @param aX Horizontal starting point of baseline
* @param aY Vertical starting point of baseline.
* @param aFontID an optional parameter used to speed font
* selection for complex unicode strings. the value
* passed is returned by the DrawString() methods.
* @param aSpacing inter-character spacing to apply
*/
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull) = 0;
enum GraphicDataType {
NATIVE_CAIRO_CONTEXT = 1,
NATIVE_GDK_DRAWABLE = 2,
NATIVE_WINDOWS_DC = 3,
NATIVE_MAC_THING = 4,
NATIVE_THEBES_CONTEXT = 5,
NATIVE_OS2_PS = 6
};
/**
* Retrieve the native graphic data given by aType. Return
* nsnull if not available.
*/
virtual void* GetNativeGraphicData(GraphicDataType aType) = 0;
#ifdef MOZ_MATHML
/**
* Returns bounding metrics (in app units) of an 8-bit character string
* @param aString string to measure
* @param aLength number of characters in string
* @return aBoundingMetrics struct that contains various metrics (see below)
* @return error status
*/
NS_IMETHOD
GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
/**
* Returns bounding metrics (in app units) of an Unicode character string
* @param aString string to measure
* @param aLength number of characters in string
* @param aFontID an optional out parameter used to store a
* font identifier that can be passed into the GetBoundingMetrics()
* methods to speed measurements
* @return aBoundingMetrics struct that contains various metrics (see below)
* @return error status
*/
NS_IMETHOD
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull) = 0;
#endif
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL) = 0;
/**
* This sets the direction of the text; all characters should be
* overridden to have this direction.
*/
virtual void SetTextRunRTL(PRBool aIsRTL) = 0;
/**
* Find the closest cursor position for a given x coordinate.
*
* This will find the closest byte index for a given x coordinate.
* This takes into account grapheme clusters and bidi text.
*
* @param aText Text on which to operate.
* @param aLength Length of the text.
* @param aPt the x/y position in the string to check.
*
* @return Index where the cursor falls. If the return is zero,
* it's before the first character, if it falls off the end of
* the string it's the length of the string + 1.
*
*/
virtual PRInt32 GetPosition(const PRUnichar *aText,
PRUint32 aLength,
nsPoint aPt) = 0;
/**
* Get the width for the specific range of a given string.
*
* This function is similar to other GetWidth functions, except that
* it gets the width for a part of the string instead of the entire
* string. This is useful when you're interested in finding out the
* length of a chunk in the middle of the string. Lots of languages
* require you to include surrounding information to accurately
* determine the length of a substring.
*
* @param aText Text on which to operate
* @param aLength Length of the text
* @param aStart Start index into the string
* @param aEnd End index into the string (inclusive)
* @param aWidth Returned with in app coordinates
*
*/
NS_IMETHOD GetRangeWidth(const PRUnichar *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth) = 0;
/**
* Get the width for the specific range of a given string.
*
* Same as GetRangeWidth for PRUnichar, but takes a char * as the
* text argument.
*
*/
NS_IMETHOD GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth) = 0;
/**
* Render an encapsulated postscript object onto the current rendering
* surface.
*
* The EPS object must conform to the EPSF standard. See Adobe
* specification #5002, "Encapsulated PostScript File Format Specification"
* at <http://partners.adobe.com/asn/developer/pdfs/tn/5002.EPSF_Spec.pdf>.
* In particular, the EPS object must contain a BoundingBox comment.
*
* @param aRect Rectangle in which to render the EPSF.
* @param aDataFile - plugin data stored in a file
* @return NS_OK for success, or a suitable error value.
* NS_ERROR_NOT_IMPLEMENTED is returned if the rendering context
* doesn't support rendering EPSF,
*/
NS_IMETHOD RenderEPS(const nsRect& aRect, FILE *aDataFile) = 0;
/**
* Return the Thebes gfxContext associated with this nsIRenderingContext.
*/
virtual gfxContext *ThebesContext() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIRenderingContext, NS_IRENDERING_CONTEXT_IID)
//flags for copy CopyOffScreenBits
//when performing the blit, use the region, if any,
//that exists in the source drawingsurface as a
//blit mask.
#define NS_COPYBITS_USE_SOURCE_CLIP_REGION 0x0001
//transform the source offsets by the xform in the
//rendering context
#define NS_COPYBITS_XFORM_SOURCE_VALUES 0x0002
//transform the destination rect by the xform in the
//rendering context
#define NS_COPYBITS_XFORM_DEST_VALUES 0x0004
//this is basically a hack and is used by callers
//who have selected an alternate drawing surface and
//wish the copy to happen to that buffer rather than
//the "front" buffer. i'm not proud of this. MMP
//XXX: This is no longer needed by the XPCODE. It will
//be removed once all of the platform specific nsRenderingContext's
//stop using it.
#define NS_COPYBITS_TO_BACK_BUFFER 0x0008
/* Struct used to represent the overall extent of a string
whose rendering may involve switching between different
fonts that have different metrics.
*/
struct nsTextDimensions {
// max ascent amongst all the fonts needed to represent the string
nscoord ascent;
// max descent amongst all the fonts needed to represent the string
nscoord descent;
// width of the string
nscoord width;
nsTextDimensions()
{
Clear();
}
/* Set all member data to zero */
void
Clear() {
ascent = descent = width = 0;
}
/* Sum with another dimension */
void
Combine(const nsTextDimensions& aOther) {
if (ascent < aOther.ascent) ascent = aOther.ascent;
if (descent < aOther.descent) descent = aOther.descent;
width += aOther.width;
}
};
#ifdef MOZ_MATHML
/* Struct used for accurate measurements of a string in order
to allow precise positioning when processing MathML.
*/
struct nsBoundingMetrics {
///////////
// Metrics that _exactly_ enclose the text:
// The character coordinate system is the one used on X Windows:
// 1. The origin is located at the intersection of the baseline
// with the left of the character's cell.
// 2. All horizontal bearings are oriented from left to right.
// 3. The ascent is oriented from bottom to top (being 0 at the orgin).
// 4. The descent is oriented from top to bottom (being 0 at the origin).
// Note that Win32/Mac/PostScript use a different convention for
// the descent (all vertical measurements are oriented from bottom
// to top on these palatforms). Make sure to flip the sign of the
// descent on these platforms for cross-platform compatibility.
// Any of the following member variables listed here can have
// positive or negative value.
nscoord leftBearing;
/* The horizontal distance from the origin of the drawing
operation to the left-most part of the drawn string. */
nscoord rightBearing;
/* The horizontal distance from the origin of the drawing
operation to the right-most part of the drawn string.
The _exact_ width of the string is therefore:
rightBearing - leftBearing */
nscoord ascent;
/* The vertical distance from the origin of the drawing
operation to the top-most part of the drawn string. */
nscoord descent;
/* The vertical distance from the origin of the drawing
operation to the bottom-most part of the drawn string.
The _exact_ height of the string is therefore:
ascent + descent */
//////////
// Metrics for placing other surrounding text:
nscoord width;
/* The horizontal distance from the origin of the drawing
operation to the correct origin for drawing another string
to follow the current one. Depending on the font, this
could be greater than or less than the right bearing. */
nsBoundingMetrics() {
Clear();
}
//////////
// Utility methods and operators:
/* Set all member data to zero */
void
Clear() {
leftBearing = rightBearing = 0;
ascent = descent = width = 0;
}
/* Append another bounding metrics */
void
operator += (const nsBoundingMetrics& bm) {
if (ascent + descent == 0 && rightBearing - leftBearing == 0) {
ascent = bm.ascent;
descent = bm.descent;
leftBearing = width + bm.leftBearing;
rightBearing = width + bm.rightBearing;
}
else {
if (ascent < bm.ascent) ascent = bm.ascent;
if (descent < bm.descent) descent = bm.descent;
leftBearing = PR_MIN(leftBearing, width + bm.leftBearing);
rightBearing = PR_MAX(rightBearing, width + bm.rightBearing);
}
width += bm.width;
}
};
#endif // MOZ_MATHML
#endif /* nsIRenderingContext_h___ */

View File

@ -39,11 +39,11 @@
#define __nsIThebesFontMetrics_h
#include "nsIFontMetrics.h"
#include "nsIRenderingContext.h"
class nsThebesRenderingContext;
struct nsTextDimensions;
struct nsBoundingMetrics;
class gfxFontGroup;
class nsRenderingContext;
class nsIThebesFontMetrics : public nsIFontMetrics {
public:

View File

@ -37,7 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsThebesRenderingContext.h"
#include "nsRenderingContext.h"
#include "nsThebesDeviceContext.h"
#include "nsString.h"
@ -60,30 +60,22 @@
#include "cairo-win32.h"
#endif
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
//////////////////////////////////////////////////////////////////////
// XXXTodo: rename FORM_TWIPS to FROM_APPUNITS
#define FROM_TWIPS(_x) ((gfxFloat)((_x)/(mP2A)))
#define FROM_TWIPS_INT(_x) (NSToIntRound((gfxFloat)((_x)/(mP2A))))
#define TO_TWIPS(_x) ((nscoord)((_x)*(mP2A)))
#define GFX_RECT_FROM_TWIPS_RECT(_r) (gfxRect(FROM_TWIPS((_r).x), FROM_TWIPS((_r).y), FROM_TWIPS((_r).width), FROM_TWIPS((_r).height)))
//////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS1(nsThebesRenderingContext, nsIRenderingContext)
// Hard limit substring lengths to 8000 characters ... this lets us statically
// size the cluster buffer array in FindSafeLength
#define MAX_GFX_TEXT_BUF_SIZE 8000
static PRInt32 GetMaxChunkLength(nsThebesRenderingContext* aContext)
static PRInt32 GetMaxChunkLength(nsRenderingContext* aContext)
{
PRInt32 len = aContext->GetMaxStringLength();
return PR_MIN(len, MAX_GFX_TEXT_BUF_SIZE);
}
static PRInt32 FindSafeLength(nsThebesRenderingContext* aContext,
static PRInt32 FindSafeLength(nsRenderingContext* aContext,
const PRUnichar *aString, PRUint32 aLength,
PRUint32 aMaxChunkLength)
{
@ -107,7 +99,7 @@ static PRInt32 FindSafeLength(nsThebesRenderingContext* aContext,
return len;
}
static PRInt32 FindSafeLength(nsThebesRenderingContext* aContext,
static PRInt32 FindSafeLength(nsRenderingContext* aContext,
const char *aString, PRUint32 aLength,
PRUint32 aMaxChunkLength)
{
@ -115,21 +107,11 @@ static PRInt32 FindSafeLength(nsThebesRenderingContext* aContext,
return PR_MIN(aLength, aMaxChunkLength);
}
nsThebesRenderingContext::nsThebesRenderingContext()
: mLineStyle(nsLineStyle_kNone)
, mColor(NS_RGB(0,0,0))
{
}
nsThebesRenderingContext::~nsThebesRenderingContext()
{
}
//////////////////////////////////////////////////////////////////////
//// nsIRenderingContext
NS_IMETHODIMP
nsThebesRenderingContext::Init(nsIDeviceContext* aContext, gfxASurface *aThebesSurface)
nsresult
nsRenderingContext::Init(nsIDeviceContext* aContext, gfxASurface *aThebesSurface)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Init ctx %p thebesSurface %p\n", this, aContext, aThebesSurface));
@ -141,8 +123,8 @@ nsThebesRenderingContext::Init(nsIDeviceContext* aContext, gfxASurface *aThebesS
return (CommonInit());
}
NS_IMETHODIMP
nsThebesRenderingContext::Init(nsIDeviceContext* aContext, gfxContext *aThebesContext)
nsresult
nsRenderingContext::Init(nsIDeviceContext* aContext, gfxContext *aThebesContext)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Init ctx %p thebesContext %p\n", this, aContext, aThebesContext));
@ -154,8 +136,8 @@ nsThebesRenderingContext::Init(nsIDeviceContext* aContext, gfxContext *aThebesCo
return (CommonInit());
}
NS_IMETHODIMP
nsThebesRenderingContext::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
nsresult
nsRenderingContext::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Init ctx %p widget %p\n", this, aContext, aWidget));
@ -173,8 +155,8 @@ nsThebesRenderingContext::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
return (CommonInit());
}
NS_IMETHODIMP
nsThebesRenderingContext::CommonInit(void)
nsresult
nsRenderingContext::CommonInit(void)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::CommonInit\n", this));
@ -186,14 +168,14 @@ nsThebesRenderingContext::CommonInit(void)
}
already_AddRefed<nsIDeviceContext>
nsThebesRenderingContext::GetDeviceContext()
nsRenderingContext::GetDeviceContext()
{
NS_IF_ADDREF(mDeviceContext);
return mDeviceContext.get();
}
NS_IMETHODIMP
nsThebesRenderingContext::PushTranslation(PushedTranslation* aState)
nsresult
nsRenderingContext::PushTranslation(PushedTranslation* aState)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PushTranslation\n", this));
@ -202,8 +184,8 @@ nsThebesRenderingContext::PushTranslation(PushedTranslation* aState)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::PopTranslation(PushedTranslation* aState)
nsresult
nsRenderingContext::PopTranslation(PushedTranslation* aState)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PopTranslation\n", this));
@ -212,8 +194,8 @@ nsThebesRenderingContext::PopTranslation(PushedTranslation* aState)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::SetTranslation(const nsPoint& aPt)
nsresult
nsRenderingContext::SetTranslation(const nsPoint& aPt)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetTranslation %d %d\n", this, aPt.x, aPt.y));
@ -224,8 +206,8 @@ nsThebesRenderingContext::SetTranslation(const nsPoint& aPt)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::PushState()
nsresult
nsRenderingContext::PushState()
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PushState\n", this));
@ -233,8 +215,8 @@ nsThebesRenderingContext::PushState()
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::PopState()
nsresult
nsRenderingContext::PopState()
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PopState\n", this));
@ -246,9 +228,8 @@ nsThebesRenderingContext::PopState()
// clipping
//
NS_IMETHODIMP
nsThebesRenderingContext::SetClipRect(const nsRect& aRect,
nsClipCombine aCombine)
nsresult
nsRenderingContext::SetClipRect(const nsRect& aRect, nsClipCombine aCombine)
{
//return NS_OK;
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetClipRect [%d,%d,%d,%d] %d\n", this, aRect.x, aRect.y, aRect.width, aRect.height, aCombine));
@ -275,9 +256,9 @@ nsThebesRenderingContext::SetClipRect(const nsRect& aRect,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::SetClipRegion(const nsIntRegion& aRegion,
nsClipCombine aCombine)
nsresult
nsRenderingContext::SetClipRegion(const nsIntRegion& aRegion,
nsClipCombine aCombine)
{
// Region is in device coords, no transformation.
// This should only be called when there is no transform in place, when we
@ -290,7 +271,7 @@ nsThebesRenderingContext::SetClipRegion(const nsIntRegion& aRegion,
mThebes->IdentityMatrix();
mThebes->ResetClip();
mThebes->NewPath();
nsIntRegionRectIterator iter(aRegion);
const nsIntRect* rect;
@ -309,8 +290,8 @@ nsThebesRenderingContext::SetClipRegion(const nsIntRegion& aRegion,
// other junk
//
NS_IMETHODIMP
nsThebesRenderingContext::SetLineStyle(nsLineStyle aLineStyle)
nsresult
nsRenderingContext::SetLineStyle(nsLineStyle aLineStyle)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetLineStyle %d\n", this, aLineStyle));
switch (aLineStyle) {
@ -335,8 +316,8 @@ nsThebesRenderingContext::SetLineStyle(nsLineStyle aLineStyle)
}
NS_IMETHODIMP
nsThebesRenderingContext::SetColor(nscolor aColor)
nsresult
nsRenderingContext::SetColor(nscolor aColor)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetColor 0x%08x\n", this, aColor));
/* This sets the color assuming the sRGB color space, since that's what all
@ -348,23 +329,23 @@ nsThebesRenderingContext::SetColor(nscolor aColor)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetColor(nscolor &aColor) const
nsresult
nsRenderingContext::GetColor(nscolor &aColor) const
{
aColor = mColor;
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::Translate(const nsPoint& aPt)
nsresult
nsRenderingContext::Translate(const nsPoint& aPt)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Translate %d %d\n", this, aPt.x, aPt.y));
mThebes->Translate (gfxPoint(FROM_TWIPS(aPt.x), FROM_TWIPS(aPt.y)));
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::Scale(float aSx, float aSy)
nsresult
nsRenderingContext::Scale(float aSx, float aSy)
{
// as far as I can tell, noone actually calls this
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Scale %f %f\n", this, aSx, aSy));
@ -373,7 +354,7 @@ nsThebesRenderingContext::Scale(float aSx, float aSy)
}
void
nsThebesRenderingContext::UpdateTempTransformMatrix()
nsRenderingContext::UpdateTempTransformMatrix()
{
//PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::UpdateTempTransformMatrix\n", this));
@ -391,7 +372,7 @@ nsThebesRenderingContext::UpdateTempTransformMatrix()
}
nsTransform2D&
nsThebesRenderingContext::CurrentTransform()
nsRenderingContext::CurrentTransform()
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::CurrentTransform\n", this));
UpdateTempTransformMatrix();
@ -410,7 +391,7 @@ nsThebesRenderingContext::CurrentTransform()
****/
nsTransform2D*
nsThebesRenderingContext::GetCurrentTransform()
nsRenderingContext::GetCurrentTransform()
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG,
("## %p nsTRC::GetCurrentTransform\n", this));
@ -419,7 +400,7 @@ nsThebesRenderingContext::GetCurrentTransform()
}
void
nsThebesRenderingContext::TransformCoord (nscoord *aX, nscoord *aY)
nsRenderingContext::TransformCoord (nscoord *aX, nscoord *aY)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::TransformCoord\n", this));
@ -431,16 +412,15 @@ nsThebesRenderingContext::TransformCoord (nscoord *aX, nscoord *aY)
*aY = TO_TWIPS(pt.y);
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawLine(const nsPoint& aStartPt,
const nsPoint& aEndPt)
nsresult
nsRenderingContext::DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt)
{
return DrawLine(aStartPt.x, aStartPt.y, aEndPt.x, aEndPt.y);
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawLine(nscoord aX0, nscoord aY0,
nscoord aX1, nscoord aY1)
nsresult
nsRenderingContext::DrawLine(nscoord aX0, nscoord aY0,
nscoord aX1, nscoord aY1)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG,
("## %p nsTRC::DrawLine %d %d %d %d\n", this, aX0, aY0, aX1, aY1));
@ -485,8 +465,8 @@ nsThebesRenderingContext::DrawLine(nscoord aX0, nscoord aY0,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawRect(const nsRect& aRect)
nsresult
nsRenderingContext::DrawRect(const nsRect& aRect)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::DrawRect [%d,%d,%d,%d]\n", this, aRect.x, aRect.y, aRect.width, aRect.height));
@ -497,8 +477,9 @@ nsThebesRenderingContext::DrawRect(const nsRect& aRect)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsresult
nsRenderingContext::DrawRect(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
DrawRect(nsRect(aX, aY, aWidth, aHeight));
return NS_OK;
@ -566,8 +547,8 @@ ConditionRect(gfxRect& r) {
return PR_TRUE;
}
NS_IMETHODIMP
nsThebesRenderingContext::FillRect(const nsRect& aRect)
nsresult
nsRenderingContext::FillRect(const nsRect& aRect)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::FillRect [%d,%d,%d,%d]\n", this, aRect.x, aRect.y, aRect.width, aRect.height));
@ -610,15 +591,16 @@ nsThebesRenderingContext::FillRect(const nsRect& aRect)
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsresult
nsRenderingContext::FillRect(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
FillRect(nsRect(aX, aY, aWidth, aHeight));
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::InvertRect(const nsRect& aRect)
nsresult
nsRenderingContext::InvertRect(const nsRect& aRect)
{
gfxContext::GraphicsOperator lastOp = mThebes->CurrentOperator();
@ -629,20 +611,22 @@ nsThebesRenderingContext::InvertRect(const nsRect& aRect)
return rv;
}
NS_IMETHODIMP
nsThebesRenderingContext::InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsresult
nsRenderingContext::InvertRect(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
return InvertRect(nsRect(aX, aY, aWidth, aHeight));
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawEllipse(const nsRect& aRect)
nsresult
nsRenderingContext::DrawEllipse(const nsRect& aRect)
{
return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsresult
nsRenderingContext::DrawEllipse(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::DrawEllipse [%d,%d,%d,%d]\n", this, aX, aY, aWidth, aHeight));
@ -656,14 +640,15 @@ nsThebesRenderingContext::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, ns
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::FillEllipse(const nsRect& aRect)
nsresult
nsRenderingContext::FillEllipse(const nsRect& aRect)
{
return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
NS_IMETHODIMP
nsThebesRenderingContext::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
nsresult
nsRenderingContext::FillEllipse(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::FillEllipse [%d,%d,%d,%d]\n", this, aX, aY, aWidth, aHeight));
@ -677,8 +662,8 @@ nsThebesRenderingContext::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, ns
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::FillPolygon(const nsPoint twPoints[], PRInt32 aNumPoints)
nsresult
nsRenderingContext::FillPolygon(const nsPoint twPoints[], PRInt32 aNumPoints)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::FillPolygon %d\n", this, aNumPoints));
@ -703,7 +688,7 @@ nsThebesRenderingContext::FillPolygon(const nsPoint twPoints[], PRInt32 aNumPoin
}
void*
nsThebesRenderingContext::GetNativeGraphicData(GraphicDataType aType)
nsRenderingContext::GetNativeGraphicData(GraphicDataType aType)
{
if (aType == NATIVE_GDK_DRAWABLE)
{
@ -734,8 +719,9 @@ nsThebesRenderingContext::GetNativeGraphicData(GraphicDataType aType)
return nsnull;
}
NS_IMETHODIMP
nsThebesRenderingContext::PushFilter(const nsRect& twRect, PRBool aAreaIsOpaque, float aOpacity)
nsresult
nsRenderingContext::PushFilter(const nsRect& twRect, PRBool aAreaIsOpaque,
float aOpacity)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG,
("## %p nsTRC::PushFilter [%d,%d,%d,%d] isOpaque: %d opacity: %f\n",
@ -751,8 +737,8 @@ nsThebesRenderingContext::PushFilter(const nsRect& twRect, PRBool aAreaIsOpaque,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::PopFilter()
nsresult
nsRenderingContext::PopFilter()
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PopFilter\n"));
@ -780,28 +766,28 @@ nsThebesRenderingContext::PopFilter()
//
// text junk
//
NS_IMETHODIMP
nsThebesRenderingContext::SetRightToLeftText(PRBool aIsRTL)
nsresult
nsRenderingContext::SetRightToLeftText(PRBool aIsRTL)
{
return mFontMetrics->SetRightToLeftText(aIsRTL);
}
NS_IMETHODIMP
nsThebesRenderingContext::GetRightToLeftText(PRBool* aIsRTL)
nsresult
nsRenderingContext::GetRightToLeftText(PRBool* aIsRTL)
{
*aIsRTL = mFontMetrics->GetRightToLeftText();
return NS_OK;
}
void
nsThebesRenderingContext::SetTextRunRTL(PRBool aIsRTL)
nsRenderingContext::SetTextRunRTL(PRBool aIsRTL)
{
mFontMetrics->SetTextRunRTL(aIsRTL);
}
NS_IMETHODIMP
nsThebesRenderingContext::SetFont(const nsFont& aFont, nsIAtom* aLanguage,
gfxUserFontSet *aUserFontSet)
nsresult
nsRenderingContext::SetFont(const nsFont& aFont, nsIAtom* aLanguage,
gfxUserFontSet *aUserFontSet)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetFont %p\n", this, &aFont));
@ -812,9 +798,9 @@ nsThebesRenderingContext::SetFont(const nsFont& aFont, nsIAtom* aLanguage,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::SetFont(const nsFont& aFont,
gfxUserFontSet *aUserFontSet)
nsresult
nsRenderingContext::SetFont(const nsFont& aFont,
gfxUserFontSet *aUserFontSet)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetFont %p\n", this, &aFont));
@ -825,8 +811,8 @@ nsThebesRenderingContext::SetFont(const nsFont& aFont,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::SetFont(nsIFontMetrics *aFontMetrics)
nsresult
nsRenderingContext::SetFont(nsIFontMetrics *aFontMetrics)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::SetFont[Metrics] %p\n", this, aFontMetrics));
@ -835,22 +821,22 @@ nsThebesRenderingContext::SetFont(nsIFontMetrics *aFontMetrics)
}
already_AddRefed<nsIFontMetrics>
nsThebesRenderingContext::GetFontMetrics()
nsRenderingContext::GetFontMetrics()
{
NS_IF_ADDREF(mFontMetrics);
return mFontMetrics.get();
}
PRInt32
nsThebesRenderingContext::GetMaxStringLength()
nsRenderingContext::GetMaxStringLength()
{
if (!mFontMetrics)
return 1;
return mFontMetrics->GetMaxStringLength();
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(char aC, nscoord &aWidth)
nsresult
nsRenderingContext::GetWidth(char aC, nscoord &aWidth)
{
if (aC == ' ' && mFontMetrics)
return mFontMetrics->GetSpaceWidth(aWidth);
@ -858,36 +844,37 @@ nsThebesRenderingContext::GetWidth(char aC, nscoord &aWidth)
return GetWidth(&aC, 1, aWidth);
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID)
nsresult
nsRenderingContext::GetWidth(PRUnichar aC, nscoord &aWidth, PRInt32 *aFontID)
{
return GetWidth(&aC, 1, aWidth, aFontID);
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(const nsString& aString, nscoord &aWidth,
nsresult
nsRenderingContext::GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID)
{
return GetWidth(aString.get(), aString.Length(), aWidth, aFontID);
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(const char* aString, nscoord& aWidth)
nsresult
nsRenderingContext::GetWidth(const char* aString, nscoord& aWidth)
{
return GetWidth(aString, strlen(aString), aWidth);
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID, const nscoord* aSpacing)
nsresult
nsRenderingContext::DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID, const nscoord* aSpacing)
{
return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing);
return DrawString(aString.get(), aString.Length(), aX, aY,
aFontID, aSpacing);
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(const char* aString,
PRUint32 aLength,
nscoord& aWidth)
nsresult
nsRenderingContext::GetWidth(const char* aString,
PRUint32 aLength,
nscoord& aWidth)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
aWidth = 0;
@ -904,11 +891,11 @@ nsThebesRenderingContext::GetWidth(const char* aString,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetWidth(const PRUnichar *aString,
PRUint32 aLength,
nscoord &aWidth,
PRInt32 *aFontID)
nsresult
nsRenderingContext::GetWidth(const PRUnichar *aString,
PRUint32 aLength,
nscoord &aWidth,
PRInt32 *aFontID)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
aWidth = 0;
@ -930,10 +917,10 @@ nsThebesRenderingContext::GetWidth(const PRUnichar *aString,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetTextDimensions(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions)
nsresult
nsRenderingContext::GetTextDimensions(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= maxChunkLength)
@ -961,11 +948,11 @@ nsThebesRenderingContext::GetTextDimensions(const char* aString,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetTextDimensions(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID)
nsresult
nsRenderingContext::GetTextDimensions(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= maxChunkLength)
@ -998,16 +985,16 @@ nsThebesRenderingContext::GetTextDimensions(const PRUnichar* aString,
}
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11)
NS_IMETHODIMP
nsThebesRenderingContext::GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
nsresult
nsRenderingContext::GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= PRInt32(maxChunkLength))
@ -1054,16 +1041,16 @@ nsThebesRenderingContext::GetTextDimensions(const char* aString,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
nsresult
nsRenderingContext::GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= PRInt32(maxChunkLength))
@ -1111,10 +1098,10 @@ nsThebesRenderingContext::GetTextDimensions(const PRUnichar* aString,
#endif
#ifdef MOZ_MATHML
NS_IMETHODIMP
nsThebesRenderingContext::GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
nsresult
nsRenderingContext::GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= maxChunkLength)
@ -1143,11 +1130,11 @@ nsThebesRenderingContext::GetBoundingMetrics(const char* aString,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
nsresult
nsRenderingContext::GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= maxChunkLength)
@ -1181,10 +1168,10 @@ nsThebesRenderingContext::GetBoundingMetrics(const PRUnichar* aString,
}
#endif
NS_IMETHODIMP
nsThebesRenderingContext::DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing)
nsresult
nsRenderingContext::DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
while (aLength > 0) {
@ -1206,11 +1193,11 @@ nsThebesRenderingContext::DrawString(const char *aString, PRUint32 aLength,
return NS_OK;
}
NS_IMETHODIMP
nsThebesRenderingContext::DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
nsresult
nsRenderingContext::DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
{
PRUint32 maxChunkLength = GetMaxChunkLength(this);
if (aLength <= maxChunkLength) {
@ -1266,7 +1253,8 @@ nsThebesRenderingContext::DrawString(const PRUnichar *aString, PRUint32 aLength,
}
nsresult
nsThebesRenderingContext::GetWidthInternal(const char* aString, PRUint32 aLength, nscoord& aWidth)
nsRenderingContext::GetWidthInternal(const char* aString, PRUint32 aLength,
nscoord& aWidth)
{
#ifdef DISABLE_TEXT
aWidth = (8 * aLength);
@ -1282,8 +1270,8 @@ nsThebesRenderingContext::GetWidthInternal(const char* aString, PRUint32 aLength
}
nsresult
nsThebesRenderingContext::GetWidthInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID)
nsRenderingContext::GetWidthInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID)
{
#ifdef DISABLE_TEXT
aWidth = (8 * aLength);
@ -1299,8 +1287,9 @@ nsThebesRenderingContext::GetWidthInternal(const PRUnichar *aString, PRUint32 aL
}
nsresult
nsThebesRenderingContext::GetTextDimensionsInternal(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions)
nsRenderingContext::GetTextDimensionsInternal(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions)
{
mFontMetrics->GetMaxAscent(aDimensions.ascent);
mFontMetrics->GetMaxDescent(aDimensions.descent);
@ -1308,10 +1297,10 @@ nsThebesRenderingContext::GetTextDimensionsInternal(const char* aString, PRUint3
}
nsresult
nsThebesRenderingContext::GetTextDimensionsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID)
nsRenderingContext::GetTextDimensionsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID)
{
mFontMetrics->GetMaxAscent(aDimensions.ascent);
mFontMetrics->GetMaxDescent(aDimensions.descent);
@ -1320,57 +1309,59 @@ nsThebesRenderingContext::GetTextDimensionsInternal(const PRUnichar* aString,
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11) || defined(XP_MACOSX) || defined (MOZ_DFB)
nsresult
nsThebesRenderingContext::GetTextDimensionsInternal(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
nsRenderingContext::GetTextDimensionsInternal(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsThebesRenderingContext::GetTextDimensionsInternal(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
nsRenderingContext::GetTextDimensionsInternal(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
#endif
#ifdef MOZ_MATHML
nsresult
nsThebesRenderingContext::GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
nsresult
nsRenderingContext::GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
{
return mFontMetrics->GetBoundingMetrics(aString, aLength, this, aBoundingMetrics);
return mFontMetrics->GetBoundingMetrics(aString, aLength, this,
aBoundingMetrics);
}
nsresult
nsThebesRenderingContext::GetBoundingMetricsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
nsRenderingContext::GetBoundingMetricsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
{
return mFontMetrics->GetBoundingMetrics(aString, aLength, this, aBoundingMetrics);
return mFontMetrics->GetBoundingMetrics(aString, aLength, this,
aBoundingMetrics);
}
#endif // MOZ_MATHML
nsresult
nsThebesRenderingContext::DrawStringInternal(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing)
nsRenderingContext::DrawStringInternal(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing)
{
#ifdef DISABLE_TEXT
return NS_OK;
@ -1381,10 +1372,11 @@ nsThebesRenderingContext::DrawStringInternal(const char *aString, PRUint32 aLeng
}
nsresult
nsThebesRenderingContext::DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
nsRenderingContext::DrawStringInternal(const PRUnichar *aString,
PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing)
{
#ifdef DISABLE_TEXT
return NS_OK;
@ -1395,35 +1387,35 @@ nsThebesRenderingContext::DrawStringInternal(const PRUnichar *aString, PRUint32
}
PRInt32
nsThebesRenderingContext::GetPosition(const PRUnichar *aText,
PRUint32 aLength,
nsPoint aPt)
nsRenderingContext::GetPosition(const PRUnichar *aText,
PRUint32 aLength,
nsPoint aPt)
{
return -1;
return -1;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetRangeWidth(const PRUnichar *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsThebesRenderingContext::GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsThebesRenderingContext::RenderEPS(const nsRect& aRect, FILE *aDataFile)
nsresult
nsRenderingContext::GetRangeWidth(const PRUnichar *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsRenderingContext::GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsRenderingContext::RenderEPS(const nsRect& aRect, FILE *aDataFile)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,454 @@
/* -*- 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 thebes gfx
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* 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 NSRENDERINGCONTEXT__H__
#define NSRENDERINGCONTEXT__H__
#include "nsCOMPtr.h"
#include "nsTArray.h"
#include "nsIDeviceContext.h"
#include "nsIFontMetrics.h"
#include "nsIWidget.h"
#include "nsPoint.h"
#include "nsSize.h"
#include "nsColor.h"
#include "nsRect.h"
#include "nsIRegion.h"
#include "nsTransform2D.h"
#include "nsIThebesFontMetrics.h"
#include "gfxContext.h"
typedef enum {
nsClipCombine_kIntersect = 0,
nsClipCombine_kUnion = 1,
nsClipCombine_kSubtract = 2,
nsClipCombine_kReplace = 3
} nsClipCombine;
typedef enum {
nsLineStyle_kNone = 0,
nsLineStyle_kSolid = 1,
nsLineStyle_kDashed = 2,
nsLineStyle_kDotted = 3
} nsLineStyle;
/* Struct used to represent the overall extent of a string
* whose rendering may involve switching between different
* fonts that have different metrics.
*/
struct nsTextDimensions {
// max ascent amongst all the fonts needed to represent the string
nscoord ascent;
// max descent amongst all the fonts needed to represent the string
nscoord descent;
// width of the string
nscoord width;
nsTextDimensions()
{
Clear();
}
/* Set all member data to zero */
void
Clear() {
ascent = descent = width = 0;
}
/* Sum with another dimension */
void
Combine(const nsTextDimensions& aOther) {
if (ascent < aOther.ascent) ascent = aOther.ascent;
if (descent < aOther.descent) descent = aOther.descent;
width += aOther.width;
}
};
#ifdef MOZ_MATHML
/* Struct used for accurate measurements of a string in order
* to allow precise positioning when processing MathML.
*/
struct nsBoundingMetrics {
///////////
// Metrics that _exactly_ enclose the text:
// The character coordinate system is the one used on X Windows:
// 1. The origin is located at the intersection of the baseline
// with the left of the character's cell.
// 2. All horizontal bearings are oriented from left to right.
// 2. All horizontal bearings are oriented from left to right.
// 3. The ascent is oriented from bottom to top (being 0 at the orgin).
// 4. The descent is oriented from top to bottom (being 0 at the origin).
// Note that Win32/Mac/PostScript use a different convention for
// the descent (all vertical measurements are oriented from bottom
// to top on these palatforms). Make sure to flip the sign of the
// descent on these platforms for cross-platform compatibility.
// Any of the following member variables listed here can have
// positive or negative value.
nscoord leftBearing;
/* The horizontal distance from the origin of the drawing
operation to the left-most part of the drawn string. */
nscoord rightBearing;
/* The horizontal distance from the origin of the drawing
operation to the right-most part of the drawn string.
The _exact_ width of the string is therefore:
rightBearing - leftBearing */
nscoord ascent;
/* The vertical distance from the origin of the drawing
operation to the top-most part of the drawn string. */
nscoord descent;
/* The vertical distance from the origin of the drawing
operation to the bottom-most part of the drawn string.
The _exact_ height of the string is therefore:
ascent + descent */
//////////
// Metrics for placing other surrounding text:
nscoord width;
/* The horizontal distance from the origin of the drawing
operation to the correct origin for drawing another string
to follow the current one. Depending on the font, this
could be greater than or less than the right bearing. */
nsBoundingMetrics() {
Clear();
}
//////////
// Utility methods and operators:
/* Set all member data to zero */
void
Clear() {
leftBearing = rightBearing = 0;
ascent = descent = width = 0;
}
/* Append another bounding metrics */
void
operator += (const nsBoundingMetrics& bm) {
if (ascent + descent == 0 && rightBearing - leftBearing == 0) {
ascent = bm.ascent;
descent = bm.descent;
leftBearing = width + bm.leftBearing;
rightBearing = width + bm.rightBearing;
}
else {
if (ascent < bm.ascent) ascent = bm.ascent;
if (descent < bm.descent) descent = bm.descent;
leftBearing = PR_MIN(leftBearing, width + bm.leftBearing);
rightBearing = PR_MAX(rightBearing, width + bm.rightBearing);
}
width += bm.width;
}
};
#endif // MOZ_MATHML
class nsRenderingContext
{
public:
nsRenderingContext()
: mP2A(0.), mLineStyle(nsLineStyle_kNone), mColor(NS_RGB(0,0,0))
{}
// ~nsRenderingContext() {}
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
/**
* Return the maximum length of a string that can be handled by
* the platform using the current font metrics.
*/
PRInt32 GetMaxStringLength();
// Safe string method variants: by default, these defer to the more
// elaborate methods below
nsresult GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull);
nsresult GetWidth(const char* aString, nscoord& aWidth);
nsresult DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
// Safe string methods
nsresult GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth);
nsresult GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull);
nsresult GetWidth(char aC, nscoord &aWidth);
nsresult GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
nsresult GetTextDimensions(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions);
nsresult GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID = nsnull);
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11)
nsresult GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
nsresult GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
#endif
#ifdef MOZ_MATHML
nsresult GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
nsresult GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif
nsresult DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
nsresult DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
nsresult Init(nsIDeviceContext* aContext, gfxASurface* aThebesSurface);
nsresult Init(nsIDeviceContext* aContext, gfxContext* aThebesContext);
nsresult Init(nsIDeviceContext* aContext, nsIWidget *aWidget);
nsresult CommonInit(void);
already_AddRefed<nsIDeviceContext> GetDeviceContext();
nsresult PushState(void);
nsresult PopState(void);
nsresult SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
nsresult SetLineStyle(nsLineStyle aLineStyle);
nsresult SetClipRegion(const nsIntRegion& aRegion, nsClipCombine aCombine);
nsresult SetColor(nscolor aColor);
nsresult GetColor(nscolor &aColor) const;
nsresult SetFont(const nsFont& aFont, nsIAtom* aLanguage,
gfxUserFontSet *aUserFontSet);
nsresult SetFont(const nsFont& aFont,
gfxUserFontSet *aUserFontSet);
nsresult SetFont(nsIFontMetrics *aFontMetrics);
already_AddRefed<nsIFontMetrics> GetFontMetrics();
nsresult Translate(const nsPoint& aPt);
nsresult Scale(float aSx, float aSy);
nsTransform2D* GetCurrentTransform();
nsresult DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt);
nsresult DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
nsresult DrawRect(const nsRect& aRect);
nsresult DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
nsresult FillRect(const nsRect& aRect);
nsresult FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
nsresult InvertRect(const nsRect& aRect);
nsresult InvertRect(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
nsresult FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
nsresult DrawEllipse(const nsRect& aRect);
nsresult DrawEllipse(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
nsresult FillEllipse(const nsRect& aRect);
nsresult FillEllipse(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
nsresult PushFilter(const nsRect& aRect,
PRBool aAreaIsOpaque, float aOpacity);
nsresult PopFilter();
enum GraphicDataType {
NATIVE_CAIRO_CONTEXT = 1,
NATIVE_GDK_DRAWABLE = 2,
NATIVE_WINDOWS_DC = 3,
NATIVE_MAC_THING = 4,
NATIVE_THEBES_CONTEXT = 5,
NATIVE_OS2_PS = 6
};
void* GetNativeGraphicData(GraphicDataType aType);
struct PushedTranslation {
float mSavedX, mSavedY;
};
class AutoPushTranslation {
nsRenderingContext* mCtx;
PushedTranslation mPushed;
public:
AutoPushTranslation(nsRenderingContext* aCtx, const nsPoint& aPt)
: mCtx(aCtx) {
mCtx->PushTranslation(&mPushed);
mCtx->Translate(aPt);
}
~AutoPushTranslation() {
mCtx->PopTranslation(&mPushed);
}
};
nsresult PushTranslation(PushedTranslation* aState);
nsresult PopTranslation(PushedTranslation* aState);
nsresult SetTranslation(const nsPoint& aPoint);
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction
*/
nsresult SetRightToLeftText(PRBool aIsRTL);
nsresult GetRightToLeftText(PRBool* aIsRTL);
void SetTextRunRTL(PRBool aIsRTL);
PRInt32 GetPosition(const PRUnichar *aText,
PRUint32 aLength,
nsPoint aPt);
nsresult GetRangeWidth(const PRUnichar *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth);
nsresult GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth);
nsresult RenderEPS(const nsRect& aRect, FILE *aDataFile);
// Thebes specific stuff
gfxContext *ThebesContext() { return mThebes; }
nsTransform2D& CurrentTransform();
void TransformCoord (nscoord *aX, nscoord *aY);
protected:
nsresult GetWidthInternal(const char *aString, PRUint32 aLength,
nscoord &aWidth);
nsresult GetWidthInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull);
nsresult DrawStringInternal(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
nsresult DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
nsresult GetTextDimensionsInternal(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions);
nsresult GetTextDimensionsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID = nsnull);
nsresult GetTextDimensionsInternal(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
nsresult GetTextDimensionsInternal(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
void UpdateTempTransformMatrix();
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
nsresult GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/**
* Returns metrics (in app units) of a Unicode character string
*/
nsresult GetBoundingMetricsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
nsRefPtr<gfxContext> mThebes;
nsCOMPtr<nsIDeviceContext> mDeviceContext;
nsCOMPtr<nsIWidget> mWidget;
nsCOMPtr<nsIThebesFontMetrics> mFontMetrics;
double mP2A; // cached app units per device pixel value
nsLineStyle mLineStyle;
nscolor mColor;
// for handing out to people
nsTransform2D mTempTransform;
// keeping track of pushgroup/popgroup opacities
nsTArray<float> mOpacityArray;
};
#endif // NSRENDERINGCONTEXT__H__

View File

@ -35,11 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDeviceContext.h"
#include "nsIRenderingContext.h"
#include "nsSystemFontsAndroid.h"
#include "gfxPlatform.h"
#define DEFAULT_FONT "Droid Sans"

View File

@ -38,7 +38,8 @@
#ifndef _NS_SYSTEMFONTSANDROID_H_
#define _NS_SYSTEMFONTSANDROID_H_
#include <gfxFont.h>
#include "gfxFont.h"
#include "nsIDeviceContext.h"
class nsSystemFontsAndroid
{

View File

@ -39,8 +39,8 @@
// for strtod()
#include <stdlib.h>
#include "nsIDeviceContext.h"
#include "nsIRenderingContext.h"
#include "nsSystemFontsGTK2.h"
#include "nsRenderingContext.h"
#include "prlink.h"
#include <gtk/gtk.h>
@ -52,7 +52,6 @@
#endif
#include <fontconfig/fontconfig.h>
#include "nsSystemFontsGTK2.h"
#include "gfxPlatformGtk.h"
// Glue to avoid build/runtime dependencies on Pango > 1.6

View File

@ -40,6 +40,8 @@
#define _NS_SYSTEMFONTSGTK2_H_
#include "gfxFont.h"
#include "nsIDeviceContext.h"
typedef struct _GtkWidget GtkWidget;
class nsSystemFontsGTK2

View File

@ -36,10 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include <Cocoa/Cocoa.h>
#include "nsSystemFontsMac.h"
#include <Cocoa/Cocoa.h>
nsSystemFontsMac::nsSystemFontsMac()
{

View File

@ -39,8 +39,14 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDeviceContext.h"
#include "nsSystemFontsOS2.h"
#define INCL_WINWINDOWMGR
#define INCL_WINSHELLDATA
#define INCL_DOSNLS
#define INCL_DOSERRORS
#include <os2.h>
#include <stdlib.h>
/************************

View File

@ -41,12 +41,8 @@
#ifndef _NS_SYSTEMFONTSOS2_H_
#define _NS_SYSTEMFONTSOS2_H_
#include <gfxFont.h>
#define INCL_WINWINDOWMGR
#define INCL_WINSHELLDATA
#define INCL_DOSNLS
#define INCL_DOSERRORS
#include <os2.h>
#include "gfxFont.h"
#include "nsIDeviceContext.h"
class nsSystemFontsOS2
{

View File

@ -36,12 +36,11 @@
*
* ***** END LICENSE BLOCK ***** */
// Qt headers must be included before anything that might pull in our
// malloc wrappers.
#include <QApplication>
#include <QFont>
#include "nsIDeviceContext.h"
#include "nsIRenderingContext.h"
#include "nsSystemFontsQt.h"
#include "gfxQtPlatform.h"
@ -57,7 +56,7 @@ nsSystemFontsQt::nsSystemFontsQt()
GetSystemFontInfo("QlineEdit", &mFieldFontName, &mFieldFontStyle);
GetSystemFontInfo("QAction", &mMenuFontName, &mMenuFontStyle);
GetSystemFontInfo("QPushButton", &mButtonFontName, &mButtonFontStyle);
}

View File

@ -39,9 +39,8 @@
#ifndef _NS_SYSTEMFONTSQT_H_
#define _NS_SYSTEMFONTSQT_H_
#include <gfxFont.h>
class QFont;
#include "gfxFont.h"
#include "nsIDeviceContext.h"
class nsSystemFontsQt
{

View File

@ -36,12 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIRenderingContext.h"
#include "gfxWindowsSurface.h"
#include "nsSystemFontsWin.h"
#include "gfxWindowsSurface.h"
nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLogFont,
nsString *aFontName,

View File

@ -41,6 +41,7 @@
#include "gfxFont.h"
#include "nsIDeviceContext.h"
#include <windows.h> // need HDC and LOGFONTW
class nsSystemFontsWin
{
@ -58,4 +59,3 @@ private:
};
#endif /* _NS_SYSTEMFONTSWIN_H_ */

View File

@ -43,7 +43,6 @@
#include "nsScriptableRegion.h"
#include "nsThebesDeviceContext.h"
#include "nsThebesRenderingContext.h"
#include "nsThebesRegion.h"
#include "nsThebesFontMetrics.h"
#include "nsThebesFontEnumerator.h"
@ -51,7 +50,6 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontMetrics)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesDeviceContext)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRenderingContext)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
@ -99,7 +97,6 @@ nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
NS_DEFINE_NAMED_CID(NS_FONT_METRICS_CID);
NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_CID);
NS_DEFINE_NAMED_CID(NS_RENDERING_CONTEXT_CID);
NS_DEFINE_NAMED_CID(NS_REGION_CID);
NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
@ -107,7 +104,6 @@ static const mozilla::Module::CIDEntry kThebesCIDs[] = {
{ &kNS_FONT_METRICS_CID, false, NULL, nsThebesFontMetricsConstructor },
{ &kNS_FONT_ENUMERATOR_CID, false, NULL, nsThebesFontEnumeratorConstructor },
{ &kNS_DEVICE_CONTEXT_CID, false, NULL, nsThebesDeviceContextConstructor },
{ &kNS_RENDERING_CONTEXT_CID, false, NULL, nsThebesRenderingContextConstructor },
{ &kNS_REGION_CID, false, NULL, nsThebesRegionConstructor },
{ &kNS_SCRIPTABLE_REGION_CID, false, NULL, nsScriptableRegionConstructor },
{ NULL }
@ -117,7 +113,6 @@ static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
{ "@mozilla.org/gfx/fontmetrics;1", &kNS_FONT_METRICS_CID },
{ "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
{ "@mozilla.org/gfx/devicecontext;1", &kNS_DEVICE_CONTEXT_CID },
{ "@mozilla.org/gfx/renderingcontext;1", &kNS_RENDERING_CONTEXT_CID },
{ "@mozilla.org/gfx/region/nsThebes;1", &kNS_REGION_CID },
{ "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
{ NULL }

View File

@ -1,291 +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 thebes gfx
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2005
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* 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 NSTHEBESRENDERINGCONTEXT__H__
#define NSTHEBESRENDERINGCONTEXT__H__
#include "nsCOMPtr.h"
#include "nsTArray.h"
#include "nsIRenderingContext.h"
#include "nsIDeviceContext.h"
#include "nsIFontMetrics.h"
#include "nsIWidget.h"
#include "nsPoint.h"
#include "nsSize.h"
#include "nsColor.h"
#include "nsRect.h"
#include "nsIRegion.h"
#include "nsTransform2D.h"
#include "nsIThebesFontMetrics.h"
#include "gfxContext.h"
class nsThebesRenderingContext : public nsIRenderingContext
{
public:
nsThebesRenderingContext();
virtual ~nsThebesRenderingContext();
NS_DECL_ISUPPORTS
/**
* Return the maximum length of a string that can be handled by the platform
* using the current font metrics.
*/
virtual PRInt32 GetMaxStringLength();
// Safe string method variants: by default, these defer to the more
// elaborate methods below
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
// Safe string methods
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth, PRInt32 *aFontID = nsnull);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions);
NS_IMETHOD GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
nsTextDimensions& aDimensions, PRInt32* aFontID = nsnull);
#if defined(_WIN32) || defined(XP_OS2) || defined(MOZ_X11)
NS_IMETHOD GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
#endif
#ifdef MOZ_MATHML
NS_IMETHOD GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
NS_IMETHOD GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxASurface* aThebesSurface);
NS_IMETHOD Init(nsIDeviceContext* aContext, gfxContext* aThebesContext);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget);
NS_IMETHOD CommonInit(void);
virtual already_AddRefed<nsIDeviceContext> GetDeviceContext();
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(void);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD SetClipRegion(const nsIntRegion& aRegion, nsClipCombine aCombine);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLanguage,
gfxUserFontSet *aUserFontSet);
NS_IMETHOD SetFont(const nsFont& aFont,
gfxUserFontSet *aUserFontSet);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
virtual already_AddRefed<nsIFontMetrics> GetFontMetrics();
NS_IMETHOD Translate(const nsPoint& aPt);
NS_IMETHOD Scale(float aSx, float aSy);
virtual nsTransform2D* GetCurrentTransform();
NS_IMETHOD DrawLine(const nsPoint& aStartPt, const nsPoint& aEndPt);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD PushFilter(const nsRect& aRect, PRBool aAreaIsOpaque, float aOpacity);
NS_IMETHOD PopFilter();
virtual void* GetNativeGraphicData(GraphicDataType aType);
NS_IMETHOD PushTranslation(PushedTranslation* aState);
NS_IMETHOD PopTranslation(PushedTranslation* aState);
NS_IMETHOD SetTranslation(const nsPoint& aPoint);
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
virtual void SetTextRunRTL(PRBool aIsRTL);
virtual PRInt32 GetPosition(const PRUnichar *aText,
PRUint32 aLength,
nsPoint aPt);
NS_IMETHOD GetRangeWidth(const PRUnichar *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth);
NS_IMETHOD GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth);
NS_IMETHOD RenderEPS(const nsRect& aRect, FILE *aDataFile);
// Thebes specific stuff
gfxContext *ThebesContext() { return mThebes; }
nsTransform2D& CurrentTransform();
void TransformCoord (nscoord *aX, nscoord *aY);
protected:
nsresult GetWidthInternal(const char *aString, PRUint32 aLength, nscoord &aWidth);
nsresult GetWidthInternal(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID = nsnull);
nsresult DrawStringInternal(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing = nsnull);
nsresult DrawStringInternal(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID = -1,
const nscoord* aSpacing = nsnull);
nsresult GetTextDimensionsInternal(const char* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions);
nsresult GetTextDimensionsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID = nsnull);
nsresult GetTextDimensionsInternal(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
nsresult GetTextDimensionsInternal(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
nsresult GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/**
* Returns metrics (in app units) of a Unicode character string
*/
nsresult GetBoundingMetricsInternal(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
nsCOMPtr<nsIDeviceContext> mDeviceContext;
// cached app units per device pixel value
double mP2A;
nsCOMPtr<nsIWidget> mWidget;
// we need to manage our own clip region (since we can't get at
// the old one from cairo)
nsCOMPtr<nsIThebesFontMetrics> mFontMetrics;
nsLineStyle mLineStyle;
nscolor mColor;
// the rendering context
nsRefPtr<gfxContext> mThebes;
// for handing out to people
void UpdateTempTransformMatrix();
nsTransform2D mTempTransform;
// keeping track of pushgroup/popgroup opacities
nsTArray<float> mOpacityArray;
};
#endif // NSCAIRORENDERINGCONTEXT__H__

View File

@ -135,7 +135,6 @@ extern nsISupportsArray *gDraggedTransferables;
ChildView* ChildViewMouseTracker::sLastMouseEventView = nil;
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#ifdef INVALIDATE_DEBUGGING
static void blinkRect(Rect* r);
static void blinkRgn(RgnHandle rgn);

View File

@ -355,9 +355,6 @@ PRBool gDisableNativeTheme = PR_FALSE;
static PRBool gWindowsVisible = PR_FALSE;
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
#ifdef WINCE_WINDOWS_MOBILE
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#endif
// General purpose user32.dll hook object
static WindowsDllInterceptor sUser32Intercept;

View File

@ -107,15 +107,6 @@ using namespace mozilla::layers;
static nsAutoPtr<PRUint8> sSharedSurfaceData;
static gfxIntSize sSharedSurfaceSize;
/**************************************************************
*
* SECTION: global variables.
*
**************************************************************/
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
/**************************************************************
**************************************************************
**