1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#ifndef nsCSSRendering_h___
|
|
|
|
#define nsCSSRendering_h___
|
|
|
|
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
struct nsPoint;
|
|
|
|
|
|
|
|
class nsCSSRendering {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Render the border for an element using css rendering rules
|
|
|
|
* for borders. aSkipSides is a bitmask of the sides to skip
|
|
|
|
* when rendering. If 0 then no sides are skipped.
|
1998-07-22 06:46:00 +04:00
|
|
|
*
|
1999-01-15 21:25:58 +03:00
|
|
|
* Both aDirtyRect and aBorderArea are in the local coordinate space
|
1998-07-22 06:46:00 +04:00
|
|
|
* of aForFrame
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
static void PaintBorder(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsIFrame* aForFrame,
|
|
|
|
const nsRect& aDirtyRect,
|
1999-01-15 21:25:58 +03:00
|
|
|
const nsRect& aBorderArea,
|
1999-01-23 01:22:26 +03:00
|
|
|
const nsStyleSpacing& aBorderStyle,
|
1999-03-05 22:23:52 +03:00
|
|
|
nsIStyleContext* aStyleContext,
|
1998-10-08 08:38:41 +04:00
|
|
|
PRIntn aSkipSides,
|
|
|
|
nsRect* aGap = 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-18 01:58:51 +03:00
|
|
|
/**
|
|
|
|
* Just like PaintBorder, but takes as input a list of border segments
|
|
|
|
* rather than a single border style. Useful for any object that needs to
|
|
|
|
* draw a border where an edge is not necessarily homogenous.
|
|
|
|
* Render the border for an element using css rendering rules
|
|
|
|
* for borders. aSkipSides is a bitmask of the sides to skip
|
|
|
|
* when rendering. If 0 then no sides are skipped.
|
|
|
|
*
|
1999-01-15 21:25:58 +03:00
|
|
|
* Both aDirtyRect and aBorderArea are in the local coordinate space
|
1998-12-18 01:58:51 +03:00
|
|
|
* of aForFrame
|
|
|
|
*/
|
|
|
|
static void PaintBorderEdges(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsIFrame* aForFrame,
|
|
|
|
const nsRect& aDirtyRect,
|
1999-01-15 21:25:58 +03:00
|
|
|
const nsRect& aBorderArea,
|
1998-12-18 01:58:51 +03:00
|
|
|
nsBorderEdges * aBorderEdges,
|
1999-03-05 22:23:52 +03:00
|
|
|
nsIStyleContext* aStyleContext,
|
1998-12-18 01:58:51 +03:00
|
|
|
PRIntn aSkipSides,
|
|
|
|
nsRect* aGap = 0);
|
|
|
|
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* Render the background for an element using css rendering rules
|
|
|
|
* for backgrounds.
|
1998-07-22 09:02:07 +04:00
|
|
|
*
|
1999-01-15 21:25:58 +03:00
|
|
|
* Both aDirtyRect and aBorderArea are in the local coordinate space
|
1998-07-22 09:02:07 +04:00
|
|
|
* of aForFrame
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
static void PaintBackground(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsIFrame* aForFrame,
|
|
|
|
const nsRect& aDirtyRect,
|
1999-01-15 21:25:58 +03:00
|
|
|
const nsRect& aBorderArea,
|
1998-09-26 21:16:56 +04:00
|
|
|
const nsStyleColor& aColor,
|
1999-01-15 21:25:58 +03:00
|
|
|
const nsStyleSpacing& aStyle,
|
1998-09-26 21:16:56 +04:00
|
|
|
nscoord aDX,
|
|
|
|
nscoord aDY);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-17 04:35:32 +04:00
|
|
|
static void DrawDashedSides(PRIntn startSide,
|
|
|
|
nsIRenderingContext& aContext,
|
|
|
|
const PRUint8 borderStyles[],
|
1998-12-07 22:04:39 +03:00
|
|
|
const nscolor borderColors[],
|
|
|
|
const nsRect& borderOutside,
|
|
|
|
const nsRect& borderInside,
|
|
|
|
PRIntn aSkipSides,
|
|
|
|
nsRect* aGap);
|
|
|
|
|
|
|
|
static void DrawDashedSides(PRIntn startSide,
|
|
|
|
nsIRenderingContext& aContext,
|
|
|
|
const nsStyleSpacing& aSpacing,
|
1998-10-17 04:35:32 +04:00
|
|
|
const nsRect& borderOutside,
|
|
|
|
const nsRect& borderInside,
|
|
|
|
PRIntn aSkipSides,
|
|
|
|
nsRect* aGap);
|
|
|
|
|
1998-12-30 09:47:26 +03:00
|
|
|
/** draw the dashed segements of a segmented border */
|
|
|
|
//XXX: boy is it annoying that we have 3 methods to draw dashed sides!
|
|
|
|
// they clearly can be factored.
|
|
|
|
static void DrawDashedSegments(nsIRenderingContext& aContext,
|
|
|
|
const nsRect& aBounds,
|
|
|
|
nsBorderEdges * aBorderEdges,
|
|
|
|
PRIntn aSkipSides,
|
|
|
|
nsRect* aGap);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
static nscolor MakeBevelColor(PRIntn whichSide, PRUint8 style,
|
1999-01-23 01:22:26 +03:00
|
|
|
nscolor aBackgroundColor,
|
1999-03-05 22:23:52 +03:00
|
|
|
nscolor aBorderColor,
|
|
|
|
PRBool aSpecialCase);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
static PRIntn MakeSide(nsPoint aPoints[],
|
|
|
|
nsIRenderingContext& aContext,
|
|
|
|
PRIntn whichSide,
|
1998-06-18 09:43:32 +04:00
|
|
|
const nsRect& outside, const nsRect& inside,
|
1998-06-18 02:14:20 +04:00
|
|
|
PRIntn borderPart, float borderFrac,
|
|
|
|
nscoord twipsPerPixel);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
static void DrawSide(nsIRenderingContext& aContext,
|
|
|
|
PRIntn whichSide,
|
1998-12-07 22:04:39 +03:00
|
|
|
const PRUint8 borderStyle,
|
|
|
|
const nscolor borderColor,
|
1999-03-05 22:23:52 +03:00
|
|
|
const nscolor aBackgroundColor,
|
|
|
|
const nsRect& borderOutside,
|
1998-05-27 00:52:59 +04:00
|
|
|
const nsRect& borderInside,
|
1998-10-08 08:38:41 +04:00
|
|
|
nscoord twipsPerPixel,
|
|
|
|
nsRect* aGap = 0);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-07 22:04:39 +03:00
|
|
|
|
1998-10-08 08:38:41 +04:00
|
|
|
static void DrawLine (nsIRenderingContext& aContext,
|
|
|
|
nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2,
|
|
|
|
nsRect* aGap);
|
|
|
|
|
|
|
|
static void FillPolygon (nsIRenderingContext& aContext,
|
|
|
|
const nsPoint aPoints[],
|
|
|
|
PRInt32 aNumPoints,
|
|
|
|
nsRect* aGap);
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsCSSRendering_h___ */
|