b=368247 (and others, see bug), rewrite border rendering for thebes, r=dbaron

This commit is contained in:
vladimir%pobox.com 2007-05-01 03:31:25 +00:00
Родитель 7167217479
Коммит 5dedab3707
8 изменённых файлов: 1534 добавлений и 1689 удалений

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

@ -140,6 +140,12 @@ public:
*/
void MoveTo(const gfxPoint& pt);
/**
* Creates a new subpath starting at the current point.
* Equivalent to MoveTo(CurrentPoint()).
*/
void NewSubPath();
/**
* Returns the current point in the current path.
*/

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

@ -67,7 +67,6 @@ struct THEBES_API gfxRect {
return gfxRect(pos + aPt, size);
}
const gfxPoint& TopLeft() const { return pos; }
gfxFloat Width() const { return size.width; }
gfxFloat Height() const { return size.height; }
gfxFloat X() const { return pos.x; }
@ -79,6 +78,14 @@ struct THEBES_API gfxRect {
gfxRect Intersect(const gfxRect& aRect) const;
gfxRect Union(const gfxRect& aRect) const;
// XXX figure out what methods (intersect, union, etc) we use and add them.
void Round();
// grabbing specific points
gfxPoint TopLeft() const { return gfxPoint(pos); }
gfxPoint TopRight() const { return pos + gfxSize(size.width, 0.0); }
gfxPoint BottomLeft() const { return pos + gfxSize(0.0, size.height); }
gfxPoint BottomRight() const { return pos + size; }
};
#endif /* GFX_RECT_H */

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

@ -140,6 +140,12 @@ gfxContext::MoveTo(const gfxPoint& pt)
cairo_move_to(mCairo, pt.x, pt.y);
}
void
gfxContext::NewSubPath()
{
cairo_new_sub_path(mCairo);
}
void
gfxContext::LineTo(const gfxPoint& pt)
{

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

@ -37,7 +37,10 @@
#include "gfxRect.h"
gfxRect gfxRect::Intersect(const gfxRect& aRect) const
#include <math.h>
gfxRect
gfxRect::Intersect(const gfxRect& aRect) const
{
gfxRect result(0,0,0,0);
@ -55,7 +58,8 @@ gfxRect gfxRect::Intersect(const gfxRect& aRect) const
return result;
}
gfxRect gfxRect::Union(const gfxRect& aRect) const
gfxRect
gfxRect::Union(const gfxRect& aRect) const
{
if (IsEmpty())
return aRect;
@ -68,3 +72,18 @@ gfxRect gfxRect::Union(const gfxRect& aRect) const
gfxFloat ymost = PR_MAX(aRect.YMost(), YMost());
return gfxRect(x, y, xmost - x, ymost - y);
}
void
gfxRect::Round()
{
gfxFloat x0 = floor(X() + 0.5);
gfxFloat y0 = floor(Y() + 0.5);
gfxFloat x1 = floor(XMost() + 0.5);
gfxFloat y1 = floor(YMost() + 0.5);
pos.x = x0;
pos.y = y0;
size.width = x1 - x0;
size.height = y1 - y0;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -93,31 +93,8 @@ public:
const nsStyleBorder& aBorderStyle,
const nsStyleOutline& aOutlineStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* 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.
*
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintBorderEdges(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
nsBorderEdges * aBorderEdges,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
nsRect* aGap = 0);
/**
* Fill in an nsStyleBackground to be used to paint the background for
* an element. The nsStyleBackground should first be initialized
@ -202,15 +179,6 @@ public:
PRIntn aSkipSides,
nsRect* aGap);
/** 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);
// Draw a border segment in the table collapsing border model without beveling corners
static void DrawTableBorderSegment(nsIRenderingContext& aContext,
PRUint8 aBorderStyle,
@ -231,29 +199,6 @@ public:
static nscolor TransformColor(nscolor aMapColor,PRBool aNoBackGround);
protected:
/**
* 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.
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
static void PaintRoundedBorder(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
const nsStyleBorder* aBorderStyle,
const nsStyleOutline* aOutlineStyle,
nsStyleContext* aStyleContext,
PRIntn aSkipSides,
PRInt16 aBorderRadius[4],nsRect* aGap = 0,
PRBool aIsOutline=PR_FALSE);
static void RenderSide(nsFloatPoint aPoints[],nsIRenderingContext& aRenderingContext,
const nsStyleBorder* aBorderStyle,const nsStyleOutline* aOutlineStyle,nsStyleContext* aStyleContext,
PRUint8 aSide,nsMargin &aBorThick,nscoord aTwipsPerPixel,
PRBool aIsOutline=PR_FALSE);
static void PaintBackgroundColor(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -277,35 +222,6 @@ protected:
nscolor aBackgroundColor,
nscolor aBorderColor);
static PRIntn MakeSide(nsPoint aPoints[],
nsIRenderingContext& aContext,
PRIntn whichSide,
const nsRect& outside, const nsRect& inside,
PRIntn aSkipSides,
PRIntn borderPart, float borderFrac,
nscoord twipsPerPixel);
static void DrawSide(nsIRenderingContext& aContext,
PRIntn whichSide,
const PRUint8 borderStyle,
const nscolor borderColor,
const nscolor aBackgroundColor,
const nsRect& borderOutside,
const nsRect& borderInside,
PRIntn aSkipSides,
nscoord twipsPerPixel,
nsRect* aGap = 0);
static void DrawCompositeSide(nsIRenderingContext& aContext,
PRIntn aWhichSide,
nsBorderColors* aCompositeColors,
const nsRect& aOuterRect,
const nsRect& aInnerRect,
PRInt16* aBorderRadii,
nscoord aTwipsPerPixel,
nsRect* aGap);
static void DrawLine (nsIRenderingContext& aContext,
nscoord aX1, nscoord aY1, nscoord aX2, nscoord aY2,
nsRect* aGap);

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

@ -33,7 +33,7 @@ div { background: green; }
<div style="left: 351px"></div>
<div style="left: 371px"></div>
<div style="top: 30px; left: 11px; width: 31px; height: 30px">
<div style="top: 30px; left: 11px; width: 30px; height: 30px">
<div style="background:white; top: 10px; left: 10px"></div>
</div>

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

@ -32,22 +32,23 @@ random == check-image.html check-image-ref.html # bug 371232
== background-color-width-left-6.html background-color-width-6.html
# The cocoa failures are due to bug 379317
!= border-base-ref.html border-height-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-4.html border-base-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-5.html border-height-10-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-6.html border-height-10-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-4.html border-base-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-5.html border-height-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-height-6.html border-height-10-ref.html
!= border-base-ref.html border-width-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-width-4.html border-base-ref.html # bug 361523
fails == border-width-5.html border-width-10-ref.html # bug 363220; bug 361523 on Mac
fails == border-width-6.html border-width-10-ref.html # bug 363220; bug 361523 on Mac
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-width-4.html border-base-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-width-5.html border-width-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-width-6.html border-width-10-ref.html
!= border-base-ref.html border-left-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-left-4.html border-base-ref.html # bug 361523
fails == border-left-5.html border-left-10-ref.html # bug 363220; bug 361523 on Mac
fails == border-left-6.html border-left-10-ref.html # bug 363220; bug 361523 on Mac
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-left-4.html border-base-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-left-5.html border-left-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-left-6.html border-left-10-ref.html
!= border-base-ref.html border-top-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-4.html border-base-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-5.html border-top-10-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-6.html border-top-10-ref.html # bug 361523
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-4.html border-base-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-5.html border-top-10-ref.html
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == border-top-6.html border-top-10-ref.html
!= background-image-base.html background-image-height-10-ref.html