Bug 641426. Part 5: Avoid operator== where possible to distinguish between 'equal edges' and 'equal areas' for rectangles. r=dbaron,sr=cjones

This commit is contained in:
Robert O'Callahan 2011-04-19 15:07:23 +12:00
parent 763a5f47a7
commit c957ae039e
50 changed files with 137 additions and 122 deletions

View File

@ -7289,7 +7289,7 @@ nsDocShell::RestoreFromHistory()
// cached viewer size (skipping the resize if they are equal).
if (newRootView) {
if (!newBounds.IsEmpty() && newBounds != oldBounds) {
if (!newBounds.IsEmpty() && !newBounds.IsEqualEdges(oldBounds)) {
#ifdef DEBUG_PAGE_CACHE
printf("resize widget(%d, %d, %d, %d)\n", newBounds.x,
newBounds.y, newBounds.width, newBounds.height);

View File

@ -300,7 +300,7 @@ nsDOMWindowUtils::SetDisplayPortForElement(float aXPx, float aYPx,
nsRect lastDisplayPort;
if (nsLayoutUtils::GetDisplayPort(content, &lastDisplayPort) &&
displayport == lastDisplayPort) {
displayport.IsEqualInterior(lastDisplayPort)) {
return NS_OK;
}

View File

@ -108,9 +108,9 @@ public:
PRBool operator==(const FrameMetrics& aOther) const
{
return (mViewport == aOther.mViewport &&
return (mViewport.IsEqualEdges(aOther.mViewport) &&
mViewportScrollOffset == aOther.mViewportScrollOffset &&
mDisplayPort == aOther.mDisplayPort &&
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
mScrollId == aOther.mScrollId);
}

View File

@ -265,7 +265,7 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
}
if ((aFlags & PAINT_WILL_RESAMPLE) &&
(neededRegion.GetBounds() != destBufferRect ||
(!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
neededRegion.GetNumRects() > 1)) {
// The area we add to neededRegion might not be painted opaquely
contentType = gfxASurface::CONTENT_COLOR_ALPHA;

View File

@ -467,7 +467,7 @@ ClipToContain(gfxContext* aContext, const nsIntRect& aRect)
aContext->Clip();
aContext->SetMatrix(currentMatrix);
return aContext->DeviceToUser(deviceRect) == userRect;
return aContext->DeviceToUser(deviceRect).IsEqualInterior(userRect);
}
static nsIntRegion

View File

@ -194,7 +194,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
// doesn't fill the entire texture rect we need to make sure we draw all the
// pixels in the texture rect anyway in case they get sampled.
nsIntRegion neededRegion = mVisibleRegion;
if (neededRegion.GetBounds() != newTextureRect ||
if (!neededRegion.GetBounds().IsEqualInterior(newTextureRect) ||
neededRegion.GetNumRects() > 1) {
gfxMatrix transform2d;
if (!GetEffectiveTransform().Is2D(&transform2d) ||
@ -228,7 +228,7 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
}
if (mTexture) {
if (mTextureRect != newTextureRect) {
if (!mTextureRect.IsEqualInterior(newTextureRect)) {
nsRefPtr<ID3D10Texture2D> oldTexture = mTexture;
mTexture = nsnull;
nsRefPtr<ID3D10Texture2D> oldTextureOnWhite = mTextureOnWhite;

View File

@ -138,7 +138,7 @@ ThebesLayerD3D9::UpdateTextures(SurfaceMode aMode)
}
if (HaveTextures(aMode)) {
if (mTextureRect != visibleRect) {
if (!mTextureRect.IsEqualInterior(visibleRect)) {
nsRefPtr<IDirect3DTexture9> oldTexture = mTexture;
nsRefPtr<IDirect3DTexture9> oldTextureOnWhite = mTextureOnWhite;
@ -221,7 +221,7 @@ ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback)
// doesn't fill the entire texture rect we need to make sure we draw all the
// pixels in the texture rect anyway in case they get sampled.
nsIntRegion neededRegion = mVisibleRegion;
if (neededRegion.GetBounds() != newTextureRect ||
if (!neededRegion.GetBounds().IsEqualInterior(newTextureRect) ||
neededRegion.GetNumRects() > 1) {
gfxMatrix transform2d;
if (!GetEffectiveTransform().Is2D(&transform2d) ||

View File

@ -485,7 +485,7 @@ BasicBufferOGL::BeginPaint(ContentType aContentType,
}
if ((aFlags & PAINT_WILL_RESAMPLE) &&
(neededRegion.GetBounds() != destBufferRect ||
(!neededRegion.GetBounds().IsEqualInterior(destBufferRect) ||
neededRegion.GetNumRects() > 1)) {
// The area we add to neededRegion might not be painted opaquely
if (mode == Layer::SURFACE_OPAQUE) {

View File

@ -124,13 +124,13 @@ PRBool nsRect::UnionRect(const nsRect &aRect1, const nsRect &aRect2)
// aRect2 is empty so set the result to aRect1
*this = aRect1;
} else {
UnionRectIncludeEmpty(aRect1, aRect2);
UnionRectEdges(aRect1, aRect2);
}
return result;
}
void nsRect::UnionRectIncludeEmpty(const nsRect &aRect1, const nsRect &aRect2)
void nsRect::UnionRectEdges(const nsRect &aRect1, const nsRect &aRect2)
{
nscoord xmost1 = aRect1.XMost();
nscoord xmost2 = aRect2.XMost();

View File

@ -85,37 +85,42 @@ struct NS_GFX nsRect {
}
void Empty() {width = height = 0;}
// Containment
// Returns true if this rectangle contains the interior of aRect. Always
// returns true if aRect is empty, and always returns false is aRect is
// nonempty but this rect is empty.
PRBool Contains(const nsRect& aRect) const;
// Returns true if this rectangle contains the given point; if the point
// is on the edge of the rectangle, this returns true.
PRBool Contains(nscoord aX, nscoord aY) const;
PRBool Contains(const nsPoint& aPoint) const {return Contains(aPoint.x, aPoint.y);}
// Intersection. Returns TRUE if the receiver overlaps aRect and
// FALSE otherwise
// Intersection. Returns TRUE if the receiver's area has non-empty
// intersection with aRect's area, and FALSE otherwise.
// Always returns false if aRect is empty or 'this' is empty.
PRBool Intersects(const nsRect& aRect) const;
// Computes the area in which aRect1 and aRect2 overlap, and fills 'this' with
// the result. Returns FALSE if the rectangles don't intersect, and sets 'this'
// rect to be an empty rect.
// Sets 'this' to be a rectangle containing the intersection of the points
// (including edges) of aRect1 and aRect2, or 0,0,0,0 if that intersection is
// empty. Returns false if the resulting rectangle is empty.
//
// 'this' can be the same object as either aRect1 or aRect2
PRBool IntersectRect(const nsRect& aRect1, const nsRect& aRect2);
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
// fills 'this' with the result, ignoring empty input rectangles.
// Computes the smallest rectangle that contains both the area of both
// aRect1 and aRect2, and fills 'this' with the result.
// Thus, empty input rectangles are ignored.
// Returns FALSE and sets 'this' rect to be an empty rect if both aRect1
// and aRect2 are empty.
//
// 'this' can be the same object as either aRect1 or aRect2
PRBool UnionRect(const nsRect& aRect1, const nsRect& aRect2);
// Computes the smallest rectangle that contains both aRect1 and aRect2,
// where empty input rectangles are allowed to affect the result; the
// top-left of an empty input rectangle will be inside or on the edge of
// the result.
// Computes the smallest rectangle that contains both the points (including
// edges) of both aRect1 and aRect2.
// Thus, empty input rectangles are allowed to affect the result.
//
// 'this' can be the same object as either aRect1 or aRect2
void UnionRectIncludeEmpty(const nsRect& aRect1, const nsRect& aRect2);
void UnionRectEdges(const nsRect& aRect1, const nsRect& aRect2);
// Accessors
void SetRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) {
@ -143,23 +148,19 @@ struct NS_GFX nsRect {
void Deflate(const nsSize& aSize) {Deflate(aSize.width, aSize.height);}
void Deflate(const nsMargin& aMargin);
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator.
PRBool operator==(const nsRect& aRect) const {
return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
((x == aRect.x) && (y == aRect.y) &&
(width == aRect.width) && (height == aRect.height)));
}
PRBool operator!=(const nsRect& aRect) const {
return (PRBool) !operator==(aRect);
}
// Useful when we care about the exact x/y/width/height values being
// equal (i.e. we care about differences in empty rectangles)
PRBool IsExactEqual(const nsRect& aRect) const {
// Return true if the rectangles contain the same set of points, including
// points on the edges.
// Use when we care about the exact x/y/width/height values being
// equal (i.e. we care about differences in empty rectangles).
PRBool IsEqualEdges(const nsRect& aRect) const {
return x == aRect.x && y == aRect.y &&
width == aRect.width && height == aRect.height;
}
// Return true if the rectangles contain the same area of the plane.
// Use when we do not care about differences in empty rectangles.
PRBool IsEqualInterior(const nsRect& aRect) const {
return IsEqualEdges(aRect) || (IsEmpty() && aRect.IsEmpty());
}
// Arithmetic with nsPoints
nsRect operator+(const nsPoint& aPoint) const {
@ -265,12 +266,21 @@ struct NS_GFX nsIntRect {
// Overloaded operators. Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator.
PRBool operator==(const nsIntRect& aRect) const {
return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
((x == aRect.x) && (y == aRect.y) &&
(width == aRect.width) && (height == aRect.height)));
return IsEqualEdges(aRect);
}
PRBool operator!=(const nsIntRect& aRect) const {
return (PRBool) !operator==(aRect);
// Return true if the rectangles contain the same set of points, including
// points on the edges.
// Use when we care about the exact x/y/width/height values being
// equal (i.e. we care about differences in empty rectangles).
PRBool IsEqualEdges(const nsIntRect& aRect) const {
return x == aRect.x && y == aRect.y &&
width == aRect.width && height == aRect.height;
}
// Return true if the rectangles contain the same area of the plane.
// Use when we do not care about differences in empty rectangles.
PRBool IsEqualInterior(const nsIntRect& aRect) const {
return IsEqualEdges(aRect) || (IsEmpty() && aRect.IsEmpty());
}
nsIntRect operator+(const nsIntPoint& aPoint) const {

View File

@ -1151,7 +1151,7 @@ void nsRegion::SubRect (const nsRectFast& aRect, nsRegion& aResult, nsRegion& aC
{
aResult.InsertInPlace (new RgnRect (ixm, ay, axm - ixm, ah));
} else
if (*pSrcRect == aRect) // 4. subset
if (pSrcRect->IsEqualInterior(aRect)) // 4. subset
{ // Current rectangle is equal to aRect
pSrcRect = pSrcRect->next; // don't add this one to the result, it's removed
break; // No any other rectangle in region can intersect it
@ -1261,10 +1261,10 @@ PRBool nsRegion::IsEqual (const nsRegion& aRegion) const
return (mRectCount == 0) ? PR_TRUE : PR_FALSE;
if (mRectCount == 1 && aRegion.mRectCount == 1) // Both regions are simple rectangles
return (*mRectListHead.next == *aRegion.mRectListHead.next);
return (mRectListHead.next->IsEqualInterior(*aRegion.mRectListHead.next));
else // At least one is complex region.
{
if (mBoundRect != aRegion.mBoundRect) // If regions are equal then bounding rectangles should match
if (!mBoundRect.IsEqualInterior(aRegion.mBoundRect)) // If regions are equal then bounding rectangles should match
return PR_FALSE;
else
{

View File

@ -41,7 +41,7 @@
class TestLargestRegion {
static PRBool TestSingleRect(nsRect r) {
nsRegion region(r);
if (region.GetLargestRectangle() != r) {
if (!region.GetLargestRectangle().IsEqualInterior(r)) {
fail("largest rect of singleton %d %d %d %d", r.x, r.y, r.width, r.height);
return PR_FALSE;
}
@ -134,7 +134,7 @@ class TestLargestRegion {
static PRBool TestContainsSpecifiedRect() {
nsRegion r(nsRect(0, 0, 100, 100));
r.Or(r, nsRect(0, 300, 50, 50));
if (r.GetLargestRectangle(nsRect(0, 300, 10, 10)) != nsRect(0, 300, 50, 50)) {
if (!r.GetLargestRectangle(nsRect(0, 300, 10, 10)).IsEqualInterior(nsRect(0, 300, 50, 50))) {
fail("Chose wrong rectangle");
return PR_FALSE;
}
@ -143,7 +143,7 @@ class TestLargestRegion {
static PRBool TestContainsSpecifiedOverflowingRect() {
nsRegion r(nsRect(0, 0, 100, 100));
r.Or(r, nsRect(0, 300, 50, 50));
if (r.GetLargestRectangle(nsRect(0, 290, 10, 20)) != nsRect(0, 300, 50, 50)) {
if (!r.GetLargestRectangle(nsRect(0, 290, 10, 20)).IsEqualInterior(nsRect(0, 300, 50, 50))) {
fail("Chose wrong rectangle");
return PR_FALSE;
}

View File

@ -1147,7 +1147,7 @@ public:
nsIntRect thisRect = ScissorRect();
mScissorStack.TruncateLength(mScissorStack.Length() - 1);
if (thisRect != ScissorRect()) {
if (!thisRect.IsEqualInterior(ScissorRect())) {
raw_fScissor(ScissorRect().x, ScissorRect().y,
ScissorRect().width, ScissorRect().height);
}
@ -1198,7 +1198,7 @@ public:
nsIntRect thisRect = ViewportRect();
mViewportStack.TruncateLength(mViewportStack.Length() - 1);
if (thisRect != ViewportRect()) {
if (!thisRect.IsEqualInterior(ViewportRect())) {
raw_fViewport(ViewportRect().x, ViewportRect().y,
ViewportRect().width, ViewportRect().height);
}

View File

@ -95,7 +95,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
nsIntRect shadowIntRect;
gfxUtils::GfxRectToIntRect(rect, &shadowIntRect);
mSkipRect.IntersectRect(mSkipRect, shadowIntRect);
if (mSkipRect == shadowIntRect)
if (mSkipRect.IsEqualInterior(shadowIntRect))
return nsnull;
mSkipRect -= shadowIntRect.TopLeft();

View File

@ -275,7 +275,7 @@ gfxImageSurface::MovePixels(const nsIntRect& aSourceRect,
source.Size() == dest.Size() &&
offset == (dest.TopLeft() - source.TopLeft()),
"Messed up clipping, crash or corruption will follow");
if (source.IsEmpty() || source == dest) {
if (source.IsEmpty() || source.IsEqualInterior(dest)) {
return;
}

View File

@ -87,8 +87,14 @@ struct THEBES_API gfxRect
int operator==(const gfxRect& s) const {
return x == s.x && y == s.y && width == s.width && height == s.height;
}
int operator!=(const gfxRect& s) const {
return !(*this == s);
PRBool IsEqualEdges(const gfxRect& aRect) const {
return x == aRect.x && y == aRect.y &&
width == aRect.width && height == aRect.height;
}
// Return true if the rectangles contain the same area of the plane.
// Use when we do not care about differences in empty rectangles.
PRBool IsEqualInterior(const gfxRect& aRect) const {
return IsEqualEdges(aRect) || (IsEmpty() && aRect.IsEmpty());
}
void MoveTo(const gfxPoint& aPt) { x = aPt.x; y = aPt.y; }

View File

@ -514,6 +514,6 @@ gfxUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut)
{
*aOut = nsIntRect(PRInt32(aIn.X()), PRInt32(aIn.Y()),
PRInt32(aIn.Width()), PRInt32(aIn.Height()));
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height) == aIn;
return gfxRect(aOut->x, aOut->y, aOut->width, aOut->height).IsEqualEdges(aIn);
}

View File

@ -130,7 +130,7 @@ _get_rectangular_clip (cairo_t *cr,
goto FINISH;
}
if (rect == bounds) {
if (rect.IsEqualInterior(bounds)) {
/* the bounds are entirely inside the clip region so we don't need to clip. */
*need_clip = PR_FALSE;
goto FINISH;

View File

@ -1651,7 +1651,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder,
state.Finish(&flags);
nsRect bounds = state.GetChildrenBounds();
NS_ASSERTION(bounds == aChildren.GetBounds(aBuilder), "Wrong bounds");
NS_ASSERTION(bounds.IsEqualInterior(aChildren.GetBounds(aBuilder)), "Wrong bounds");
nsIntRect pixBounds = bounds.ToOutsidePixels(appUnitsPerDevPixel);
containerLayer->SetVisibleRegion(pixBounds);
// Make sure that rounding the visible region out didn't add any area

View File

@ -307,7 +307,7 @@ public:
nscoord mRadii[8];
bool operator==(const RoundedRect& aOther) const {
if (mRect != aOther.mRect) {
if (!mRect.IsEqualInterior(aOther.mRect)) {
return false;
}
@ -354,7 +354,7 @@ public:
bool operator==(const Clip& aOther) const {
return mHaveClipRect == aOther.mHaveClipRect &&
(!mHaveClipRect || mClipRect == aOther.mClipRect) &&
(!mHaveClipRect || mClipRect.IsEqualInterior(aOther.mClipRect)) &&
mRoundedClipRects == aOther.mRoundedClipRects;
}
bool operator!=(const Clip& aOther) const {

View File

@ -38,7 +38,7 @@ load 254367-1.html
load 265027-1.html
load 265736-1.html
load 265736-2.html
asserts(4) load 265899-1.html # bug 575011
asserts(2) load 265899-1.html # bug 575011
load 265973-1.html
asserts(8-12) load 265986-1.html # Bug 512405
asserts(4) load 265999-1.html # bug 575011

View File

@ -443,7 +443,7 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
#ifdef DEBUG
nsRegion r;
r.And(*aVisibleRegion, GetBounds(aBuilder));
NS_ASSERTION(r.GetBounds() == aListVisibleBounds,
NS_ASSERTION(r.GetBounds().IsEqualInterior(aListVisibleBounds),
"bad aListVisibleBounds");
#endif
mVisibleRect = aListVisibleBounds;
@ -1919,7 +1919,7 @@ PRBool nsDisplayClip::TryMerge(nsDisplayListBuilder* aBuilder,
if (aItem->GetType() != TYPE_CLIP)
return PR_FALSE;
nsDisplayClip* other = static_cast<nsDisplayClip*>(aItem);
if (other->mClip != mClip)
if (!other->mClip.IsEqualInterior(mClip))
return PR_FALSE;
mList.AppendToBottom(&other->mList);
return PR_TRUE;
@ -2015,7 +2015,7 @@ PRBool nsDisplayClipRoundedRect::TryMerge(nsDisplayListBuilder* aBuilder, nsDisp
return PR_FALSE;
nsDisplayClipRoundedRect* other =
static_cast<nsDisplayClipRoundedRect*>(aItem);
if (mClip != other->mClip ||
if (!mClip.IsEqualInterior(other->mClip) ||
memcmp(mRadii, other->mRadii, sizeof(mRadii)) != 0)
return PR_FALSE;
mList.AppendToBottom(&other->mList);

View File

@ -204,7 +204,7 @@ NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
return NS_OK;
}
nsRect r = (*aDirtyRect == nsIntRect::GetMaxSizedIntRect()) ?
nsRect r = aDirtyRect->IsEqualInterior(nsIntRect::GetMaxSizedIntRect()) ?
nsRect(nsPoint(0, 0), mFrame->GetSize()) :
aDirtyRect->ToAppUnits(nsPresContext::AppUnitsPerCSSPixel());

View File

@ -483,7 +483,7 @@ public:
* nscoord units (as scaled by the device context).
*/
void SetVisibleArea(const nsRect& r) {
if (!r.IsExactEqual(mVisibleArea)) {
if (!r.IsEqualEdges(mVisibleArea)) {
mVisibleArea = r;
// Visible area does not affect media queries when paginated.
if (!IsPaginated() && HasCachedStyleData())

View File

@ -4026,7 +4026,7 @@ AccumulateFrameBounds(nsIFrame* aContainerFrame,
// We can't use nsRect::UnionRect since it drops empty rects on
// the floor, and we need to include them. (Thus we need
// aHaveRect to know when to drop the initial value on the floor.)
aRect.UnionRectIncludeEmpty(aRect, frameBounds);
aRect.UnionRectEdges(aRect, frameBounds);
} else {
aHaveRect = PR_TRUE;
aRect = frameBounds;
@ -7723,13 +7723,13 @@ PresShell::DoReflow(nsIFrame* target, PRBool aInterruptible)
desiredSize.height == size.height),
"non-root frame's desired size changed during an "
"incremental reflow");
NS_ASSERTION(desiredSize.VisualOverflow() ==
NS_ASSERTION(desiredSize.VisualOverflow().IsEqualInterior(
nsRect(nsPoint(0, 0),
nsSize(desiredSize.width, desiredSize.height)),
nsSize(desiredSize.width, desiredSize.height))),
"reflow roots must not have visible overflow");
NS_ASSERTION(desiredSize.ScrollableOverflow() ==
NS_ASSERTION(desiredSize.ScrollableOverflow().IsEqualEdges(
nsRect(nsPoint(0, 0),
nsSize(desiredSize.width, desiredSize.height)),
nsSize(desiredSize.width, desiredSize.height))),
"reflow roots must not have scrollable overflow");
NS_ASSERTION(status == NS_FRAME_COMPLETE,
"reflow roots should never split");
@ -8193,7 +8193,7 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
}
else if (nsnull != k1) {
// Verify that the frames are the same size
if (k1->GetRect() != k2->GetRect()) {
if (!k1->GetRect().IsEqualInterior(k2->GetRect())) {
ok = PR_FALSE;
LogVerifyMessage(k1, k2, "(frame rects)", k1->GetRect(), k2->GetRect());
}
@ -8210,7 +8210,7 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
LogVerifyMessage(k1, k2, "child views are not matched\n");
}
else if (nsnull != v1) {
if (v1->GetBounds() != v2->GetBounds()) {
if (!v1->GetBounds().IsEqualInterior(v2->GetBounds())) {
LogVerifyMessage(k1, k2, "(view rects)", v1->GetBounds(), v2->GetBounds());
}
@ -8224,7 +8224,7 @@ CompareTrees(nsPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
else if (nsnull != w1) {
w1->GetBounds(r1);
w2->GetBounds(r2);
if (r1 != r2) {
if (!r1.IsEqualEdges(r2)) {
LogVerifyMessage(k1, k2, "(widget rects)", r1, r2);
}
}

View File

@ -254,7 +254,7 @@ load 461294-1.html
load 463350-1.html
load 463350-2.html
load 463350-3.html
asserts(6-8) load 463741-1.html # Bug 575011
load 463741-1.html
load 465651-1.html
load 467137-1.html
load 467213-1.html

View File

@ -5917,7 +5917,7 @@ nsBlockFrame::ReflowPushedFloats(nsBlockReflowState& aState,
// Invalidate if there was a position or size change
nsRect rect = f->GetRect();
if (rect != oldRect) {
if (!rect.IsEqualInterior(oldRect)) {
nsRect dirtyRect = oldOverflow;
dirtyRect.MoveBy(oldRect.x, oldRect.y);
Invalidate(dirtyRect);

View File

@ -886,7 +886,7 @@ nsBlockReflowState::FlowAndPlaceFloat(nsIFrame* aFloat)
// If the float's dimensions have changed, note the damage in the
// float manager.
if (region != oldRegion) {
if (!region.IsEqualEdges(oldRegion)) {
// XXXwaterson conservative: we could probably get away with noting
// less damage; e.g., if only height has changed, then only note the
// area into which the float has grown or from which the float has

View File

@ -941,7 +941,7 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
// Invalidate if there was a position or size change
nsRect rect = frame->GetRect();
if (rect != oldRect) {
if (!rect.IsEqualInterior(oldRect)) {
nsRect dirtyRect = oldOverflow;
dirtyRect.MoveBy(oldRect.x, oldRect.y);
Invalidate(dirtyRect);

View File

@ -345,7 +345,7 @@ nsFloatManager::StoreRegionFor(nsIFrame* aFloat,
nsresult rv = NS_OK;
nsRect rect = aFloat->GetRect();
FrameProperties props = aFloat->Properties();
if (aRegion == rect) {
if (aRegion.IsEqualEdges(rect)) {
props.Delete(FloatRegionProperty());
}
else {

View File

@ -6127,7 +6127,7 @@ nsIFrame::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
t = -vis.y, // top: positive is upwards
r = vis.XMost() - mRect.width, // right: positive is rightwards
b = vis.YMost() - mRect.height; // bottom: positive is downwards
if (aOverflowAreas.ScrollableOverflow() == nsRect(nsPoint(0, 0), GetSize()) &&
if (aOverflowAreas.ScrollableOverflow().IsEqualEdges(nsRect(nsPoint(0, 0), GetSize())) &&
l <= NS_FRAME_OVERFLOW_DELTA_MAX &&
t <= NS_FRAME_OVERFLOW_DELTA_MAX &&
r <= NS_FRAME_OVERFLOW_DELTA_MAX &&
@ -6202,7 +6202,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
if (aNewSize.width != 0 || !IsInlineFrame(this)) {
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = aOverflowAreas.Overflow(otype);
o.UnionRectIncludeEmpty(o, bounds);
o.UnionRectEdges(o, bounds);
}
}
@ -6216,7 +6216,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
disp->mAppearance, &r)) {
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
nsRect& o = aOverflowAreas.Overflow(otype);
o.UnionRectIncludeEmpty(o, r);
o.UnionRectEdges(o, r);
}
}
}
@ -6260,7 +6260,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
}
PRBool visualOverflowChanged =
GetVisualOverflowRect() != aOverflowAreas.VisualOverflow();
!GetVisualOverflowRect().IsEqualInterior(aOverflowAreas.VisualOverflow());
if (aOverflowAreas != nsOverflowAreas(bounds, bounds)) {
SetOverflowAreas(aOverflowAreas);

View File

@ -606,7 +606,7 @@ nsFrameUtil::CompareTrees(Node* tree1, Node* tree2)
DumpNode(tree2, stdout, 1);
result = PR_FALSE; // we have a non-critical failure, so remember that but continue
}
if (tree1->bbox != tree2->bbox) {
if (tree1->bbox.IsEqualInterior(tree2->bbox)) {
printf("frame bbox mismatch: %d,%d,%d,%d vs. %d,%d,%d,%d\n",
tree1->bbox.x, tree1->bbox.y,
tree1->bbox.width, tree1->bbox.height,

View File

@ -219,7 +219,7 @@ nsHTMLScrollFrame::InvalidateInternal(const nsRect& aDamageRect,
// can contain content outside the scrollport that may need to be
// invalidated.
nsRect thebesLayerDamage = damage + GetScrollPosition() - mInner.mScrollPosAtLastPaint;
if (parentDamage == thebesLayerDamage) {
if (parentDamage.IsEqualInterior(thebesLayerDamage)) {
// This single call will take care of both rects
nsHTMLContainerFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
} else {
@ -239,7 +239,7 @@ nsHTMLScrollFrame::InvalidateInternal(const nsRect& aDamageRect,
}
}
if (mInner.mIsRoot && parentDamage != damage) {
if (mInner.mIsRoot && !parentDamage.IsEqualInterior(damage)) {
// Make sure we notify our prescontext about invalidations outside
// viewport clipping.
// This is important for things that are snapshotting the viewport,
@ -719,8 +719,8 @@ nsHTMLScrollFrame::PlaceScrollArea(const ScrollReflowState& aState,
// Preserve the width or height of empty rects
nsSize portSize = mInner.mScrollPort.Size();
nsRect scrolledRect = mInner.GetScrolledRectInternal(aState.mContentsOverflowArea, portSize);
scrolledArea.UnionRectIncludeEmpty(scrolledRect,
nsRect(nsPoint(0,0), portSize));
scrolledArea.UnionRectEdges(scrolledRect,
nsRect(nsPoint(0,0), portSize));
// Store the new overflow area. Note that this changes where an outline
// of the scrolled frame would be painted, but scrolled frames can't have
@ -902,8 +902,8 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
(GetStateBits() & NS_FRAME_IS_DIRTY) ||
didHaveHScrollbar != state.mShowHScrollbar ||
didHaveVScrollbar != state.mShowVScrollbar ||
oldScrollAreaBounds != newScrollAreaBounds ||
oldScrolledAreaBounds != newScrolledAreaBounds) {
!oldScrollAreaBounds.IsEqualEdges(newScrollAreaBounds) ||
!oldScrolledAreaBounds.IsEqualEdges(newScrolledAreaBounds)) {
if (!mInner.mSupppressScrollbarUpdate) {
mInner.mSkippedScrollbarLayout = PR_FALSE;
mInner.SetScrollbarVisibility(mInner.mHScrollbarBox, state.mShowHScrollbar);
@ -934,7 +934,7 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
mInner.mHadNonInitialReflow = PR_TRUE;
}
if (mInner.mIsRoot && oldScrolledAreaBounds != newScrolledAreaBounds) {
if (mInner.mIsRoot && !oldScrolledAreaBounds.IsEqualEdges(newScrolledAreaBounds)) {
mInner.PostScrolledAreaEvent();
}
@ -1138,7 +1138,7 @@ nsXULScrollFrame::InvalidateInternal(const nsRect& aDamageRect,
// can contain content outside the scrollport that may need to be
// invalidated.
nsRect thebesLayerDamage = damage + GetScrollPosition() - mInner.mScrollPosAtLastPaint;
if (parentDamage == thebesLayerDamage) {
if (parentDamage.IsEqualInterior(thebesLayerDamage)) {
// This single call will take care of both rects
nsBoxFrame::InvalidateInternal(parentDamage, 0, 0, aForChild, aFlags);
} else {
@ -2829,7 +2829,7 @@ nsXULScrollFrame::LayoutScrollArea(nsBoxLayoutState& aState,
mInner.mScrolledFrame->Invalidate(
originalVisOverflow + originalRect.TopLeft() - finalRect.TopLeft());
mInner.mScrolledFrame->Invalidate(finalVisOverflow);
} else if (!originalVisOverflow.IsExactEqual(finalVisOverflow)) {
} else if (!originalVisOverflow.IsEqualInterior(finalVisOverflow)) {
// If the overflow rect changed then invalidate the difference between the
// old and new overflow rects.
mInner.mScrolledFrame->CheckInvalidateSizeChange(
@ -3238,7 +3238,7 @@ static void LayoutAndInvalidate(nsBoxLayoutState& aState,
// to invalidate the scrollbar area here.
// But we also need to invalidate the scrollbar itself in case it has
// its own layer; we need to ensure that layer is updated.
PRBool rectChanged = aBox->GetRect() != aRect;
PRBool rectChanged = !aBox->GetRect().IsEqualInterior(aRect);
if (rectChanged) {
if (aScrollbarIsBeingHidden) {
aBox->GetParent()->Invalidate(aBox->GetVisualOverflowRect() +

View File

@ -111,8 +111,8 @@ public:
bool operator==(const nsOverflowAreas& aOther) const {
// Scrollable overflow is a point-set rectangle and visual overflow
// is a pixel-set rectangle.
return VisualOverflow() == aOther.VisualOverflow() &&
ScrollableOverflow().IsExactEqual(aOther.ScrollableOverflow());
return VisualOverflow().IsEqualInterior(aOther.VisualOverflow()) &&
ScrollableOverflow().IsEqualEdges(aOther.ScrollableOverflow());
}
bool operator!=(const nsOverflowAreas& aOther) const {

View File

@ -595,7 +595,7 @@ nsImageFrame::OnDataAvailable(imgIRequest *aRequest,
// XXX We really need to round this out, now that we're doing better
// image scaling!
nsRect r = (*aRect == nsIntRect::GetMaxSizedIntRect()) ?
nsRect r = aRect->IsEqualInterior(nsIntRect::GetMaxSizedIntRect()) ?
GetInnerArea() :
SourceRectToDest(*aRect);
@ -679,7 +679,7 @@ nsImageFrame::FrameChanged(imgIContainer *aContainer,
return NS_OK;
}
nsRect r = (*aDirtyRect == nsIntRect::GetMaxSizedIntRect()) ?
nsRect r = aDirtyRect->IsEqualInterior(nsIntRect::GetMaxSizedIntRect()) ?
GetInnerArea() :
SourceRectToDest(*aDirtyRect);

View File

@ -503,9 +503,8 @@ nsLineBox::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
NS_ASSERTION(aOverflowAreas.Overflow(otype).height >= 0,
"illegal height for combined area");
}
// REVIEW: should this use IsExactEqual?
if (aOverflowAreas.VisualOverflow() != mBounds ||
aOverflowAreas.ScrollableOverflow() != mBounds) {
if (!aOverflowAreas.VisualOverflow().IsEqualInterior(mBounds) ||
!aOverflowAreas.ScrollableOverflow().IsEqualEdges(mBounds)) {
if (!mData) {
if (IsInline()) {
mInlineData = new ExtraInlineData(mBounds);

View File

@ -2395,7 +2395,7 @@ nsObjectFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
nsIntPoint origin = GetWindowOriginInPixels(PR_TRUE);
nsIntRect winlessRect = nsIntRect(origin, nsIntSize(window->width, window->height));
if (mWindowlessRect != winlessRect) {
if (!mWindowlessRect.IsEqualEdges(winlessRect)) {
mWindowlessRect = winlessRect;
WINDOWPOS winpos;

View File

@ -5556,7 +5556,7 @@ nsTypedSelection::GetSelectionAnchorGeometry(SelectionRegion aRegion,
// make focusRect relative to anchorFrame
focusRect += focusFrame->GetOffsetTo(anchorFrame);
aRect->UnionRectIncludeEmpty(anchorRect, focusRect);
aRect->UnionRectEdges(anchorRect, focusRect);
return anchorFrame;
}

View File

@ -699,7 +699,7 @@ nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
return NS_STYLE_HINT_FRAMECHANGE;
if (EqualImages(mListStyleImage, aOther.mListStyleImage) &&
mListStyleType == aOther.mListStyleType) {
if (mImageRegion == aOther.mImageRegion)
if (mImageRegion.IsEqualInterior(aOther.mImageRegion))
return NS_STYLE_HINT_NONE;
if (mImageRegion.width == aOther.mImageRegion.width &&
mImageRegion.height == aOther.mImageRegion.height)
@ -1599,7 +1599,7 @@ nsStyleImage::ComputeActualCropRect(nsIntRect& aActualCropRect,
aActualCropRect.IntersectRect(imageRect, cropRect);
if (aIsEntireImage)
*aIsEntireImage = (aActualCropRect == imageRect);
*aIsEntireImage = aActualCropRect.IsEqualInterior(imageRect);
return PR_TRUE;
}
@ -2128,7 +2128,7 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
|| mBreakBefore != aOther.mBreakBefore
|| mBreakAfter != aOther.mBreakAfter
|| mAppearance != aOther.mAppearance
|| mClipFlags != aOther.mClipFlags || mClip != aOther.mClip)
|| mClipFlags != aOther.mClipFlags || !mClip.IsEqualInterior(aOther.mClip))
NS_UpdateHint(hint, NS_CombineHint(nsChangeHint_ReflowFrame, nsChangeHint_RepaintFrame));
if (mOpacity != aOther.mOpacity) {

View File

@ -658,7 +658,7 @@ nsSVGOuterSVGFrame::UpdateAndInvalidateCoveredRegion(nsIFrame *aFrame)
Invalidate(nsSVGUtils::FindFilterInvalidation(aFrame, oldRegion));
svgFrame->UpdateCoveredRegion();
nsRect newRegion = svgFrame->GetCoveredRegion();
if (oldRegion == newRegion)
if (oldRegion.IsEqualInterior(newRegion))
return PR_FALSE;
Invalidate(nsSVGUtils::FindFilterInvalidation(aFrame, newRegion));

View File

@ -439,7 +439,7 @@ nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
SyncLayout(aState);
// Redraw only if thumb changed size.
if (oldThumbRect != thumbRect)
if (!oldThumbRect.IsEqualInterior(thumbRect))
Redraw(aState);
return NS_OK;

View File

@ -524,7 +524,7 @@ nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
// We have to check for this.
nsRect newChildRect(child->GetRect());
if (newChildRect != childRect) {
if (!newChildRect.IsEqualEdges(childRect)) {
#ifdef DEBUG_GROW
child->DumpBox(stdout);
printf(" GREW from (%d,%d) -> (%d,%d)\n", childRect.width, childRect.height, newChildRect.width, newChildRect.height);
@ -1163,7 +1163,7 @@ nsSprocketLayout::ChildResized(nsIBox* aBox,
if (recompute)
ComputeChildSizes(aBox, aState, containingWidth, aBoxSizes, aComputedBoxSizes);
if (childCurrentRect != aChildActualRect) {
if (!childCurrentRect.IsEqualEdges(aChildActualRect)) {
// the childRect includes the margin
// make sure we remove it before setting
// the bounds.

View File

@ -308,7 +308,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
childRect.height = 0;
nsRect oldRect(child->GetRect());
PRBool sizeChanged = !oldRect.IsExactEqual(childRect);
PRBool sizeChanged = !oldRect.IsEqualEdges(childRect);
// only lay out dirty children or children whose sizes have changed
if (sizeChanged || NS_SUBTREE_DIRTY(child)) {
@ -388,7 +388,7 @@ nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
}
}
if (childRectNoMargin != oldRect)
if (!childRectNoMargin.IsEqualInterior(oldRect))
{
// redraw the new and old positions if the
// child moved or resized.

View File

@ -411,7 +411,7 @@ nsTreeBodyFrame::SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRec
PRBool aRemoveOverflowArea)
{
nscoord horzWidth = CalcHorzWidth(GetScrollParts());
if ((aRect != mRect || mHorzWidth != horzWidth) && !mReflowCallbackPosted) {
if ((!aRect.IsEqualEdges(mRect) || mHorzWidth != horzWidth) && !mReflowCallbackPosted) {
mReflowCallbackPosted = PR_TRUE;
PresContext()->PresShell()->PostReflowCallback(this);
}

View File

@ -523,7 +523,7 @@ RasterImage::GetCurrentFrameIsOpaque(PRBool *aIsOpaque)
// We are also transparent if the current frame's size doesn't cover our
// entire area.
nsIntRect framerect = curframe->GetRect();
*aIsOpaque = *aIsOpaque && (framerect != nsIntRect(0, 0, mSize.width, mSize.height));
*aIsOpaque = *aIsOpaque && framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height));
}
return NS_OK;

View File

@ -764,7 +764,7 @@ void imgFrame::SetBlendMethod(PRInt32 aBlendMethod)
PRBool imgFrame::ImageComplete() const
{
return mDecoded == nsIntRect(mOffset, mSize);
return mDecoded.IsEqualInterior(nsIntRect(mOffset, mSize));
}
// A hint from the image decoders that this image has no alpha, even

View File

@ -302,7 +302,7 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight)
nsRect newDim(0, 0, aWidth, aHeight);
mRootView->GetDimensions(oldDim);
// We care about resizes even when one dimension is already zero.
if (!oldDim.IsExactEqual(newDim)) {
if (!oldDim.IsEqualEdges(newDim)) {
// Don't resize the widget. It is already being set elsewhere.
mRootView->SetDimensions(newDim, PR_TRUE, PR_FALSE);
if (mObserver)
@ -1352,7 +1352,7 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, PRB
nsRect oldDimensions;
view->GetDimensions(oldDimensions);
if (!oldDimensions.IsExactEqual(aRect)) {
if (!oldDimensions.IsEqualEdges(aRect)) {
// resize the view.
// Prevent Invalidation of hidden views
if (view->GetVisibility() == nsViewVisibility_kHide) {

View File

@ -1045,7 +1045,7 @@ void nsWindow::SetPluginClipRegion(const Configuration& aConfiguration)
// If nothing has changed, exit.
if (!StoreWindowClipRegion(aConfiguration.mClipRegion) &&
mBounds == aConfiguration.mBounds) {
mBounds.IsEqualInterior(aConfiguration.mBounds)) {
return;
}

View File

@ -1537,7 +1537,7 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRInt32 aY)
if (mWindowType == eWindowType_plugin &&
(!mLayerManager || mLayerManager->GetBackendType() == LayerManager::LAYERS_D3D9) &&
mClipRects &&
(mClipRectCount != 1 || mClipRects[0] != nsIntRect(0, 0, mBounds.width, mBounds.height))) {
(mClipRectCount != 1 || !mClipRects[0].IsEqualInterior(nsIntRect(0, 0, mBounds.width, mBounds.height)))) {
flags |= SWP_NOCOPYBITS;
}
VERIFY(::SetWindowPos(mWnd, NULL, aX, aY, 0, 0, flags));

View File

@ -215,7 +215,7 @@ PuppetWidget::Resize(PRInt32 aWidth,
InvalidateRegion(this, dirty);
}
if (oldBounds != mBounds) {
if (!oldBounds.IsEqualEdges(mBounds)) {
DispatchResizeEvent();
}