From 6e58070f5f2de3d9f73e53e35fce06c04b9eb939 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 25 Jul 2011 17:19:37 -0500 Subject: [PATCH] Bug 635643. Remove nsIRegion, because it is a useless wrapper class. r=tnikkel --- embedding/browser/webBrowser/nsWebBrowser.cpp | 1 - gfx/src/Makefile.in | 2 - gfx/src/nsIRegion.h | 286 ------------------ gfx/src/nsIScriptableRegion.idl | 8 +- gfx/src/nsScriptableRegion.cpp | 121 ++++---- gfx/src/nsScriptableRegion.h | 16 +- gfx/src/nsThebesGfxFactory.cpp | 43 +-- gfx/src/nsThebesRegion.cpp | 217 ------------- gfx/src/nsThebesRegion.h | 79 ----- layout/base/nsPresShell.cpp | 1 - view/src/nsView.cpp | 1 - view/src/nsViewManager.cpp | 24 -- view/src/nsViewManager.h | 4 - widget/src/cocoa/nsChildView.mm | 1 - widget/src/cocoa/nsDragService.mm | 1 - widget/src/qt/nsWindow.cpp | 1 - widget/src/windows/nsWindow.cpp | 1 - widget/src/windows/nsWindowGfx.cpp | 1 - widget/src/xpwidgets/nsBaseDragService.cpp | 7 +- 19 files changed, 76 insertions(+), 739 deletions(-) delete mode 100644 gfx/src/nsIRegion.h delete mode 100644 gfx/src/nsThebesRegion.cpp delete mode 100644 gfx/src/nsThebesRegion.h diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index cd46e79112b..f59753d59bd 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -75,7 +75,6 @@ #include "gfxContext.h" // for painting the background window -#include "nsIRegion.h" #include "nsILookAndFeel.h" // Printing Includes diff --git a/gfx/src/Makefile.in b/gfx/src/Makefile.in index 7928b52ca34..167560215a2 100644 --- a/gfx/src/Makefile.in +++ b/gfx/src/Makefile.in @@ -77,7 +77,6 @@ EXPORTS = \ nsFontMetrics.h \ nsDeviceContext.h \ nsGfxCIID.h \ - nsIRegion.h \ nsITheme.h \ nsThemeConstants.h \ nsBoundingMetrics.h \ @@ -98,7 +97,6 @@ CPPSRCS = \ nsScriptableRegion.cpp \ gfxCrashReporterUtils.cpp \ nsDeviceContext.cpp \ - nsThebesRegion.cpp \ nsThebesGfxFactory.cpp \ nsRenderingContext.cpp \ nsFontMetrics.cpp \ diff --git a/gfx/src/nsIRegion.h b/gfx/src/nsIRegion.h deleted file mode 100644 index 377ba8ae236..00000000000 --- a/gfx/src/nsIRegion.h +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIRegion_h___ -#define nsIRegion_h___ - -#include "nscore.h" -#include "nsISupports.h" -#include "nsRect.h" -#include "nsRegion.h" - -enum nsRegionComplexity -{ - eRegionComplexity_empty = 0, - eRegionComplexity_rect = 1, - eRegionComplexity_complex = 2 -}; - -typedef struct -{ - PRInt32 x; - PRInt32 y; - PRUint32 width; - PRUint32 height; -} nsRegionRect; - -typedef struct -{ - PRUint32 mNumRects; //number of actual rects in the mRects array - PRUint32 mRectsLen; //length, in rects, of the mRects array - PRUint32 mArea; //area of the covered portion of the region - nsRegionRect mRects[1]; -} nsRegionRectSet; - -// An implementation of a region primitive that can be used to -// represent arbitrary pixel areas. Probably implemented on top -// of the native region primitive. The assumption is that, at worst, -// it is a rectangle list. - -#define NS_IREGION_IID \ -{ 0x8ef366e0, 0xee94, 0x11d1, \ -{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } } - -class nsIRegion : public nsISupports -{ -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IREGION_IID) - - virtual nsresult Init(void) = 0; - - /** - * copy operator equivalent that takes another region - * - * @param region to copy - * @return void - * - **/ - - virtual void SetTo(const nsIRegion &aRegion) = 0; - - /** - * copy operator equivalent that takes a rect - * - * @param aX xoffset of rect to set region to - * @param aY yoffset of rect to set region to - * @param aWidth width of rect to set region to - * @param aHeight height of rect to set region to - * @return void - * - **/ - - virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0; - - /** - * destructively intersect another region with this one - * - * @param region to intersect - * @return void - * - **/ - - virtual void Intersect(const nsIRegion &aRegion) = 0; - - /** - * destructively intersect a rect with this region - * - * @param aX xoffset of rect to intersect with region - * @param aY yoffset of rect to intersect with region - * @param aWidth width of rect to intersect with region - * @param aHeight height of rect to intersect with region - * @return void - * - **/ - - virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0; - - /** - * destructively union another region with this one - * - * @param region to union - * @return void - * - **/ - - virtual void Union(const nsIRegion &aRegion) = 0; - - /** - * destructively union a rect with this region - * - * @param aX xoffset of rect to union with region - * @param aY yoffset of rect to union with region - * @param aWidth width of rect to union with region - * @param aHeight height of rect to union with region - * @return void - * - **/ - - virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0; - - /** - * destructively subtract another region with this one - * - * @param region to subtract - * @return void - * - **/ - - virtual void Subtract(const nsIRegion &aRegion) = 0; - - /** - * destructively subtract a rect from this region - * - * @param aX xoffset of rect to subtract with region - * @param aY yoffset of rect to subtract with region - * @param aWidth width of rect to subtract with region - * @param aHeight height of rect to subtract with region - * @return void - * - **/ - - virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0; - - /** - * is this region empty? i.e. does it contain any pixels - * - * @param none - * @return returns whether the region is empty - * - **/ - - virtual PRBool IsEmpty(void) = 0; - - /** - * == operator equivalent i.e. do the regions contain exactly - * the same pixels - * - * @param region to compare - * @return whether the regions are identical - * - **/ - - virtual PRBool IsEqual(const nsIRegion &aRegion) = 0; - - /** - * returns the bounding box of the region i.e. the smallest - * rectangle that completely contains the region. - * - * @param aX out parameter for xoffset of bounding rect for region - * @param aY out parameter for yoffset of bounding rect for region - * @param aWidth out parameter for width of bounding rect for region - * @param aHeight out parameter for height of bounding rect for region - * @return void - * - **/ - virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) = 0; - - /** - * offsets the region in x and y - * - * @param xoffset pixel offset in x - * @param yoffset pixel offset in y - * @return void - * - **/ - virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset) = 0; - - /** - * does the region intersect the rectangle? - * - * @param rect to check for containment - * @return true if the region intersects the rect - * - **/ - - virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0; - - /** - * get the set of rects which make up this region. the aRects - * parameter must be freed by calling FreeRects before the region - * is deleted. aRects may be passed in again when requesting - * the rect list as a recycling method. - * - * @param aRects out parameter containing set of rects - * comprising the region - * @return error status - * - **/ - NS_IMETHOD GetRects(nsRegionRectSet **aRects) = 0; - - /** - * Free a rect set returned by GetRects. - * - * @param aRects rects to free - * @return error status - * - **/ - NS_IMETHOD FreeRects(nsRegionRectSet *aRects) = 0; - - /** - * Get the underlying nsIntRegion that this nsIRegion represents. - **/ - virtual nsIntRegion GetUnderlyingRegion() const = 0; - - /** - * Get the native region that this nsIRegion represents. - * @param aRegion out parameter for native region handle - * @return error status - **/ - NS_IMETHOD GetNativeRegion(void *&aRegion) const = 0; - - /** - * Get the complexity of the region as defined by the - * nsRegionComplexity enum. - * @param aComplexity out parameter for region complexity - * @return error status - **/ - NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0; - - /** - * get the number of rects which make up this region. - * - * @param aRects out parameter containing the number of rects - * comprising the region - * @return error status - * - **/ - NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIRegion, NS_IREGION_IID) - -#endif // nsIRegion_h___ diff --git a/gfx/src/nsIScriptableRegion.idl b/gfx/src/nsIScriptableRegion.idl index cbedd035810..2611d58a8e2 100644 --- a/gfx/src/nsIScriptableRegion.idl +++ b/gfx/src/nsIScriptableRegion.idl @@ -40,13 +40,13 @@ #include "nsISupports.idl" %{C++ -class nsIRegion; +class nsIntRegion; %} -[ptr] native nsIRegion(nsIRegion); +native nsIntRegion(nsIntRegion); -[scriptable, uuid(4d179656-a5bd-42a6-a937-c81f820dcf2f)] +[scriptable, uuid(f390b97c-a0cf-4cb4-b9e8-bfc15df76ab5)] interface nsIScriptableRegion : nsISupports { void init ( ) ; @@ -204,7 +204,7 @@ interface nsIScriptableRegion : nsISupports boolean containsRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ; - [noscript] readonly attribute nsIRegion region; + [noscript] readonly attribute nsIntRegion region; }; diff --git a/gfx/src/nsScriptableRegion.cpp b/gfx/src/nsScriptableRegion.cpp index cebc19d9954..adf02f0ea97 100644 --- a/gfx/src/nsScriptableRegion.cpp +++ b/gfx/src/nsScriptableRegion.cpp @@ -44,115 +44,111 @@ #include "nsServiceManagerUtils.h" #include "jsapi.h" -nsScriptableRegion::nsScriptableRegion(nsIRegion* region) : mRegion(nsnull), mRectSet(nsnull) +nsScriptableRegion::nsScriptableRegion() { - mRegion = region; - NS_IF_ADDREF(mRegion); -} - -nsScriptableRegion::~nsScriptableRegion() -{ - if (mRegion) { - mRegion->FreeRects(mRectSet); - NS_RELEASE(mRegion); - } } NS_IMPL_ISUPPORTS1(nsScriptableRegion, nsIScriptableRegion) NS_IMETHODIMP nsScriptableRegion::Init() { - return mRegion->Init(); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::SetToRegion(nsIScriptableRegion *aRegion) { - nsCOMPtr region(do_QueryInterface(aRegion)); - mRegion->SetTo(*region); - return NS_OK; + aRegion->GetRegion(&mRegion); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::SetToRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { - mRegion->SetTo(aX, aY, aWidth, aHeight); - return NS_OK; + mRegion = nsIntRect(aX, aY, aWidth, aHeight); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::IntersectRegion(nsIScriptableRegion *aRegion) { - nsCOMPtr region(do_QueryInterface(aRegion)); - mRegion->Intersect(*region); - return NS_OK; + nsIntRegion region; + aRegion->GetRegion(®ion); + mRegion.And(mRegion, region); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::IntersectRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { - mRegion->Intersect(aX, aY, aWidth, aHeight); - return NS_OK; + mRegion.And(mRegion, nsIntRect(aX, aY, aWidth, aHeight)); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::UnionRegion(nsIScriptableRegion *aRegion) { - nsCOMPtr region(do_QueryInterface(aRegion)); - mRegion->Union(*region); - return NS_OK; + nsIntRegion region; + aRegion->GetRegion(®ion); + mRegion.Or(mRegion, region); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::UnionRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { - mRegion->Union(aX, aY, aWidth, aHeight); - return NS_OK; + mRegion.Or(mRegion, nsIntRect(aX, aY, aWidth, aHeight)); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::SubtractRegion(nsIScriptableRegion *aRegion) { - nsCOMPtr region(do_QueryInterface(aRegion)); - mRegion->Subtract(*region); - return NS_OK; + nsIntRegion region; + aRegion->GetRegion(®ion); + mRegion.Sub(mRegion, region); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::SubtractRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) { - mRegion->Subtract(aX, aY, aWidth, aHeight); - return NS_OK; + mRegion.Sub(mRegion, nsIntRect(aX, aY, aWidth, aHeight)); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::IsEmpty(PRBool *isEmpty) { - *isEmpty = mRegion->IsEmpty(); - return NS_OK; + *isEmpty = mRegion.IsEmpty(); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::IsEqualRegion(nsIScriptableRegion *aRegion, PRBool *isEqual) { - nsCOMPtr region(do_QueryInterface(aRegion)); - *isEqual = mRegion->IsEqual(*region); - return NS_OK; + nsIntRegion region; + aRegion->GetRegion(®ion); + *isEqual = mRegion.IsEqual(region); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) { - mRegion->GetBoundingBox(aX, aY, aWidth, aHeight); - return NS_OK; + nsIntRect boundRect = mRegion.GetBounds(); + *aX = boundRect.x; + *aY = boundRect.y; + *aWidth = boundRect.width; + *aHeight = boundRect.height; + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::Offset(PRInt32 aXOffset, PRInt32 aYOffset) { - mRegion->Offset(aXOffset, aYOffset); - return NS_OK; + mRegion.MoveBy(aXOffset, aYOffset); + return NS_OK; } NS_IMETHODIMP nsScriptableRegion::ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool *containsRect) { - *containsRect = mRegion->ContainsRect(aX, aY, aWidth, aHeight); - return NS_OK; + *containsRect = mRegion.Contains(nsIntRect(aX, aY, aWidth, aHeight)); + return NS_OK; } -NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIRegion** outRgn) +NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIntRegion* outRgn) { *outRgn = mRegion; - NS_IF_ADDREF(*outRgn); return NS_OK; } @@ -170,33 +166,36 @@ NS_IMETHODIMP nsScriptableRegion::GetRects() { jsval *retvalPtr; ncc->GetRetValPtr(&retvalPtr); - - rv = mRegion->GetRects(&mRectSet); - NS_ENSURE_SUCCESS(rv, rv); - - if (!mRectSet->mNumRects) { + + PRUint32 numRects = mRegion.GetNumRects(); + + if (!numRects) { *retvalPtr = JSVAL_NULL; ncc->SetReturnValueWasSet(PR_TRUE); return NS_OK; } JSContext *cx = nsnull; - + rv = ncc->GetJSContext(&cx); NS_ENSURE_SUCCESS(rv, rv); - - JSObject *destArray = JS_NewArrayObject(cx, mRectSet->mNumRects*4, NULL); + + JSObject *destArray = JS_NewArrayObject(cx, numRects*4, NULL); *retvalPtr = OBJECT_TO_JSVAL(destArray); ncc->SetReturnValueWasSet(PR_TRUE); - - for(PRUint32 i = 0; i < mRectSet->mNumRects; i++) { - nsRegionRect &rect = mRectSet->mRects[i]; - int n = i*4; + + int n = 0; + nsIntRegionRectIterator iter(mRegion); + const nsIntRect *rect; + + while ((rect = iter.Next())) { // This will contain bogus data if values don't fit in 31 bit - JS_DefineElement(cx, destArray, n, INT_TO_JSVAL(rect.x), NULL, NULL, JSPROP_ENUMERATE); - JS_DefineElement(cx, destArray, n+1, INT_TO_JSVAL(rect.y), NULL, NULL, JSPROP_ENUMERATE); - JS_DefineElement(cx, destArray, n+2, INT_TO_JSVAL(rect.width), NULL, NULL, JSPROP_ENUMERATE); - JS_DefineElement(cx, destArray, n+3, INT_TO_JSVAL(rect.height), NULL, NULL, JSPROP_ENUMERATE); + JS_DefineElement(cx, destArray, n, INT_TO_JSVAL(rect->x), NULL, NULL, JSPROP_ENUMERATE); + JS_DefineElement(cx, destArray, n+1, INT_TO_JSVAL(rect->y), NULL, NULL, JSPROP_ENUMERATE); + JS_DefineElement(cx, destArray, n+2, INT_TO_JSVAL(rect->width), NULL, NULL, JSPROP_ENUMERATE); + JS_DefineElement(cx, destArray, n+3, INT_TO_JSVAL(rect->height), NULL, NULL, JSPROP_ENUMERATE); + + n += 4; } NS_ENSURE_SUCCESS(rv, rv); diff --git a/gfx/src/nsScriptableRegion.h b/gfx/src/nsScriptableRegion.h index 317cc96f1f7..977bbeb56af 100644 --- a/gfx/src/nsScriptableRegion.h +++ b/gfx/src/nsScriptableRegion.h @@ -39,23 +39,17 @@ #include "nsIScriptableRegion.h" #include "gfxCore.h" -#include "nsIRegion.h" +#include "nsISupports.h" +#include "nsRegion.h" -class nsIRegion; - -/** - * An adapter class for the unscriptable nsIRegion interface. - */ class NS_GFX nsScriptableRegion : public nsIScriptableRegion { public: - nsScriptableRegion(nsIRegion* region); - virtual ~nsScriptableRegion(); - + nsScriptableRegion(); + NS_DECL_ISUPPORTS NS_DECL_NSISCRIPTABLEREGION private: - nsIRegion* mRegion; - nsRegionRectSet *mRectSet; + nsIntRegion mRegion; }; diff --git a/gfx/src/nsThebesGfxFactory.cpp b/gfx/src/nsThebesGfxFactory.cpp index 93f6e3ee3e9..e57d5dc61fc 100644 --- a/gfx/src/nsThebesGfxFactory.cpp +++ b/gfx/src/nsThebesGfxFactory.cpp @@ -41,7 +41,6 @@ #include "nsGfxCIID.h" #include "nsThebesFontEnumerator.h" -#include "nsThebesRegion.h" #include "nsScriptableRegion.h" #include "nsDeviceContext.h" @@ -62,59 +61,30 @@ NS_IMPL_ISUPPORTS0(GfxInitialization) } NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion) static nsresult nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) { - nsresult rv; - - nsIScriptableRegion *inst = nsnull; - - if ( !aResult ) - { - rv = NS_ERROR_NULL_POINTER; - return rv; + if (!aResult) { + return NS_ERROR_NULL_POINTER; } *aResult = nsnull; - if (aOuter) - { - rv = NS_ERROR_NO_AGGREGATION; - return rv; + if (aOuter) { + return NS_ERROR_NO_AGGREGATION; } - nsCOMPtr rgn = new nsThebesRegion(); - nsCOMPtr scriptableRgn; - if (rgn != nsnull) - { - scriptableRgn = new nsScriptableRegion(rgn); - inst = scriptableRgn; - } - if (!inst) - { - rv = NS_ERROR_OUT_OF_MEMORY; - return rv; - } - NS_ADDREF(inst); - // release our variable above now that we have created our owning - // reference - we don't want this to go out of scope early! - scriptableRgn = nsnull; - rv = inst->QueryInterface(aIID, aResult); - NS_RELEASE(inst); - - return rv; + nsCOMPtr scriptableRgn = new nsScriptableRegion(); + return scriptableRgn->QueryInterface(aIID, aResult); } NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization) NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID); -NS_DEFINE_NAMED_CID(NS_REGION_CID); NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID); NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID); static const mozilla::Module::CIDEntry kThebesCIDs[] = { { &kNS_FONT_ENUMERATOR_CID, false, NULL, nsThebesFontEnumeratorConstructor }, - { &kNS_REGION_CID, false, NULL, nsThebesRegionConstructor }, { &kNS_SCRIPTABLE_REGION_CID, false, NULL, nsScriptableRegionConstructor }, { &kNS_GFX_INITIALIZATION_CID, false, NULL, GfxInitializationConstructor }, { NULL } @@ -122,7 +92,6 @@ static const mozilla::Module::CIDEntry kThebesCIDs[] = { static const mozilla::Module::ContractIDEntry kThebesContracts[] = { { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID }, - { "@mozilla.org/gfx/region/nsThebes;1", &kNS_REGION_CID }, { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID }, { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID }, { NULL } diff --git a/gfx/src/nsThebesRegion.cpp b/gfx/src/nsThebesRegion.cpp deleted file mode 100644 index 1e272df8d98..00000000000 --- a/gfx/src/nsThebesRegion.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Stuart Parmenter - * Vladimir Vukicevic - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#include "nsThebesRegion.h" - -NS_IMPL_ISUPPORTS1(nsThebesRegion, nsIRegion) - -nsThebesRegion::nsThebesRegion() -{ - NS_INIT_ISUPPORTS(); -} - -nsresult nsThebesRegion::Init (void) -{ - mRegion.SetEmpty(); - return NS_OK; -} - -void nsThebesRegion::SetTo (const nsIRegion &aRegion) -{ - const nsThebesRegion* pRegion = static_cast(&aRegion); - mRegion = pRegion->mRegion; -} - -void nsThebesRegion::SetTo (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - mRegion = nsIntRect (aX, aY, aWidth, aHeight); -} - -void nsThebesRegion::Intersect (const nsIRegion &aRegion) -{ - const nsThebesRegion* pRegion = static_cast(&aRegion); - mRegion.And (mRegion, pRegion->mRegion); -} - -void nsThebesRegion::Intersect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - mRegion.And (mRegion, nsIntRect (aX, aY, aWidth, aHeight)); -} - -void nsThebesRegion::Union (const nsIRegion &aRegion) -{ - const nsThebesRegion* pRegion = static_cast(&aRegion); - mRegion.Or (mRegion, pRegion->mRegion); -} - -void nsThebesRegion::Union (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - mRegion.Or (mRegion, nsIntRect (aX, aY, aWidth, aHeight)); -} - -void nsThebesRegion::Subtract (const nsIRegion &aRegion) -{ - const nsThebesRegion* pRegion = static_cast(&aRegion); - mRegion.Sub (mRegion, pRegion->mRegion); -} - -void nsThebesRegion::Subtract (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - mRegion.Sub (mRegion, nsIntRect (aX, aY, aWidth, aHeight)); -} - -PRBool nsThebesRegion::IsEmpty (void) -{ - return mRegion.IsEmpty (); -} - -PRBool nsThebesRegion::IsEqual (const nsIRegion &aRegion) -{ - const nsThebesRegion* pRegion = static_cast(&aRegion); - return mRegion.IsEqual (pRegion->mRegion); -} - -void nsThebesRegion::GetBoundingBox (PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) -{ - nsIntRect BoundRect; - BoundRect = mRegion.GetBounds(); - *aX = BoundRect.x; - *aY = BoundRect.y; - *aWidth = BoundRect.width; - *aHeight = BoundRect.height; -} - -void nsThebesRegion::Offset (PRInt32 aXOffset, PRInt32 aYOffset) -{ - mRegion.MoveBy (aXOffset, aYOffset); -} - -PRBool nsThebesRegion::ContainsRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) -{ - nsIntRegion TmpRegion; - TmpRegion.And (mRegion, nsIntRect (aX, aY, aWidth, aHeight)); - return (!TmpRegion.IsEmpty ()); -} - -NS_IMETHODIMP -nsThebesRegion::GetRects (nsRegionRectSet **aRects) -{ - if (!aRects) - return NS_ERROR_NULL_POINTER; - - nsRegionRectSet* pRegionSet = *aRects; - PRUint32 NumRects = mRegion.GetNumRects (); - - if (pRegionSet == nsnull) // Not yet allocated - { - PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)]; - pRegionSet = reinterpret_cast(pBuf); - pRegionSet->mRectsLen = NumRects + 1; - } else // Already allocated in previous call - { - if (NumRects > pRegionSet->mRectsLen) // passed array is not big enough - reallocate it. - { - delete [] reinterpret_cast(pRegionSet); - PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)]; - pRegionSet = reinterpret_cast(pBuf); - pRegionSet->mRectsLen = NumRects + 1; - } - } - pRegionSet->mNumRects = NumRects; - *aRects = pRegionSet; - - - nsIntRegionRectIterator ri (mRegion); - nsRegionRect* pDest = &pRegionSet->mRects [0]; - const nsIntRect* pSrc; - - while ((pSrc = ri.Next ())) - { - pDest->x = pSrc->x; - pDest->y = pSrc->y; - pDest->width = pSrc->width; - pDest->height = pSrc->height; - - pDest++; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsThebesRegion::FreeRects (nsRegionRectSet *aRects) -{ - if (!aRects) - return NS_ERROR_NULL_POINTER; - - delete [] reinterpret_cast(aRects); - return NS_OK; -} - -nsIntRegion nsThebesRegion::GetUnderlyingRegion () const -{ - return mRegion; -} - -NS_IMETHODIMP -nsThebesRegion::GetNativeRegion (void *&aRegion) const -{ - aRegion = 0; - return NS_OK; -} - -NS_IMETHODIMP -nsThebesRegion::GetRegionComplexity (nsRegionComplexity &aComplexity) const -{ - switch (mRegion.GetNumRects ()) - { - case 0: aComplexity = eRegionComplexity_empty; break; - case 1: aComplexity = eRegionComplexity_rect; break; - default: aComplexity = eRegionComplexity_complex; break; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsThebesRegion::GetNumRects (PRUint32 *aRects) const -{ - *aRects = mRegion.GetNumRects (); - return NS_OK; -} diff --git a/gfx/src/nsThebesRegion.h b/gfx/src/nsThebesRegion.h deleted file mode 100644 index 2112b15d247..00000000000 --- a/gfx/src/nsThebesRegion.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Stuart Parmenter - * Vladimir Vukicevic - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef NSTHEBESREGION__H__ -#define NSTHEBESREGION__H__ - -#include "nsIRegion.h" -#include "nsRegion.h" - -class nsThebesRegion : public nsIRegion -{ -public: - nsThebesRegion(); - - NS_DECL_ISUPPORTS - - // nsIRegion - nsresult Init (void); - void SetTo (const nsIRegion &aRegion); - void SetTo (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - void Intersect (const nsIRegion &aRegion); - void Intersect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - void Union (const nsIRegion &aRegion); - void Union (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - void Subtract (const nsIRegion &aRegion); - void Subtract (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - PRBool IsEmpty (void); - PRBool IsEqual (const nsIRegion &aRegion); - void GetBoundingBox (PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight); - void Offset (PRInt32 aXOffset, PRInt32 aYOffset); - PRBool ContainsRect (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight); - NS_IMETHOD GetRects (nsRegionRectSet **aRects); - NS_IMETHOD FreeRects (nsRegionRectSet *aRects); - nsIntRegion GetUnderlyingRegion() const; - NS_IMETHOD GetNativeRegion (void *&aRegion) const; - NS_IMETHOD GetRegionComplexity (nsRegionComplexity &aComplexity) const; - NS_IMETHOD GetNumRects (PRUint32 *aRects) const; - -protected: - nsIntRegion mRegion; -}; - -#endif diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index e0267a2da9e..1ff332cae85 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -133,7 +133,6 @@ #include "nsIAttribute.h" #include "nsIGlobalHistory2.h" #include "nsDisplayList.h" -#include "nsIRegion.h" #include "nsRegion.h" #include "nsRenderingContext.h" diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 8c3d9dbbbe6..77f8eb3589e 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -42,7 +42,6 @@ #include "nsGUIEvent.h" #include "nsIComponentManager.h" #include "nsGfxCIID.h" -#include "nsIRegion.h" #include "nsIInterfaceRequestor.h" //mmptemp diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 0968a366090..1955de0ecf6 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -60,8 +60,6 @@ #include "nsPresContext.h" #include "nsEventStateManager.h" -static NS_DEFINE_IID(kRegionCID, NS_REGION_CID); - PRTime gFirstPaintTimestamp = 0; // Timestamp of the first paint event /** XXX TODO XXX @@ -165,28 +163,6 @@ nsViewManager::~nsViewManager() NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager) -nsresult -nsViewManager::CreateRegion(nsIRegion* *result) -{ - nsresult rv; - - if (!mRegionFactory) { - mRegionFactory = do_GetClassObject(kRegionCID, &rv); - if (NS_FAILED(rv)) { - *result = nsnull; - return rv; - } - } - - nsIRegion* region = nsnull; - rv = CallCreateInstance(mRegionFactory.get(), ®ion); - if (NS_SUCCEEDED(rv)) { - rv = region->Init(); - *result = region; - } - return rv; -} - // We don't hold a reference to the presentation context because it // holds a reference to us. NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 3383957ed28..fb5f7face19 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -45,7 +45,6 @@ #include "prinrval.h" #include "nsVoidArray.h" #include "nsThreadUtils.h" -#include "nsIRegion.h" #include "nsView.h" #include "nsIViewObserver.h" #include "nsDeviceContext.h" @@ -248,8 +247,6 @@ public: // NOT in nsIViewManager, so private to the view module nsEventStatus HandleEvent(nsView* aView, nsGUIEvent* aEvent); - nsresult CreateRegion(nsIRegion* *result); - PRBool IsRefreshEnabled() { return RootViewManager()->mUpdateBatchCnt == 0; } // Call this when you need to let the viewmanager know that it now has @@ -269,7 +266,6 @@ private: // visible again. nsSize mDelayedResize; - nsCOMPtr mRegionFactory; nsView *mRootView; // mRootViewManager is a strong ref unless it equals |this|. It's // never null (if we have no ancestors, it will be |this|). diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 1951d2fa598..e38119fe4b7 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -57,7 +57,6 @@ #include "nsCRT.h" #include "nsFontMetrics.h" -#include "nsIRegion.h" #include "nsIRollupListener.h" #include "nsIViewManager.h" #include "nsIInterfaceRequestor.h" diff --git a/widget/src/cocoa/nsDragService.mm b/widget/src/cocoa/nsDragService.mm index 00228ba8e9f..6854a0ec01a 100644 --- a/widget/src/cocoa/nsDragService.mm +++ b/widget/src/cocoa/nsDragService.mm @@ -62,7 +62,6 @@ #include "nsIContent.h" #include "nsIFrame.h" #include "nsIView.h" -#include "nsIRegion.h" #include "gfxASurface.h" #include "gfxContext.h" diff --git a/widget/src/qt/nsWindow.cpp b/widget/src/qt/nsWindow.cpp index ff85d02801d..df350412482 100644 --- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -96,7 +96,6 @@ using namespace QtMobility; #include "nsToolkit.h" #include "nsIdleService.h" #include "nsRenderingContext.h" -#include "nsIRegion.h" #include "nsIRollupListener.h" #include "nsIMenuRollup.h" #include "nsWidgetsCID.h" diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index f93e9d0ced7..5e9156bab0f 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -127,7 +127,6 @@ #include "nsIFile.h" #include "nsIRollupListener.h" #include "nsIMenuRollup.h" -#include "nsIRegion.h" #include "nsIServiceManager.h" #include "nsIClipboard.h" #include "nsIMM32Handler.h" diff --git a/widget/src/windows/nsWindowGfx.cpp b/widget/src/windows/nsWindowGfx.cpp index 13ba67c9ea7..1dec926f8c8 100644 --- a/widget/src/windows/nsWindowGfx.cpp +++ b/widget/src/windows/nsWindowGfx.cpp @@ -58,7 +58,6 @@ using mozilla::plugins::PluginInstanceParent; #include "nsWindowGfx.h" #include -#include "nsIRegion.h" #include "gfxImageSurface.h" #include "gfxWindowsSurface.h" #include "gfxWindowsPlatform.h" diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index d682e0343c3..dbc41f3ddf1 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -43,7 +43,6 @@ #include "nsITransferable.h" #include "nsISupportsArray.h" #include "nsSize.h" -#include "nsIRegion.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsCOMPtr.h" @@ -520,11 +519,7 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode, // otherwise, just draw the node nsIntRegion clipRegion; if (aRegion) { - nsCOMPtr clipIRegion; - aRegion->GetRegion(getter_AddRefs(clipIRegion)); - if (clipIRegion) { - clipRegion = clipIRegion->GetUnderlyingRegion(); - } + aRegion->GetRegion(&clipRegion); } nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y);