Bug 850817 - Move ClientRect to Paris bindings; r=bz

--HG--
rename : dom/interfaces/base/nsIDOMClientRect.idl => dom/webidl/ClientRect.webidl
This commit is contained in:
Ms2ger 2013-03-17 08:55:17 +01:00
Родитель 371e929457
Коммит 4a10101367
18 изменённых файлов: 177 добавлений и 142 удалений

Просмотреть файл

@ -654,7 +654,7 @@ Element::GetClientAreaRect()
already_AddRefed<nsClientRect>
Element::GetBoundingClientRect()
{
nsRefPtr<nsClientRect> rect = new nsClientRect();
nsRefPtr<nsClientRect> rect = new nsClientRect(this);
nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
if (!frame) {

Просмотреть файл

@ -2938,12 +2938,13 @@ nsRange::GetBoundingClientRect(nsIDOMClientRect** aResult)
return NS_OK;
}
already_AddRefed<nsIDOMClientRect>
already_AddRefed<nsClientRect>
nsRange::GetBoundingClientRect()
{
nsRefPtr<nsClientRect> rect = new nsClientRect();
if (!mStartParent)
nsRefPtr<nsClientRect> rect = new nsClientRect(ToSupports(this));
if (!mStartParent) {
return rect.forget();
}
nsLayoutUtils::RectAccumulator accumulator;
CollectClientRects(&accumulator, this, mStartParent, mStartOffset,

Просмотреть файл

@ -20,6 +20,7 @@
#include "nsWrapperCache.h"
#include "mozilla/Attributes.h"
class nsClientRect;
class nsClientRectList;
class nsIDOMDocumentFragment;
@ -192,7 +193,7 @@ public:
void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
void SurroundContents(nsINode& aNode, ErrorResult& aErr);
already_AddRefed<nsIDOMClientRect> GetBoundingClientRect();
already_AddRefed<nsClientRect> GetBoundingClientRect();
already_AddRefed<nsClientRectList> GetClientRects();
nsINode* GetParentObject() const { return mOwner; }

Просмотреть файл

@ -54,33 +54,26 @@ nsDOMNotifyPaintEvent::GetRegion()
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
{
// Weak ref, since we addref it below
nsClientRect* rect = new nsClientRect();
if (!rect)
return NS_ERROR_OUT_OF_MEMORY;
nsRefPtr<nsClientRect> rect = new nsClientRect(ToSupports(this));
NS_ADDREF(*aResult = rect);
if (!mPresContext)
return NS_OK;
if (mPresContext) {
rect->SetLayoutRect(GetRegion().GetBounds());
}
rect->SetLayoutRect(GetRegion().GetBounds());
rect.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
{
nsRefPtr<nsClientRectList> rectList =
new nsClientRectList(static_cast<nsIDOMEvent*>(static_cast<nsDOMEvent*>(this)));
if (!rectList)
return NS_ERROR_OUT_OF_MEMORY;
nsISupports* parent = ToSupports(this);
nsRefPtr<nsClientRectList> rectList = new nsClientRectList(parent);
nsRegion r = GetRegion();
nsRegionRectIterator iter(r);
for (const nsRect* rgnRect = iter.Next(); rgnRect; rgnRect = iter.Next()) {
nsRefPtr<nsClientRect> rect = new nsClientRect();
if (!rect)
return NS_ERROR_OUT_OF_MEMORY;
nsRefPtr<nsClientRect> rect = new nsClientRect(parent);
rect->SetLayoutRect(*rgnRect);
rectList->Append(rect);

Просмотреть файл

@ -17,6 +17,7 @@ nsDOMScrollAreaEvent::nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
nsScrollAreaEvent *aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent)
, mClientArea(nullptr)
{
mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
}
@ -42,29 +43,18 @@ NS_INTERFACE_MAP_BEGIN(nsDOMScrollAreaEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
NS_IMETHODIMP
nsDOMScrollAreaEvent::GetX(float *aX)
{
return mClientArea.GetLeft(aX);
}
#define FORWARD_GETTER(_name) \
NS_IMETHODIMP \
nsDOMScrollAreaEvent::Get ## _name(float* aResult) \
{ \
*aResult = _name(); \
return NS_OK; \
}
NS_IMETHODIMP
nsDOMScrollAreaEvent::GetY(float *aY)
{
return mClientArea.GetTop(aY);
}
NS_IMETHODIMP
nsDOMScrollAreaEvent::GetWidth(float *aWidth)
{
return mClientArea.GetWidth(aWidth);
}
NS_IMETHODIMP
nsDOMScrollAreaEvent::GetHeight(float *aHeight)
{
return mClientArea.GetHeight(aHeight);
}
FORWARD_GETTER(X)
FORWARD_GETTER(Y)
FORWARD_GETTER(Width)
FORWARD_GETTER(Height)
NS_IMETHODIMP
nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
@ -93,15 +83,10 @@ nsDOMScrollAreaEvent::Serialize(IPC::Message* aMsg,
nsDOMEvent::Serialize(aMsg, false);
float val;
mClientArea.GetLeft(&val);
IPC::WriteParam(aMsg, val);
mClientArea.GetTop(&val);
IPC::WriteParam(aMsg, val);
mClientArea.GetWidth(&val);
IPC::WriteParam(aMsg, val);
mClientArea.GetHeight(&val);
IPC::WriteParam(aMsg, val);
IPC::WriteParam(aMsg, X());
IPC::WriteParam(aMsg, Y());
IPC::WriteParam(aMsg, Width());
IPC::WriteParam(aMsg, Height());
}
NS_IMETHODIMP_(bool)

Просмотреть файл

@ -35,6 +35,26 @@ public:
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter);
float X() const
{
return mClientArea.Left();
}
float Y() const
{
return mClientArea.Top();
}
float Width() const
{
return mClientArea.Width();
}
float Height() const
{
return mClientArea.Height();
}
protected:
nsClientRect mClientArea;
};

Просмотреть файл

@ -33,7 +33,7 @@ nsPaintRequest::WrapObject(JSContext* aCx, JSObject* aScope)
already_AddRefed<nsClientRect>
nsPaintRequest::ClientRect()
{
nsRefPtr<nsClientRect> clientRect = new nsClientRect();
nsRefPtr<nsClientRect> clientRect = new nsClientRect(this);
clientRect->SetLayoutRect(mRequest.mRect);
return clientRect.forget();
}

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; 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/. */
@ -9,66 +9,45 @@
#include "nsPresContext.h"
#include "mozilla/dom/ClientRectListBinding.h"
#include "mozilla/dom/ClientRectBinding.h"
DOMCI_DATA(ClientRect, nsClientRect)
using namespace mozilla;
using namespace mozilla::dom;
NS_INTERFACE_TABLE_HEAD(nsClientRect)
NS_INTERFACE_TABLE1(nsClientRect, nsIDOMClientRect)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ClientRect)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsClientRect, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsClientRect)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsClientRect)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsClientRect)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMClientRect)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsClientRect)
NS_IMPL_RELEASE(nsClientRect)
#define FORWARD_GETTER(_name) \
NS_IMETHODIMP \
nsClientRect::Get ## _name(float* aResult) \
{ \
*aResult = _name(); \
return NS_OK; \
}
nsClientRect::nsClientRect()
: mX(0.0), mY(0.0), mWidth(0.0), mHeight(0.0)
FORWARD_GETTER(Left)
FORWARD_GETTER(Top)
FORWARD_GETTER(Right)
FORWARD_GETTER(Bottom)
FORWARD_GETTER(Width)
FORWARD_GETTER(Height)
JSObject*
nsClientRect::WrapObject(JSContext* aCx, JSObject* aScope)
{
MOZ_ASSERT(mParent);
return ClientRectBinding::Wrap(aCx, aScope, this);
}
NS_IMETHODIMP
nsClientRect::GetLeft(float* aResult)
{
*aResult = mX;
return NS_OK;
}
// -----------------------------------------------------------------------------
NS_IMETHODIMP
nsClientRect::GetTop(float* aResult)
{
*aResult = mY;
return NS_OK;
}
NS_IMETHODIMP
nsClientRect::GetRight(float* aResult)
{
*aResult = mX + mWidth;
return NS_OK;
}
NS_IMETHODIMP
nsClientRect::GetBottom(float* aResult)
{
*aResult = mY + mHeight;
return NS_OK;
}
NS_IMETHODIMP
nsClientRect::GetWidth(float* aResult)
{
*aResult = mWidth;
return NS_OK;
}
NS_IMETHODIMP
nsClientRect::GetHeight(float* aResult)
{
*aResult = mHeight;
return NS_OK;
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsClientRectList, mParent)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsClientRectList, mParent, mArray)
NS_INTERFACE_TABLE_HEAD(nsClientRectList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; 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/. */
@ -8,28 +8,78 @@
#include "nsIDOMClientRect.h"
#include "nsIDOMClientRectList.h"
#include "nsCOMArray.h"
#include "nsTArray.h"
#include "nsRect.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsWrapperCache.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/Attributes.h"
class nsClientRect : public nsIDOMClientRect
class nsClientRect MOZ_FINAL : public nsIDOMClientRect
, public nsWrapperCache
{
public:
NS_DECL_ISUPPORTS
nsClientRect(nsISupports* aParent)
: mParent(aParent), mX(0.0), mY(0.0), mWidth(0.0), mHeight(0.0)
{
SetIsDOMBinding();
}
virtual ~nsClientRect() {}
nsClientRect();
void SetRect(float aX, float aY, float aWidth, float aHeight) {
mX = aX; mY = aY; mWidth = aWidth; mHeight = aHeight;
}
virtual ~nsClientRect() {}
NS_DECL_NSIDOMCLIENTRECT
void SetLayoutRect(const nsRect& aLayoutRect);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsClientRect)
NS_DECL_NSIDOMCLIENTRECT
nsISupports* GetParentObject() const
{
MOZ_ASSERT(mParent);
return mParent;
}
virtual JSObject*
WrapObject(JSContext* aCx, JSObject* aScope) MOZ_OVERRIDE;
float Left() const
{
return mX;
}
float Top() const
{
return mY;
}
float Right() const
{
return mX + mWidth;
}
float Bottom() const
{
return mY + mHeight;
}
float Width() const
{
return mWidth;
}
float Height() const
{
return mHeight;
}
protected:
nsCOMPtr<nsISupports> mParent;
float mX, mY, mWidth, mHeight;
};
@ -54,7 +104,7 @@ public:
return mParent;
}
void Append(nsIDOMClientRect* aElement) { mArray.AppendObject(aElement); }
void Append(nsClientRect* aElement) { mArray.AppendElement(aElement); }
static nsClientRectList* FromSupports(nsISupports* aSupports)
{
@ -75,22 +125,25 @@ public:
uint32_t Length()
{
return mArray.Count();
return mArray.Length();
}
nsIDOMClientRect* Item(uint32_t aIndex)
nsClientRect* Item(uint32_t aIndex)
{
return mArray.SafeObjectAt(aIndex);
return mArray.SafeElementAt(aIndex);
}
nsIDOMClientRect* IndexedGetter(uint32_t aIndex, bool& aFound)
nsClientRect* IndexedGetter(uint32_t aIndex, bool& aFound)
{
aFound = aIndex < static_cast<uint32_t>(mArray.Count());
return aFound ? mArray.ObjectAt(aIndex) : nullptr;
aFound = aIndex < mArray.Length();
if (!aFound) {
return nullptr;
}
return mArray[aIndex];
}
protected:
virtual ~nsClientRectList() {}
nsCOMArray<nsIDOMClientRect> mArray;
nsTArray< nsRefPtr<nsClientRect> > mArray;
nsCOMPtr<nsISupports> mParent;
};

Просмотреть файл

@ -99,7 +99,6 @@
#include "nsIDOMMediaList.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMConstructor.h"
#include "nsClientRect.h"
// DOM core includes
#include "nsError.h"
@ -908,9 +907,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsEventSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -2442,10 +2438,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(ClientRect, nsIDOMClientRect)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientRect)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
DOM_CLASSINFO_MAP_END

Просмотреть файл

@ -170,8 +170,6 @@ DOMCI_CLASS(StorageObsolete)
DOMCI_CLASS(Storage)
DOMCI_CLASS(StorageItem)
DOMCI_CLASS(ClientRect)
DOMCI_CLASS(XULCommandEvent)
DOMCI_CLASS(CommandEvent)
DOMCI_CLASS(OfflineResourceList)

Просмотреть файл

@ -1501,14 +1501,10 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
return NS_ERROR_DOM_SECURITY_ERR;
}
// Weak ref, since we addref it below
nsClientRect* rect = new nsClientRect();
NS_ADDREF(*aResult = rect);
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
nsCOMPtr<nsIDocument> doc(do_QueryInterface(window->GetExtantDocument()));
nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
nsRect bounds(0, 0, 0, 0);
@ -1524,10 +1520,12 @@ nsDOMWindowUtils::GetRootBounds(nsIDOMClientRect** aResult)
}
}
nsRefPtr<nsClientRect> rect = new nsClientRect(window);
rect->SetRect(nsPresContext::AppUnitsToFloatCSSPixels(bounds.x),
nsPresContext::AppUnitsToFloatCSSPixels(bounds.y),
nsPresContext::AppUnitsToFloatCSSPixels(bounds.width),
nsPresContext::AppUnitsToFloatCSSPixels(bounds.height));
rect.forget(aResult);
return NS_OK;
}

Просмотреть файл

@ -157,6 +157,10 @@ DOMInterfaces = {
'concrete': False
},
'ClientRect': {
'nativeType': 'nsClientRect',
},
'ClientRectList': {
'nativeType': 'nsClientRectList',
'headerFile': 'nsClientRect.h',
@ -1280,7 +1284,6 @@ addExternalIface('ArchiveRequest')
addExternalIface('Attr')
addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
addExternalIface('ClientRect')
addExternalIface('Counter')
addExternalIface('CSSRule')
addExternalIface('DOMRequest')

Просмотреть файл

@ -0,0 +1,14 @@
/* -*- 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/. */
interface ClientRect
{
readonly attribute float left;
readonly attribute float top;
readonly attribute float right;
readonly attribute float bottom;
readonly attribute float width;
readonly attribute float height;
};

Просмотреть файл

@ -27,6 +27,7 @@ webidl_files = \
CDATASection.webidl \
CFStateChangeEvent.webidl \
CharacterData.webidl \
ClientRect.webidl \
ClientRectList.webidl \
CommandEvent.webidl \
Comment.webidl \

Просмотреть файл

@ -46,7 +46,6 @@ members = [
'nsIDOMWindow.onmouseleave',
'nsIDOMWindowPerformance.performance',
'nsIDOMJSWindow.dump',
'nsIDOMClientRect.*',
# nsLocationSH has ~ALLOW_PROP_MODS_TO_PROTOTYPE, so don't try.
#'nsIDOMLocation.hostname',
#'nsIDOMLocation.href',

Просмотреть файл

@ -2266,7 +2266,7 @@ nsLayoutUtils::RectListBuilder::RectListBuilder(nsClientRectList* aList)
}
void nsLayoutUtils::RectListBuilder::AddRect(const nsRect& aRect) {
nsRefPtr<nsClientRect> rect = new nsClientRect();
nsRefPtr<nsClientRect> rect = new nsClientRect(mRectList);
rect->SetLayoutRect(aRect);
mRectList->Append(rect);

Просмотреть файл

@ -277,9 +277,7 @@ nsPopupBoxObject::GetAnchorNode(nsIDOMElement** aAnchor)
NS_IMETHODIMP
nsPopupBoxObject::GetOuterScreenRect(nsIDOMClientRect** aRect)
{
nsClientRect* rect = new nsClientRect();
if (!rect)
return NS_ERROR_OUT_OF_MEMORY;
nsClientRect* rect = new nsClientRect(mContent);
NS_ADDREF(*aRect = rect);