diff --git a/gfx/src/moz.build b/gfx/src/moz.build index b37b57caad44..8c0e6b9a089a 100644 --- a/gfx/src/moz.build +++ b/gfx/src/moz.build @@ -6,7 +6,6 @@ XPIDL_SOURCES += [ 'nsIFontEnumerator.idl', - 'nsIScriptableRegion.idl', ] XPIDL_MODULE = 'gfx' @@ -68,7 +67,6 @@ UNIFIED_SOURCES += [ 'nsFontMetrics.cpp', 'nsRect.cpp', 'nsRegion.cpp', - 'nsScriptableRegion.cpp', 'nsThebesFontEnumerator.cpp', 'nsThebesGfxFactory.cpp', 'nsTransform2D.cpp', diff --git a/gfx/src/nsIScriptableRegion.idl b/gfx/src/nsIScriptableRegion.idl deleted file mode 100644 index 1e32fdd1baec..000000000000 --- a/gfx/src/nsIScriptableRegion.idl +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -%{C++ -#include "nsRegionFwd.h" -%} - -native nsIntRegion(nsIntRegion); - - -[scriptable, uuid(a5f44cc7-2820-489b-b817-ae8a08506ff6)] -interface nsIScriptableRegion : nsISupports -{ - void init ( ) ; - - /** - * copy operator equivalent that takes another region - * - * @param region to copy - * @return void - * - **/ - - void setToRegion ( in nsIScriptableRegion aRegion ); - - /** - * 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 - * - **/ - - void setToRect ( in long aX, in long aY, in long aWidth, in long aHeight ); - - /** - * destructively intersect another region with this one - * - * @param region to intersect - * @return void - * - **/ - - void intersectRegion ( in nsIScriptableRegion aRegion ) ; - - /** - * 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 - * - **/ - - void intersectRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ; - - /** - * destructively union another region with this one - * - * @param region to union - * @return void - * - **/ - - void unionRegion ( in nsIScriptableRegion aRegion ) ; - - /** - * 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 - * - **/ - - void unionRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ; - - /** - * destructively subtract another region with this one - * - * @param region to subtract - * @return void - * - **/ - - void subtractRegion ( in nsIScriptableRegion aRegion ) ; - - /** - * 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 - * - **/ - - void subtractRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ; - - /** - * is this region empty? i.e. does it contain any pixels - * - * @param none - * @return returns whether the region is empty - * - **/ - - boolean isEmpty ( ) ; - - /** - * == operator equivalent i.e. do the regions contain exactly - * the same pixels - * - * @param region to compare - * @return whether the regions are identical - * - **/ - - boolean isEqualRegion ( in nsIScriptableRegion aRegion ) ; - - /** - * 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 - * - **/ - void getBoundingBox ( out long aX, out long aY, out long aWidth, out long aHeight ) ; - - /** - * offsets the region in x and y - * - * @param xoffset pixel offset in x - * @param yoffset pixel offset in y - * @return void - * - **/ - void offset ( in long aXOffset, in long aYOffset ) ; - - /** - * @return null if there are no rects, - * @return flat array of rects,ie [x1,y1,width1,height1,x2...]. - * The result will contain bogus data if values don't fit in 31 bit - **/ - [implicit_jscontext] jsval getRects(); - - /** - * does the region intersect the rectangle? - * - * @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 nsIntRegion region; - -}; diff --git a/gfx/src/nsScriptableRegion.cpp b/gfx/src/nsScriptableRegion.cpp deleted file mode 100644 index a6d4ff98ac71..000000000000 --- a/gfx/src/nsScriptableRegion.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsScriptableRegion.h" -#include // for uint32_t -#include // for int32_t -#include "js/RootingAPI.h" // for Rooted -#include "js/Value.h" // for INT_TO_JSVAL, etc -#include "jsapi.h" // for JS_DefineElement, etc -#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 -#include "nsError.h" // for NS_OK, NS_ERROR_FAILURE, etc -#include "nsID.h" -#include "nsRect.h" // for mozilla::gfx::IntRect -#include "nscore.h" // for NS_IMETHODIMP - -class JSObject; -struct JSContext; - -nsScriptableRegion::nsScriptableRegion() -{ -} - -NS_IMPL_ISUPPORTS(nsScriptableRegion, nsIScriptableRegion) - -NS_IMETHODIMP nsScriptableRegion::Init() -{ - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::SetToRegion(nsIScriptableRegion *aRegion) -{ - aRegion->GetRegion(&mRegion); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::SetToRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) -{ - mRegion = mozilla::gfx::IntRect(aX, aY, aWidth, aHeight); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::IntersectRegion(nsIScriptableRegion *aRegion) -{ - nsIntRegion region; - aRegion->GetRegion(®ion); - mRegion.And(mRegion, region); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::IntersectRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) -{ - mRegion.And(mRegion, mozilla::gfx::IntRect(aX, aY, aWidth, aHeight)); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::UnionRegion(nsIScriptableRegion *aRegion) -{ - nsIntRegion region; - aRegion->GetRegion(®ion); - mRegion.Or(mRegion, region); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::UnionRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) -{ - mRegion.Or(mRegion, mozilla::gfx::IntRect(aX, aY, aWidth, aHeight)); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::SubtractRegion(nsIScriptableRegion *aRegion) -{ - nsIntRegion region; - aRegion->GetRegion(®ion); - mRegion.Sub(mRegion, region); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::SubtractRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight) -{ - mRegion.Sub(mRegion, mozilla::gfx::IntRect(aX, aY, aWidth, aHeight)); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::IsEmpty(bool *isEmpty) -{ - *isEmpty = mRegion.IsEmpty(); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::IsEqualRegion(nsIScriptableRegion *aRegion, bool *isEqual) -{ - nsIntRegion region; - aRegion->GetRegion(®ion); - *isEqual = mRegion.IsEqual(region); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::GetBoundingBox(int32_t *aX, int32_t *aY, int32_t *aWidth, int32_t *aHeight) -{ - mozilla::gfx::IntRect boundRect = mRegion.GetBounds(); - boundRect.GetRect(aX, aY, aWidth, aHeight); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::Offset(int32_t aXOffset, int32_t aYOffset) -{ - mRegion.MoveBy(aXOffset, aYOffset); - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::ContainsRect(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight, bool *containsRect) -{ - *containsRect = mRegion.Contains(mozilla::gfx::IntRect(aX, aY, aWidth, aHeight)); - return NS_OK; -} - - -NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIntRegion* outRgn) -{ - *outRgn = mRegion; - return NS_OK; -} - -NS_IMETHODIMP nsScriptableRegion::GetRects(JSContext* aCx, JS::MutableHandle aRects) -{ - uint32_t numRects = mRegion.GetNumRects(); - - if (!numRects) { - aRects.setNull(); - return NS_OK; - } - - JS::Rooted destArray(aCx, JS_NewArrayObject(aCx, numRects * 4)); - if (!destArray) { - return NS_ERROR_OUT_OF_MEMORY; - } - - aRects.setObject(*destArray); - - uint32_t n = 0; - for (auto iter = mRegion.RectIter(); !iter.Done(); iter.Next()) { - const mozilla::gfx::IntRect& rect = iter.Get(); - if (!JS_DefineElement(aCx, destArray, n, rect.X(), JSPROP_ENUMERATE) || - !JS_DefineElement(aCx, destArray, n + 1, rect.Y(), JSPROP_ENUMERATE) || - !JS_DefineElement(aCx, destArray, n + 2, rect.Width(), JSPROP_ENUMERATE) || - !JS_DefineElement(aCx, destArray, n + 3, rect.Height(), JSPROP_ENUMERATE)) { - return NS_ERROR_FAILURE; - } - n += 4; - } - - return NS_OK; -} diff --git a/gfx/src/nsScriptableRegion.h b/gfx/src/nsScriptableRegion.h deleted file mode 100644 index 706b0bbe6118..000000000000 --- a/gfx/src/nsScriptableRegion.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsScriptableRegion_h -#define nsScriptableRegion_h - -#include "nsIScriptableRegion.h" -#include "nsISupports.h" -#include "nsRegion.h" -#include "mozilla/Attributes.h" - -class nsScriptableRegion final : public nsIScriptableRegion { -public: - nsScriptableRegion(); - - NS_DECL_ISUPPORTS - - NS_DECL_NSISCRIPTABLEREGION - -private: - ~nsScriptableRegion() {} - nsIntRegion mRegion; -}; - -#endif diff --git a/gfx/src/nsThebesGfxFactory.cpp b/gfx/src/nsThebesGfxFactory.cpp index 5cbca4d1afd8..ffde0d1d65b0 100644 --- a/gfx/src/nsThebesGfxFactory.cpp +++ b/gfx/src/nsThebesGfxFactory.cpp @@ -14,40 +14,20 @@ #include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc #include "nsGfxCIID.h" // for NS_FONT_ENUMERATOR_CID, etc #include "nsID.h" // for NS_DEFINE_NAMED_CID, etc -#include "nsIScriptableRegion.h" // for nsIScriptableRegion #include "nsISupports.h" // for NS_DECL_ISUPPORTS, etc -#include "nsScriptableRegion.h" // for nsScriptableRegion #include "nsThebesFontEnumerator.h" // for nsThebesFontEnumerator NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator) -static nsresult -nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - if (!aResult) { - return NS_ERROR_NULL_POINTER; - } - *aResult = nullptr; - if (aOuter) { - return NS_ERROR_NO_AGGREGATION; - } - - nsCOMPtr scriptableRgn = new nsScriptableRegion(); - return scriptableRgn->QueryInterface(aIID, aResult); -} - NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID); -NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID); static const mozilla::Module::CIDEntry kThebesCIDs[] = { { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor }, - { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor }, { nullptr } }; static const mozilla::Module::ContractIDEntry kThebesContracts[] = { { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID }, - { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID }, { nullptr } }; diff --git a/gfx/tests/moz.build b/gfx/tests/moz.build index ec51ffdf0c4f..dda8e1611471 100644 --- a/gfx/tests/moz.build +++ b/gfx/tests/moz.build @@ -4,7 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini'] BROWSER_CHROME_MANIFESTS += ['browser/browser.ini'] -MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini'] \ No newline at end of file +MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini'] diff --git a/gfx/tests/unit/.eslintrc.js b/gfx/tests/unit/.eslintrc.js deleted file mode 100644 index 70fe35407782..000000000000 --- a/gfx/tests/unit/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "plugin:mozilla/xpcshell-test" - ] -}; diff --git a/gfx/tests/unit/test_nsIScriptableRegion.js b/gfx/tests/unit/test_nsIScriptableRegion.js deleted file mode 100644 index a916e92386f4..000000000000 --- a/gfx/tests/unit/test_nsIScriptableRegion.js +++ /dev/null @@ -1,10 +0,0 @@ -function run_test() -{ - let rgn = Cc["@mozilla.org/gfx/region;1"].createInstance(Ci.nsIScriptableRegion); - Assert.ok (rgn.getRects() === null) - rgn.unionRect(0,0,80,60); - Assert.ok (rgn.getRects().toString() == "0,0,80,60") - rgn.unionRect(90,70,1,1); - Assert.ok (rgn.getRects().toString() == "0,0,80,60,90,70,1,1") -} - diff --git a/gfx/tests/unit/xpcshell.ini b/gfx/tests/unit/xpcshell.ini deleted file mode 100644 index 982c34efa671..000000000000 --- a/gfx/tests/unit/xpcshell.ini +++ /dev/null @@ -1,4 +0,0 @@ -[DEFAULT] -head = - -[test_nsIScriptableRegion.js]