2012-12-22 20:54:20 -08:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "mozilla/dom/SVGPointBinding.h"
|
2013-01-16 17:35:24 -08:00
|
|
|
#include "DOMSVGPointList.h"
|
2012-12-22 20:54:20 -08:00
|
|
|
|
|
|
|
class nsSVGElement;
|
|
|
|
|
|
|
|
// {d6b6c440-af8d-40ee-856b-02a317cab275}
|
|
|
|
#define MOZILLA_NSISVGPOINT_IID \
|
|
|
|
{ 0xd6b6c440, 0xaf8d, 0x40ee, \
|
|
|
|
{ 0x85, 0x6b, 0x02, 0xa3, 0x17, 0xca, 0xb2, 0x75 } }
|
|
|
|
|
2014-08-06 06:58:57 -07:00
|
|
|
#define MOZ_SVG_LIST_INDEX_BIT_COUNT 29
|
2013-01-16 17:35:24 -08:00
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
namespace mozilla {
|
|
|
|
|
2013-01-11 12:30:21 -08:00
|
|
|
namespace dom {
|
|
|
|
class SVGMatrix;
|
|
|
|
}
|
2012-12-22 20:54:20 -08:00
|
|
|
|
2012-12-22 20:54:20 -08:00
|
|
|
/**
|
|
|
|
* Class nsISVGPoint
|
|
|
|
*
|
|
|
|
* This class creates the DOM objects that wrap internal SVGPoint objects.
|
2013-01-16 17:35:24 -08:00
|
|
|
* An nsISVGPoint can be either a DOMSVGPoint or a DOMSVGTranslatePoint
|
2012-12-22 20:54:20 -08:00
|
|
|
*/
|
2012-12-22 20:54:25 -08:00
|
|
|
class nsISVGPoint : public nsISupports,
|
2012-12-22 20:54:20 -08:00
|
|
|
public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_NSISVGPOINT_IID)
|
2013-01-16 17:35:24 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsISVGPoint)
|
2012-12-22 20:54:20 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic ctor for DOMSVGPoint objects that are created for an attribute.
|
|
|
|
*/
|
|
|
|
explicit nsISVGPoint()
|
2013-01-16 17:35:24 -08:00
|
|
|
: mList(nullptr)
|
|
|
|
, mListIndex(0)
|
|
|
|
, mIsReadonly(false)
|
|
|
|
, mIsAnimValItem(false)
|
2014-08-06 06:58:57 -07:00
|
|
|
, mIsTranslatePoint(false)
|
2013-01-16 17:35:24 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-06 06:58:57 -07:00
|
|
|
explicit nsISVGPoint(SVGPoint* aPt, bool aIsTranslatePoint)
|
2013-01-16 17:35:24 -08:00
|
|
|
: mList(nullptr)
|
|
|
|
, mListIndex(0)
|
|
|
|
, mIsReadonly(false)
|
|
|
|
, mIsAnimValItem(false)
|
2014-08-06 06:58:57 -07:00
|
|
|
, mIsTranslatePoint(aIsTranslatePoint)
|
2012-12-22 20:54:20 -08:00
|
|
|
{
|
2013-01-16 17:35:24 -08:00
|
|
|
mPt.mX = aPt->GetX();
|
|
|
|
mPt.mY = aPt->GetY();
|
|
|
|
}
|
|
|
|
|
2014-06-24 09:36:45 -07:00
|
|
|
protected:
|
2013-01-16 17:35:24 -08:00
|
|
|
virtual ~nsISVGPoint()
|
|
|
|
{
|
|
|
|
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
|
|
|
// unlinked us using the cycle collector code, then that has already
|
|
|
|
// happened, and mList is null.
|
|
|
|
if (mList) {
|
|
|
|
mList->mItems[mListIndex] = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 09:36:45 -07:00
|
|
|
public:
|
2013-01-16 17:35:24 -08:00
|
|
|
/**
|
2014-08-06 06:58:57 -07:00
|
|
|
* Creates an unowned copy of this object's point as a DOMSVGPoint.
|
2013-01-16 17:35:24 -08:00
|
|
|
*/
|
2014-08-06 06:58:57 -07:00
|
|
|
virtual DOMSVGPoint* Copy() = 0;
|
2013-01-16 17:35:24 -08:00
|
|
|
|
|
|
|
SVGPoint ToSVGPoint() const {
|
|
|
|
return HasOwner() ? const_cast<nsISVGPoint*>(this)->InternalItem() : mPt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsInList() const {
|
|
|
|
return !!mList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In future, if this class is used for non-list points, this will be
|
|
|
|
* different to IsInList(). "Owner" here means that the instance has an
|
|
|
|
* internal counterpart from which it gets its values. (A better name may
|
|
|
|
* be HasWrappee().)
|
|
|
|
*/
|
|
|
|
bool HasOwner() const {
|
|
|
|
return !!mList;
|
|
|
|
}
|
|
|
|
|
2014-08-06 06:58:57 -07:00
|
|
|
bool IsTranslatePoint() const {
|
|
|
|
return mIsTranslatePoint;
|
|
|
|
}
|
|
|
|
|
2013-01-16 17:35:24 -08:00
|
|
|
/**
|
|
|
|
* This method is called to notify this DOM object that it is being inserted
|
|
|
|
* into a list, and give it the information it needs as a result.
|
|
|
|
*
|
|
|
|
* This object MUST NOT already belong to a list when this method is called.
|
|
|
|
* That's not to say that script can't move these DOM objects between
|
|
|
|
* lists - it can - it's just that the logic to handle that (and send out
|
|
|
|
* the necessary notifications) is located elsewhere (in DOMSVGPointList).)
|
|
|
|
*/
|
|
|
|
void InsertingIntoList(DOMSVGPointList *aList,
|
|
|
|
uint32_t aListIndex,
|
|
|
|
bool aIsAnimValItem);
|
|
|
|
|
|
|
|
static uint32_t MaxListIndex() {
|
|
|
|
return (1U << MOZ_SVG_LIST_INDEX_BIT_COUNT) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This method is called to notify this object that its list index changed.
|
|
|
|
void UpdateListIndex(uint32_t aListIndex) {
|
|
|
|
mListIndex = aListIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called to notify this DOM object that it is about to be
|
|
|
|
* removed from its current DOM list so that it can first make a copy of its
|
|
|
|
* internal counterpart's values. (If it didn't do this, then it would
|
|
|
|
* "lose" its value on being removed.)
|
|
|
|
*/
|
|
|
|
void RemovingFromList();
|
|
|
|
|
|
|
|
bool IsReadonly() const {
|
|
|
|
return mIsReadonly;
|
|
|
|
}
|
|
|
|
void SetReadonly(bool aReadonly) {
|
|
|
|
mIsReadonly = aReadonly;
|
2012-12-22 20:54:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL
|
|
|
|
virtual float X() = 0;
|
|
|
|
virtual void SetX(float aX, ErrorResult& rv) = 0;
|
|
|
|
virtual float Y() = 0;
|
|
|
|
virtual void SetY(float aY, ErrorResult& rv) = 0;
|
2013-01-11 12:30:21 -08:00
|
|
|
virtual already_AddRefed<nsISVGPoint> MatrixTransform(dom::SVGMatrix& matrix) = 0;
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override
|
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 dom::SVGPointBinding::Wrap(cx, this, aGivenProto); }
|
2012-12-22 20:54:20 -08:00
|
|
|
|
|
|
|
virtual nsISupports* GetParentObject() = 0;
|
2013-01-16 17:35:24 -08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool IndexIsValid();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsRefPtr<DOMSVGPointList> mList;
|
|
|
|
|
|
|
|
// Bounds for the following are checked in the ctor, so be sure to update
|
|
|
|
// that if you change the capacity of any of the following.
|
|
|
|
|
|
|
|
uint32_t mListIndex:MOZ_SVG_LIST_INDEX_BIT_COUNT;
|
2014-08-06 06:58:57 -07:00
|
|
|
uint32_t mIsReadonly:1; // These flags are uint32_t because MSVC won't
|
|
|
|
uint32_t mIsAnimValItem:1; // pack otherwise.
|
|
|
|
uint32_t mIsTranslatePoint:1;
|
2013-01-16 17:35:24 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a reference to the internal SVGPoint list item that this DOM wrapper
|
|
|
|
* object currently wraps.
|
|
|
|
*
|
|
|
|
* To simplify the code we just have this one method for obtaining both
|
|
|
|
* baseVal and animVal internal items. This means that animVal items don't
|
|
|
|
* get const protection, but then our setter methods guard against changing
|
|
|
|
* animVal items.
|
|
|
|
*/
|
|
|
|
SVGPoint& InternalItem();
|
|
|
|
|
|
|
|
// The following member is only used when we're not in a list:
|
|
|
|
SVGPoint mPt;
|
2012-12-22 20:54:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGPoint, MOZILLA_NSISVGPOINT_IID)
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2013-01-16 17:35:24 -08:00
|
|
|
#undef MOZ_SVG_LIST_INDEX_BIT_COUNT
|
|
|
|
|
|
|
|
|