author | Marco Castelluccio <mar.castelluccio@studenti.unina.it> |
Mon, 25 Jul 2011 17:19:37 -0500 | |
changeset 73316 | 22b20e5dcdce2d7f9366bec9020c74ad0890f493 |
parent 73315 | cd6bf87809e96b24a783a24a72374f418f2c4a42 |
child 73317 | a840cf51978aea30bc9c61a0e3827e80270cbe89 |
push id | 20846 |
push user | mak77@bonardo.net |
push date | Tue, 26 Jul 2011 09:50:30 +0000 |
treeherder | mozilla-central@982a5835fba1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | tnikkel |
bugs | 635643 |
milestone | 8.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -70,17 +70,16 @@ #include "nsCWebBrowserPersist.h" #include "nsIServiceManager.h" #include "nsAutoPtr.h" #include "nsFocusManager.h" #include "Layers.h" #include "gfxContext.h" // for painting the background window -#include "nsIRegion.h" #include "nsILookAndFeel.h" // Printing Includes #ifdef NS_PRINTING #include "nsIWebBrowserPrint.h" #include "nsIContentViewer.h" #endif
--- a/gfx/src/Makefile.in +++ b/gfx/src/Makefile.in @@ -72,17 +72,16 @@ EXPORTS = \ nsPoint.h \ nsSize.h \ nsMargin.h \ nsTransform2D.h \ nsRenderingContext.h \ nsFontMetrics.h \ nsDeviceContext.h \ nsGfxCIID.h \ - nsIRegion.h \ nsITheme.h \ nsThemeConstants.h \ nsBoundingMetrics.h \ $(NULL) ifdef MOZ_X11 EXPORTS_NAMESPACES = mozilla @@ -93,17 +92,16 @@ CPPSRCS = \ nsColor.cpp \ nsFont.cpp \ nsRect.cpp \ nsRegion.cpp \ nsTransform2D.cpp \ nsScriptableRegion.cpp \ gfxCrashReporterUtils.cpp \ nsDeviceContext.cpp \ - nsThebesRegion.cpp \ nsThebesGfxFactory.cpp \ nsRenderingContext.cpp \ nsFontMetrics.cpp \ nsThebesFontEnumerator.cpp \ $(NULL) ifdef MOZ_X11 CPPSRCS += X11Util.cpp
deleted file mode 100644 --- 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___
--- a/gfx/src/nsIScriptableRegion.idl +++ b/gfx/src/nsIScriptableRegion.idl @@ -35,23 +35,23 @@ * 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 "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 ( ) ; /** * copy operator equivalent that takes another region * * @param region to copy @@ -199,16 +199,16 @@ interface nsIScriptableRegion : nsISuppo * * @param rect to check for containment * @return true if the region intersects the rect * **/ boolean containsRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ; - [noscript] readonly attribute nsIRegion region; + [noscript] readonly attribute nsIntRegion region; }; %{ C++ %}
--- a/gfx/src/nsScriptableRegion.cpp +++ b/gfx/src/nsScriptableRegion.cpp @@ -39,125 +39,121 @@ * ***** END LICENSE BLOCK ***** */ #include "nsScriptableRegion.h" #include "nsCOMPtr.h" #include "nsIXPConnect.h" #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<nsIRegion> 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<nsIRegion> 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<nsIRegion> 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<nsIRegion> 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<nsIRegion> 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; } NS_IMETHODIMP nsScriptableRegion::GetRects() { nsAXPCNativeCallContext *ncc = nsnull; nsresult rv; nsCOMPtr<nsIXPConnect> xpConnect = do_GetService(nsIXPConnect::GetCID(), &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -165,40 +161,43 @@ NS_IMETHODIMP nsScriptableRegion::GetRec rv = xpConnect->GetCurrentNativeCallContext(&ncc); NS_ENSURE_SUCCESS(rv, rv); if (!ncc) return NS_ERROR_FAILURE; 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); return NS_OK; }
--- a/gfx/src/nsScriptableRegion.h +++ b/gfx/src/nsScriptableRegion.h @@ -34,28 +34,22 @@ * 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 "nsIScriptableRegion.h" #include "gfxCore.h" -#include "nsIRegion.h" - -class nsIRegion; +#include "nsISupports.h" +#include "nsRegion.h" -/** - * 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; };
--- a/gfx/src/nsThebesGfxFactory.cpp +++ b/gfx/src/nsThebesGfxFactory.cpp @@ -36,17 +36,16 @@ * * ***** END LICENSE BLOCK ***** */ #include "mozilla/ModuleUtils.h" #include "nsCOMPtr.h" #include "nsGfxCIID.h" #include "nsThebesFontEnumerator.h" -#include "nsThebesRegion.h" #include "nsScriptableRegion.h" #include "nsDeviceContext.h" #include "gfxPlatform.h" // This class doesn't do anything; its only purpose is to give // gfxPlatform::Init a way to force this component to be registered, // so that gfxPlatform::Shutdown will be called at an appropriate @@ -57,77 +56,47 @@ namespace { class GfxInitialization : public nsISupports { NS_DECL_ISUPPORTS }; 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 <nsIRegion> rgn = new nsThebesRegion(); - nsCOMPtr<nsIScriptableRegion> 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<nsIScriptableRegion> 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 } }; 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 } }; static void nsThebesGfxModuleDtor() {
deleted file mode 100644 --- 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 <pavlov@pavlov.net> - * Vladimir Vukicevic <vladimir@pobox.com> - * - * 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<const nsThebesRegion*>(&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<const nsThebesRegion*>(&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<const nsThebesRegion*>(&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<const nsThebesRegion*>(&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<const nsThebesRegion*>(&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<nsRegionRectSet*>(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<PRUint8*>(pRegionSet); - PRUint8* pBuf = new PRUint8 [sizeof (nsRegionRectSet) + NumRects * sizeof (nsRegionRect)]; - pRegionSet = reinterpret_cast<nsRegionRectSet*>(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<PRUint8*>(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; -}
deleted file mode 100644 --- 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 <pavlov@pavlov.net> - * Vladimir Vukicevic <vladimir@pobox.com> - * - * 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
--- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -128,17 +128,16 @@ #include "nsLayoutUtils.h" #include "nsCSSRendering.h" // for |#ifdef DEBUG| code #include "prenv.h" #include "nsAlgorithm.h" #include "nsIAttribute.h" #include "nsIGlobalHistory2.h" #include "nsDisplayList.h" -#include "nsIRegion.h" #include "nsRegion.h" #include "nsRenderingContext.h" #ifdef MOZ_REFLOW_PERF #include "nsFontMetrics.h" #endif #include "nsIReflowCallback.h"
--- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -37,17 +37,16 @@ #include "nsView.h" #include "nsIWidget.h" #include "nsWidgetsCID.h" #include "nsViewManager.h" #include "nsGUIEvent.h" #include "nsIComponentManager.h" #include "nsGfxCIID.h" -#include "nsIRegion.h" #include "nsIInterfaceRequestor.h" //mmptemp static nsEventStatus HandleEvent(nsGUIEvent *aEvent); //#define SHOW_VIEW_BORDERS
--- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -55,18 +55,16 @@ #include "nsThreadUtils.h" #include "nsContentUtils.h" #include "nsIPluginWidget.h" #include "nsXULPopupManager.h" #include "nsIPresShell.h" #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 DeCOMify newly private methods Optimize view storage */ @@ -160,38 +158,16 @@ nsViewManager::~nsViewManager() gViewManagers = nsnull; } mObserver = nsnull; } 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) { NS_PRECONDITION(nsnull != aContext, "null ptr"); if (nsnull == aContext) { return NS_ERROR_NULL_POINTER;
--- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -40,17 +40,16 @@ #include "nsCOMPtr.h" #include "nsIViewManager.h" #include "nsCRT.h" #include "nsITimer.h" #include "prtime.h" #include "prinrval.h" #include "nsVoidArray.h" #include "nsThreadUtils.h" -#include "nsIRegion.h" #include "nsView.h" #include "nsIViewObserver.h" #include "nsDeviceContext.h" /** Invalidation model: @@ -243,18 +242,16 @@ private: public: // NOT in nsIViewManager, so private to the view module nsView* GetRootViewImpl() const { return mRootView; } nsViewManager* RootViewManager() const { return mRootViewManager; } PRBool IsRootVM() const { return this == RootViewManager(); } 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 // pending updates. void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; } PRInt32 AppUnitsPerDevPixel() const { @@ -264,17 +261,16 @@ public: // NOT in nsIViewManager, so pri private: nsRefPtr<nsDeviceContext> mContext; nsIViewObserver *mObserver; // The size for a resize that we delayed until the root view becomes // visible again. nsSize mDelayedResize; - nsCOMPtr<nsIFactory> 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|). nsViewManager *mRootViewManager; nsRevocableEventPtr<nsInvalidateEvent> mInvalidateEvent; // The following members should not be accessed directly except by
--- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -52,17 +52,16 @@ #include "nsCocoaWindow.h" #include "nsObjCExceptions.h" #include "nsCOMPtr.h" #include "nsToolkit.h" #include "nsCRT.h" #include "nsFontMetrics.h" -#include "nsIRegion.h" #include "nsIRollupListener.h" #include "nsIViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsILocalFile.h" #include "nsILocalFileMac.h" #include "nsGfxCIID.h" #include "nsIMenuRollup.h" #include "nsIDOMSimpleGestureEvent.h"
--- a/widget/src/cocoa/nsDragService.mm +++ b/widget/src/cocoa/nsDragService.mm @@ -57,17 +57,16 @@ #include "nsPoint.h" #include "nsICharsetConverterManager.h" #include "nsIIOService.h" #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsIContent.h" #include "nsIFrame.h" #include "nsIView.h" -#include "nsIRegion.h" #include "gfxASurface.h" #include "gfxContext.h" #import <Cocoa/Cocoa.h> #ifdef PR_LOGGING extern PRLogModuleInfo* sCocoaLog; #endif
--- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -91,17 +91,16 @@ using namespace QtMobility; #ifdef MOZ_ENABLE_QTMOBILITY #include "mozqorientationsensorfilter.h" #endif #include "nsToolkit.h" #include "nsIdleService.h" #include "nsRenderingContext.h" -#include "nsIRegion.h" #include "nsIRollupListener.h" #include "nsIMenuRollup.h" #include "nsWidgetsCID.h" #include "nsQtKeyUtils.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" #include "nsIStringBundle.h"
--- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -122,17 +122,16 @@ #include "nsIDOMNSUIEvent.h" #include "nsITheme.h" #include "nsIObserverService.h" #include "nsIScreenManager.h" #include "imgIContainer.h" #include "nsIFile.h" #include "nsIRollupListener.h" #include "nsIMenuRollup.h" -#include "nsIRegion.h" #include "nsIServiceManager.h" #include "nsIClipboard.h" #include "nsIMM32Handler.h" #include "nsILocalFile.h" #include "nsFontMetrics.h" #include "nsIFontEnumerator.h" #include "nsILookAndFeel.h" #include "nsGUIEvent.h"
--- a/widget/src/windows/nsWindowGfx.cpp +++ b/widget/src/windows/nsWindowGfx.cpp @@ -53,17 +53,16 @@ ************************************************************** **************************************************************/ #include "mozilla/plugins/PluginInstanceParent.h" using mozilla::plugins::PluginInstanceParent; #include "nsWindowGfx.h" #include <windows.h> -#include "nsIRegion.h" #include "gfxImageSurface.h" #include "gfxWindowsSurface.h" #include "gfxWindowsPlatform.h" #include "nsGfxCIID.h" #include "gfxContext.h" #include "nsRenderingContext.h" #include "prmem.h"
--- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -38,17 +38,16 @@ #include "nsBaseDragService.h" #include "nsITransferable.h" #include "nsIServiceManager.h" #include "nsITransferable.h" #include "nsISupportsArray.h" #include "nsSize.h" -#include "nsIRegion.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsCOMPtr.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIFrame.h" #include "nsIDocument.h" #include "nsIContent.h" #include "nsIPresShell.h" @@ -515,21 +514,17 @@ nsBaseDragService::DrawDrag(nsIDOMNode* return DrawDragForImage(*aPresContext, imageLoader, nsnull, aScreenX, aScreenY, aScreenDragRect, aSurface); } } // otherwise, just draw the node nsIntRegion clipRegion; if (aRegion) { - nsCOMPtr<nsIRegion> clipIRegion; - aRegion->GetRegion(getter_AddRefs(clipIRegion)); - if (clipIRegion) { - clipRegion = clipIRegion->GetUnderlyingRegion(); - } + aRegion->GetRegion(&clipRegion); } nsIntPoint pnt(aScreenDragRect->x, aScreenDragRect->y); nsRefPtr<gfxASurface> surface = presShell->RenderNode(dragNode, aRegion ? &clipRegion : nsnull, pnt, aScreenDragRect); // if an image was specified, reposition the drag rectangle to