Bug 38370.

Allow color of an HR element to be changed.
Make HR be a block element in quirks mode instead of the hacky inline we were previously using (standards mode already had it as a block).
Patch by Ian Hickson <ian@hixie.ch> with minor modifications by me.
r+sr=bzbarsky@mit.edu


git-svn-id: svn://10.0.0.236/trunk@145375 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
caillon%returnzero.com
2003-07-30 08:13:07 +00:00
parent 5f9e95ef04
commit c8612ff038
31 changed files with 497 additions and 769 deletions

View File

@@ -309,11 +309,10 @@ nscolor nsCSSRendering::MakeBevelColor(PRIntn whichSide, PRUint8 style,
else
NS_Get3DColors(colors, aBackgroundColor);
if ((style == NS_STYLE_BORDER_STYLE_BG_OUTSET) ||
(style == NS_STYLE_BORDER_STYLE_OUTSET) ||
(style == NS_STYLE_BORDER_STYLE_OUTSET) ||
(style == NS_STYLE_BORDER_STYLE_RIDGE)) {
// Flip colors for these two border style
// Flip colors for these three border styles
switch (whichSide) {
case NS_SIDE_BOTTOM: whichSide = NS_SIDE_TOP; break;
case NS_SIDE_RIGHT: whichSide = NS_SIDE_LEFT; break;
@@ -533,8 +532,8 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext,
((theStyle == NS_STYLE_BORDER_STYLE_RIDGE) ?
NS_STYLE_BORDER_STYLE_GROOVE :
NS_STYLE_BORDER_STYLE_RIDGE),
aBackgroundColor, theColor,
PR_TRUE));
aBackgroundColor, theColor,
PR_TRUE));
if (2 == np) {
//aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y);
DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap);
@@ -545,7 +544,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext,
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides,
BORDER_OUTSIDE, 0.5f, twipsPerPixel);
aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor,
theColor, PR_TRUE));
theColor, PR_TRUE));
if (2 == np) {
//aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y);
DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap);
@@ -568,6 +567,19 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext,
}
break;
case NS_STYLE_BORDER_STYLE_BG_SOLID:
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, aSkipSides,
BORDER_FULL, 1.0f, twipsPerPixel);
nscolor colors[2];
NS_Get3DColors(colors, aBackgroundColor);
aContext.SetColor (colors[0]);
if (2 == np) {
DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap);
} else {
FillPolygon (aContext, theSide, np, aGap);
}
break;
case NS_STYLE_BORDER_STYLE_DOUBLE:
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides,
BORDER_INSIDE, 0.333333f, twipsPerPixel);
@@ -595,7 +607,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext,
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides,
BORDER_FULL, 1.0f, twipsPerPixel);
aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor,
theColor, PR_FALSE));
theColor, PR_FALSE));
if (2 == np) {
//aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y);
DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap);
@@ -606,10 +618,10 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext,
break;
case NS_STYLE_BORDER_STYLE_OUTSET:
case NS_STYLE_BORDER_STYLE_INSET:
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides,
np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides,
BORDER_FULL, 1.0f, twipsPerPixel);
aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor,
theColor, PR_TRUE));
theColor, PR_TRUE));
if (2 == np) {
//aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y);
DrawLine (aContext, theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y, aGap);
@@ -858,7 +870,7 @@ PRBool skippedSide = PR_FALSE;
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 10/22/99 dwc
* @update 10/22/99 dwc
*/
void nsCSSRendering::DrawDashedSides(PRIntn startSide,
nsIRenderingContext& aContext,
@@ -1332,7 +1344,7 @@ PRIntn whichSide=0;
width = aBounds.width - aBorderEdges->mMaxBorderWidth.right;
width += segment->mWidth;
}
else
else
{
width = aBounds.width;
}
@@ -1357,7 +1369,7 @@ PRIntn whichSide=0;
neighborBorderEdges = segment->mInsideNeighbor;
neighborEdgeCount=0;
}
nsBorderEdge * neighborRight = (nsBorderEdge *)(segment->mInsideNeighbor->mEdges[NS_SIDE_RIGHT].ElementAt(neighborEdgeCount));
nsBorderEdge * neighborRight = (nsBorderEdge *)(segment->mInsideNeighbor->mEdges[NS_SIDE_RIGHT].ElementAt(neighborEdgeCount));
totalLength = neighborRight->mLength;
}
dashRect.width = borderOutside.XMost() - borderInside.XMost();
@@ -1366,7 +1378,7 @@ PRIntn whichSide=0;
dashRect.y = borderOutside.y + (totalLength/2) - dashRect.height;
if ((PR_TRUE==aBorderEdges->mOutsideEdge) && (0!=i))
dashRect.y -= topEdge->mWidth;
currRect = dashRect;
currRect = dashRect;
// draw the top half
while (currRect.YMost() > borderInside.y) {
@@ -1626,7 +1638,8 @@ nsresult GetFrameForBackgroundUpdate(nsIPresContext *aPresContext,nsIFrame *aFra
// helper macro to determine if the borderstyle 'a' is a MOZ-BG-XXX style
#define MOZ_BG_BORDER(a)\
((a==NS_STYLE_BORDER_STYLE_BG_INSET) || (a==NS_STYLE_BORDER_STYLE_BG_OUTSET))
((a==NS_STYLE_BORDER_STYLE_BG_INSET) || (a==NS_STYLE_BORDER_STYLE_BG_OUTSET)\
|| (a==NS_STYLE_BORDER_STYLE_BG_SOLID))
static
PRBool GetBorderColor(const nsStyleColor* aColor, const nsStyleBorder& aBorder, PRUint8 aSide, nscolor& aColorVal,
@@ -1687,13 +1700,15 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
const nsStyleBackground* bgColor =
nsCSSRendering::FindNonTransparentBackground(aStyleContext,
compatMode == eCompatibility_NavQuirks ? PR_TRUE : PR_FALSE);
// mozBGColor is used instead of bgColor when the display type is BG_INSET or BG_OUTSET
// AND, in quirk mode, it is set to the BODY element's background color instead of the nearest
// ancestor's background color.
// or BG_SOLID, and, in quirk mode, it is set to the BODY element's background color
// instead of the nearest ancestor's background color.
const nsStyleBackground* mozBGColor = bgColor;
// now check if we are in Quirks mode and have a border style of BG_INSET or OUTSET
// - if so we use the bgColor from the HTML element instead of the nearest ancestor
// or BG_SOLID - if so we use the bgColor from the HTML element instead of the
// nearest ancestor
if (compatMode == eCompatibility_NavQuirks) {
PRBool bNeedBodyBGColor = PR_FALSE;
if (aStyleContext) {
@@ -3421,7 +3436,7 @@ nsCSSRendering::PaintBackgroundColor(nsIPresContext* aPresContext,
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 3/26/99 dwc
* @update 3/26/99 dwc
*/
void
nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
@@ -3531,7 +3546,7 @@ nsCSSRendering::PaintRoundedBackground(nsIPresContext* aPresContext,
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 3/26/99 dwc
* @update 3/26/99 dwc
*/
void
nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
@@ -3676,7 +3691,7 @@ nsCSSRendering::PaintRoundedBorder(nsIPresContext* aPresContext,
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 3/26/99 dwc
* @update 3/26/99 dwc
*/
void
nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
@@ -3739,13 +3754,23 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
switch (border_Style){
case NS_STYLE_BORDER_STYLE_OUTSET:
case NS_STYLE_BORDER_STYLE_INSET:
case NS_STYLE_BORDER_STYLE_BG_OUTSET:
case NS_STYLE_BORDER_STYLE_BG_INSET:
case NS_STYLE_BORDER_STYLE_BG_SOLID:
{
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(aStyleContext);
aRenderingContext.SetColor ( MakeBevelColor (aSide, border_Style, bgColor->mBackgroundColor,sideColor, PR_TRUE));
const nsStyleBackground* bgColor = nsCSSRendering::FindNonTransparentBackground(aStyleContext);
if (border_Style == NS_STYLE_BORDER_STYLE_BG_SOLID) {
nscolor colors[2];
NS_Get3DColors(colors, bgColor->mBackgroundColor);
aRenderingContext.SetColor(colors[0]);
} else {
aRenderingContext.SetColor(MakeBevelColor(aSide, border_Style, bgColor->mBackgroundColor, sideColor,
!MOZ_BG_BORDER(border_Style));
}
}
case NS_STYLE_BORDER_STYLE_DOTTED:
case NS_STYLE_BORDER_STYLE_DASHED:
// break; This is here until dotted and dashed are supported. It is ok to have
// break; XXX This is here until dotted and dashed are supported. It is ok to have
// dotted and dashed render in solid until this style is supported. This code should
// be moved when it is supported so that the above outset and inset will fall into the
// solid code below....
@@ -3828,7 +3853,7 @@ nsCSSRendering::RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderin
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 3/26/99 dwc
* @update 3/26/99 dwc
*/
void
RoundedRect::CalcInsetCurves(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve,nsMargin &aBorder)
@@ -3907,7 +3932,7 @@ PRInt16 adjust=0;
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 4/13/99 dwc
* @update 4/13/99 dwc
*/
void
RoundedRect::Set(nscoord aLeft,nscoord aTop,PRInt32 aWidth,PRInt32 aHeight,PRInt16 aRadius[4],PRInt16 aNumTwipPerPix)
@@ -3965,7 +3990,7 @@ RoundedRect::Set(nscoord aLeft,nscoord aTop,PRInt32 aWidth,PRInt32 aHeight,PRIn
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 4/13/99 dwc
* @update 4/13/99 dwc
*/
void
RoundedRect::GetRoundedBorders(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLCurve,QBCurve &aLRCurve)
@@ -3993,7 +4018,7 @@ RoundedRect::GetRoundedBorders(QBCurve &aULCurve,QBCurve &aURCurve,QBCurve &aLLC
/** ---------------------------------------------------
* Given a qbezier path, convert it into a polygon path
* @update 3/26/99 dwc
* @update 3/26/99 dwc
* @param aPoints -- an array of points to use for the path
* @param aPolyPath -- an array of points containing the flattened polygon to use
* @param aCurIndex -- the index that points to the last element of the array
@@ -4056,7 +4081,7 @@ GetPath(nsFloatPoint aPoints[],nsPoint aPolyPath[],PRInt32 *aCurIndex,ePathTypes
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 4/13/99 dwc
* @update 4/13/99 dwc
*/
void
QBCurve::SubDivide(nsIRenderingContext *aRenderingContext,nsPoint aPointArray[],PRInt32 *aCurIndex)
@@ -4065,19 +4090,19 @@ QBCurve curve1,curve2;
float fx,fy,smag;
// divide the curve into 2 pieces
MidPointDivide(&curve1,&curve2);
fx = (float)fabs(curve1.mAnc2.x - this->mCon.x);
fy = (float)fabs(curve1.mAnc2.y - this->mCon.y);
MidPointDivide(&curve1,&curve2);
//smag = fx+fy-(PR_MIN(fx,fy)>>1);
fx = (float)fabs(curve1.mAnc2.x - this->mCon.x);
fy = (float)fabs(curve1.mAnc2.y - this->mCon.y);
//smag = fx+fy-(PR_MIN(fx,fy)>>1);
smag = fx*fx + fy*fy;
if (smag>1){
// split the curve again
if (smag>1){
// split the curve again
curve1.SubDivide(aRenderingContext,aPointArray,aCurIndex);
curve2.SubDivide(aRenderingContext,aPointArray,aCurIndex);
}else{
}else{
if(aPointArray ) {
// save the points for further processing
aPointArray[*aCurIndex].x = (nscoord)curve1.mAnc2.x;
@@ -4087,7 +4112,7 @@ float fx,fy,smag;
aPointArray[*aCurIndex].y = (nscoord)curve2.mAnc2.y;
(*aCurIndex)++;
}else{
// draw the curve
// draw the curve
nsTransform2D *aTransform;
aRenderingContext->GetCurrentTransform(aTransform);
@@ -4095,18 +4120,18 @@ float fx,fy,smag;
aRenderingContext->DrawLine((nscoord)curve1.mAnc1.x,(nscoord)curve1.mAnc1.y,(nscoord)curve1.mAnc2.x,(nscoord)curve1.mAnc2.y);
aRenderingContext->DrawLine((nscoord)curve1.mAnc2.x,(nscoord)curve1.mAnc2.y,(nscoord)curve2.mAnc2.x,(nscoord)curve2.mAnc2.y);
}
}
}
}
/** ---------------------------------------------------
* See documentation in nsCSSRendering.h
* @update 4/13/99 dwc
* @update 4/13/99 dwc
*/
void
QBCurve::MidPointDivide(QBCurve *A,QBCurve *B)
{
float c1x,c1y,c2x,c2y;
nsFloatPoint a1;
float c1x,c1y,c2x,c2y;
nsFloatPoint a1;
c1x = (mAnc1.x+mCon.x)/2.0f;
c1y = (mAnc1.y+mCon.y)/2.0f;
@@ -4114,7 +4139,7 @@ nsFloatPoint a1;
c2y = (mAnc2.y+mCon.y)/2.0f;
a1.x = (c1x + c2x)/2.0f;
a1.y = (c1y + c2y)/2.0f;
a1.y = (c1y + c2y)/2.0f;
// put the math into our 2 new curves
A->mAnc1 = this->mAnc1;
@@ -4486,6 +4511,7 @@ nsCSSRendering::DrawTableBorderSegment(nsIRenderingContext& aContext,
break;
}
// else fall through to solid
case NS_STYLE_BORDER_STYLE_BG_SOLID:
case NS_STYLE_BORDER_STYLE_SOLID:
DrawSolidBorderSegment(aContext, aBorder, twipsPerPixel, aStartBevelSide,
aStartBevelOffset, aEndBevelSide, aEndBevelOffset);