2015-05-03 12:32:37 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2008-03-11 17:51:12 -07:00
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
#include "mozilla/dom/DOMRect.h"
|
2008-03-11 17:51:12 -07:00
|
|
|
|
2008-09-18 02:47:21 -07:00
|
|
|
#include "nsPresContext.h"
|
2013-09-20 03:21:03 -07:00
|
|
|
#include "mozilla/dom/DOMRectListBinding.h"
|
|
|
|
#include "mozilla/dom/DOMRectBinding.h"
|
2008-09-18 02:47:21 -07:00
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2010-01-12 05:08:43 -08:00
|
|
|
|
2014-04-29 01:57:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMRectReadOnly, mParent)
|
2013-09-20 03:21:03 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRectReadOnly)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRectReadOnly)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMRectReadOnly)
|
2013-03-17 00:55:17 -07:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2008-03-11 17:51:12 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
DOMRectReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-09-20 03:21:03 -07:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(mParent);
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return DOMRectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
2013-09-20 03:21:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(DOMRect, DOMRectReadOnly, nsIDOMClientRect)
|
2013-09-20 03:21:03 -07:00
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
#define FORWARD_GETTER(_name) \
|
|
|
|
NS_IMETHODIMP \
|
2013-09-20 03:21:03 -07:00
|
|
|
DOMRect::Get ## _name(float* aResult) \
|
2013-03-17 00:55:17 -07:00
|
|
|
{ \
|
2013-09-20 03:21:03 -07:00
|
|
|
*aResult = float(_name()); \
|
2013-03-17 00:55:17 -07:00
|
|
|
return NS_OK; \
|
|
|
|
}
|
|
|
|
|
|
|
|
FORWARD_GETTER(Left)
|
|
|
|
FORWARD_GETTER(Top)
|
|
|
|
FORWARD_GETTER(Right)
|
|
|
|
FORWARD_GETTER(Bottom)
|
|
|
|
FORWARD_GETTER(Width)
|
|
|
|
FORWARD_GETTER(Height)
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
DOMRect::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2008-03-11 17:51:12 -07:00
|
|
|
{
|
2013-03-17 00:55:17 -07:00
|
|
|
MOZ_ASSERT(mParent);
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return DOMRectBinding::Wrap(aCx, this, aGivenProto);
|
2008-03-11 17:51:12 -07:00
|
|
|
}
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
already_AddRefed<DOMRect>
|
|
|
|
DOMRect::Constructor(const GlobalObject& aGlobal, ErrorResult& aRV)
|
|
|
|
{
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<DOMRect> obj =
|
2013-09-20 03:21:03 -07:00
|
|
|
new DOMRect(aGlobal.GetAsSupports(), 0.0, 0.0, 0.0, 0.0);
|
|
|
|
return obj.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<DOMRect>
|
|
|
|
DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
|
|
|
double aWidth, double aHeight, ErrorResult& aRV)
|
|
|
|
{
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<DOMRect> obj =
|
2013-09-20 03:21:03 -07:00
|
|
|
new DOMRect(aGlobal.GetAsSupports(), aX, aY, aWidth, aHeight);
|
|
|
|
return obj.forget();
|
|
|
|
}
|
|
|
|
|
2013-03-17 00:55:17 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
2008-08-15 15:26:37 -07:00
|
|
|
|
2014-04-29 01:57:00 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMRectList, mParent, mArray)
|
2011-08-22 02:14:13 -07:00
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
NS_INTERFACE_TABLE_HEAD(DOMRectList)
|
2014-08-25 16:21:35 -07:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_INTERFACE_TABLE(DOMRectList, nsIDOMClientRectList)
|
2013-09-20 03:21:03 -07:00
|
|
|
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(DOMRectList)
|
2008-03-11 17:51:12 -07:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRectList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRectList)
|
2008-03-11 17:51:12 -07:00
|
|
|
|
|
|
|
|
2013-09-20 03:21:03 -07:00
|
|
|
NS_IMETHODIMP
|
2013-09-20 03:21:03 -07:00
|
|
|
DOMRectList::GetLength(uint32_t* aLength)
|
2008-03-11 17:51:12 -07:00
|
|
|
{
|
2012-09-05 13:49:53 -07:00
|
|
|
*aLength = Length();
|
2008-03-11 17:51:12 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-09-20 03:21:03 -07:00
|
|
|
DOMRectList::Item(uint32_t aIndex, nsIDOMClientRect** aReturn)
|
2008-03-11 17:51:12 -07:00
|
|
|
{
|
2012-09-05 13:49:53 -07:00
|
|
|
NS_IF_ADDREF(*aReturn = Item(aIndex));
|
2008-03-11 17:51:12 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2008-09-18 02:47:21 -07:00
|
|
|
|
2011-08-22 02:14:13 -07:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
DOMRectList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
|
2011-08-22 02:14:13 -07:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 07:13:33 -07:00
|
|
|
return mozilla::dom::DOMRectListBinding::Wrap(cx, this, aGivenProto);
|
2011-08-22 02:14:13 -07:00
|
|
|
}
|
|
|
|
|
2008-09-18 02:47:21 -07:00
|
|
|
static double
|
|
|
|
RoundFloat(double aValue)
|
|
|
|
{
|
|
|
|
return floor(aValue + 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-09-20 03:21:03 -07:00
|
|
|
DOMRect::SetLayoutRect(const nsRect& aLayoutRect)
|
2008-09-18 02:47:21 -07:00
|
|
|
{
|
|
|
|
double scale = 65536.0;
|
|
|
|
// Round to the nearest 1/scale units. We choose scale so it can be represented
|
|
|
|
// exactly by machine floating point.
|
|
|
|
double scaleInv = 1/scale;
|
2009-09-03 21:49:18 -07:00
|
|
|
double t2pScaled = scale/nsPresContext::AppUnitsPerCSSPixel();
|
2008-09-18 02:47:21 -07:00
|
|
|
double x = RoundFloat(aLayoutRect.x*t2pScaled)*scaleInv;
|
|
|
|
double y = RoundFloat(aLayoutRect.y*t2pScaled)*scaleInv;
|
|
|
|
SetRect(x, y, RoundFloat(aLayoutRect.XMost()*t2pScaled)*scaleInv - x,
|
|
|
|
RoundFloat(aLayoutRect.YMost()*t2pScaled)*scaleInv - y);
|
|
|
|
}
|