diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 00333447f059..d3b0146459c8 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -203,165 +203,148 @@ PRIntn nsCSSRendering::MakeSide(nsPoint aPoints[], nsIRenderingContext& aContext, PRIntn whichSide, const nsRect& outside, const nsRect& inside, + PRIntn aSkipSides, PRIntn borderPart, float borderFrac, nscoord twipsPerPixel) { float borderRest = 1.0f - borderFrac; - // XXX QQQ We really should decide to do a bevel based on whether there - // is a side adjacent or not. This could let you join borders across - // block elements (paragraphs). - PRIntn np = 0; - nscoord thickness; + nscoord thickness, outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, + insideBR; + + // Initialize the following six nscoord's: + // outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, insideBR + // so that outsideEdge is the x or y of the outside edge, etc., and + // outsideTR is the y or x at the top or right end, etc., e.g.: + // + // outsideEdge --- ---------------------------------------- + // \ / + // \ / + // \ / + // insideEdge ------- ---------------------------------- + // | | | | + // outsideTL insideTL insideBR outsideBR + // + // if we don't want the bevel, we'll get rid of it later by setting + // outsideXX to insideXX + + switch (whichSide) { + case NS_SIDE_TOP: + // the TL points are the left end; the BR points are the right end + 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 = 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 = outside.x; + insideEdge = inside.x; + outsideTL = outside.y; + insideTL = inside.y; + insideBR = inside.YMost(); + outsideBR = outside.YMost(); + break; + + case NS_SIDE_RIGHT: + // the TL points are the top end; the BR points are the bottom end + 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 ( (whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_BOTTOM) ) { + // a top or bottom side + if ((1<> 2; - switch (whichSide) { - case NS_SIDE_TOP: - if (borderPart == BORDER_FULL) { - thickness = inside.y - outside.y; + // find the thickness of the piece being drawn + if ((whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_LEFT)) { + thickness = insideEdge - outsideEdge; + } else { + thickness = outsideEdge - insideEdge; + } - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.x, inside.y); - } - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.x, inside.y); - } else { - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); + // 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 >= twipsPerPixel) || (borderPart != BORDER_FULL)) && + ((whichSide == NS_SIDE_BOTTOM) || (whichSide == NS_SIDE_RIGHT))) { + outsideEdge = insideEdge; } - break; - case NS_SIDE_LEFT: - if (borderPart == BORDER_FULL) { - thickness = inside.x - outside.x; - - aPoints[np++].MoveTo(outside.x, outside.y); - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(inside.x, inside.y); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - } - aPoints[np++].MoveTo(outside.x, outside.YMost()); - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(inside.x, inside.y); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - } else { - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(outside.x, outside.YMost()); + // return the appropriate line or trapezoid + 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 >= 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 >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { + aPoints[np++].MoveTo(insideBR,insideEdge); + aPoints[np++].MoveTo(insideTL,insideEdge); } - break; - - case NS_SIDE_BOTTOM: - if (borderPart == BORDER_FULL) { - thickness = outside.YMost() - inside.YMost(); - - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(outside.x, outside.YMost()); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - } else { - aPoints[np++].MoveTo(outside.x, inside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), inside.YMost()); - } - - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - } else { - aPoints[np++].MoveTo(outside.x, outside.YMost()); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); + } else { + // right and left borders + // XXX Ditto above + if ((thickness >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { + aPoints[np++].MoveTo(insideEdge,insideBR); + aPoints[np++].MoveTo(insideEdge,insideTL); } - break; - - case NS_SIDE_RIGHT: - if (borderPart == BORDER_FULL) { - thickness = outside.XMost() - inside.XMost(); - - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - } - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - } else { - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - } - break; + aPoints[np++].MoveTo(outsideEdge,outsideTL); + aPoints[np++].MoveTo(outsideEdge,outsideBR); } return np; } @@ -373,6 +356,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, const nscolor aBackgroundColor, const nsRect& borderOutside, const nsRect& borderInside, + PRIntn aSkipSides, nscoord twipsPerPixel, nsRect* aGap) { @@ -391,7 +375,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, case NS_STYLE_BORDER_STYLE_GROOVE: case NS_STYLE_BORDER_STYLE_RIDGE: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, aSkipSides, BORDER_INSIDE, 0.5f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, ((theStyle == NS_STYLE_BORDER_STYLE_RIDGE) ? @@ -406,7 +390,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, //aContext.FillPolygon (theSide, np); FillPolygon (aContext, theSide, np, aGap); } - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_OUTSIDE, 0.5f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_TRUE)); @@ -420,7 +404,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, break; case NS_STYLE_BORDER_STYLE_SOLID: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor (borderColor); if (2 == np) { @@ -433,7 +417,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, break; case NS_STYLE_BORDER_STYLE_DOUBLE: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_INSIDE, 0.333333f, twipsPerPixel); aContext.SetColor (borderColor); if (2 == np) { @@ -443,7 +427,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, //aContext.FillPolygon (theSide, np); FillPolygon (aContext, theSide, np, aGap); } - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_OUTSIDE, 0.333333f, twipsPerPixel); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); @@ -456,7 +440,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, case NS_STYLE_BORDER_STYLE_BG_OUTSET: case NS_STYLE_BORDER_STYLE_BG_INSET: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_FALSE)); @@ -470,7 +454,7 @@ 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, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_TRUE)); @@ -1444,7 +1428,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_TOP, aBorderStyle.GetBorderStyle(NS_SIDE_TOP), sideColor, - bgColor->mBackgroundColor, inside,outside, + bgColor->mBackgroundColor, inside,outside, aSkipSides, twipsPerPixel, aGap); } } @@ -1453,7 +1437,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_LEFT, aBorderStyle.GetBorderStyle(NS_SIDE_LEFT), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1462,7 +1446,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_BOTTOM, aBorderStyle.GetBorderStyle(NS_SIDE_BOTTOM), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1471,7 +1455,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_RIGHT, aBorderStyle.GetBorderStyle(NS_SIDE_RIGHT), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1542,7 +1526,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1564,7 +1548,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside, aSkipSides, twipsPerPixel, aGap); } } @@ -1589,7 +1573,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1621,7 +1605,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index d3116e289ada..d48c38ad7f6f 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -151,6 +151,7 @@ protected: nsIRenderingContext& aContext, PRIntn whichSide, const nsRect& outside, const nsRect& inside, + PRIntn aSkipSides, PRIntn borderPart, float borderFrac, nscoord twipsPerPixel); @@ -161,6 +162,7 @@ protected: const nscolor aBackgroundColor, const nsRect& borderOutside, const nsRect& borderInside, + PRIntn aSkipSides, nscoord twipsPerPixel, nsRect* aGap = 0); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 092e7117fe53..53569341a7f7 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -545,7 +545,7 @@ nsComboboxControlFrame::GetAbsoluteFramePosition(nsIPresContext& aPresContext, // Add in the absolute offset of the widget. nsRect absBounds; - widget->GetAbsoluteBounds(absBounds); + //XXX: Remove this widget->GetAbsoluteBounds(absBounds); // Convert widget coordinates to twips aAbsoluteTwipsRect.x += NSIntPixelsToTwips(absBounds.x, p2t); diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 092e7117fe53..53569341a7f7 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -545,7 +545,7 @@ nsComboboxControlFrame::GetAbsoluteFramePosition(nsIPresContext& aPresContext, // Add in the absolute offset of the widget. nsRect absBounds; - widget->GetAbsoluteBounds(absBounds); + //XXX: Remove this widget->GetAbsoluteBounds(absBounds); // Convert widget coordinates to twips aAbsoluteTwipsRect.x += NSIntPixelsToTwips(absBounds.x, p2t); diff --git a/layout/html/style/src/nsCSSRendering.cpp b/layout/html/style/src/nsCSSRendering.cpp index 00333447f059..d3b0146459c8 100644 --- a/layout/html/style/src/nsCSSRendering.cpp +++ b/layout/html/style/src/nsCSSRendering.cpp @@ -203,165 +203,148 @@ PRIntn nsCSSRendering::MakeSide(nsPoint aPoints[], nsIRenderingContext& aContext, PRIntn whichSide, const nsRect& outside, const nsRect& inside, + PRIntn aSkipSides, PRIntn borderPart, float borderFrac, nscoord twipsPerPixel) { float borderRest = 1.0f - borderFrac; - // XXX QQQ We really should decide to do a bevel based on whether there - // is a side adjacent or not. This could let you join borders across - // block elements (paragraphs). - PRIntn np = 0; - nscoord thickness; + nscoord thickness, outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, + insideBR; + + // Initialize the following six nscoord's: + // outsideEdge, insideEdge, outsideTL, insideTL, outsideBR, insideBR + // so that outsideEdge is the x or y of the outside edge, etc., and + // outsideTR is the y or x at the top or right end, etc., e.g.: + // + // outsideEdge --- ---------------------------------------- + // \ / + // \ / + // \ / + // insideEdge ------- ---------------------------------- + // | | | | + // outsideTL insideTL insideBR outsideBR + // + // if we don't want the bevel, we'll get rid of it later by setting + // outsideXX to insideXX + + switch (whichSide) { + case NS_SIDE_TOP: + // the TL points are the left end; the BR points are the right end + 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 = 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 = outside.x; + insideEdge = inside.x; + outsideTL = outside.y; + insideTL = inside.y; + insideBR = inside.YMost(); + outsideBR = outside.YMost(); + break; + + case NS_SIDE_RIGHT: + // the TL points are the top end; the BR points are the bottom end + 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 ( (whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_BOTTOM) ) { + // a top or bottom side + if ((1<> 2; - switch (whichSide) { - case NS_SIDE_TOP: - if (borderPart == BORDER_FULL) { - thickness = inside.y - outside.y; + // find the thickness of the piece being drawn + if ((whichSide == NS_SIDE_TOP) || (whichSide == NS_SIDE_LEFT)) { + thickness = insideEdge - outsideEdge; + } else { + thickness = outsideEdge - insideEdge; + } - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.x, inside.y); - } - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.x, inside.y); - } else { - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); + // 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 >= twipsPerPixel) || (borderPart != BORDER_FULL)) && + ((whichSide == NS_SIDE_BOTTOM) || (whichSide == NS_SIDE_RIGHT))) { + outsideEdge = insideEdge; } - break; - case NS_SIDE_LEFT: - if (borderPart == BORDER_FULL) { - thickness = inside.x - outside.x; - - aPoints[np++].MoveTo(outside.x, outside.y); - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(inside.x, inside.y); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - } - aPoints[np++].MoveTo(outside.x, outside.YMost()); - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(inside.x, inside.y); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - } else { - aPoints[np++].MoveTo(outside.x, outside.y); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(outside.x, outside.YMost()); + // return the appropriate line or trapezoid + 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 >= 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 >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { + aPoints[np++].MoveTo(insideBR,insideEdge); + aPoints[np++].MoveTo(insideTL,insideEdge); } - break; - - case NS_SIDE_BOTTOM: - if (borderPart == BORDER_FULL) { - thickness = outside.YMost() - inside.YMost(); - - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(outside.x, outside.YMost()); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - } else { - aPoints[np++].MoveTo(outside.x, inside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), inside.YMost()); - } - - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(nscoord(outside.x * borderFrac + - inside.x * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - aPoints[np++].MoveTo(inside.x, inside.YMost()); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - } else { - aPoints[np++].MoveTo(outside.x, outside.YMost()); - aPoints[np++].MoveTo(nscoord(inside.x * borderFrac + - outside.x * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); + } else { + // right and left borders + // XXX Ditto above + if ((thickness >= twipsPerPixel) || (borderPart != BORDER_FULL) ) { + aPoints[np++].MoveTo(insideEdge,insideBR); + aPoints[np++].MoveTo(insideEdge,insideTL); } - break; - - case NS_SIDE_RIGHT: - if (borderPart == BORDER_FULL) { - thickness = outside.XMost() - inside.XMost(); - - if (thickness >= twipsPerPixel) { - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - } - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - } else if (borderPart == BORDER_INSIDE) { - aPoints[np++].MoveTo(inside.XMost(), inside.y); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.y * borderFrac + - inside.y * borderRest)); - aPoints[np++].MoveTo(nscoord(outside.XMost() * borderFrac + - inside.XMost() * borderRest), - nscoord(outside.YMost() * borderFrac + - inside.YMost() * borderRest)); - aPoints[np++].MoveTo(inside.XMost(), inside.YMost()); - } else { - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.y * borderFrac + - outside.y * borderRest)); - aPoints[np++].MoveTo(outside.XMost(), outside.y); - aPoints[np++].MoveTo(outside.XMost(), outside.YMost()); - aPoints[np++].MoveTo(nscoord(inside.XMost() * borderFrac + - outside.XMost() * borderRest), - nscoord(inside.YMost() * borderFrac + - outside.YMost() * borderRest)); - } - break; + aPoints[np++].MoveTo(outsideEdge,outsideTL); + aPoints[np++].MoveTo(outsideEdge,outsideBR); } return np; } @@ -373,6 +356,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, const nscolor aBackgroundColor, const nsRect& borderOutside, const nsRect& borderInside, + PRIntn aSkipSides, nscoord twipsPerPixel, nsRect* aGap) { @@ -391,7 +375,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, case NS_STYLE_BORDER_STYLE_GROOVE: case NS_STYLE_BORDER_STYLE_RIDGE: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, aSkipSides, BORDER_INSIDE, 0.5f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, ((theStyle == NS_STYLE_BORDER_STYLE_RIDGE) ? @@ -406,7 +390,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, //aContext.FillPolygon (theSide, np); FillPolygon (aContext, theSide, np, aGap); } - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_OUTSIDE, 0.5f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_TRUE)); @@ -420,7 +404,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, break; case NS_STYLE_BORDER_STYLE_SOLID: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor (borderColor); if (2 == np) { @@ -433,7 +417,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, break; case NS_STYLE_BORDER_STYLE_DOUBLE: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_INSIDE, 0.333333f, twipsPerPixel); aContext.SetColor (borderColor); if (2 == np) { @@ -443,7 +427,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, //aContext.FillPolygon (theSide, np); FillPolygon (aContext, theSide, np, aGap); } - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_OUTSIDE, 0.333333f, twipsPerPixel); if (2 == np) { //aContext.DrawLine (theSide[0].x, theSide[0].y, theSide[1].x, theSide[1].y); @@ -456,7 +440,7 @@ void nsCSSRendering::DrawSide(nsIRenderingContext& aContext, case NS_STYLE_BORDER_STYLE_BG_OUTSET: case NS_STYLE_BORDER_STYLE_BG_INSET: - np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_FALSE)); @@ -470,7 +454,7 @@ 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, + np = MakeSide (theSide, aContext, whichSide, borderOutside, borderInside,aSkipSides, BORDER_FULL, 1.0f, twipsPerPixel); aContext.SetColor ( MakeBevelColor (whichSide, theStyle, aBackgroundColor, theColor, PR_TRUE)); @@ -1444,7 +1428,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_TOP, aBorderStyle.GetBorderStyle(NS_SIDE_TOP), sideColor, - bgColor->mBackgroundColor, inside,outside, + bgColor->mBackgroundColor, inside,outside, aSkipSides, twipsPerPixel, aGap); } } @@ -1453,7 +1437,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_LEFT, aBorderStyle.GetBorderStyle(NS_SIDE_LEFT), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1462,7 +1446,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_BOTTOM, aBorderStyle.GetBorderStyle(NS_SIDE_BOTTOM), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1471,7 +1455,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext& aPresContext, DrawSide(aRenderingContext, NS_SIDE_RIGHT, aBorderStyle.GetBorderStyle(NS_SIDE_RIGHT), sideColor, - bgColor->mBackgroundColor,inside, outside, + bgColor->mBackgroundColor,inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1542,7 +1526,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1564,7 +1548,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside, aSkipSides, twipsPerPixel, aGap); } } @@ -1589,7 +1573,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } @@ -1621,7 +1605,7 @@ void nsCSSRendering::PaintBorderEdges(nsIPresContext& aPresContext, borderEdge->mStyle, borderEdge->mColor, bgColor->mBackgroundColor, - inside, outside, + inside, outside,aSkipSides, twipsPerPixel, aGap); } } diff --git a/layout/html/style/src/nsCSSRendering.h b/layout/html/style/src/nsCSSRendering.h index d3116e289ada..d48c38ad7f6f 100644 --- a/layout/html/style/src/nsCSSRendering.h +++ b/layout/html/style/src/nsCSSRendering.h @@ -151,6 +151,7 @@ protected: nsIRenderingContext& aContext, PRIntn whichSide, const nsRect& outside, const nsRect& inside, + PRIntn aSkipSides, PRIntn borderPart, float borderFrac, nscoord twipsPerPixel); @@ -161,6 +162,7 @@ protected: const nscolor aBackgroundColor, const nsRect& borderOutside, const nsRect& borderInside, + PRIntn aSkipSides, nscoord twipsPerPixel, nsRect* aGap = 0); diff --git a/webshell/tests/viewer/samples/test_lbox.html b/webshell/tests/viewer/samples/test_lbox.html index b9747d95003f..378019fbd2b9 100644 --- a/webshell/tests/viewer/samples/test_lbox.html +++ b/webshell/tests/viewer/samples/test_lbox.html @@ -64,7 +64,37 @@
- +

This listbox is multiple with no size + + +
+

This listbox is multiple with size=1 + + +

This listbox contains two option groups + + + + diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index 629877e3ae52..5ff6bac3c534 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -313,7 +313,7 @@ class nsIWidget : public nsISupports { * @param aY the new y position expressed in the parent's coordinate system * **/ - NS_IMETHOD Move(PRUint32 aX, PRUint32 aY) = 0; + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY) = 0; /** * Resize this widget. @@ -323,9 +323,9 @@ class nsIWidget : public nsISupports { * @param aRepaint whether the widget should be repainted * */ - NS_IMETHOD Resize(PRUint32 aWidth, - PRUint32 aHeight, - PRBool aRepaint) = 0; + NS_IMETHOD Resize(PRInt32 aWidth, + PRInt32 aHeight, + PRBool aRepaint) = 0; /** * Move or resize this widget. @@ -337,11 +337,11 @@ class nsIWidget : public nsISupports { * @param aRepaint whether the widget should be repainted if the size changes * */ - NS_IMETHOD Resize(PRUint32 aX, - PRUint32 aY, - PRUint32 aWidth, - PRUint32 aHeight, - PRBool aRepaint) = 0; + NS_IMETHOD Resize(PRInt32 aX, + PRInt32 aY, + PRInt32 aWidth, + PRInt32 aHeight, + PRBool aRepaint) = 0; /** * Enable or disable this Widget @@ -364,14 +364,7 @@ class nsIWidget : public nsISupports { */ NS_IMETHOD GetBounds(nsRect &aRect) = 0; - /** - * Get this widget's absolute outside dimensions, - * - * @param aRect on return it holds the x. y, width and height of this widget - * - */ - NS_IMETHOD GetAbsoluteBounds(nsRect &aRect) = 0; - + /** * Get this widget's client area dimensions, if the window has a 3D border appearance * this returns the area inside the border, The x and y are always zero diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 934b786122db..19dd4ace2fc4 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -308,7 +308,7 @@ NS_METHOD nsWidget::IsVisible(PRBool &aState) // //------------------------------------------------------------------------- -NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY) +NS_METHOD nsWidget::Move(PRInt32 aX, PRInt32 aY) { if (mWidget) { ::gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY); @@ -316,7 +316,7 @@ NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY) return NS_OK; } -NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_METHOD nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { #if 0 printf("nsWidget::Resize %s (%p) to %d %d\n", @@ -337,8 +337,8 @@ NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) return NS_OK; } -NS_METHOD nsWidget::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, - PRUint32 aHeight, PRBool aRepaint) +NS_METHOD nsWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint) { Resize(aWidth,aHeight,aRepaint); Move(aX,aY); diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index 63a895bf368c..fc6917db0465 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -87,10 +87,10 @@ class nsWidget : public nsBaseWidget NS_IMETHOD Show(PRBool state); NS_IMETHOD IsVisible(PRBool &aState); - NS_IMETHOD Move(PRUint32 aX, PRUint32 aY); - NS_IMETHOD Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint); - NS_IMETHOD Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, - PRUint32 aHeight, PRBool aRepaint); + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint); NS_IMETHOD Enable(PRBool aState); NS_IMETHOD SetFocus(void); diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 20ffdf1736a5..ea9146608318 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -693,7 +693,17 @@ NS_METHOD nsWindow::ShowMenuBar(PRBool aShow) return NS_OK; } +NS_METHOD nsWindow::IsMenuBarVisible(PRBool *aVisible) +{ + *aVisible = PR_TRUE; + return NS_ERROR_FAILURE; // todo: (maybe. method isn't actually used yet.) +} + +<<<<<<< nsWindow.cpp +NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY) +======= NS_METHOD nsWindow::Move(PRUint32 aX, PRUint32 aY) +>>>>>>> 1.135 { // not implimented for toplevel windows if (mIsToplevel && mShell) @@ -719,7 +729,7 @@ NS_METHOD nsWindow::Move(PRUint32 aX, PRUint32 aY) } -NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { #if 0 printf("nsWidget::Resize %s (%p) to %d %d\n", @@ -759,8 +769,8 @@ NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) } -NS_METHOD nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, - PRUint32 aHeight, PRBool aRepaint) +NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint) { Resize(aWidth,aHeight,aRepaint); Move(aX,aY); diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index f844cc2f2a60..fffd5e74eaf1 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -62,11 +62,16 @@ public: NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar); NS_IMETHOD Show(PRBool aShow); NS_IMETHOD ShowMenuBar(PRBool aShow); +<<<<<<< nsWindow.h + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD IsMenuBarVisible(PRBool *aVisible); +======= NS_IMETHOD Move(PRUint32 aX, PRUint32 aY); +>>>>>>> 1.45 - NS_IMETHOD Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint); - NS_IMETHOD Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, - PRUint32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint); NS_IMETHOD Invalidate(PRBool aIsSynchronous); NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous); diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index dcad4da197fa..d09c57097bca 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -487,7 +487,7 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool bState) // Move this window // //------------------------------------------------------------------------- -NS_IMETHODIMP nsMacWindow::Move(PRUint32 aX, PRUint32 aY) +NS_IMETHODIMP nsMacWindow::Move(PRInt32 aX, PRInt32 aY) { if (mWindowMadeHere) { @@ -567,7 +567,7 @@ NS_IMETHODIMP nsMacWindow::Move(PRUint32 aX, PRUint32 aY) // Resize this window // //------------------------------------------------------------------------- -NS_IMETHODIMP nsMacWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { if (mWindowMadeHere) { diff --git a/widget/src/mac/nsMacWindow.h b/widget/src/mac/nsMacWindow.h index 110db92eae59..f929a2c71ed5 100644 --- a/widget/src/mac/nsMacWindow.h +++ b/widget/src/mac/nsMacWindow.h @@ -72,8 +72,8 @@ public: nsNativeWidget aNativeParent = nsnull); NS_IMETHOD Show(PRBool aState); - NS_IMETHOD Move(PRUint32 aX, PRUint32 aY); - NS_IMETHOD Resize(PRUint32 aWidth,PRUint32 aHeight, PRBool aRepaint); + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); virtual PRBool OnPaint(nsPaintEvent &event); NS_IMETHOD SetTitle(const nsString& aTitle); diff --git a/widget/src/mac/nsTextAreaWidget.cpp b/widget/src/mac/nsTextAreaWidget.cpp index 6ae70457baff..888ea399c4a5 100644 --- a/widget/src/mac/nsTextAreaWidget.cpp +++ b/widget/src/mac/nsTextAreaWidget.cpp @@ -563,7 +563,7 @@ NS_METHOD nsTextAreaWidget::GetText(nsString& aTextBuffer, PRUint32 aBufferSize * @param aRepaint -- indicates if a repaint is needed. * @return PR_TRUE if the pt is contained in the widget */ -NS_IMETHODIMP nsTextAreaWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_IMETHODIMP nsTextAreaWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { return Resize(0, 0, aWidth, aHeight, aRepaint); } @@ -578,7 +578,7 @@ NS_IMETHODIMP nsTextAreaWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool * @param aW * @return PR_TRUE */ -NS_IMETHODIMP nsTextAreaWidget::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_IMETHODIMP nsTextAreaWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { Inherited::Resize(aX, aY, aWidth, aHeight, aRepaint); diff --git a/widget/src/mac/nsTextAreaWidget.h b/widget/src/mac/nsTextAreaWidget.h index d285c5f5f6de..a245ac7b719a 100644 --- a/widget/src/mac/nsTextAreaWidget.h +++ b/widget/src/mac/nsTextAreaWidget.h @@ -67,8 +67,8 @@ public: NS_IMETHOD GetSelection(PRUint32 *aStartSel, PRUint32 *aEndSel); NS_IMETHOD SetCaretPosition(PRUint32 aPosition); NS_IMETHOD GetCaretPosition(PRUint32& aPosition); - NS_IMETHOD Resize(PRUint32 aWidth,PRUint32 aHeight, PRBool aRepaint); - NS_IMETHOD Resize(PRUint32 aX, PRUint32 aY,PRUint32 aWidth,PRUint32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); virtual PRBool OnPaint(nsPaintEvent & aEvent); diff --git a/widget/src/mac/nsWindow.cpp b/widget/src/mac/nsWindow.cpp index 2f3d674dfb66..ff64095108a7 100644 --- a/widget/src/mac/nsWindow.cpp +++ b/widget/src/mac/nsWindow.cpp @@ -525,7 +525,7 @@ NS_IMETHODIMP nsWindow::GetBounds(nsRect &aRect) // Move this component // aX and aY are in the parent widget coordinate system //------------------------------------------------------------------------- -NS_IMETHODIMP nsWindow::Move(PRUint32 aX, PRUint32 aY) +NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY) { if ((mBounds.x != aX) || (mBounds.y != aY)) { @@ -551,7 +551,7 @@ NS_IMETHODIMP nsWindow::Move(PRUint32 aX, PRUint32 aY) // Resize this component // //------------------------------------------------------------------------- -NS_IMETHODIMP nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { if ((mBounds.width != aWidth) || (mBounds.height != aHeight)) { @@ -577,7 +577,7 @@ NS_IMETHODIMP nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepain // Resize this component // //------------------------------------------------------------------------- -NS_IMETHODIMP nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { nsWindow::Move(aX, aY); nsWindow::Resize(aWidth, aHeight, aRepaint); diff --git a/widget/src/mac/nsWindow.h b/widget/src/mac/nsWindow.h index bf9a138ebecf..abc15fafde38 100644 --- a/widget/src/mac/nsWindow.h +++ b/widget/src/mac/nsWindow.h @@ -84,9 +84,9 @@ public: NS_IMETHOD Show(PRBool aState); NS_IMETHOD IsVisible(PRBool & aState); - NS_IMETHOD Move(PRUint32 aX, PRUint32 aY); - NS_IMETHOD Resize(PRUint32 aWidth,PRUint32 aHeight, PRBool aRepaint); - NS_IMETHOD Resize(PRUint32 aX, PRUint32 aY,PRUint32 aWidth,PRUint32 aHeight, PRBool aRepaint); + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Resize(PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); + NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY,PRInt32 aWidth,PRInt32 aHeight, PRBool aRepaint); NS_IMETHOD Enable(PRBool bState); NS_IMETHOD SetFocus(void); diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 47542c2a0882..bc759b1ab434 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -659,6 +659,10 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent, extendedStyle = WS_EX_TOPMOST; style = WS_POPUP; mBorderlessParent = parent; + // Get the top most level window to use as the parent + while (::GetParent(parent)) { + parent = ::GetParent(parent); + } } if (aInitData->mBorderStyle != eBorderStyle_all) { @@ -882,7 +886,7 @@ NS_METHOD nsWindow::IsVisible(PRBool & bState) // Move this component // //------------------------------------------------------------------------- -NS_METHOD nsWindow::Move(PRUint32 aX, PRUint32 aY) +NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY) { // When moving a borderless top-level window the window // must be placed relative to its parent. WIN32 wants to @@ -931,8 +935,10 @@ NS_METHOD nsWindow::Move(PRUint32 aX, PRUint32 aY) // Resize this component // //------------------------------------------------------------------------- -NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) +NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { + NS_ASSERTION((aWidth >=0 ) , "Negative width passed to nsWindow::Resize"); + NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize"); // Set cached value for lightweight and printing mBounds.width = aWidth; mBounds.height = aHeight; @@ -970,12 +976,15 @@ NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) // Resize this component // //------------------------------------------------------------------------- -NS_METHOD nsWindow::Resize(PRUint32 aX, - PRUint32 aY, - PRUint32 aWidth, - PRUint32 aHeight, +NS_METHOD nsWindow::Resize(PRInt32 aX, + PRInt32 aY, + PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint) { + NS_ASSERTION((aWidth >=0 ), "Negative width passed to nsWindow::Resize"); + NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize"); + // Set cached value for lightweight and printing mBounds.x = aX; mBounds.y = aY; @@ -1082,28 +1091,6 @@ NS_METHOD nsWindow::GetBounds(nsRect &aRect) return NS_OK; } - -//------------------------------------------------------------------------- -// -// Get the bounding rectangle in screen coordinates -// -//------------------------------------------------------------------------- - -NS_METHOD nsWindow::GetAbsoluteBounds(nsRect &aRect) -{ - if (mWnd) { - RECT r; - VERIFY(::GetWindowRect(mWnd, &r)); - - // assign size - aRect.width = r.right - r.left; - aRect.height = r.bottom - r.top; - aRect.x = r.left; - aRect.y = r.top; - } - return NS_OK; -} - //------------------------------------------------------------------------- // // Get this component dimension diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h index 627c92bf6dfc..9ad2d12b6956 100644 --- a/widget/src/windows/nsWindow.h +++ b/widget/src/windows/nsWindow.h @@ -87,18 +87,17 @@ public: HWND mBorderlessParent; NS_IMETHOD CaptureMouse(PRBool aCapture); - NS_IMETHOD Move(PRUint32 aX, PRUint32 aY); - NS_IMETHOD Resize(PRUint32 aWidth, - PRUint32 aHeight, + NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); + NS_IMETHOD Resize(PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint); - NS_IMETHOD Resize(PRUint32 aX, - PRUint32 aY, - PRUint32 aWidth, - PRUint32 aHeight, + NS_IMETHOD Resize(PRInt32 aX, + PRInt32 aY, + PRInt32 aWidth, + PRInt32 aHeight, PRBool aRepaint); NS_IMETHOD Enable(PRBool bState); NS_IMETHOD SetFocus(void); - NS_IMETHOD GetAbsoluteBounds(nsRect &aRect); NS_IMETHOD GetBounds(nsRect &aRect); NS_IMETHOD GetClientBounds(nsRect &aRect); NS_IMETHOD SetBackgroundColor(const nscolor &aColor); diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 3ccf5e3a38ea..47c0e362f9dc 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -650,16 +650,6 @@ NS_METHOD nsBaseWidget::GetBounds(nsRect &aRect) return NS_OK; } -/** - * This implementation of nsWindow MUST be overridden. - * - **/ - -NS_METHOD nsBaseWidget::GetAbsoluteBounds(nsRect &aRect) -{ - return NS_ERROR_FAILURE; -} - /** * If the implementation of nsWindow supports borders this method MUST be overridden diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index 8e58cdcf52fe..8a31a8c93ae1 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -55,7 +55,6 @@ public: NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData) { return NS_OK;} // nsIWidget interface - NS_IMETHOD GetAbsoluteBounds(nsRect &aRect); NS_IMETHOD CaptureMouse(PRBool aCapture); NS_IMETHOD GetClientData(void*& aClientData); NS_IMETHOD SetClientData(void* aClientData);