Bug 446498 – use new border rendering for focus rectangles, and strip dead code. r+sr=vlad

This commit is contained in:
Zack Weinberg 2008-08-06 12:33:18 +02:00
Родитель 2cd60bbf08
Коммит 4d06747563
14 изменённых файлов: 118 добавлений и 641 удалений

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

@ -263,10 +263,6 @@ protected:
static InlineBackgroundData* gInlineBGData = nsnull;
// FillRect or InvertRect depending on the renderingaInvert parameter
static void FillOrInvertRect(nsIRenderingContext& aRC,nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aInvert);
static void FillOrInvertRect(nsIRenderingContext& aRC,const nsRect& aRect, PRBool aInvert);
// Initialize any static variables used by nsCSSRendering.
nsresult nsCSSRendering::Init()
{
@ -413,471 +409,6 @@ nscolor nsCSSRendering::MakeBevelColor(PRIntn whichSide, PRUint8 style,
return theColor;
}
// Maximum poly points in any of the polygons we generate below
#define MAX_POLY_POINTS 4
#define ACTUAL_THICKNESS(outside, inside, frac, tpp) \
(NSToCoordRound(((outside) - (inside)) * (frac) / (tpp)) * (tpp))
/**
* Draw a dotted/dashed sides of a box
*/
//XXX dashes which span more than two edges are not handled properly MMP
void nsCSSRendering::DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
/* XXX unused */ const nsRect& aDirtyRect,
const PRUint8 borderStyles[],
const nscolor borderColors[],
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
/* XXX unused */ nsRect* aGap)
{
PRIntn dashLength;
nsRect dashRect, firstRect, currRect;
PRBool bSolid = PR_TRUE;
float over = 0.0f;
PRUint8 style = borderStyles[startSide];
PRBool skippedSide = PR_FALSE;
for (PRIntn whichSide = startSide; whichSide < 4; whichSide++) {
PRUint8 prevStyle = style;
style = borderStyles[whichSide];
if ((1<<whichSide) & aSkipSides) {
// Skipped side
skippedSide = PR_TRUE;
continue;
}
if ((style == NS_STYLE_BORDER_STYLE_DASHED) ||
(style == NS_STYLE_BORDER_STYLE_DOTTED))
{
if ((style != prevStyle) || skippedSide) {
//style discontinuity
over = 0.0f;
bSolid = PR_TRUE;
}
// XXX units for dash & dot?
if (style == NS_STYLE_BORDER_STYLE_DASHED) {
dashLength = DASH_LENGTH;
} else {
dashLength = DOT_LENGTH;
}
aContext.SetColor(borderColors[whichSide]);
switch (whichSide) {
case NS_SIDE_LEFT:
//XXX need to properly handle wrap around from last edge to first edge
//(this is the first edge) MMP
dashRect.width = borderInside.x - borderOutside.x;
dashRect.height = nscoord(dashRect.width * dashLength);
dashRect.x = borderOutside.x;
dashRect.y = borderInside.YMost() - dashRect.height;
if (over > 0.0f) {
firstRect.x = dashRect.x;
firstRect.width = dashRect.width;
firstRect.height = nscoord(dashRect.height * over);
firstRect.y = dashRect.y + (dashRect.height - firstRect.height);
over = 0.0f;
currRect = firstRect;
} else {
currRect = dashRect;
}
while (currRect.YMost() > borderInside.y) {
//clip if necessary
if (currRect.y < borderInside.y) {
over = float(borderInside.y - dashRect.y) /
float(dashRect.height);
currRect.height = currRect.height - (borderInside.y - currRect.y);
currRect.y = borderInside.y;
}
//draw if necessary
if (bSolid) {
aContext.FillRect(currRect);
}
//setup for next iteration
if (over == 0.0f) {
bSolid = PRBool(!bSolid);
}
dashRect.y = dashRect.y - currRect.height;
currRect = dashRect;
}
break;
case NS_SIDE_TOP:
//if we are continuing a solid rect, fill in the corner first
if (bSolid) {
aContext.FillRect(borderOutside.x, borderOutside.y,
borderInside.x - borderOutside.x,
borderInside.y - borderOutside.y);
}
dashRect.height = borderInside.y - borderOutside.y;
dashRect.width = dashRect.height * dashLength;
dashRect.x = borderInside.x;
dashRect.y = borderOutside.y;
if (over > 0.0f) {
firstRect.x = dashRect.x;
firstRect.y = dashRect.y;
firstRect.width = nscoord(dashRect.width * over);
firstRect.height = dashRect.height;
over = 0.0f;
currRect = firstRect;
} else {
currRect = dashRect;
}
while (currRect.x < borderInside.XMost()) {
//clip if necessary
if (currRect.XMost() > borderInside.XMost()) {
over = float(dashRect.XMost() - borderInside.XMost()) /
float(dashRect.width);
currRect.width = currRect.width -
(currRect.XMost() - borderInside.XMost());
}
//draw if necessary
if (bSolid) {
aContext.FillRect(currRect);
}
//setup for next iteration
if (over == 0.0f) {
bSolid = PRBool(!bSolid);
}
dashRect.x = dashRect.x + currRect.width;
currRect = dashRect;
}
break;
case NS_SIDE_RIGHT:
//if we are continuing a solid rect, fill in the corner first
if (bSolid) {
aContext.FillRect(borderInside.XMost(), borderOutside.y,
borderOutside.XMost() - borderInside.XMost(),
borderInside.y - borderOutside.y);
}
dashRect.width = borderOutside.XMost() - borderInside.XMost();
dashRect.height = nscoord(dashRect.width * dashLength);
dashRect.x = borderInside.XMost();
dashRect.y = borderInside.y;
if (over > 0.0f) {
firstRect.x = dashRect.x;
firstRect.y = dashRect.y;
firstRect.width = dashRect.width;
firstRect.height = nscoord(dashRect.height * over);
over = 0.0f;
currRect = firstRect;
} else {
currRect = dashRect;
}
while (currRect.y < borderInside.YMost()) {
//clip if necessary
if (currRect.YMost() > borderInside.YMost()) {
over = float(dashRect.YMost() - borderInside.YMost()) /
float(dashRect.height);
currRect.height = currRect.height -
(currRect.YMost() - borderInside.YMost());
}
//draw if necessary
if (bSolid) {
aContext.FillRect(currRect);
}
//setup for next iteration
if (over == 0.0f) {
bSolid = PRBool(!bSolid);
}
dashRect.y = dashRect.y + currRect.height;
currRect = dashRect;
}
break;
case NS_SIDE_BOTTOM:
//if we are continuing a solid rect, fill in the corner first
if (bSolid) {
aContext.FillRect(borderInside.XMost(), borderInside.YMost(),
borderOutside.XMost() - borderInside.XMost(),
borderOutside.YMost() - borderInside.YMost());
}
dashRect.height = borderOutside.YMost() - borderInside.YMost();
dashRect.width = nscoord(dashRect.height * dashLength);
dashRect.x = borderInside.XMost() - dashRect.width;
dashRect.y = borderInside.YMost();
if (over > 0.0f) {
firstRect.y = dashRect.y;
firstRect.width = nscoord(dashRect.width * over);
firstRect.height = dashRect.height;
firstRect.x = dashRect.x + (dashRect.width - firstRect.width);
over = 0.0f;
currRect = firstRect;
} else {
currRect = dashRect;
}
while (currRect.XMost() > borderInside.x) {
//clip if necessary
if (currRect.x < borderInside.x) {
over = float(borderInside.x - dashRect.x) / float(dashRect.width);
currRect.width = currRect.width - (borderInside.x - currRect.x);
currRect.x = borderInside.x;
}
//draw if necessary
if (bSolid) {
aContext.FillRect(currRect);
}
//setup for next iteration
if (over == 0.0f) {
bSolid = PRBool(!bSolid);
}
dashRect.x = dashRect.x - currRect.width;
currRect = dashRect;
}
break;
}
}
skippedSide = PR_FALSE;
}
}
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 10/22/99 dwc
*/
void nsCSSRendering::DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleColor* aColorStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
/* XXX unused */ nsRect* aGap)
{
PRIntn dashLength;
nsRect dashRect, currRect;
nscoord temp, temp1, adjust;
PRBool bSolid = PR_TRUE;
float over = 0.0f;
PRBool skippedSide = PR_FALSE;
NS_ASSERTION(aColorStyle &&
((aDoOutline && aOutlineStyle) || (!aDoOutline && aBorderStyle)),
"null params not allowed");
PRUint8 style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(startSide);
// find the x and y width
nscoord xwidth = aDirtyRect.XMost();
nscoord ywidth = aDirtyRect.YMost();
for (PRIntn whichSide = startSide; whichSide < 4; whichSide++) {
PRUint8 prevStyle = style;
style = aDoOutline
? aOutlineStyle->GetOutlineStyle()
: aBorderStyle->GetBorderStyle(whichSide);
if ((1<<whichSide) & aSkipSides) {
// Skipped side
skippedSide = PR_TRUE;
continue;
}
if ((style == NS_STYLE_BORDER_STYLE_DASHED) ||
(style == NS_STYLE_BORDER_STYLE_DOTTED))
{
if ((style != prevStyle) || skippedSide) {
//style discontinuity
over = 0.0f;
bSolid = PR_TRUE;
}
if (style == NS_STYLE_BORDER_STYLE_DASHED) {
dashLength = DASH_LENGTH;
} else {
dashLength = DOT_LENGTH;
}
// default to current color in case color cannot be resolved
// (because invert is not supported on cur platform)
nscolor sideColor(aColorStyle->mColor);
PRBool isInvert = PR_FALSE;
if (aDoOutline) {
if (!aOutlineStyle->GetOutlineInitialColor()) {
aOutlineStyle->GetOutlineColor(sideColor);
}
#ifdef GFX_HAS_INVERT
else {
isInvert = PR_TRUE;
}
#endif
} else {
PRBool transparent;
PRBool foreground;
aBorderStyle->GetBorderColor(whichSide, sideColor, transparent, foreground);
if (foreground)
sideColor = aColorStyle->mColor;
if (transparent)
continue; // side is transparent
}
aContext.SetColor(sideColor);
switch (whichSide) {
case NS_SIDE_RIGHT:
case NS_SIDE_LEFT:
bSolid = PR_FALSE;
// This is our dot or dash..
if(whichSide==NS_SIDE_LEFT){
dashRect.width = borderInside.x - borderOutside.x;
} else {
dashRect.width = borderOutside.XMost() - borderInside.XMost();
}
if( dashRect.width >0 ) {
dashRect.height = dashRect.width * dashLength;
dashRect.y = borderOutside.y;
if(whichSide == NS_SIDE_RIGHT){
dashRect.x = borderInside.XMost();
} else {
dashRect.x = borderOutside.x;
}
temp = borderOutside.height;
temp1 = temp/dashRect.height;
currRect = dashRect;
if((temp1%2)==0){
adjust = (dashRect.height-(temp%dashRect.height))/2; // adjust back
// draw in the left and right
FillOrInvertRect(aContext, dashRect.x, borderOutside.y,dashRect.width, dashRect.height-adjust,isInvert);
FillOrInvertRect(aContext,dashRect.x,(borderOutside.YMost()-(dashRect.height-adjust)),dashRect.width, dashRect.height-adjust,isInvert);
currRect.y += (dashRect.height-adjust);
temp-= (dashRect.height-adjust);
} else {
adjust = (temp%dashRect.width)/2; // adjust a tad longer
// draw in the left and right
FillOrInvertRect(aContext, dashRect.x, borderOutside.y,dashRect.width, dashRect.height+adjust,isInvert);
FillOrInvertRect(aContext, dashRect.x,(borderOutside.YMost()-(dashRect.height+adjust)),dashRect.width, dashRect.height+adjust,isInvert);
currRect.y += (dashRect.height+adjust);
temp-= (dashRect.height+adjust);
}
temp += borderOutside.y;
if( temp > ywidth)
temp = ywidth;
// get the currRect's x into the view before we start
if( currRect.y < aDirtyRect.y){
temp1 = NSToCoordFloor((float)((aDirtyRect.y-currRect.y)/dashRect.height));
currRect.y += temp1*dashRect.height;
if((temp1%2)==1){
bSolid = PR_TRUE;
}
}
while(currRect.y<temp) {
//draw if necessary
if (bSolid) {
FillOrInvertRect(aContext, currRect,isInvert);
}
bSolid = PRBool(!bSolid);
currRect.y += dashRect.height;
}
}
break;
case NS_SIDE_BOTTOM:
case NS_SIDE_TOP:
bSolid = PR_FALSE;
// This is our dot or dash..
if(whichSide==NS_SIDE_TOP){
dashRect.height = borderInside.y - borderOutside.y;
} else {
dashRect.height = borderOutside.YMost() - borderInside.YMost();
}
if( dashRect.height >0 ) {
dashRect.width = dashRect.height * dashLength;
dashRect.x = borderOutside.x;
if(whichSide == NS_SIDE_BOTTOM){
dashRect.y = borderInside.YMost();
} else {
dashRect.y = borderOutside.y;
}
temp = borderOutside.width;
temp1 = temp/dashRect.width;
currRect = dashRect;
if((temp1%2)==0){
adjust = (dashRect.width-(temp%dashRect.width))/2; // even, adjust back
// draw in the left and right
FillOrInvertRect(aContext, borderOutside.x,dashRect.y,dashRect.width-adjust,dashRect.height,isInvert);
FillOrInvertRect(aContext, (borderOutside.XMost()-(dashRect.width-adjust)),dashRect.y,dashRect.width-adjust,dashRect.height,isInvert);
currRect.x += (dashRect.width-adjust);
temp-= (dashRect.width-adjust);
} else {
adjust = (temp%dashRect.width)/2;
// draw in the left and right
FillOrInvertRect(aContext, borderOutside.x,dashRect.y,dashRect.width+adjust,dashRect.height,isInvert);
FillOrInvertRect(aContext, (borderOutside.XMost()-(dashRect.width+adjust)),dashRect.y,dashRect.width+adjust,dashRect.height,isInvert);
currRect.x += (dashRect.width+adjust);
temp-= (dashRect.width+adjust);
}
temp += borderOutside.x;
if( temp > xwidth)
temp = xwidth;
// get the currRect's x into the view before we start
if( currRect.x < aDirtyRect.x){
temp1 = NSToCoordFloor((float)((aDirtyRect.x-currRect.x)/dashRect.width));
currRect.x += temp1*dashRect.width;
if((temp1%2)==1){
bSolid = PR_TRUE;
}
}
while(currRect.x<temp) {
//draw if necessary
if (bSolid) {
FillOrInvertRect(aContext, currRect,isInvert);
}
bSolid = PRBool(!bSolid);
currRect.x += dashRect.width;
}
}
break;
}
}
skippedSide = PR_FALSE;
}
}
nscolor
nsCSSRendering::TransformColor(nscolor aMapColor,PRBool aNoBackGround)
{
@ -988,14 +519,10 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap,
nscoord aHardBorderSize,
PRBool aShouldIgnoreRounded)
PRIntn aSkipSides)
{
nsMargin border;
nscoord twipsRadii[4];
float percent;
nsCompatibility compatMode = aPresContext->CompatibilityMode();
SN("++ PaintBorder");
@ -1012,7 +539,7 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
if (aBorderStyle.IsBorderImageLoaded()) {
DrawBorderImage(aPresContext, aRenderingContext, aForFrame,
aBorderArea, aBorderStyle, aHardBorderSize);
aBorderArea, aBorderStyle);
return;
}
@ -1024,12 +551,7 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground
(aStyleContext, compatMode == eCompatibility_NavQuirks ? PR_TRUE : PR_FALSE);
if (aHardBorderSize > 0) {
border.SizeTo(aHardBorderSize, aHardBorderSize, aHardBorderSize, aHardBorderSize);
} else {
border = aBorderStyle.GetComputedBorder();
}
border = aBorderStyle.GetComputedBorder();
if ((0 == border.left) && (0 == border.right) &&
(0 == border.top) && (0 == border.bottom)) {
// Empty border area
@ -1102,10 +624,6 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
//SF ("borderRadii: %f %f %f %f\n", borderRadii[0], borderRadii[1], borderRadii[2], borderRadii[3]);
gfxRect gapRect;
if (aGap)
gapRect = RectToGfxRect(*aGap, twipsPerPixel);
nsCSSBorderRenderer br(twipsPerPixel,
ctx,
oRect,
@ -1115,8 +633,7 @@ nsCSSRendering::PaintBorder(nsPresContext* aPresContext,
borderColors,
compositeColors,
aSkipSides,
bgColor->mBackgroundColor,
aGap ? &gapRect : nsnull);
bgColor->mBackgroundColor);
br.DrawBorders();
ctx->Restore();
@ -1132,8 +649,7 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsStyleContext* aStyleContext,
nsRect* aGap)
nsStyleContext* aStyleContext)
{
nscoord twipsRadii[4];
@ -1242,8 +758,6 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
outlineColor,
outlineColor };
nsBorderColors *outlineCompositeColors[4] = { nsnull };
// convert the border widths
gfxFloat outlineWidths[4] = { width / twipsPerPixel,
width / twipsPerPixel,
@ -1255,10 +769,6 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
ctx->Save();
gfxRect gapRect;
if (aGap)
gapRect = RectToGfxRect(*aGap, twipsPerPixel);
nsCSSBorderRenderer br(twipsPerPixel,
ctx,
oRect,
@ -1266,10 +776,63 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
outlineWidths,
outlineRadii,
outlineColors,
outlineCompositeColors,
0,
bgColor->mBackgroundColor,
aGap ? &gapRect : nsnull);
nsnull, 0,
bgColor->mBackgroundColor);
br.DrawBorders();
ctx->Restore();
SN();
}
void
nsCSSRendering::PaintFocus(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aFocusRect,
nscolor aColor)
{
nscoord oneCSSPixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord oneDevPixel = aPresContext->DevPixelsToAppUnits(1);
gfxRect focusRect(RectToGfxRect(aFocusRect, oneDevPixel));
gfxCornerSizes focusRadii;
{
nscoord twipsRadii[4] = { 0, 0, 0, 0 };
nsMargin focusMargin(oneCSSPixel, oneCSSPixel, oneCSSPixel, oneCSSPixel);
ComputePixelRadii(twipsRadii, aFocusRect, focusMargin, 0, oneDevPixel,
&focusRadii);
}
gfxFloat focusWidths[4] = { oneCSSPixel / oneDevPixel,
oneCSSPixel / oneDevPixel,
oneCSSPixel / oneDevPixel,
oneCSSPixel / oneDevPixel };
PRUint8 focusStyles[4] = { NS_STYLE_BORDER_STYLE_DOTTED,
NS_STYLE_BORDER_STYLE_DOTTED,
NS_STYLE_BORDER_STYLE_DOTTED,
NS_STYLE_BORDER_STYLE_DOTTED };
nscolor focusColors[4] = { aColor, aColor, aColor, aColor };
gfxContext *ctx = aRenderingContext.ThebesContext();
ctx->Save();
// Because this renders a dotted border, the background color
// should not be used. Therefore, we provide a value that will
// be blatantly wrong if it ever does get used. (If this becomes
// something that CSS can style, this function will then have access
// to a style context and can use the same logic that PaintBorder
// and PaintOutline do.)
nsCSSBorderRenderer br(oneDevPixel,
ctx,
focusRect,
focusStyles,
focusWidths,
focusRadii,
focusColors,
nsnull, 0,
NS_RGB(255, 0, 0));
br.DrawBorders();
ctx->Restore();
@ -2362,8 +1925,7 @@ nsCSSRendering::DrawBorderImage(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nscoord aHardBorderSize)
const nsStyleBorder& aBorderStyle)
{
float percent;
nsStyleCoord borderImageSplit[4];
@ -2372,12 +1934,7 @@ nsCSSRendering::DrawBorderImage(nsPresContext* aPresContext,
gfxFloat borderTop, borderRight, borderBottom, borderLeft;
gfxFloat borderImageSplitGfx[4];
if (aHardBorderSize > 0) {
border.SizeTo(aHardBorderSize, aHardBorderSize, aHardBorderSize, aHardBorderSize);
} else {
border = aBorderStyle.GetActualBorder();
}
border = aBorderStyle.GetActualBorder();
if ((0 == border.left) && (0 == border.right) &&
(0 == border.top) && (0 == border.bottom)) {
// Empty border area
@ -2872,32 +2429,6 @@ nsCSSRendering::PaintRoundedBackground(nsPresContext* aPresContext,
}
void FillOrInvertRect(nsIRenderingContext& aRC, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aInvert)
{
#ifdef GFX_HAS_INVERT
if (aInvert) {
aRC.InvertRect(aX, aY, aWidth, aHeight);
} else {
#endif
aRC.FillRect(aX, aY, aWidth, aHeight);
#ifdef GFX_HAS_INVERT
}
#endif
}
void FillOrInvertRect(nsIRenderingContext& aRC, const nsRect& aRect, PRBool aInvert)
{
#ifdef GFX_HAS_INVERT
if (aInvert) {
aRC.InvertRect(aRect);
} else {
#endif
aRC.FillRect(aRect);
#ifdef GFX_HAS_INVERT
}
#endif
}
// Begin table border-collapsing section
// These functions were written to not disrupt the normal ones and yet satisfy some additional requirements
// At some point, all functions should be unified to include the additional functionality that these provide

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

@ -80,10 +80,7 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0,
nscoord aHardBorderSize = 0,
PRBool aShouldIgnoreRounded = PR_FALSE);
PRIntn aSkipSides = 0);
/**
* Render the outline for an element using css rendering rules
@ -100,8 +97,18 @@ public:
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsStyleContext* aStyleContext,
nsRect* aGap = 0);
nsStyleContext* aStyleContext);
/**
* Render keyboard focus on an element.
* |aFocusRect| is the outer rectangle of the focused element.
* Uses a fixed style equivalent to "1px dotted |aColor|".
* Not used for controls, because the native theme may differ.
*/
static void PaintFocus(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aFocusRect,
nscolor aColor);
/**
* Fill in an nsStyleBackground to be used to paint the background for
@ -164,29 +171,6 @@ public:
*/
static void DidPaint();
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const PRUint8 borderStyles[],
const nscolor borderColors[],
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap);
static void DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
const nsRect& aDirtyRect,
const nsStyleColor* aColorStyle,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
PRBool aDoOutline,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nsRect* aGap);
// Draw a border segment in the table collapsing border model without beveling corners
static void DrawTableBorderSegment(nsIRenderingContext& aContext,
PRUint8 aBorderStyle,
@ -277,8 +261,7 @@ protected:
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nscoord aHardBorderSize);
const nsStyleBorder& aBorderStyle);
static void DrawBorderImageSide(gfxContext *aThebesContext,
nsIDeviceContext* aDeviceContext,

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

@ -79,7 +79,6 @@
* DrawBorders
* |- separate corners?
* |- dashed side mask
* |- gap clip
* |
* -> can border be drawn in 1 pass? (e.g., solid border same color all around)
* |- DrawBorderSides with all 4 sides
@ -176,8 +175,7 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(PRInt32 aAppUnitsPerPixel,
const nscolor* aBorderColors,
nsBorderColors* const* aCompositeColors,
PRIntn aSkipSides,
nscolor aBackgroundColor,
const gfxRect* aGapRect)
nscolor aBackgroundColor)
: mAUPP(aAppUnitsPerPixel),
mContext(aDestContext),
mOuterRect(aOuterRect),
@ -187,8 +185,7 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(PRInt32 aAppUnitsPerPixel,
mBorderColors(aBorderColors),
mCompositeColors(aCompositeColors),
mSkipSides(aSkipSides),
mBackgroundColor(aBackgroundColor),
mGapRect(aGapRect)
mBackgroundColor(aBackgroundColor)
{
if (!mCompositeColors) {
static nsBorderColors * const noColors[4] = { NULL };
@ -1104,24 +1101,6 @@ nsCSSBorderRenderer::DrawBorders()
mContext->SetMatrix(mat);
}
// Only do this clip if we have to clip out a gap; otherwise,
// intersecting with this clip is pretty expensive.
if (mGapRect) {
mContext->NewPath();
mContext->Rectangle(mOuterRect);
// draw the rectangle backwards, so that we get it
// clipped out via the winding rule
mContext->MoveTo(mGapRect->pos);
mContext->LineTo(mGapRect->pos + gfxSize(0.0, mGapRect->size.height));
mContext->LineTo(mGapRect->pos + mGapRect->size);
mContext->LineTo(mGapRect->pos + gfxSize(mGapRect->size.width, 0.0));
mContext->ClosePath();
mContext->Clip();
}
if (allBordersSame && !forceSeparateCorners) {
/* Draw everything in one go */
DrawBorderSides(SIDE_BITS_ALL);

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

@ -105,8 +105,7 @@ struct nsCSSBorderRenderer {
const nscolor* aBorderColors,
nsBorderColors* const* aCompositeColors,
PRIntn aSkipSides,
nscolor aBackgroundColor,
const gfxRect* aGapRect = nsnull);
nscolor aBackgroundColor);
// core app units per pixel
PRInt32 mAUPP;
@ -127,11 +126,9 @@ struct nsCSSBorderRenderer {
const nscolor* mBorderColors;
nsBorderColors* const* mCompositeColors;
// misc -- which sides to skip, the background color, and whether we should
// leave a gap in the border (e.g. for a label)
// misc -- which sides to skip, the background color
PRIntn mSkipSides;
nscolor mBackgroundColor;
const gfxRect* mGapRect;
// calculated values
PRPackedBool mOneUnitBorder;

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

@ -567,8 +567,8 @@ nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
nsCSSRendering::PaintOutline(mFrame->PresContext(), *aCtx, mFrame,
aDirtyRect, nsRect(offset, mFrame->GetSize()),
*mFrame->GetStyleBorder(),
*mFrame->GetStyleOutline(),
mFrame->GetStyleContext(), 0);
*mFrame->GetStyleOutline(),
mFrame->GetStyleContext());
}
PRBool
@ -632,7 +632,8 @@ nsDisplayBorder::Paint(nsDisplayListBuilder* aBuilder,
nsCSSRendering::PaintBorder(mFrame->PresContext(), *aCtx, mFrame,
aDirtyRect, nsRect(offset, mFrame->GetSize()),
*mFrame->GetStyleBorder(),
mFrame->GetStyleContext(), mFrame->GetSkipSides());
mFrame->GetStyleContext(),
mFrame->GetSkipSides());
}
void

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

@ -178,10 +178,12 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aRect)
{
// once we have all that we'll draw the focus if we have it. We will need to draw 2 focuses,
// the inner and the outer. This is so we can do any kind of look and feel some buttons have
// focus on the outside like mac and motif. While others like windows have it inside (dotted line).
// Usually only one will be specifed. But I guess you could have both if you wanted to.
// once we have all that we'll draw the focus if we have it. We will
// need to draw 2 focuses, the inner and the outer. This is so we
// can do any kind of look and feel. Some buttons have focus on the
// outside like mac and motif. While others like windows have it
// inside (dotted line). Usually only one will be specifed. But I
// guess you could have both if you wanted to.
nsRect rect;
@ -192,7 +194,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsPresContext* aPresContext,
const nsStyleBorder* border = mOuterFocusStyle->GetStyleBorder();
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
aDirtyRect, rect, *border, mOuterFocusStyle);
}
if (mInnerFocusStyle) {
@ -202,7 +204,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsPresContext* aPresContext,
const nsStyleBorder* border = mInnerFocusStyle->GetStyleBorder();
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
aDirtyRect, rect, *border, mInnerFocusStyle);
}
}
@ -227,7 +229,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsPresContext* aPresContext,
aDirtyRect, buttonRect, *border, *padding,
PR_FALSE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *border, context, 0);
aDirtyRect, buttonRect, *border, context);
}

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

@ -294,7 +294,8 @@ nsFieldSetFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext,
skipSides);
aRenderingContext.PopState();
@ -308,7 +309,8 @@ nsFieldSetFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext,
skipSides);
aRenderingContext.PopState();
@ -321,7 +323,8 @@ nsFieldSetFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyle, mStyleContext,
skipSides);
aRenderingContext.PopState();
} else {

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

@ -269,7 +269,8 @@ nsGfxCheckboxControlFrame::PaintCheckBoxFromStyle(
this, aDirtyRect, rect, *myBackground,
*myBorder, *myPadding, PR_FALSE);
nsCSSRendering::PaintBorder(PresContext(), aRenderingContext, this,
aDirtyRect, rect, *myBorder, mCheckButtonFaceStyle, 0);
aDirtyRect, rect, *myBorder,
mCheckButtonFaceStyle);
}
//------------------------------------------------------------

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

@ -365,14 +365,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsPoint aPt)
nsILookAndFeel::eColor_WidgetSelectForeground :
nsILookAndFeel::eColor_WidgetSelectBackground, color);
nscoord onePixelInTwips = nsPresContext::CSSPixelsToAppUnits(1);
nsRect dirty;
nscolor colors[] = {color, color, color, color};
PRUint8 borderStyle[] = {NS_STYLE_BORDER_STYLE_DOTTED, NS_STYLE_BORDER_STYLE_DOTTED, NS_STYLE_BORDER_STYLE_DOTTED, NS_STYLE_BORDER_STYLE_DOTTED};
nsRect innerRect = fRect;
innerRect.Deflate(nsSize(onePixelInTwips, onePixelInTwips));
nsCSSRendering::DrawDashedSides(0, aRC, dirty, borderStyle, colors, fRect, innerRect, 0, nsnull);
nsCSSRendering::PaintFocus(presContext, aRC, fRect, color);
}
void

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

@ -487,10 +487,6 @@ CanvasFrame::PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt)
focusRect.y += y;
}
nsStyleOutline outlineStyle(PresContext());
outlineStyle.SetOutlineStyle(NS_STYLE_BORDER_STYLE_DOTTED);
outlineStyle.SetOutlineInitialColor();
// XXX use the root frame foreground color, but should we find BODY frame
// for HTML documents?
nsIFrame* root = mFrames.FirstChild();
@ -502,21 +498,8 @@ CanvasFrame::PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt)
return;
}
// XXX the CSS border for links is specified as 2px, but it
// is only drawn as 1px. Match this here.
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
nsRect borderInside(focusRect.x + onePixel,
focusRect.y + onePixel,
focusRect.width - 2 * onePixel,
focusRect.height - 2 * onePixel);
nsCSSRendering::DrawDashedSides(0, aRenderingContext,
focusRect, color,
nsnull, &outlineStyle,
PR_TRUE, focusRect,
borderInside, 0,
nsnull);
nsCSSRendering::PaintFocus(PresContext(), aRenderingContext,
focusRect, color->mColor);
}
/* virtual */ nscoord

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

@ -1034,7 +1034,7 @@ nsImageFrame::DisplayAltFeedback(nsIRenderingContext& aRenderingContext,
// Paint the border
nsRecessedBorder recessedBorder(borderEdgeWidth, PresContext());
nsCSSRendering::PaintBorder(PresContext(), aRenderingContext, this, inner,
inner, recessedBorder, mStyleContext, 0);
inner, recessedBorder, mStyleContext);
// Adjust the inner rect to account for the one pixel recessed border,
// and a six pixel padding on each edge

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

@ -2007,10 +2007,11 @@ void nsDisplayMathMLCharDebug::Paint(nsDisplayListBuilder* aBuilder,
nsStyleContext* styleContext = mFrame->GetStyleContext();
nsRect rect = mRect + aBuilder->ToReferenceFrame(mFrame);
nsCSSRendering::PaintBorder(presContext, *aCtx, mFrame,
aDirtyRect, rect, *border, styleContext, skipSides);
aDirtyRect, rect, *border, styleContext,
skipSides);
nsCSSRendering::PaintOutline(presContext, *aCtx, mFrame,
aDirtyRect, rect, *border,
*mFrame->GetStyleOutline(), styleContext, 0);
*mFrame->GetStyleOutline(), styleContext);
}
#endif

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

@ -190,7 +190,8 @@ nsGroupBoxFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyleData, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyleData,
mStyleContext, skipSides);
aRenderingContext.PopState();
@ -204,7 +205,8 @@ nsGroupBoxFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyleData, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyleData,
mStyleContext, skipSides);
aRenderingContext.PopState();
@ -219,7 +221,8 @@ nsGroupBoxFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyleData, mStyleContext, skipSides);
aDirtyRect, rect, *borderStyleData,
mStyleContext, skipSides);
aRenderingContext.PopState();

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

@ -3793,11 +3793,11 @@ nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext* aStyleContext,
PR_TRUE);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, aRect, *myBorder, mStyleContext, 0);
aDirtyRect, aRect, *myBorder, mStyleContext);
nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
aDirtyRect, aRect, *myBorder, *myOutline,
aStyleContext, 0);
aStyleContext);
}
// Scrolling