Bug 392252 need new APIs for converting AppUnits to gfx usable pixels r=sharparrow1, sr+a=roc

This commit is contained in:
masayuki@d-toybox.com 2007-08-22 04:13:46 -07:00
Родитель 486571c119
Коммит 5cf046b40d
55 изменённых файлов: 127 добавлений и 58 удалений

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

@ -50,6 +50,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
intl \ intl \
layout \ layout \
locale \ locale \

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

@ -54,6 +54,7 @@ REQUIRES = appshell \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
intl \ intl \
layout \ layout \
locale \ locale \

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

@ -51,6 +51,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
intl \ intl \
locale \ locale \
string \ string \

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

@ -50,6 +50,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
htmlparser \ htmlparser \
intl \ intl \
layout \ layout \

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

@ -50,6 +50,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
htmlparser \ htmlparser \
intl \ intl \
layout \ layout \

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

@ -52,6 +52,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
intl \ intl \
layout \ layout \
locale \ locale \

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

@ -52,6 +52,7 @@ REQUIRES = content \
dom \ dom \
editor \ editor \
gfx \ gfx \
thebes \
intl \ intl \
layout \ layout \
locale \ locale \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
js \ js \
locale \ locale \
gfx \ gfx \
thebes \
layout \ layout \
widget \ widget \
caps \ caps \

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

@ -49,6 +49,7 @@ LIBXUL_LIBRARY = 1
REQUIRES = xpcom \ REQUIRES = xpcom \
string \ string \
gfx \ gfx \
thebes \
layout \ layout \
widget \ widget \
dom \ dom \

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

@ -49,6 +49,7 @@ LIBXUL_LIBRARY = 1
REQUIRES = xpcom \ REQUIRES = xpcom \
string \ string \
gfx \ gfx \
thebes \
layout \ layout \
widget \ widget \
dom \ dom \

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

@ -51,6 +51,7 @@ REQUIRES = content \
xpcom \ xpcom \
string \ string \
gfx \ gfx \
thebes \
dom \ dom \
webshell \ webshell \
htmlparser \ htmlparser \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
js \ js \
dom \ dom \
gfx \ gfx \
thebes \
layout \ layout \
xultmpl \ xultmpl \
widget \ widget \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
js \ js \
dom \ dom \
gfx \ gfx \
thebes \
layout \ layout \
widget \ widget \
necko \ necko \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
js \ js \
dom \ dom \
gfx \ gfx \
thebes \
layout \ layout \
widget \ widget \
caps \ caps \

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

@ -50,6 +50,7 @@ REQUIRES = xpcom \
layout \ layout \
widget \ widget \
gfx \ gfx \
thebes \
dom \ dom \
js \ js \
locale \ locale \

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

@ -52,6 +52,7 @@ endif
REQUIRES = xpcom \ REQUIRES = xpcom \
string \ string \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
widget \ widget \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
exthandler \ exthandler \
mimetype \ mimetype \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
widget \ widget \

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

@ -52,6 +52,7 @@ REQUIRES = xpcom \
xpconnect \ xpconnect \
caps \ caps \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
pref \ pref \

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

@ -56,6 +56,7 @@ REQUIRES = xpcom \
caps \ caps \
necko \ necko \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
dom \ dom \

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

@ -62,6 +62,7 @@ REQUIRES = xpcom \
necko \ necko \
nkcache \ nkcache \
gfx \ gfx \
thebes \
content \ content \
layout \ layout \
webshell \ webshell \

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

@ -53,6 +53,7 @@ REQUIRES = xpcom \
js \ js \
widget \ widget \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
caps \ caps \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
content \ content \
caps \ caps \
gfx \ gfx \
thebes \
js \ js \
layout \ layout \
locale \ locale \

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

@ -51,6 +51,7 @@ REQUIRES = xpcom \
content \ content \
caps \ caps \
gfx \ gfx \
thebes \
js \ js \
layout \ layout \
locale \ locale \

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

@ -65,6 +65,7 @@ REQUIRES = xpcom \
webshell \ webshell \
docshell \ docshell \
gfx \ gfx \
thebes \
widget \ widget \
xuldoc \ xuldoc \
txtsvc \ txtsvc \

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

@ -59,6 +59,7 @@ REQUIRES = xpcom \
pref \ pref \
view \ view \
gfx \ gfx \
thebes \
widget \ widget \
unicharutil \ unicharutil \
commandhandler \ commandhandler \

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

@ -59,6 +59,7 @@ REQUIRES = xpcom \
pref \ pref \
lwbrk \ lwbrk \
gfx \ gfx \
thebes \
widget \ widget \
unicharutil \ unicharutil \
$(NULL) $(NULL)

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

@ -52,6 +52,7 @@ REQUIRES = xpcom \
string \ string \
editor \ editor \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
dom \ dom \

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

@ -54,6 +54,7 @@ REQUIRES = xpcom \
docshell \ docshell \
widget \ widget \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
dom \ dom \

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

@ -51,6 +51,7 @@ REQUIRES = string \
dom \ dom \
docshell \ docshell \
gfx \ gfx \
thebes \
layout \ layout \
editor \ editor \
locale \ locale \

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

@ -55,6 +55,7 @@ REQUIRES = xpcom \
docshell \ docshell \
dom \ dom \
gfx \ gfx \
thebes \
content \ content \
necko \ necko \
layout \ layout \

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

@ -44,6 +44,8 @@
#include "nsRect.h" #include "nsRect.h"
#include "nsIWidget.h" #include "nsIWidget.h"
#include "nsIRenderingContext.h" #include "nsIRenderingContext.h"
// XXX we need only gfxTypes.h, but we cannot include it directly.
#include "gfxPoint.h"
class nsIView; class nsIView;
class nsIFontMetrics; class nsIFontMetrics;
@ -166,10 +168,10 @@ const PRUint8 kUseAltDCFor_CREATERC_PAINT = 0x04; // Use when creating Renderin
const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Surface Dimensions const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Surface Dimensions
#endif #endif
// 7353cfdf-964f-4c20-8729-b11729cc0000 // 4dd372b6-ef19-4995-a7ac-ba3efd3f656f
#define NS_IDEVICE_CONTEXT_IID \ #define NS_IDEVICE_CONTEXT_IID \
{ 0x7353cfdf, 0x964f, 0x4c20, \ { 0x4dd372b6, 0xef19, 0x4995, \
{ 0x87, 0x29, 0xb1, 0x17, 0x29, 0xcc, 0x00, 0x00 } } { 0xa7, 0xac, 0xba, 0x3e, 0xfd, 0x3f, 0x65, 0x6f } }
//a cross platform way of specifying a native palette handle //a cross platform way of specifying a native palette handle
typedef void * nsPalette; typedef void * nsPalette;
@ -280,12 +282,24 @@ public:
*/ */
static PRInt32 AppUnitsPerCSSPixel() { return 60; } static PRInt32 AppUnitsPerCSSPixel() { return 60; }
/**
* Convert app units to CSS pixels which is used in gfx/thebes.
*/
static gfxFloat AppUnitsToGfxCSSPixels(nscoord aAppUnits)
{ return gfxFloat(aAppUnits) / AppUnitsPerCSSPixel(); }
/** /**
* Gets the number of app units in one device pixel; this number is usually * Gets the number of app units in one device pixel; this number is usually
* a factor of AppUnitsPerCSSPixel(), although that is not guaranteed. * a factor of AppUnitsPerCSSPixel(), although that is not guaranteed.
*/ */
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; } PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
/**
* Convert app units to device pixels which is used in gfx/thebes.
*/
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
{ return gfxFloat(aAppUnits) / AppUnitsPerDevPixel(); }
/** /**
* Gets the number of app units in one inch; this is the device's DPI * Gets the number of app units in one inch; this is the device's DPI
* times AppUnitsPerDevPixel(). * times AppUnitsPerDevPixel().

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

@ -59,6 +59,7 @@ REQUIRES = xpcom \
view \ view \
pref \ pref \
unicharutil \ unicharutil \
thebes \
$(NULL) $(NULL)
DIRS = shared DIRS = shared

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

@ -73,7 +73,7 @@ nsThebesFontMetrics::Init(const nsFont& aFont, nsIAtom* aLangGroup,
mTextRunRTL = PR_FALSE; mTextRunRTL = PR_FALSE;
// work around layout giving us 0 sized fonts... // work around layout giving us 0 sized fonts...
double size = NSAppUnitsToFloatPixels(aFont.size, mP2A); gfxFloat size = gfxFloat(aFont.size) / mP2A;
if (size == 0.0) if (size == 0.0)
size = 1.0; size = 1.0;

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

@ -201,7 +201,7 @@ public:
/** /**
* Function for painting the decoration lines for the text. * Function for painting the decoration lines for the text.
* NOTE: aPt, aLineSize, aAscent, aOffset and aReferredHeight are non-rounded * NOTE: aPt, aLineSize, aAscent, aOffset and aPreferredHeight are non-rounded
* device pixels, not app units. * device pixels, not app units.
* input: * input:
* @param aGfxContext * @param aGfxContext

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

@ -2141,11 +2141,10 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
// of the image) // of the image)
gfxRect pxSrc; gfxRect pxSrc;
if (aSourceRect) { if (aSourceRect) {
PRInt32 p2a = nsIDeviceContext::AppUnitsPerCSSPixel(); pxSrc.pos.x = nsIDeviceContext::AppUnitsToGfxCSSPixels(aSourceRect->x);
pxSrc.pos.x = NSAppUnitsToFloatPixels(aSourceRect->x, p2a); pxSrc.pos.y = nsIDeviceContext::AppUnitsToGfxCSSPixels(aSourceRect->y);
pxSrc.pos.y = NSAppUnitsToFloatPixels(aSourceRect->y, p2a); pxSrc.size.width = nsIDeviceContext::AppUnitsToGfxCSSPixels(aSourceRect->width);
pxSrc.size.width = NSAppUnitsToFloatPixels(aSourceRect->width, p2a); pxSrc.size.height = nsIDeviceContext::AppUnitsToGfxCSSPixels(aSourceRect->height);
pxSrc.size.height = NSAppUnitsToFloatPixels(aSourceRect->height, p2a);
} else { } else {
pxSrc.pos.x = pxSrc.pos.y = 0.0; pxSrc.pos.x = pxSrc.pos.y = 0.0;
PRInt32 w = 0, h = 0; PRInt32 w = 0, h = 0;
@ -2157,7 +2156,6 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
nsCOMPtr<nsIDeviceContext> dc; nsCOMPtr<nsIDeviceContext> dc;
aRenderingContext->GetDeviceContext(*getter_AddRefs(dc)); aRenderingContext->GetDeviceContext(*getter_AddRefs(dc));
PRInt32 d2a = dc->AppUnitsPerDevPixel();
nsRefPtr<gfxContext> ctx = static_cast<gfxContext*> nsRefPtr<gfxContext> ctx = static_cast<gfxContext*>
(aRenderingContext->GetNativeGraphicData( (aRenderingContext->GetNativeGraphicData(
@ -2170,10 +2168,10 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
// pixel, but then convert back to gfxFloats for the rest of the math. // pixel, but then convert back to gfxFloats for the rest of the math.
gfxRect pxDest; gfxRect pxDest;
{ {
pxDest.pos.x = NSAppUnitsToFloatPixels(aDestRect.x, d2a); pxDest.pos.x = dc->AppUnitsToGfxUnits(aDestRect.x);
pxDest.pos.y = NSAppUnitsToFloatPixels(aDestRect.y, d2a); pxDest.pos.y = dc->AppUnitsToGfxUnits(aDestRect.y);
pxDest.size.width = NSAppUnitsToFloatPixels(aDestRect.width, d2a); pxDest.size.width = dc->AppUnitsToGfxUnits(aDestRect.width);
pxDest.size.height = NSAppUnitsToFloatPixels(aDestRect.height, d2a); pxDest.size.height = dc->AppUnitsToGfxUnits(aDestRect.height);
if (ctx->UserToDevicePixelSnapped(pxDest)) if (ctx->UserToDevicePixelSnapped(pxDest))
pxDest = ctx->DeviceToUser(pxDest); pxDest = ctx->DeviceToUser(pxDest);
} }
@ -2184,10 +2182,10 @@ nsLayoutUtils::DrawImage(nsIRenderingContext* aRenderingContext,
// been intersected with, and we should be rounding those consistently.) // been intersected with, and we should be rounding those consistently.)
gfxRect pxDirty; gfxRect pxDirty;
{ {
pxDirty.pos.x = NSAppUnitsToFloatPixels(dirtyRect.x, d2a); pxDirty.pos.x = dc->AppUnitsToGfxUnits(dirtyRect.x);
pxDirty.pos.y = NSAppUnitsToFloatPixels(dirtyRect.y, d2a); pxDirty.pos.y = dc->AppUnitsToGfxUnits(dirtyRect.y);
pxDirty.size.width = NSAppUnitsToFloatPixels(dirtyRect.width, d2a); pxDirty.size.width = dc->AppUnitsToGfxUnits(dirtyRect.width);
pxDirty.size.height = NSAppUnitsToFloatPixels(dirtyRect.height, d2a); pxDirty.size.height = dc->AppUnitsToGfxUnits(dirtyRect.height);
if (ctx->UserToDevicePixelSnapped(pxDirty)) if (ctx->UserToDevicePixelSnapped(pxDirty))
pxDirty = ctx->DeviceToUser(pxDirty); pxDirty = ctx->DeviceToUser(pxDirty);
} }

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

@ -660,10 +660,10 @@ public:
/** /**
* Draw a single image. * Draw a single image.
* @param aImage The image.
* @param aRenderingContext Where to draw the image, set up with an * @param aRenderingContext Where to draw the image, set up with an
* appropriate scale and transform for drawing in * appropriate scale and transform for drawing in
* app units (aDestRect). * app units (aDestRect).
* @param aImage The image.
* @param aDestRect Where to draw the image (app units). * @param aDestRect Where to draw the image (app units).
* @param aDirtyRect Draw only within this region (rounded to the * @param aDirtyRect Draw only within this region (rounded to the
* nearest pixel); the intersection of * nearest pixel); the intersection of

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

@ -61,6 +61,8 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsInterfaceHashtable.h" #include "nsInterfaceHashtable.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
// XXX we need only gfxTypes.h, but we cannot include it directly.
#include "gfxPoint.h"
class nsImageLoader; class nsImageLoader;
#ifdef IBMBIDI #ifdef IBMBIDI
class nsBidiPresUtils; class nsBidiPresUtils;
@ -496,6 +498,9 @@ public:
{ return NSAppUnitsToFloatPixels(aAppUnits, { return NSAppUnitsToFloatPixels(aAppUnits,
nsIDeviceContext::AppUnitsPerCSSPixel()); } nsIDeviceContext::AppUnitsPerCSSPixel()); }
static gfxFloat AppUnitsToGfxCSSPixels(nscoord aAppUnits)
{ return nsIDeviceContext::AppUnitsToGfxCSSPixels(aAppUnits); }
nscoord DevPixelsToAppUnits(PRInt32 aPixels) const nscoord DevPixelsToAppUnits(PRInt32 aPixels) const
{ return NSIntPixelsToAppUnits(aPixels, { return NSIntPixelsToAppUnits(aPixels,
mDeviceContext->AppUnitsPerDevPixel()); } mDeviceContext->AppUnitsPerDevPixel()); }
@ -504,6 +509,9 @@ public:
{ return NSAppUnitsToIntPixels(aAppUnits, { return NSAppUnitsToIntPixels(aAppUnits,
mDeviceContext->AppUnitsPerDevPixel()); } mDeviceContext->AppUnitsPerDevPixel()); }
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
{ return mDeviceContext->AppUnitsToGfxUnits(aAppUnits); }
nscoord TwipsToAppUnits(PRInt32 aTwips) const nscoord TwipsToAppUnits(PRInt32 aTwips) const
{ return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) * { return NSToCoordRound(NS_TWIPS_TO_INCHES(aTwips) *
mDeviceContext->AppUnitsPerInch()); } mDeviceContext->AppUnitsPerInch()); }

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

@ -22,7 +22,7 @@
* *
* Contributor(s): * Contributor(s):
* Steve Clark <buster@netscape.com> * Steve Clark <buster@netscape.com>
* Håkan Waara <hwaara@chello.se> * Håkan Waara <hwaara@chello.se>
* Dan Rosen <dr@netscape.com> * Dan Rosen <dr@netscape.com>
* Daniel Glazman <glazman@netscape.com> * Daniel Glazman <glazman@netscape.com>
* Mats Palmgren <mats.palmgren@bredband.net> * Mats Palmgren <mats.palmgren@bredband.net>
@ -4771,11 +4771,10 @@ PresShell::RenderDocument(const nsRect& aRect, PRBool aUntrusted,
builder.LeavePresShell(rootFrame, rect); builder.LeavePresShell(rootFrame, rect);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
nscoord appUnitsPerDevPixel = mPresContext->AppUnitsPerDevPixel();
// Ensure that r.x,r.y gets drawn at (0,0) // Ensure that r.x,r.y gets drawn at (0,0)
aThebesContext->Save(); aThebesContext->Save();
aThebesContext->Translate(gfxPoint(-NSAppUnitsToFloatPixels(rect.x,appUnitsPerDevPixel), aThebesContext->Translate(gfxPoint(-mPresContext->AppUnitsToGfxUnits(rect.x),
-NSAppUnitsToFloatPixels(rect.y,appUnitsPerDevPixel))); -mPresContext->AppUnitsToGfxUnits(rect.y)));
nsIDeviceContext* devCtx = mPresContext->DeviceContext(); nsIDeviceContext* devCtx = mPresContext->DeviceContext();
nsCOMPtr<nsIRenderingContext> rc; nsCOMPtr<nsIRenderingContext> rc;

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

@ -5779,14 +5779,17 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL; PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL;
nsRefPtr<gfxContext> ctx = (gfxContext*) nsRefPtr<gfxContext> ctx = (gfxContext*)
aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT); aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
gfxFloat a2p = 1.0 / PresContext()->AppUnitsPerDevPixel(); PRInt32 app = PresContext()->AppUnitsPerDevPixel();
gfxPoint pt((start + aPt.x) * a2p, (aLine->mBounds.y + aPt.y) * a2p); gfxPoint pt(PresContext()->AppUnitsToGfxUnits(start + aPt.x),
gfxSize size(width * a2p, aSize * a2p); PresContext()->AppUnitsToGfxUnits(aLine->mBounds.y + aPt.y));
nsCSSRendering::PaintDecorationLine(ctx, aColor, pt, size, gfxSize size(PresContext()->AppUnitsToGfxUnits(width),
aLine->GetAscent() * a2p, aOffset * a2p, PresContext()->AppUnitsToGfxUnits(aSize));
aSize * a2p, aDecoration, nsCSSRendering::PaintDecorationLine(
NS_STYLE_BORDER_STYLE_SOLID, ctx, aColor, pt, size,
isRTL); PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
PresContext()->AppUnitsToGfxUnits(aOffset),
PresContext()->AppUnitsToGfxUnits(aSize),
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
} }
} }

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

@ -214,12 +214,15 @@ nsHTMLContainerFrame::PaintTextDecorationLine(
nscoord innerWidth = mRect.width - bp.left - bp.right; nscoord innerWidth = mRect.width - bp.left - bp.right;
nsRefPtr<gfxContext> ctx = (gfxContext*) nsRefPtr<gfxContext> ctx = (gfxContext*)
aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT); aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
gfxFloat a2p = 1.0 / PresContext()->AppUnitsPerDevPixel(); gfxPoint pt(PresContext()->AppUnitsToGfxUnits(bp.left + aPt.x),
gfxPoint pt((bp.left + aPt.x) * a2p, (bp.top + aPt.y) * a2p); PresContext()->AppUnitsToGfxUnits(bp.top + aPt.y));
gfxSize size(innerWidth * a2p, aSize * a2p); gfxSize size(PresContext()->AppUnitsToGfxUnits(innerWidth),
nsCSSRendering::PaintDecorationLine(ctx, aColor, pt, size, aAscent * a2p, PresContext()->AppUnitsToGfxUnits(aSize));
aOffset * a2p, aSize * a2p, aDecoration, nsCSSRendering::PaintDecorationLine(
NS_STYLE_BORDER_STYLE_SOLID, isRTL); ctx, aColor, pt, size, PresContext()->AppUnitsToGfxUnits(aAscent),
PresContext()->AppUnitsToGfxUnits(aOffset),
PresContext()->AppUnitsToGfxUnits(aSize),
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
} }
void void

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

@ -560,7 +560,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
fm->GetMaxAscent(aMetrics.ascent); fm->GetMaxAscent(aMetrics.ascent);
fm->GetHeight(aMetrics.height); fm->GetHeight(aMetrics.height);
// Include the text-decoration lines to the height. // Include the text-decoration lines to the height.
// Currently, only undeline is overflowable. // Currently, only underline is overflowable.
nscoord offset, size; nscoord offset, size;
fm->GetUnderline(offset, size); fm->GetUnderline(offset, size);
nscoord ascentAndUnderline = nscoord ascentAndUnderline =

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

@ -3716,10 +3716,11 @@ FillClippedRect(gfxContext* aCtx, nsPresContext* aPresContext,
{ {
gfxRect r = aRect.Intersect(aDirtyRect); gfxRect r = aRect.Intersect(aDirtyRect);
// For now, we need to put this in pixel coordinates // For now, we need to put this in pixel coordinates
float t2p = 1.0f / aPresContext->AppUnitsPerDevPixel(); PRInt32 app = aPresContext->AppUnitsPerDevPixel();
aCtx->NewPath(); aCtx->NewPath();
// pixel-snap // pixel-snap
aCtx->Rectangle(gfxRect(r.X()*t2p, r.Y()*t2p, r.Width()*t2p, r.Height()*t2p), PR_TRUE); aCtx->Rectangle(gfxRect(r.X() / app, r.Y() / app,
r.Width() / app, r.Height() / app), PR_TRUE);
aCtx->SetColor(gfxRGBA(aColor)); aCtx->SetColor(gfxRGBA(aColor));
aCtx->Fill(); aCtx->Fill();
} }
@ -3790,12 +3791,12 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
return; return;
gfxFont::Metrics fontMetrics = GetFontMetrics(aProvider.GetFontGroup()); gfxFont::Metrics fontMetrics = GetFontMetrics(aProvider.GetFontGroup());
gfxFloat a2p = 1.0 / aTextPaintStyle.PresContext()->AppUnitsPerDevPixel(); PRInt32 app = aTextPaintStyle.PresContext()->AppUnitsPerDevPixel();
// XXX aFramePt is in AppUnits, shouldn't it be nsFloatPoint? // XXX aFramePt is in AppUnits, shouldn't it be nsFloatPoint?
gfxPoint pt(aFramePt.x * a2p, aFramePt.y * a2p); gfxPoint pt(aFramePt.x / app, aFramePt.y / app);
gfxSize size(GetRect().width * a2p, 0); gfxSize size(GetRect().width / app, 0);
gfxFloat ascent = mAscent * a2p; gfxFloat ascent = mAscent / app;
if (decorations & NS_FONT_DECORATION_OVERLINE) { if (decorations & NS_FONT_DECORATION_OVERLINE) {
size.height = fontMetrics.underlineSize; size.height = fontMetrics.underlineSize;
@ -4174,13 +4175,13 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
gfxFloat advance = hyphenWidth + gfxFloat advance = hyphenWidth +
mTextRun->GetAdvanceWidth(offset, length, &aProvider); mTextRun->GetAdvanceWidth(offset, length, &aProvider);
if (type == aSelectionType) { if (type == aSelectionType) {
gfxFloat a2p = 1.0 / aTextPaintStyle.PresContext()->AppUnitsPerDevPixel(); PRInt32 app = aTextPaintStyle.PresContext()->AppUnitsPerDevPixel();
// XXX aTextBaselinePt is in AppUnits, shouldn't it be nsFloatPoint? // XXX aTextBaselinePt is in AppUnits, shouldn't it be nsFloatPoint?
gfxPoint pt((aTextBaselinePt.x + xOffset) * a2p, gfxPoint pt((aTextBaselinePt.x + xOffset) / app,
(aTextBaselinePt.y - mAscent) * a2p); (aTextBaselinePt.y - mAscent) / app);
gfxFloat width = PR_ABS(advance) * a2p; gfxFloat width = PR_ABS(advance) / app;
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle, DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
pt, width, mAscent * a2p, decorationMetrics, pt, width, mAscent / app, decorationMetrics,
mTextRun->IsRightToLeft()); mTextRun->IsRightToLeft());
} }
iterator.UpdateWithAdvance(advance); iterator.UpdateWithAdvance(advance);

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

@ -50,6 +50,7 @@ REQUIRES = xpcom \
string \ string \
dom \ dom \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
widget \ widget \

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

@ -53,6 +53,7 @@ REQUIRES = xpcom \
dom \ dom \
widget \ widget \
gfx \ gfx \
thebes \
view \ view \
necko \ necko \
webshell \ webshell \

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

@ -56,6 +56,7 @@ REQUIRES = xpcom \
dom \ dom \
content \ content \
gfx \ gfx \
thebes \
widget \ widget \
caps \ caps \
locale \ locale \

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

@ -452,14 +452,14 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
nsRefPtr<gfxContext> ctx = (gfxContext*) nsRefPtr<gfxContext> ctx = (gfxContext*)
aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT); aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
gfxFloat a2p = 1.0 / presContext->AppUnitsPerDevPixel(); gfxPoint pt(presContext->AppUnitsToGfxUnits(textRect.x),
gfxPoint pt(textRect.x * a2p, textRect.y * a2p); presContext->AppUnitsToGfxUnits(textRect.y));
gfxFloat width = textRect.width * a2p; gfxFloat width = presContext->AppUnitsToGfxUnits(textRect.width);
gfxFloat baselinePixel = baseline * a2p; gfxFloat baselinePixel = presContext->AppUnitsToGfxUnits(baseline);
if (decorations & (NS_FONT_DECORATION_OVERLINE | NS_FONT_DECORATION_UNDERLINE)) { if (decorations & (NS_FONT_DECORATION_OVERLINE | NS_FONT_DECORATION_UNDERLINE)) {
fontMet->GetUnderline(offset, size); fontMet->GetUnderline(offset, size);
gfxFloat offsetPixel = offset * a2p; gfxFloat offsetPixel = presContext->AppUnitsToGfxUnits(offset);
gfxFloat sizePixel = size * a2p; gfxFloat sizePixel = presContext->AppUnitsToGfxUnits(size);
if (decorations & NS_FONT_DECORATION_OVERLINE) { if (decorations & NS_FONT_DECORATION_OVERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, overColor, nsCSSRendering::PaintDecorationLine(ctx, overColor,
pt, gfxSize(width, sizePixel), pt, gfxSize(width, sizePixel),
@ -481,8 +481,8 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
} }
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) { if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
fontMet->GetStrikeout(offset, size); fontMet->GetStrikeout(offset, size);
gfxFloat offsetPixel = offset * a2p; gfxFloat offsetPixel = presContext->AppUnitsToGfxUnits(offset);
gfxFloat sizePixel = size * a2p; gfxFloat sizePixel = presContext->AppUnitsToGfxUnits(size);
nsCSSRendering::PaintDecorationLine(ctx, underColor, nsCSSRendering::PaintDecorationLine(ctx, underColor,
pt, gfxSize(width, sizePixel), pt, gfxSize(width, sizePixel),
baselinePixel, offsetPixel, baselinePixel, offsetPixel,

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

@ -64,6 +64,7 @@ REQUIRES = xpcom \
xpconnect \ xpconnect \
windowwatcher \ windowwatcher \
gfx \ gfx \
thebes \
content \ content \
layout \ layout \
docshell \ docshell \

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

@ -66,6 +66,7 @@ REQUIRES = xpcom \
unicharutil \ unicharutil \
dom \ dom \
gfx \ gfx \
thebes \
content \ content \
widget \ widget \
mimetype \ mimetype \

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

@ -61,6 +61,7 @@ REQUIRES = xpcom \
content \ content \
view \ view \
gfx \ gfx \
thebes \
locale \ locale \
necko \ necko \
$(NULL) $(NULL)

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

@ -81,6 +81,7 @@ REQUIRES = \
content \ content \
find \ find \
gfx \ gfx \
thebes \
locale \ locale \
unicharutil \ unicharutil \
xuldoc \ xuldoc \

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

@ -59,6 +59,7 @@ REQUIRES = \
layout \ layout \
docshell \ docshell \
gfx \ gfx \
thebes \
necko \ necko \
widget \ widget \
content \ content \

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

@ -55,6 +55,7 @@ REQUIRES = content \
editor \ editor \
find \ find \
gfx \ gfx \
thebes \
layout \ layout \
locale \ locale \
necko \ necko \

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

@ -55,6 +55,7 @@ REQUIRES = xpcom \
js \ js \
docshell \ docshell \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
widget \ widget \

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

@ -59,6 +59,7 @@ REQUIRES = xpcom \
docshell \ docshell \
webshell \ webshell \
gfx \ gfx \
thebes \
layout \ layout \
content \ content \
dom \ dom \

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

@ -64,6 +64,7 @@ REQUIRES = \
widget \ widget \
imglib2 \ imglib2 \
gfx \ gfx \
thebes \
locale \ locale \
xulapp \ xulapp \
embed_base \ embed_base \