зеркало из https://github.com/mozilla/pjs.git
Backing out fix for bug 392785 as per roc + mconnor.
This commit is contained in:
Родитель
f3879b5f60
Коммит
9eaf60c3ff
|
@ -168,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
|
||||||
|
|
||||||
// 92a1e76c-adbd-441e-aae6-243d6004e0ee
|
// 4dd372b6-ef19-4995-a7ac-ba3efd3f656f
|
||||||
#define NS_IDEVICE_CONTEXT_IID \
|
#define NS_IDEVICE_CONTEXT_IID \
|
||||||
{ 0x92a1e76c, 0xadbd, 0x441e, \
|
{ 0x4dd372b6, 0xef19, 0x4995, \
|
||||||
{ 0xaa, 0xe6, 0x24, 0x3d, 0x60, 0x4, 0xe0, 0xee } }
|
{ 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;
|
||||||
|
@ -295,14 +295,7 @@ public:
|
||||||
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
|
PRInt32 AppUnitsPerDevPixel() const { return mAppUnitsPerDevPixel; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert device pixels which is used for gfx/thebes to nearest (rounded)
|
* Convert app units to device pixels which is used in gfx/thebes.
|
||||||
* app units
|
|
||||||
*/
|
|
||||||
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const
|
|
||||||
{ return nscoord(NS_round(aGfxUnits * AppUnitsPerDevPixel())); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert app units to device pixels which is used for gfx/thebes.
|
|
||||||
*/
|
*/
|
||||||
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
||||||
{ return gfxFloat(aAppUnits) / AppUnitsPerDevPixel(); }
|
{ return gfxFloat(aAppUnits) / AppUnitsPerDevPixel(); }
|
||||||
|
|
|
@ -4352,26 +4352,24 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
const gfxSize& aLineSize,
|
const gfxSize& aLineSize,
|
||||||
const gfxFloat aAscent,
|
const gfxFloat aAscent,
|
||||||
const gfxFloat aOffset,
|
const gfxFloat aOffset,
|
||||||
|
const gfxFloat aPreferredHeight,
|
||||||
const PRUint8 aDecoration,
|
const PRUint8 aDecoration,
|
||||||
const PRUint8 aStyle,
|
const PRUint8 aStyle,
|
||||||
const PRBool aIsRTL)
|
const PRBool aIsRTL)
|
||||||
{
|
{
|
||||||
gfxRect rect =
|
if (aLineSize.width <= 0 || aLineSize.height <= 0 ||
|
||||||
GetTextDecorationRectInternal(aPt, aLineSize, aAscent, aOffset,
|
aStyle == NS_STYLE_BORDER_STYLE_NONE)
|
||||||
aDecoration, aStyle);
|
|
||||||
if (rect.IsEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gfxFloat lineHeight = PR_MAX(NS_round(aLineSize.height), 1.0);
|
|
||||||
PRBool contextIsSaved = PR_FALSE;
|
PRBool contextIsSaved = PR_FALSE;
|
||||||
|
gfxFloat totalHeight = aLineSize.height;
|
||||||
switch (aStyle) {
|
switch (aStyle) {
|
||||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
|
||||||
break;
|
break;
|
||||||
case NS_STYLE_BORDER_STYLE_DASHED: {
|
case NS_STYLE_BORDER_STYLE_DASHED: {
|
||||||
aGfxContext->Save();
|
aGfxContext->Save();
|
||||||
contextIsSaved = PR_TRUE;
|
contextIsSaved = PR_TRUE;
|
||||||
gfxFloat dashWidth = lineHeight * DOT_LENGTH * DASH_LENGTH;
|
gfxFloat dashWidth = aLineSize.height * DOT_LENGTH * DASH_LENGTH;
|
||||||
gfxFloat dash[2] = { dashWidth, dashWidth };
|
gfxFloat dash[2] = { dashWidth, dashWidth };
|
||||||
aGfxContext->SetLineCap(gfxContext::LINE_CAP_BUTT);
|
aGfxContext->SetLineCap(gfxContext::LINE_CAP_BUTT);
|
||||||
aGfxContext->SetDash(dash, 2, 0.0);
|
aGfxContext->SetDash(dash, 2, 0.0);
|
||||||
|
@ -4380,9 +4378,9 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
case NS_STYLE_BORDER_STYLE_DOTTED: {
|
case NS_STYLE_BORDER_STYLE_DOTTED: {
|
||||||
aGfxContext->Save();
|
aGfxContext->Save();
|
||||||
contextIsSaved = PR_TRUE;
|
contextIsSaved = PR_TRUE;
|
||||||
gfxFloat dashWidth = lineHeight * DOT_LENGTH;
|
gfxFloat dashWidth = aLineSize.height * DOT_LENGTH;
|
||||||
gfxFloat dash[2];
|
gfxFloat dash[2];
|
||||||
if (lineHeight > 2.0) {
|
if (aLineSize.height > 2.0) {
|
||||||
dash[0] = 0.0;
|
dash[0] = 0.0;
|
||||||
dash[1] = dashWidth * 2.0;
|
dash[1] = dashWidth * 2.0;
|
||||||
aGfxContext->SetLineCap(gfxContext::LINE_CAP_ROUND);
|
aGfxContext->SetLineCap(gfxContext::LINE_CAP_ROUND);
|
||||||
|
@ -4393,41 +4391,74 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
aGfxContext->SetDash(dash, 2, 0.0);
|
aGfxContext->SetDash(dash, 2, 0.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||||
|
totalHeight *= 3.0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
NS_ERROR("Invalid style value!");
|
NS_ERROR("Invalid style value!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxFloat offset = aOffset;
|
||||||
|
switch (aDecoration) {
|
||||||
|
case NS_STYLE_TEXT_DECORATION_UNDERLINE:
|
||||||
|
break;
|
||||||
|
case NS_STYLE_TEXT_DECORATION_OVERLINE:
|
||||||
|
// The offset includes the preferred size, we should remove it
|
||||||
|
offset += aPreferredHeight;
|
||||||
|
// the bottom of the decoration line should be aligned to the top of the
|
||||||
|
// text.
|
||||||
|
offset -= totalHeight;
|
||||||
|
break;
|
||||||
|
case NS_STYLE_TEXT_DECORATION_LINE_THROUGH: {
|
||||||
|
// The offset includes the preferred size, we should remove it
|
||||||
|
offset += aPreferredHeight;
|
||||||
|
// the middle of the decoration line should be aligned to the middle of
|
||||||
|
// the original strike out offset.
|
||||||
|
offset -= PR_MAX(aPreferredHeight, (totalHeight / 2.0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
NS_ERROR("Invalid decoration value!");
|
||||||
|
if (contextIsSaved)
|
||||||
|
aGfxContext->Restore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// round to device pixels for suppressing the AA.
|
||||||
|
gfxFloat x = NS_round(aPt.x);
|
||||||
|
gfxFloat y = NS_round(aPt.y + aAscent) - NS_round(offset);
|
||||||
|
gfxFloat width = NS_round(aLineSize.width);
|
||||||
|
gfxFloat height = NS_round(aLineSize.height);
|
||||||
// The y position should be set to the middle of the line.
|
// The y position should be set to the middle of the line.
|
||||||
rect.pos.y += lineHeight / 2;
|
y += height / 2;
|
||||||
|
|
||||||
aGfxContext->SetColor(gfxRGBA(aColor));
|
aGfxContext->SetColor(gfxRGBA(aColor));
|
||||||
aGfxContext->SetLineWidth(lineHeight);
|
aGfxContext->SetLineWidth(height);
|
||||||
switch (aStyle) {
|
switch (aStyle) {
|
||||||
case NS_STYLE_BORDER_STYLE_SOLID:
|
case NS_STYLE_BORDER_STYLE_SOLID:
|
||||||
aGfxContext->NewPath();
|
aGfxContext->NewPath();
|
||||||
aGfxContext->MoveTo(rect.TopLeft());
|
aGfxContext->MoveTo(gfxPoint(x, y));
|
||||||
aGfxContext->LineTo(rect.TopRight());
|
aGfxContext->LineTo(gfxPoint(x + width, y));
|
||||||
aGfxContext->Stroke();
|
aGfxContext->Stroke();
|
||||||
break;
|
break;
|
||||||
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
case NS_STYLE_BORDER_STYLE_DOUBLE:
|
||||||
aGfxContext->NewPath();
|
aGfxContext->NewPath();
|
||||||
aGfxContext->MoveTo(rect.TopLeft());
|
aGfxContext->MoveTo(gfxPoint(x, y));
|
||||||
aGfxContext->LineTo(rect.TopRight());
|
aGfxContext->LineTo(gfxPoint(x + width, y));
|
||||||
rect.size.height -= lineHeight;
|
aGfxContext->MoveTo(gfxPoint(x, y + height * 2.0));
|
||||||
aGfxContext->MoveTo(rect.BottomLeft());
|
aGfxContext->LineTo(gfxPoint(x + width, y + height * 2.0));
|
||||||
aGfxContext->LineTo(rect.BottomRight());
|
|
||||||
aGfxContext->Stroke();
|
aGfxContext->Stroke();
|
||||||
break;
|
break;
|
||||||
case NS_STYLE_BORDER_STYLE_DOTTED:
|
case NS_STYLE_BORDER_STYLE_DOTTED:
|
||||||
case NS_STYLE_BORDER_STYLE_DASHED:
|
case NS_STYLE_BORDER_STYLE_DASHED:
|
||||||
aGfxContext->NewPath();
|
aGfxContext->NewPath();
|
||||||
if (aIsRTL) {
|
if (aIsRTL) {
|
||||||
aGfxContext->MoveTo(rect.TopRight());
|
aGfxContext->MoveTo(gfxPoint(x + width, y));
|
||||||
aGfxContext->LineTo(rect.TopLeft());
|
aGfxContext->LineTo(gfxPoint(x, y));
|
||||||
} else {
|
} else {
|
||||||
aGfxContext->MoveTo(rect.TopLeft());
|
aGfxContext->MoveTo(gfxPoint(x, y));
|
||||||
aGfxContext->LineTo(rect.TopRight());
|
aGfxContext->LineTo(gfxPoint(x + width, y));
|
||||||
}
|
}
|
||||||
aGfxContext->Stroke();
|
aGfxContext->Stroke();
|
||||||
aGfxContext->Restore();
|
aGfxContext->Restore();
|
||||||
|
@ -4439,70 +4470,3 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
}
|
}
|
||||||
NS_ASSERTION(!contextIsSaved, "The gfxContext has been saved, but not restored!");
|
NS_ASSERTION(!contextIsSaved, "The gfxContext has been saved, but not restored!");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect
|
|
||||||
nsCSSRendering::GetTextDecorationRect(nsPresContext* aPresContext,
|
|
||||||
const gfxSize& aLineSize,
|
|
||||||
const gfxFloat aAscent,
|
|
||||||
const gfxFloat aOffset,
|
|
||||||
const PRUint8 aDecoration,
|
|
||||||
const PRUint8 aStyle)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aPresContext, "aPresContext is null");
|
|
||||||
|
|
||||||
gfxRect rect =
|
|
||||||
GetTextDecorationRectInternal(gfxPoint(0, 0), aLineSize, aAscent, aOffset,
|
|
||||||
aDecoration, aStyle);
|
|
||||||
// The rect values are already rounded to nearest device pixels.
|
|
||||||
nsRect r;
|
|
||||||
r.x = aPresContext->GfxUnitsToAppUnits(rect.X());
|
|
||||||
r.y = aPresContext->GfxUnitsToAppUnits(rect.Y());
|
|
||||||
r.width = aPresContext->GfxUnitsToAppUnits(rect.Width());
|
|
||||||
r.height = aPresContext->GfxUnitsToAppUnits(rect.Height());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
gfxRect
|
|
||||||
nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
|
|
||||||
const gfxSize& aLineSize,
|
|
||||||
const gfxFloat aAscent,
|
|
||||||
const gfxFloat aOffset,
|
|
||||||
const PRUint8 aDecoration,
|
|
||||||
const PRUint8 aStyle)
|
|
||||||
{
|
|
||||||
gfxRect r;
|
|
||||||
r.pos.x = NS_round(aPt.x);
|
|
||||||
r.size.width = NS_round(aLineSize.width);
|
|
||||||
|
|
||||||
gfxFloat basesize = NS_round(aLineSize.height);
|
|
||||||
basesize = PR_MAX(basesize, 1.0);
|
|
||||||
r.size.height = basesize;
|
|
||||||
if (aStyle == NS_STYLE_BORDER_STYLE_DOUBLE) {
|
|
||||||
gfxFloat gap = NS_round(basesize / 2.0);
|
|
||||||
gap = PR_MAX(gap, 1.0);
|
|
||||||
r.size.height = basesize * 2.0 + gap;
|
|
||||||
} else {
|
|
||||||
r.size.height = basesize;
|
|
||||||
}
|
|
||||||
|
|
||||||
gfxFloat baseline = NS_round(aPt.y + aAscent);
|
|
||||||
gfxFloat offset = 0;
|
|
||||||
switch (aDecoration) {
|
|
||||||
case NS_STYLE_TEXT_DECORATION_UNDERLINE:
|
|
||||||
offset = NS_round(aOffset);
|
|
||||||
break;
|
|
||||||
case NS_STYLE_TEXT_DECORATION_OVERLINE:
|
|
||||||
offset = NS_round(aOffset - basesize + r.Height());
|
|
||||||
break;
|
|
||||||
case NS_STYLE_TEXT_DECORATION_LINE_THROUGH: {
|
|
||||||
gfxFloat extra = NS_round(r.Height() / 2.0);
|
|
||||||
extra = PR_MAX(extra, basesize);
|
|
||||||
offset = NS_round(aOffset - basesize + extra);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
NS_ERROR("Invalid decoration value!");
|
|
||||||
}
|
|
||||||
r.pos.y = baseline - NS_round(offset);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#define nsCSSRendering_h___
|
#define nsCSSRendering_h___
|
||||||
|
|
||||||
#include "nsIRenderingContext.h"
|
#include "nsIRenderingContext.h"
|
||||||
#include "nsStyleConsts.h"
|
|
||||||
#include "gfxContext.h"
|
#include "gfxContext.h"
|
||||||
struct nsPoint;
|
struct nsPoint;
|
||||||
class nsStyleContext;
|
class nsStyleContext;
|
||||||
|
@ -202,8 +201,8 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for painting the decoration lines for the text.
|
* Function for painting the decoration lines for the text.
|
||||||
* NOTE: aPt, aLineSize, aAscent and aOffset are non-rounded device pixels,
|
* NOTE: aPt, aLineSize, aAscent, aOffset and aPreferredHeight are non-rounded
|
||||||
* not app units.
|
* device pixels, not app units.
|
||||||
* input:
|
* input:
|
||||||
* @param aGfxContext
|
* @param aGfxContext
|
||||||
* @param aColor the color of the decoration line
|
* @param aColor the color of the decoration line
|
||||||
|
@ -214,6 +213,8 @@ public:
|
||||||
* @param aOffset the offset of the decoration line from
|
* @param aOffset the offset of the decoration line from
|
||||||
* the baseline of the text (if the value is
|
* the baseline of the text (if the value is
|
||||||
* positive, the line is lifted up)
|
* positive, the line is lifted up)
|
||||||
|
* @param aPreferredHeight the preferred size of the decoration line by
|
||||||
|
* the font of the text
|
||||||
* @param aDecoration which line will be painted. The value can be
|
* @param aDecoration which line will be painted. The value can be
|
||||||
* NS_STYLE_TEXT_DECORATION_UNDERLINE or
|
* NS_STYLE_TEXT_DECORATION_UNDERLINE or
|
||||||
* NS_STYLE_TEXT_DECORATION_OVERLINE or
|
* NS_STYLE_TEXT_DECORATION_OVERLINE or
|
||||||
|
@ -222,7 +223,8 @@ public:
|
||||||
* can be NS_STYLE_BORDER_STYLE_SOLID or
|
* can be NS_STYLE_BORDER_STYLE_SOLID or
|
||||||
* NS_STYLE_BORDER_STYLE_DOTTED or
|
* NS_STYLE_BORDER_STYLE_DOTTED or
|
||||||
* NS_STYLE_BORDER_STYLE_DASHED or
|
* NS_STYLE_BORDER_STYLE_DASHED or
|
||||||
* NS_STYLE_BORDER_STYLE_DOUBLE.
|
* NS_STYLE_BORDER_STYLE_DOUBLE or
|
||||||
|
* NS_STYLE_BORDER_STYLE_NONE.
|
||||||
* @param aIsRTL when the text is RTL, it is true.
|
* @param aIsRTL when the text is RTL, it is true.
|
||||||
*/
|
*/
|
||||||
static void PaintDecorationLine(gfxContext* aGfxContext,
|
static void PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
|
@ -231,42 +233,11 @@ public:
|
||||||
const gfxSize& aLineSize,
|
const gfxSize& aLineSize,
|
||||||
const gfxFloat aAscent,
|
const gfxFloat aAscent,
|
||||||
const gfxFloat aOffset,
|
const gfxFloat aOffset,
|
||||||
|
const gfxFloat aPreferredSize,
|
||||||
const PRUint8 aDecoration,
|
const PRUint8 aDecoration,
|
||||||
const PRUint8 aStyle,
|
const PRUint8 aStyle,
|
||||||
const PRBool aIsRTL);
|
const PRBool aIsRTL);
|
||||||
|
|
||||||
/**
|
|
||||||
* Function for getting the decoration line rect for the text.
|
|
||||||
* NOTE: aLineSize, aAscent and aOffset are non-rounded device pixels,
|
|
||||||
* not app units.
|
|
||||||
* input:
|
|
||||||
* @param aPresContext
|
|
||||||
* @param aLineSize the width and the height of the decoration
|
|
||||||
* line
|
|
||||||
* @param aAscent the ascent of the text
|
|
||||||
* @param aOffset the offset of the decoration line from
|
|
||||||
* the baseline of the text (if the value is
|
|
||||||
* positive, the line is lifted up)
|
|
||||||
* @param aDecoration which line will be painted. The value can be
|
|
||||||
* NS_STYLE_TEXT_DECORATION_UNDERLINE or
|
|
||||||
* NS_STYLE_TEXT_DECORATION_OVERLINE or
|
|
||||||
* NS_STYLE_TEXT_DECORATION_LINE_THROUGH.
|
|
||||||
* @param aStyle the style of the decoration line. The value
|
|
||||||
* can be NS_STYLE_BORDER_STYLE_SOLID or
|
|
||||||
* NS_STYLE_BORDER_STYLE_DOTTED or
|
|
||||||
* NS_STYLE_BORDER_STYLE_DASHED or
|
|
||||||
* NS_STYLE_BORDER_STYLE_DOUBLE.
|
|
||||||
* output:
|
|
||||||
* @return the decoration line rect for the input,
|
|
||||||
* the each values are app units.
|
|
||||||
*/
|
|
||||||
static nsRect GetTextDecorationRect(nsPresContext* aPresContext,
|
|
||||||
const gfxSize& aLineSize,
|
|
||||||
const gfxFloat aAscent,
|
|
||||||
const gfxFloat aOffset,
|
|
||||||
const PRUint8 aDecoration,
|
|
||||||
const PRUint8 aStyle);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void PaintBackgroundColor(nsPresContext* aPresContext,
|
static void PaintBackgroundColor(nsPresContext* aPresContext,
|
||||||
|
@ -300,12 +271,6 @@ protected:
|
||||||
PRInt32 aNumPoints,
|
PRInt32 aNumPoints,
|
||||||
nsRect* aGap);
|
nsRect* aGap);
|
||||||
|
|
||||||
static gfxRect GetTextDecorationRectInternal(const gfxPoint& aPt,
|
|
||||||
const gfxSize& aLineSize,
|
|
||||||
const gfxFloat aAscent,
|
|
||||||
const gfxFloat aOffset,
|
|
||||||
const PRUint8 aDecoration,
|
|
||||||
const PRUint8 aStyle);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -509,10 +509,6 @@ public:
|
||||||
{ return NSAppUnitsToIntPixels(aAppUnits,
|
{ return NSAppUnitsToIntPixels(aAppUnits,
|
||||||
mDeviceContext->AppUnitsPerDevPixel()); }
|
mDeviceContext->AppUnitsPerDevPixel()); }
|
||||||
|
|
||||||
// If there is a remainder, it is rounded to nearest app units.
|
|
||||||
nscoord GfxUnitsToAppUnits(gfxFloat aGfxUnits) const
|
|
||||||
{ return mDeviceContext->GfxUnitsToAppUnits(aGfxUnits); }
|
|
||||||
|
|
||||||
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
gfxFloat AppUnitsToGfxUnits(nscoord aAppUnits) const
|
||||||
{ return mDeviceContext->AppUnitsToGfxUnits(aAppUnits); }
|
{ return mDeviceContext->AppUnitsToGfxUnits(aAppUnits); }
|
||||||
|
|
||||||
|
|
|
@ -4003,16 +4003,6 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
||||||
|
|
||||||
nsRect combinedArea;
|
nsRect combinedArea;
|
||||||
aLineLayout.RelativePositionFrames(combinedArea); // XXXldb This returned width as -15, 2001-06-12, Bugzilla
|
aLineLayout.RelativePositionFrames(combinedArea); // XXXldb This returned width as -15, 2001-06-12, Bugzilla
|
||||||
if (aState.mPresContext->CompatibilityMode() != eCompatibility_NavQuirks) {
|
|
||||||
PRUint8 decorations;
|
|
||||||
nscolor underColor, overColor, strikeColor;
|
|
||||||
GetTextDecorations(aState.mPresContext, PR_TRUE, decorations,
|
|
||||||
underColor, overColor, strikeColor);
|
|
||||||
if (decorations) {
|
|
||||||
nsLineLayout::CombineTextDecorations(aState.mPresContext, decorations,
|
|
||||||
this, combinedArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aLine->SetCombinedArea(combinedArea);
|
aLine->SetCombinedArea(combinedArea);
|
||||||
if (addedBullet) {
|
if (addedBullet) {
|
||||||
aLineLayout.RemoveBulletFrame(mBullet);
|
aLineLayout.RemoveBulletFrame(mBullet);
|
||||||
|
@ -5887,6 +5877,7 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
|
||||||
ctx, aColor, pt, size,
|
ctx, aColor, pt, size,
|
||||||
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
|
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
|
||||||
PresContext()->AppUnitsToGfxUnits(aOffset),
|
PresContext()->AppUnitsToGfxUnits(aOffset),
|
||||||
|
PresContext()->AppUnitsToGfxUnits(aSize),
|
||||||
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
|
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,6 @@ public:
|
||||||
|
|
||||||
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
|
||||||
const nsRect& aDirtyRect);
|
const nsRect& aDirtyRect);
|
||||||
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
|
|
||||||
NS_DISPLAY_DECL_NAME("TextDecoration")
|
NS_DISPLAY_DECL_NAME("TextDecoration")
|
||||||
private:
|
private:
|
||||||
nsLineBox* mLine;
|
nsLineBox* mLine;
|
||||||
|
@ -123,12 +122,6 @@ nsDisplayTextDecoration::Paint(nsDisplayListBuilder* aBuilder,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect
|
|
||||||
nsDisplayTextDecoration::GetBounds(nsDisplayListBuilder* aBuilder)
|
|
||||||
{
|
|
||||||
return mFrame->GetOverflowRect() + aBuilder->ToReferenceFrame(mFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLContainerFrame::DisplayTextDecorations(nsDisplayListBuilder* aBuilder,
|
nsHTMLContainerFrame::DisplayTextDecorations(nsDisplayListBuilder* aBuilder,
|
||||||
nsDisplayList* aBelowTextDecorations,
|
nsDisplayList* aBelowTextDecorations,
|
||||||
|
@ -195,7 +188,7 @@ nsHTMLContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
HasTextFrameDescendantOrInFlow(nsIFrame* aFrame);
|
HasTextFrameDescendantOrInFlow(nsPresContext* aPresContext, nsIFrame* aFrame);
|
||||||
|
|
||||||
/*virtual*/ void
|
/*virtual*/ void
|
||||||
nsHTMLContainerFrame::PaintTextDecorationLine(
|
nsHTMLContainerFrame::PaintTextDecorationLine(
|
||||||
|
@ -228,6 +221,7 @@ nsHTMLContainerFrame::PaintTextDecorationLine(
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
ctx, aColor, pt, size, PresContext()->AppUnitsToGfxUnits(aAscent),
|
ctx, aColor, pt, size, PresContext()->AppUnitsToGfxUnits(aAscent),
|
||||||
PresContext()->AppUnitsToGfxUnits(aOffset),
|
PresContext()->AppUnitsToGfxUnits(aOffset),
|
||||||
|
PresContext()->AppUnitsToGfxUnits(aSize),
|
||||||
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
|
aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,14 +297,14 @@ nsHTMLContainerFrame::GetTextDecorations(nsPresContext* aPresContext,
|
||||||
|
|
||||||
if (aDecorations) {
|
if (aDecorations) {
|
||||||
// If this frame contains no text, we're required to ignore this property
|
// If this frame contains no text, we're required to ignore this property
|
||||||
if (!HasTextFrameDescendantOrInFlow(this)) {
|
if (!HasTextFrameDescendantOrInFlow(aPresContext, this)) {
|
||||||
aDecorations = NS_STYLE_TEXT_DECORATION_NONE;
|
aDecorations = NS_STYLE_TEXT_DECORATION_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
HasTextFrameDescendant(nsIFrame* aParent)
|
HasTextFrameDescendant(nsPresContext* aPresContext, nsIFrame* aParent)
|
||||||
{
|
{
|
||||||
for (nsIFrame* kid = aParent->GetFirstChild(nsnull); kid;
|
for (nsIFrame* kid = aParent->GetFirstChild(nsnull); kid;
|
||||||
kid = kid->GetNextSibling())
|
kid = kid->GetNextSibling())
|
||||||
|
@ -323,7 +317,7 @@ HasTextFrameDescendant(nsIFrame* aParent)
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HasTextFrameDescendant(kid)) {
|
if (HasTextFrameDescendant(aPresContext, kid)) {
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,10 +325,10 @@ HasTextFrameDescendant(nsIFrame* aParent)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRBool
|
static PRBool
|
||||||
HasTextFrameDescendantOrInFlow(nsIFrame* aFrame)
|
HasTextFrameDescendantOrInFlow(nsPresContext* aPresContext, nsIFrame* aFrame)
|
||||||
{
|
{
|
||||||
for (nsIFrame *f = aFrame->GetFirstInFlow(); f; f = f->GetNextInFlow()) {
|
for (nsIFrame *f = aFrame->GetFirstInFlow(); f; f = f->GetNextInFlow()) {
|
||||||
if (HasTextFrameDescendant(f))
|
if (HasTextFrameDescendant(aPresContext, f))
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
|
@ -568,7 +568,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
||||||
// affect our height.
|
// affect our height.
|
||||||
fm->GetMaxAscent(aMetrics.ascent);
|
fm->GetMaxAscent(aMetrics.ascent);
|
||||||
fm->GetHeight(aMetrics.height);
|
fm->GetHeight(aMetrics.height);
|
||||||
// Include the text-decoration lines to the height for readable.
|
// Include the text-decoration lines to the height.
|
||||||
|
// Currently, only underline is overflowable.
|
||||||
nscoord offset, size;
|
nscoord offset, size;
|
||||||
fm->GetUnderline(offset, size);
|
fm->GetUnderline(offset, size);
|
||||||
nscoord ascentAndUnderline =
|
nscoord ascentAndUnderline =
|
||||||
|
@ -585,7 +586,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
||||||
aReflowState.mComputedBorderPadding.bottom;
|
aReflowState.mComputedBorderPadding.bottom;
|
||||||
|
|
||||||
// For now our overflow area is zero. The real value will be
|
// For now our overflow area is zero. The real value will be
|
||||||
// computed in |nsLineLayout::RelativePositionFrames|.
|
// computed during vertical alignment of the line we are on.
|
||||||
aMetrics.mOverflowArea.SetRect(0, 0, 0, 0);
|
aMetrics.mOverflowArea.SetRect(0, 0, 0, 0);
|
||||||
|
|
||||||
#ifdef NOISY_FINAL_SIZE
|
#ifdef NOISY_FINAL_SIZE
|
||||||
|
|
|
@ -66,7 +66,6 @@
|
||||||
#include "nsBidiUtils.h"
|
#include "nsBidiUtils.h"
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "nsTextFrame.h"
|
#include "nsTextFrame.h"
|
||||||
#include "nsCSSRendering.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#undef NOISY_HORIZONTAL_ALIGN
|
#undef NOISY_HORIZONTAL_ALIGN
|
||||||
|
@ -2625,8 +2624,6 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea)
|
||||||
combinedAreaResult.height = mFinalLineHeight;
|
combinedAreaResult.height = mFinalLineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool isStandardsMode =
|
|
||||||
mPresContext->CompatibilityMode() != eCompatibility_NavQuirks;
|
|
||||||
for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) {
|
for (PerFrameData* pfd = psd->mFirstFrame; pfd; pfd = pfd->mNext) {
|
||||||
nsPoint origin = nsPoint(pfd->mBounds.x, pfd->mBounds.y);
|
nsPoint origin = nsPoint(pfd->mBounds.x, pfd->mBounds.y);
|
||||||
nsIFrame* frame = pfd->mFrame;
|
nsIFrame* frame = pfd->mFrame;
|
||||||
|
@ -2655,15 +2652,6 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea)
|
||||||
// <b>x</b> and <b>y</b> which were computed above.
|
// <b>x</b> and <b>y</b> which were computed above.
|
||||||
nsRect r;
|
nsRect r;
|
||||||
if (pfd->mSpan) {
|
if (pfd->mSpan) {
|
||||||
if (isStandardsMode) {
|
|
||||||
// Combine the text decoration area for inline elements of standards
|
|
||||||
// mode
|
|
||||||
PRUint8 decorations = frame->GetStyleTextReset()->mTextDecoration;
|
|
||||||
if (decorations) {
|
|
||||||
nsLineLayout::CombineTextDecorations(mPresContext, decorations,
|
|
||||||
frame, pfd->mSpan->mFrame->mCombinedArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Compute a new combined area for the child span before
|
// Compute a new combined area for the child span before
|
||||||
// aggregating it into our combined area.
|
// aggregating it into our combined area.
|
||||||
RelativePositionFrames(pfd->mSpan, r);
|
RelativePositionFrames(pfd->mSpan, r);
|
||||||
|
@ -2707,60 +2695,3 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsRect& aCombinedArea)
|
||||||
}
|
}
|
||||||
aCombinedArea = combinedAreaResult;
|
aCombinedArea = combinedAreaResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
nsLineLayout::CombineTextDecorations(nsPresContext* aPresContext,
|
|
||||||
PRUint8 aDecorations,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nsRect& aCombinedArea,
|
|
||||||
nscoord aAscentOverride,
|
|
||||||
float aUnderlineSizeRatio)
|
|
||||||
{
|
|
||||||
if (!(aDecorations & (NS_STYLE_TEXT_DECORATION_UNDERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_LINE_THROUGH)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFontMetrics> fm;
|
|
||||||
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
|
|
||||||
if (aAscentOverride == 0)
|
|
||||||
fm->GetMaxAscent(aAscentOverride);
|
|
||||||
gfxFloat ascent = aPresContext->AppUnitsToGfxUnits(aAscentOverride);
|
|
||||||
nsRect decorationArea;
|
|
||||||
if (aDecorations & (NS_STYLE_TEXT_DECORATION_UNDERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE)) {
|
|
||||||
nscoord offsetCoord, sizeCoord;
|
|
||||||
fm->GetUnderline(offsetCoord, sizeCoord);
|
|
||||||
gfxSize size(aPresContext->AppUnitsToGfxUnits(aCombinedArea.width),
|
|
||||||
aPresContext->AppUnitsToGfxUnits(sizeCoord));
|
|
||||||
if (aDecorations & NS_STYLE_TEXT_DECORATION_OVERLINE) {
|
|
||||||
decorationArea =
|
|
||||||
nsCSSRendering::GetTextDecorationRect(aPresContext, size, ascent,
|
|
||||||
ascent, NS_STYLE_TEXT_DECORATION_OVERLINE,
|
|
||||||
NS_STYLE_BORDER_STYLE_SOLID);
|
|
||||||
aCombinedArea.UnionRect(aCombinedArea, decorationArea);
|
|
||||||
}
|
|
||||||
if (aDecorations & NS_STYLE_TEXT_DECORATION_UNDERLINE) {
|
|
||||||
aUnderlineSizeRatio = PR_MAX(aUnderlineSizeRatio, 1.0);
|
|
||||||
size.height *= aUnderlineSizeRatio;
|
|
||||||
gfxFloat offset = aPresContext->AppUnitsToGfxUnits(offsetCoord);
|
|
||||||
decorationArea =
|
|
||||||
nsCSSRendering::GetTextDecorationRect(aPresContext, size, ascent,
|
|
||||||
offset, NS_STYLE_TEXT_DECORATION_UNDERLINE,
|
|
||||||
NS_STYLE_BORDER_STYLE_SOLID);
|
|
||||||
aCombinedArea.UnionRect(aCombinedArea, decorationArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (aDecorations & NS_STYLE_TEXT_DECORATION_LINE_THROUGH) {
|
|
||||||
nscoord offsetCoord, sizeCoord;
|
|
||||||
fm->GetStrikeout(offsetCoord, sizeCoord);
|
|
||||||
gfxSize size(aPresContext->AppUnitsToGfxUnits(aCombinedArea.width),
|
|
||||||
aPresContext->AppUnitsToGfxUnits(sizeCoord));
|
|
||||||
gfxFloat offset = aPresContext->AppUnitsToGfxUnits(offsetCoord);
|
|
||||||
decorationArea =
|
|
||||||
nsCSSRendering::GetTextDecorationRect(aPresContext, size, ascent,
|
|
||||||
offset, NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
|
|
||||||
NS_STYLE_BORDER_STYLE_SOLID);
|
|
||||||
aCombinedArea.UnionRect(aCombinedArea, decorationArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -132,12 +132,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void RelativePositionFrames(nsRect& aCombinedArea);
|
void RelativePositionFrames(nsRect& aCombinedArea);
|
||||||
|
|
||||||
static void CombineTextDecorations(nsPresContext* aPresContext,
|
|
||||||
PRUint8 aDecorations,
|
|
||||||
nsIFrame* aFrame,
|
|
||||||
nsRect& aCombinedArea,
|
|
||||||
nscoord aAscentOverride = 0,
|
|
||||||
float aUnderlineSizeRatio = 1.0f);
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
// Supporting methods and data for flags
|
// Supporting methods and data for flags
|
||||||
|
|
|
@ -359,38 +359,6 @@ protected:
|
||||||
PRBool isRTLChars,
|
PRBool isRTLChars,
|
||||||
PRBool isOddLevel,
|
PRBool isOddLevel,
|
||||||
PRBool isBidiSystem);
|
PRBool isBidiSystem);
|
||||||
|
|
||||||
void UnionTextDecorationOverflow(nsPresContext* aPresContext,
|
|
||||||
const gfxTextRun::Metrics& aTextMetrics,
|
|
||||||
nsRect* aOverflowRect);
|
|
||||||
|
|
||||||
struct TextDecorations {
|
|
||||||
PRUint8 mDecorations;
|
|
||||||
nscolor mOverColor;
|
|
||||||
nscolor mUnderColor;
|
|
||||||
nscolor mStrikeColor;
|
|
||||||
|
|
||||||
TextDecorations() :
|
|
||||||
mDecorations(0), mOverColor(NS_RGB(0, 0, 0)),
|
|
||||||
mUnderColor(NS_RGB(0, 0, 0)), mStrikeColor(NS_RGB(0, 0, 0))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
PRBool HasDecorationlines() {
|
|
||||||
return !!(mDecorations & (NS_STYLE_TEXT_DECORATION_UNDERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_LINE_THROUGH));
|
|
||||||
}
|
|
||||||
PRBool HasUnderline() {
|
|
||||||
return !!(mDecorations & NS_STYLE_TEXT_DECORATION_UNDERLINE);
|
|
||||||
}
|
|
||||||
PRBool HasOverline() {
|
|
||||||
return !!(mDecorations & NS_STYLE_TEXT_DECORATION_OVERLINE);
|
|
||||||
}
|
|
||||||
PRBool HasStrikeout() {
|
|
||||||
return !!(mDecorations & NS_STYLE_TEXT_DECORATION_LINE_THROUGH);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TextDecorations GetTextDecorations(nsPresContext* aPresContext);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3561,85 +3561,6 @@ FillClippedRect(gfxContext* aCtx, nsPresContext* aPresContext,
|
||||||
aCtx->Fill();
|
aCtx->Fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsTextFrame::TextDecorations
|
|
||||||
nsTextFrame::GetTextDecorations(nsPresContext* aPresContext)
|
|
||||||
{
|
|
||||||
TextDecorations decorations;
|
|
||||||
|
|
||||||
// Quirks mode text decoration are rendered by children; see bug 1777
|
|
||||||
// In non-quirks mode, nsHTMLContainer::Paint and nsBlockFrame::Paint
|
|
||||||
// does the painting of text decorations.
|
|
||||||
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode())
|
|
||||||
return decorations;
|
|
||||||
|
|
||||||
PRBool useOverride = PR_FALSE;
|
|
||||||
nscolor overrideColor;
|
|
||||||
|
|
||||||
// A mask of all possible decorations.
|
|
||||||
PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE |
|
|
||||||
NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
|
||||||
|
|
||||||
for (nsStyleContext* context = GetStyleContext();
|
|
||||||
decorMask && context && context->HasTextDecorations();
|
|
||||||
context = context->GetParent()) {
|
|
||||||
const nsStyleTextReset* styleText = context->GetStyleTextReset();
|
|
||||||
if (!useOverride &&
|
|
||||||
(NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL & styleText->mTextDecoration)) {
|
|
||||||
// This handles the <a href="blah.html"><font color="green">La
|
|
||||||
// la la</font></a> case. The link underline should be green.
|
|
||||||
useOverride = PR_TRUE;
|
|
||||||
overrideColor = context->GetStyleColor()->mColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRUint8 useDecorations = decorMask & styleText->mTextDecoration;
|
|
||||||
if (useDecorations) {// a decoration defined here
|
|
||||||
nscolor color = context->GetStyleColor()->mColor;
|
|
||||||
|
|
||||||
if (NS_STYLE_TEXT_DECORATION_UNDERLINE & useDecorations) {
|
|
||||||
decorations.mUnderColor = useOverride ? overrideColor : color;
|
|
||||||
decorMask &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
|
||||||
decorations.mDecorations |= NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
|
||||||
}
|
|
||||||
if (NS_STYLE_TEXT_DECORATION_OVERLINE & useDecorations) {
|
|
||||||
decorations.mOverColor = useOverride ? overrideColor : color;
|
|
||||||
decorMask &= ~NS_STYLE_TEXT_DECORATION_OVERLINE;
|
|
||||||
decorations.mDecorations |= NS_STYLE_TEXT_DECORATION_OVERLINE;
|
|
||||||
}
|
|
||||||
if (NS_STYLE_TEXT_DECORATION_LINE_THROUGH & useDecorations) {
|
|
||||||
decorations.mStrikeColor = useOverride ? overrideColor : color;
|
|
||||||
decorMask &= ~NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
|
||||||
decorations.mDecorations |= NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return decorations;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
nsTextFrame::UnionTextDecorationOverflow(
|
|
||||||
nsPresContext* aPresContext,
|
|
||||||
const gfxTextRun::Metrics& aTextMetrics,
|
|
||||||
nsRect* aOverflowRect)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(mTextRun, "mTextRun is null");
|
|
||||||
nsRect rect;
|
|
||||||
TextDecorations decorations = GetTextDecorations(aPresContext);
|
|
||||||
float ratio = 1.0f;
|
|
||||||
// Note that we need to add underline area when this frame has selection for
|
|
||||||
// spellchecking and IME.
|
|
||||||
if (mState & NS_FRAME_SELECTED_CONTENT) {
|
|
||||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
|
||||||
look->GetMetric(nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize,
|
|
||||||
ratio);
|
|
||||||
decorations.mDecorations |= NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
|
||||||
}
|
|
||||||
nsLineLayout::CombineTextDecorations(aPresContext, decorations.mDecorations,
|
|
||||||
this, *aOverflowRect, nscoord(NS_round(aTextMetrics.mAscent)),
|
|
||||||
ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
|
nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
|
||||||
const gfxPoint& aFramePt,
|
const gfxPoint& aFramePt,
|
||||||
|
@ -3647,9 +3568,63 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
|
||||||
nsTextPaintStyle& aTextPaintStyle,
|
nsTextPaintStyle& aTextPaintStyle,
|
||||||
PropertyProvider& aProvider)
|
PropertyProvider& aProvider)
|
||||||
{
|
{
|
||||||
TextDecorations decorations =
|
// Quirks mode text decoration are rendered by children; see bug 1777
|
||||||
GetTextDecorations(aTextPaintStyle.PresContext());
|
// In non-quirks mode, nsHTMLContainer::Paint and nsBlockFrame::Paint
|
||||||
if (!decorations.HasDecorationlines())
|
// does the painting of text decorations.
|
||||||
|
if (eCompatibility_NavQuirks != aTextPaintStyle.PresContext()->CompatibilityMode())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PRBool useOverride = PR_FALSE;
|
||||||
|
nscolor overrideColor;
|
||||||
|
|
||||||
|
PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE;
|
||||||
|
// A mask of all possible decorations.
|
||||||
|
PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE |
|
||||||
|
NS_STYLE_TEXT_DECORATION_OVERLINE |
|
||||||
|
NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
||||||
|
nscolor overColor, underColor, strikeColor;
|
||||||
|
nsStyleContext* context = GetStyleContext();
|
||||||
|
PRBool hasDecorations = context->HasTextDecorations();
|
||||||
|
|
||||||
|
while (hasDecorations) {
|
||||||
|
const nsStyleTextReset* styleText = context->GetStyleTextReset();
|
||||||
|
if (!useOverride &&
|
||||||
|
(NS_STYLE_TEXT_DECORATION_OVERRIDE_ALL & styleText->mTextDecoration)) {
|
||||||
|
// This handles the <a href="blah.html"><font color="green">La
|
||||||
|
// la la</font></a> case. The link underline should be green.
|
||||||
|
useOverride = PR_TRUE;
|
||||||
|
overrideColor = context->GetStyleColor()->mColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRUint8 useDecorations = decorMask & styleText->mTextDecoration;
|
||||||
|
if (useDecorations) {// a decoration defined here
|
||||||
|
nscolor color = context->GetStyleColor()->mColor;
|
||||||
|
|
||||||
|
if (NS_STYLE_TEXT_DECORATION_UNDERLINE & useDecorations) {
|
||||||
|
underColor = useOverride ? overrideColor : color;
|
||||||
|
decorMask &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
||||||
|
decorations |= NS_STYLE_TEXT_DECORATION_UNDERLINE;
|
||||||
|
}
|
||||||
|
if (NS_STYLE_TEXT_DECORATION_OVERLINE & useDecorations) {
|
||||||
|
overColor = useOverride ? overrideColor : color;
|
||||||
|
decorMask &= ~NS_STYLE_TEXT_DECORATION_OVERLINE;
|
||||||
|
decorations |= NS_STYLE_TEXT_DECORATION_OVERLINE;
|
||||||
|
}
|
||||||
|
if (NS_STYLE_TEXT_DECORATION_LINE_THROUGH & useDecorations) {
|
||||||
|
strikeColor = useOverride ? overrideColor : color;
|
||||||
|
decorMask &= ~NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
||||||
|
decorations |= NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 == decorMask)
|
||||||
|
break;
|
||||||
|
context = context->GetParent();
|
||||||
|
if (!context)
|
||||||
|
break;
|
||||||
|
hasDecorations = context->HasTextDecorations();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!decorations)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gfxFont::Metrics fontMetrics = GetFontMetrics(aProvider.GetFontGroup());
|
gfxFont::Metrics fontMetrics = GetFontMetrics(aProvider.GetFontGroup());
|
||||||
|
@ -3660,26 +3635,26 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
|
||||||
gfxSize size(GetRect().width / app, 0);
|
gfxSize size(GetRect().width / app, 0);
|
||||||
gfxFloat ascent = gfxFloat(mAscent) / app;
|
gfxFloat ascent = gfxFloat(mAscent) / app;
|
||||||
|
|
||||||
if (decorations.HasOverline()) {
|
if (decorations & NS_FONT_DECORATION_OVERLINE) {
|
||||||
size.height = fontMetrics.underlineSize;
|
size.height = fontMetrics.underlineSize;
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mOverColor, pt, size, ascent, ascent,
|
aCtx, overColor, pt, size, ascent, ascent, size.height,
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
mTextRun->IsRightToLeft());
|
mTextRun->IsRightToLeft());
|
||||||
}
|
}
|
||||||
if (decorations.HasUnderline()) {
|
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
|
||||||
size.height = fontMetrics.underlineSize;
|
size.height = fontMetrics.underlineSize;
|
||||||
gfxFloat offset = fontMetrics.underlineOffset;
|
gfxFloat offset = fontMetrics.underlineOffset;
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mUnderColor, pt, size, ascent, offset,
|
aCtx, underColor, pt, size, ascent, offset, size.height,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
mTextRun->IsRightToLeft());
|
mTextRun->IsRightToLeft());
|
||||||
}
|
}
|
||||||
if (decorations.HasStrikeout()) {
|
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
|
||||||
size.height = fontMetrics.strikeoutSize;
|
size.height = fontMetrics.strikeoutSize;
|
||||||
gfxFloat offset = fontMetrics.strikeoutOffset;
|
gfxFloat offset = fontMetrics.strikeoutOffset;
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mStrikeColor, pt, size, ascent, offset,
|
aCtx, strikeColor, pt, size, ascent, offset, size.height,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
mTextRun->IsRightToLeft());
|
mTextRun->IsRightToLeft());
|
||||||
}
|
}
|
||||||
|
@ -3707,7 +3682,7 @@ static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
|
||||||
gfxFloat width = PR_MAX(0, aWidth - 2.0 * aSize);
|
gfxFloat width = PR_MAX(0, aWidth - 2.0 * aSize);
|
||||||
gfxPoint pt(aPt.x + 1.0, aPt.y);
|
gfxPoint pt(aPt.x + 1.0, aPt.y);
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aContext, color, pt, gfxSize(width, actualSize), aAscent, aOffset,
|
aContext, color, pt, gfxSize(width, actualSize), aAscent, aOffset, aSize,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, style, aIsRTL);
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, style, aIsRTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3725,7 +3700,7 @@ static void DrawSelectionDecorations(gfxContext* aContext, SelectionType aType,
|
||||||
case nsISelectionController::SELECTION_SPELLCHECK: {
|
case nsISelectionController::SELECTION_SPELLCHECK: {
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aContext, NS_RGB(255,0,0),
|
aContext, NS_RGB(255,0,0),
|
||||||
aPt, size, aAscent, aFontMetrics.underlineOffset,
|
aPt, size, aAscent, aFontMetrics.underlineOffset, size.height,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED,
|
||||||
aIsRTL);
|
aIsRTL);
|
||||||
break;
|
break;
|
||||||
|
@ -4353,7 +4328,6 @@ nsTextFrame::SetSelected(nsPresContext* aPresContext,
|
||||||
found = PR_TRUE;
|
found = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFrameState oldState = mState;
|
|
||||||
if ( aSelected )
|
if ( aSelected )
|
||||||
AddStateBits(NS_FRAME_SELECTED_CONTENT);
|
AddStateBits(NS_FRAME_SELECTED_CONTENT);
|
||||||
else
|
else
|
||||||
|
@ -4366,20 +4340,6 @@ nsTextFrame::SetSelected(nsPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
// If the selection state is changed, we need to reflow to recompute
|
|
||||||
// the overflow area for underline of spellchecking or IME. However, if
|
|
||||||
// the non-selected text already has underline, we don't need to reflow.
|
|
||||||
// And also when the IME underline is thicker than normal underline.
|
|
||||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
|
||||||
float ratio;
|
|
||||||
look->GetMetric(nsILookAndFeel::eMetricFloat_IMEUnderlineRelativeSize,
|
|
||||||
ratio);
|
|
||||||
if (oldState != mState &&
|
|
||||||
(ratio > 1.0 || !GetTextDecorations(aPresContext).HasUnderline())) {
|
|
||||||
PresContext()->PresShell()->FrameNeedsReflow(this,
|
|
||||||
nsIPresShell::eStyleChange,
|
|
||||||
NS_FRAME_IS_DIRTY);
|
|
||||||
}
|
|
||||||
// Selection might change anything. Invalidate the overflow area.
|
// Selection might change anything. Invalidate the overflow area.
|
||||||
Invalidate(GetOverflowRect(), PR_FALSE);
|
Invalidate(GetOverflowRect(), PR_FALSE);
|
||||||
}
|
}
|
||||||
|
@ -5502,9 +5462,6 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
|
||||||
aMetrics.mOverflowArea.UnionRect(boundingBox,
|
aMetrics.mOverflowArea.UnionRect(boundingBox,
|
||||||
nsRect(0, 0, aMetrics.width, aMetrics.height));
|
nsRect(0, 0, aMetrics.width, aMetrics.height));
|
||||||
|
|
||||||
UnionTextDecorationOverflow(aPresContext, textMetrics,
|
|
||||||
&aMetrics.mOverflowArea);
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Clean up, update state
|
// Clean up, update state
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
@ -5722,9 +5679,6 @@ nsTextFrame::RecomputeOverflowRect()
|
||||||
ConvertGfxRectOutward(textMetrics.mBoundingBox + gfxPoint(0, textMetrics.mAscent));
|
ConvertGfxRectOutward(textMetrics.mBoundingBox + gfxPoint(0, textMetrics.mAscent));
|
||||||
boundingBox.UnionRect(boundingBox,
|
boundingBox.UnionRect(boundingBox,
|
||||||
nsRect(nsPoint(0,0), GetSize()));
|
nsRect(nsPoint(0,0), GetSize()));
|
||||||
|
|
||||||
UnionTextDecorationOverflow(PresContext(), textMetrics, &boundingBox);
|
|
||||||
|
|
||||||
return boundingBox;
|
return boundingBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1512,10 +1512,18 @@ nsStyleTextReset::~nsStyleTextReset(void) { }
|
||||||
|
|
||||||
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
nsChangeHint nsStyleTextReset::CalcDifference(const nsStyleTextReset& aOther) const
|
||||||
{
|
{
|
||||||
if (mVerticalAlign == aOther.mVerticalAlign &&
|
if (mVerticalAlign == aOther.mVerticalAlign
|
||||||
mUnicodeBidi == aOther.mUnicodeBidi &&
|
&& mUnicodeBidi == aOther.mUnicodeBidi) {
|
||||||
mTextDecoration == aOther.mTextDecoration)
|
if (mTextDecoration != aOther.mTextDecoration) {
|
||||||
|
// Reflow for blink changes, repaint for others
|
||||||
|
return
|
||||||
|
(mTextDecoration & NS_STYLE_TEXT_DECORATION_BLINK) ==
|
||||||
|
(aOther.mTextDecoration & NS_STYLE_TEXT_DECORATION_BLINK) ?
|
||||||
|
NS_STYLE_HINT_VISUAL : NS_STYLE_HINT_REFLOW;
|
||||||
|
}
|
||||||
|
|
||||||
return NS_STYLE_HINT_NONE;
|
return NS_STYLE_HINT_NONE;
|
||||||
|
}
|
||||||
return NS_STYLE_HINT_REFLOW;
|
return NS_STYLE_HINT_REFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,6 +465,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
||||||
nsCSSRendering::PaintDecorationLine(ctx, overColor,
|
nsCSSRendering::PaintDecorationLine(ctx, overColor,
|
||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, ascentPixel,
|
ascentPixel, ascentPixel,
|
||||||
|
sizePixel,
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE,
|
NS_STYLE_TEXT_DECORATION_OVERLINE,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
isRTL);
|
isRTL);
|
||||||
|
@ -473,6 +474,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
||||||
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, offsetPixel,
|
ascentPixel, offsetPixel,
|
||||||
|
sizePixel,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
isRTL);
|
isRTL);
|
||||||
|
@ -485,6 +487,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
||||||
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, offsetPixel,
|
ascentPixel, offsetPixel,
|
||||||
|
sizePixel,
|
||||||
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
|
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID,
|
||||||
isRTL);
|
isRTL);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче