From 4cbb72cb3bb57231645e27cf262c14c8d0debe15 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Tue, 29 Nov 2005 05:52:19 +0000 Subject: [PATCH] Oops, currently the Tree is closed, backing out previous check-in. b=310124 git-svn-id: svn://10.0.0.236/trunk@185366 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSRendering.cpp | 148 +++++++++++-------------- 1 file changed, 63 insertions(+), 85 deletions(-) diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index f0327cba0f3..aff63d4a674 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -22,8 +22,6 @@ * * Contributor(s): * Mats Palmgren - * Takeshi Ichimaru - * Masayuki Nakano * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -343,9 +341,6 @@ nscolor nsCSSRendering::MakeBevelColor(PRIntn whichSide, PRUint8 style, // 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)) - // a nifty helper function to create a polygon representing a // particular side of a border. This helps localize code for figuring // mitered edges. It is mainly used by the solid, inset, and outset @@ -355,13 +350,17 @@ nscolor nsCSSRendering::MakeBevelColor(PRIntn whichSide, PRUint8 style, // is one pixel), then a line with two endpoints is returned PRIntn nsCSSRendering::MakeSide(nsPoint aPoints[], nsIRenderingContext& aContext, - PRIntn aWhichSide, - const nsRect& aOutside, const nsRect& aInside, + PRIntn whichSide, + const nsRect& outside, const nsRect& inside, PRIntn aSkipSides, - PRIntn aBorderPart, float aBorderFrac, - nscoord aTwipsPerPixel) + PRIntn borderPart, float borderFrac, + nscoord twipsPerPixel) { - nscoord outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, insideBR; + float borderRest = 1.0f - borderFrac; + + PRIntn np = 0; + nscoord thickness, outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, + insideBR; // Initialize the following six nscoord's: // outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, insideBR @@ -379,52 +378,52 @@ PRIntn nsCSSRendering::MakeSide(nsPoint aPoints[], // if we don't want the bevel, we'll get rid of it later by setting // outsideXX to insideXX - switch (aWhichSide) { + switch (whichSide) { case NS_SIDE_TOP: // the TL points are the left end; the BR points are the right end - outsideEdge = aOutside.y; - insideEdge = aInside.y; - outsideTL = aOutside.x; - insideTL = aInside.x; - insideBR = aInside.XMost(); - outsideBR = aOutside.XMost(); + outsideEdge = outside.y; + insideEdge = inside.y; + outsideTL = outside.x; + insideTL = inside.x; + insideBR = inside.XMost(); + outsideBR = outside.XMost(); break; case NS_SIDE_BOTTOM: // the TL points are the left end; the BR points are the right end - outsideEdge = aOutside.YMost(); - insideEdge = aInside.YMost(); - outsideTL = aOutside.x; - insideTL = aInside.x; - insideBR = aInside.XMost(); - outsideBR = aOutside.XMost(); + outsideEdge = outside.YMost(); + insideEdge = inside.YMost(); + outsideTL = outside.x; + insideTL = inside.x; + insideBR = inside.XMost(); + outsideBR = outside.XMost(); break; case NS_SIDE_LEFT: // the TL points are the top end; the BR points are the bottom end - outsideEdge = aOutside.x; - insideEdge = aInside.x; - outsideTL = aOutside.y; - insideTL = aInside.y; - insideBR = aInside.YMost(); - outsideBR = aOutside.YMost(); + outsideEdge = outside.x; + insideEdge = inside.x; + outsideTL = outside.y; + insideTL = inside.y; + insideBR = inside.YMost(); + outsideBR = outside.YMost(); break; default: - NS_ASSERTION(aWhichSide == NS_SIDE_RIGHT, "aWhichSide is not a valid side"); + NS_ASSERTION(whichSide == NS_SIDE_RIGHT, "whichSide is not a valid side"); // the TL points are the top end; the BR points are the bottom end - outsideEdge = aOutside.XMost(); - insideEdge = aInside.XMost(); - outsideTL = aOutside.y; - insideTL = aInside.y; - insideBR = aInside.YMost(); - outsideBR = aOutside.YMost(); + outsideEdge = outside.XMost(); + insideEdge = inside.XMost(); + outsideTL = outside.y; + insideTL = inside.y; + insideBR = inside.YMost(); + outsideBR = outside.YMost(); break; } // Don't draw the bevels if an adjacent side is skipped - if ( (aWhichSide == NS_SIDE_TOP) || (aWhichSide == NS_SIDE_BOTTOM) ) { + if ( (whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_BOTTOM) ) { // a top or bottom side if ((1<> 2; + twipsPerPixel += twipsPerPixel >> 2; + + // find the thickness of the piece being drawn + if ((whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_LEFT)) { + thickness = insideEdge - outsideEdge; + } else { + thickness = outsideEdge - insideEdge; + } // if returning a line, do it along inside edge for bottom or right borders // so that it's in the same place as it would be with polygons (why?) // XXX The previous version of the code shortened the right border too. - if ( !((thickness >= aTwipsPerPixel) || (aBorderPart != BORDER_FULL)) && - ((aWhichSide == NS_SIDE_BOTTOM) || (aWhichSide == NS_SIDE_RIGHT))) { + if ( !((thickness >= twipsPerPixel) || (borderPart != BORDER_FULL)) && + ((whichSide == NS_SIDE_BOTTOM) || (whichSide == NS_SIDE_RIGHT))) { outsideEdge = insideEdge; } // return the appropriate line or trapezoid - PRIntn np = 0; - if ((aWhichSide == NS_SIDE_TOP) || (aWhichSide == NS_SIDE_BOTTOM)) { + if ((whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_BOTTOM)) { // top and bottom borders aPoints[np++].MoveTo(outsideTL,outsideEdge); aPoints[np++].MoveTo(outsideBR,outsideEdge); - // XXX Making this condition only (thickness >= aTwipsPerPixel) will + // XXX Making this condition only (thickness >= twipsPerPixel) will // improve double borders and some cases of groove/ridge, // but will cause problems with table borders. See last and third // from last tests in test4.htm // Doing it this way emulates the old behavior. It might be worth // fixing. - if ((thickness >= aTwipsPerPixel) || (aBorderPart != BORDER_FULL)) { + if ((thickness >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { aPoints[np++].MoveTo(insideBR,insideEdge); aPoints[np++].MoveTo(insideTL,insideEdge); } } else { // right and left borders // XXX Ditto above - if ((thickness >= aTwipsPerPixel) || (aBorderPart != BORDER_FULL)) { + if ((thickness >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { aPoints[np++].MoveTo(insideEdge,insideBR); aPoints[np++].MoveTo(insideEdge,insideTL); } @@ -1824,11 +1803,10 @@ void nsCSSRendering::PaintBorder(nsPresContext* aPresContext, for (cnt = 0; cnt < 4; cnt++) { PRUint8 side = sideOrder[cnt]; - // If a side needs a double/groove/ridge border but will be less than two - // pixels, force it to be solid (see bug 1781 and bug 310124). - if (aBorderStyle.GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_DOUBLE || - aBorderStyle.GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_GROOVE || - aBorderStyle.GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_RIDGE) { + + // If a side needs a double border but will be less than two pixels, + // force it to be solid (see bug 1781). + if (aBorderStyle.GetBorderStyle(side) == NS_STYLE_BORDER_STYLE_DOUBLE) { nscoord widths[] = { border.top, border.right, border.bottom, border.left }; forceSolid = (widths[side]/twipsPerPixel < 2); } else