2015-05-03 22:32:37 +03: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 15:12:37 +04: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/. */
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2013-07-30 18:25:31 +04:00
|
|
|
#include <stdint.h>
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2014-07-30 21:16:57 +04:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2012-05-17 08:05:09 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2014-05-24 22:46:38 +04:00
|
|
|
#include "nsLayoutStylesheetCache.h"
|
2010-12-03 19:40:23 +03:00
|
|
|
#include "DOMSVGNumber.h"
|
2010-07-17 01:42:12 +04:00
|
|
|
#include "DOMSVGLength.h"
|
2006-02-21 20:00:02 +03:00
|
|
|
#include "nsSVGAngle.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIPresShell.h"
|
2007-07-13 12:49:07 +04:00
|
|
|
#include "nsContentUtils.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsIDocument.h"
|
2013-01-12 00:30:21 +04:00
|
|
|
#include "mozilla/dom/SVGMatrix.h"
|
2010-12-08 15:15:53 +03:00
|
|
|
#include "DOMSVGPoint.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
#include "nsIFrame.h"
|
2013-07-03 11:41:53 +04:00
|
|
|
#include "nsFrameSelection.h"
|
2004-08-05 13:01:13 +04:00
|
|
|
#include "nsISVGSVGFrame.h" //XXX
|
2013-03-26 19:52:41 +04:00
|
|
|
#include "mozilla/dom/SVGRect.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2004-12-24 19:26:10 +03:00
|
|
|
#include "nsISVGChildFrame.h"
|
2013-01-10 03:02:45 +04:00
|
|
|
#include "mozilla/dom/SVGSVGElement.h"
|
2013-01-10 03:02:47 +04:00
|
|
|
#include "mozilla/dom/SVGSVGElementBinding.h"
|
2012-09-22 23:26:05 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2013-01-08 07:22:41 +04:00
|
|
|
#include "mozilla/dom/SVGViewElement.h"
|
2011-11-08 19:00:29 +04:00
|
|
|
#include "nsStyleUtil.h"
|
2012-09-22 23:26:05 +04:00
|
|
|
#include "SVGContentUtils.h"
|
2001-12-12 10:59:31 +03:00
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
#include "nsSMILTimeContainer.h"
|
|
|
|
#include "nsSMILAnimationController.h"
|
|
|
|
#include "nsSMILTypes.h"
|
2012-12-23 08:54:23 +04:00
|
|
|
#include "SVGAngle.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2013-07-03 19:56:26 +04:00
|
|
|
#include "prtime.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT_CHECK_PARSER(SVG)
|
|
|
|
|
2013-12-30 10:50:17 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-08-15 19:19:34 +04:00
|
|
|
|
2013-03-12 02:05:58 +04:00
|
|
|
class SVGAnimatedLength;
|
|
|
|
|
2013-01-10 03:02:47 +04: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 17:13:33 +03:00
|
|
|
SVGSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-01-10 03:02:47 +04: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 17:13:33 +03:00
|
|
|
return SVGSVGElementBinding::Wrap(aCx, this, aGivenProto);
|
2013-01-10 03:02:47 +04:00
|
|
|
}
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(DOMSVGTranslatePoint, nsISVGPoint,
|
|
|
|
mElement)
|
2013-03-04 19:40:25 +04:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(DOMSVGTranslatePoint, nsISVGPoint)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(DOMSVGTranslatePoint, nsISVGPoint)
|
2009-04-28 17:25:03 +04:00
|
|
|
|
2013-01-17 05:35:24 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMSVGTranslatePoint)
|
2012-12-23 08:54:20 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2013-01-10 03:10:59 +04:00
|
|
|
// We have to qualify nsISVGPoint because NS_GET_IID looks for a class in the
|
|
|
|
// global namespace
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(mozilla::nsISVGPoint)
|
2009-04-28 17:25:03 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-06-24 20:36:45 +04:00
|
|
|
SVGSVGElement::~SVGSVGElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-08-06 17:58:57 +04:00
|
|
|
DOMSVGPoint*
|
|
|
|
DOMSVGTranslatePoint::Copy()
|
2009-04-28 17:25:03 +04:00
|
|
|
{
|
2014-08-06 17:58:57 +04:00
|
|
|
return new DOMSVGPoint(mPt.GetX(), mPt.GetY());
|
2009-04-28 17:25:03 +04:00
|
|
|
}
|
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
nsISupports*
|
2013-01-17 05:35:24 +04:00
|
|
|
DOMSVGTranslatePoint::GetParentObject()
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
2013-02-08 23:55:07 +04:00
|
|
|
return static_cast<nsIDOMSVGElement*>(mElement);
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-17 05:35:24 +04:00
|
|
|
DOMSVGTranslatePoint::SetX(float aValue, ErrorResult& rv)
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
2013-02-08 23:55:07 +04:00
|
|
|
mElement->SetCurrentTranslate(aValue, mPt.GetY());
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-17 05:35:24 +04:00
|
|
|
DOMSVGTranslatePoint::SetY(float aValue, ErrorResult& rv)
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
2013-02-08 23:55:07 +04:00
|
|
|
mElement->SetCurrentTranslate(mPt.GetX(), aValue);
|
2012-12-23 08:54:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsISVGPoint>
|
2013-01-17 05:35:24 +04:00
|
|
|
DOMSVGTranslatePoint::MatrixTransform(SVGMatrix& matrix)
|
2012-12-23 08:54:20 +04:00
|
|
|
{
|
2012-12-23 08:54:20 +04:00
|
|
|
float a = matrix.A(), b = matrix.B(), c = matrix.C();
|
|
|
|
float d = matrix.D(), e = matrix.E(), f = matrix.F();
|
2013-01-17 05:35:24 +04:00
|
|
|
float x = mPt.GetX();
|
|
|
|
float y = mPt.GetY();
|
2010-12-08 15:15:53 +03:00
|
|
|
|
2012-12-23 08:54:20 +04:00
|
|
|
nsCOMPtr<nsISVGPoint> point = new DOMSVGPoint(a*x + c*y + e, b*x + d*y + f);
|
|
|
|
return point.forget();
|
2009-04-28 17:25:03 +04:00
|
|
|
}
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
nsSVGElement::LengthInfo SVGSVGElement::sLengthInfo[4] =
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
2012-09-22 23:26:05 +04:00
|
|
|
{ &nsGkAtoms::x, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::width, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::height, 100, nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
|
2001-12-12 10:59:31 +03:00
|
|
|
};
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
nsSVGEnumMapping SVGSVGElement::sZoomAndPanMap[] = {
|
2013-01-10 09:24:37 +04:00
|
|
|
{&nsGkAtoms::disable, SVG_ZOOMANDPAN_DISABLE},
|
|
|
|
{&nsGkAtoms::magnify, SVG_ZOOMANDPAN_MAGNIFY},
|
2012-07-30 18:20:58 +04:00
|
|
|
{nullptr, 0}
|
2007-08-28 03:11:14 +04:00
|
|
|
};
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
nsSVGElement::EnumInfo SVGSVGElement::sEnumInfo[1] =
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
{ &nsGkAtoms::zoomAndPan,
|
|
|
|
sZoomAndPanMap,
|
2013-01-10 09:24:37 +04:00
|
|
|
SVG_ZOOMANDPAN_MAGNIFY
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsISupports methods
|
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(SVGSVGElement)
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGSVGElement,
|
|
|
|
SVGSVGElementBase)
|
2010-01-12 23:00:49 +03:00
|
|
|
if (tmp->mTimedDocumentRoot) {
|
|
|
|
tmp->mTimedDocumentRoot->Unlink();
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGSVGElement,
|
|
|
|
SVGSVGElementBase)
|
2010-01-12 23:00:49 +03:00
|
|
|
if (tmp->mTimedDocumentRoot) {
|
|
|
|
tmp->mTimedDocumentRoot->Traverse(&cb);
|
|
|
|
}
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(SVGSVGElement,SVGSVGElementBase)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(SVGSVGElement,SVGSVGElementBase)
|
2010-01-12 16:08:43 +03:00
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGSVGElement)
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_INTERFACE_TABLE_INHERITED(SVGSVGElement, nsIDOMNode, nsIDOMElement,
|
|
|
|
nsIDOMSVGElement)
|
2013-01-10 13:54:46 +04:00
|
|
|
NS_INTERFACE_TABLE_TAIL_INHERITING(SVGSVGElementBase)
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGSVGElement::SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2014-03-15 23:00:17 +04:00
|
|
|
FromParser aFromParser)
|
2013-01-10 03:02:45 +04:00
|
|
|
: SVGSVGElementBase(aNodeInfo),
|
2007-07-10 20:38:00 +04:00
|
|
|
mViewportWidth(0),
|
|
|
|
mViewportHeight(0),
|
2009-04-28 17:25:03 +04:00
|
|
|
mCurrentTranslate(0.0f, 0.0f),
|
|
|
|
mCurrentScale(1.0f),
|
|
|
|
mPreviousTranslate(0.0f, 0.0f),
|
|
|
|
mPreviousScale(1.0f),
|
2012-10-23 12:21:49 +04:00
|
|
|
mStartAnimationOnBindToTree(aFromParser == NOT_FROM_PARSER ||
|
|
|
|
aFromParser == FROM_PARSER_FRAGMENT ||
|
|
|
|
aFromParser == FROM_PARSER_XSLT),
|
2011-11-05 14:32:52 +04:00
|
|
|
mImageNeedsTransformInvalidation(false),
|
2012-05-17 08:05:09 +04:00
|
|
|
mIsPaintingSVGImageElement(false),
|
2012-05-31 14:39:12 +04:00
|
|
|
mHasChildrenOnlyTransform(false),
|
|
|
|
mUseCurrentView(false)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
// From NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSVGElement)
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult
|
2014-06-20 06:01:40 +04:00
|
|
|
SVGSVGElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2015-10-18 08:24:48 +03:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
2014-03-15 23:00:17 +04:00
|
|
|
SVGSVGElement *it = new SVGSVGElement(ni, NOT_FROM_PARSER);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsINode> kungFuDeathGrip = it;
|
2012-07-27 18:03:08 +04:00
|
|
|
nsresult rv1 = it->Init();
|
2013-01-10 03:02:45 +04:00
|
|
|
nsresult rv2 = const_cast<SVGSVGElement*>(this)->CopyInnerTo(it);
|
2012-07-27 18:03:08 +04:00
|
|
|
if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) {
|
2009-01-15 07:38:07 +03:00
|
|
|
kungFuDeathGrip.swap(*aResult);
|
|
|
|
}
|
|
|
|
|
2012-07-27 18:03:08 +04:00
|
|
|
return NS_FAILED(rv1) ? rv1 : rv2;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMSVGSVGElement methods:
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::X()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X].ToDOMAnimatedLength(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::Y()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y].ToDOMAnimatedLength(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::Width()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_WIDTH].ToDOMAnimatedLength(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-20 00:56:00 +04:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::Height()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_HEIGHT].ToDOMAnimatedLength(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
float
|
|
|
|
SVGSVGElement::PixelUnitToMillimeterX()
|
|
|
|
{
|
|
|
|
return MM_PER_INCH_FLOAT / 96;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
SVGSVGElement::PixelUnitToMillimeterY()
|
|
|
|
{
|
|
|
|
return PixelUnitToMillimeterX();
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
SVGSVGElement::ScreenPixelToMillimeterX()
|
|
|
|
{
|
|
|
|
return MM_PER_INCH_FLOAT / 96;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
SVGSVGElement::ScreenPixelToMillimeterY()
|
|
|
|
{
|
|
|
|
return ScreenPixelToMillimeterX();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SVGSVGElement::UseCurrentView()
|
|
|
|
{
|
|
|
|
return mUseCurrentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
SVGSVGElement::CurrentScale()
|
|
|
|
{
|
|
|
|
return mCurrentScale;
|
|
|
|
}
|
|
|
|
|
2005-09-30 22:51:43 +04:00
|
|
|
#define CURRENT_SCALE_MAX 16.0f
|
|
|
|
#define CURRENT_SCALE_MIN 0.0625f
|
|
|
|
|
2013-02-08 23:55:07 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetCurrentScale(float aCurrentScale)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-02-08 23:55:07 +04:00
|
|
|
SetCurrentScaleTranslate(aCurrentScale,
|
2009-04-28 17:25:03 +04:00
|
|
|
mCurrentTranslate.GetX(), mCurrentTranslate.GetY());
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
already_AddRefed<nsISVGPoint>
|
|
|
|
SVGSVGElement::CurrentTranslate()
|
|
|
|
{
|
2013-01-17 05:35:24 +04:00
|
|
|
nsCOMPtr<nsISVGPoint> point = new DOMSVGTranslatePoint(&mCurrentTranslate, this);
|
2013-01-10 03:02:47 +04:00
|
|
|
return point.forget();
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
uint32_t
|
|
|
|
SVGSVGElement::SuspendRedraw(uint32_t max_wait_milliseconds)
|
|
|
|
{
|
|
|
|
// suspendRedraw is a no-op in Mozilla, so it doesn't matter what
|
|
|
|
// we return
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-02-08 23:55:07 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::UnsuspendRedraw(uint32_t suspend_handle_id)
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-03-20 16:15:53 +04:00
|
|
|
// no-op
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-02-08 23:55:07 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::UnsuspendRedrawAll()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-03-20 16:15:53 +04:00
|
|
|
// no-op
|
2013-01-10 03:02:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-01-24 12:35:22 +03:00
|
|
|
SVGSVGElement::ForceRedraw()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2015-01-23 18:28:25 +03:00
|
|
|
// no-op
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
void
|
2013-02-08 23:55:07 +04:00
|
|
|
SVGSVGElement::PauseAnimations()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-01-27 23:30:21 +04:00
|
|
|
if (mTimedDocumentRoot) {
|
|
|
|
mTimedDocumentRoot->Pause(nsSMILTimeContainer::PAUSE_SCRIPT);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2013-01-27 23:30:21 +04:00
|
|
|
// else we're not the outermost <svg> or not bound to a tree, so silently fail
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
void
|
2013-02-08 23:55:07 +04:00
|
|
|
SVGSVGElement::UnpauseAnimations()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-01-27 23:30:21 +04:00
|
|
|
if (mTimedDocumentRoot) {
|
|
|
|
mTimedDocumentRoot->Resume(nsSMILTimeContainer::PAUSE_SCRIPT);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2013-01-27 23:30:21 +04:00
|
|
|
// else we're not the outermost <svg> or not bound to a tree, so silently fail
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
bool
|
2013-02-08 23:55:07 +04:00
|
|
|
SVGSVGElement::AnimationsPaused()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-01-27 23:30:21 +04:00
|
|
|
nsSMILTimeContainer* root = GetTimedDocumentRoot();
|
|
|
|
return root && root->IsPausedByType(nsSMILTimeContainer::PAUSE_SCRIPT);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
float
|
2013-02-08 23:55:07 +04:00
|
|
|
SVGSVGElement::GetCurrentTime()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2013-01-27 23:30:21 +04:00
|
|
|
nsSMILTimeContainer* root = GetTimedDocumentRoot();
|
|
|
|
if (root) {
|
|
|
|
double fCurrentTimeMs = double(root->GetCurrentTime());
|
|
|
|
return (float)(fCurrentTimeMs / PR_MSEC_PER_SEC);
|
|
|
|
} else {
|
|
|
|
return 0.f;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
void
|
2013-02-08 23:55:07 +04:00
|
|
|
SVGSVGElement::SetCurrentTime(float seconds)
|
2013-01-10 03:02:47 +04:00
|
|
|
{
|
2013-01-27 23:30:21 +04:00
|
|
|
if (mTimedDocumentRoot) {
|
|
|
|
// Make sure the timegraph is up-to-date
|
|
|
|
FlushAnimations();
|
|
|
|
double fMilliseconds = double(seconds) * PR_MSEC_PER_SEC;
|
|
|
|
// Round to nearest whole number before converting, to avoid precision
|
|
|
|
// errors
|
|
|
|
nsSMILTime lMilliseconds = int64_t(NS_round(fMilliseconds));
|
|
|
|
mTimedDocumentRoot->SetCurrentTime(lMilliseconds);
|
|
|
|
AnimationNeedsResample();
|
|
|
|
// Trigger synchronous sample now, to:
|
|
|
|
// - Make sure we get an up-to-date paint after this method
|
|
|
|
// - re-enable event firing (it got disabled during seeking, and it
|
|
|
|
// doesn't get re-enabled until the first sample after the seek -- so
|
|
|
|
// let's make that happen now.)
|
|
|
|
FlushAnimations();
|
2009-03-10 04:20:17 +03:00
|
|
|
}
|
2013-01-27 23:30:21 +04:00
|
|
|
// else we're not the outermost <svg> or not bound to a tree, so silently fail
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-07-03 11:41:53 +04:00
|
|
|
void
|
|
|
|
SVGSVGElement::DeselectAll()
|
|
|
|
{
|
|
|
|
nsIFrame* frame = GetPrimaryFrame();
|
|
|
|
if (frame) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFrameSelection> frameSelection = frame->GetFrameSelection();
|
2013-07-03 11:41:53 +04:00
|
|
|
frameSelection->ClearNormalSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-30 11:36:52 +04:00
|
|
|
already_AddRefed<DOMSVGNumber>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::CreateSVGNumber()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMSVGNumber> number = new DOMSVGNumber(ToSupports(this));
|
2013-01-10 03:02:47 +04:00
|
|
|
return number.forget();
|
|
|
|
}
|
|
|
|
|
2014-04-12 01:26:29 +04:00
|
|
|
already_AddRefed<DOMSVGLength>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::CreateSVGLength()
|
|
|
|
{
|
2014-04-12 01:26:29 +04:00
|
|
|
nsCOMPtr<DOMSVGLength> length = new DOMSVGLength();
|
2013-01-10 03:02:47 +04:00
|
|
|
return length.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<SVGAngle>
|
|
|
|
SVGSVGElement::CreateSVGAngle()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2012-12-23 08:54:23 +04:00
|
|
|
nsSVGAngle* angle = new nsSVGAngle();
|
|
|
|
angle->Init();
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGAngle> svgangle = new SVGAngle(angle, this, SVGAngle::CreatedValue);
|
2013-01-10 03:02:47 +04:00
|
|
|
return svgangle.forget();
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
already_AddRefed<nsISVGPoint>
|
|
|
|
SVGSVGElement::CreateSVGPoint()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISVGPoint> point = new DOMSVGPoint(0, 0);
|
|
|
|
return point.forget();
|
|
|
|
}
|
|
|
|
|
2013-01-12 00:30:21 +04:00
|
|
|
already_AddRefed<SVGMatrix>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::CreateSVGMatrix()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGMatrix> matrix = new SVGMatrix();
|
2013-01-10 03:02:47 +04:00
|
|
|
return matrix.forget();
|
|
|
|
}
|
|
|
|
|
2013-03-26 19:53:13 +04:00
|
|
|
already_AddRefed<SVGIRect>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::CreateSVGRect()
|
|
|
|
{
|
2013-05-09 21:42:12 +04:00
|
|
|
return NS_NewSVGRect(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
already_AddRefed<SVGTransform>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::CreateSVGTransform()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGTransform> transform = new SVGTransform();
|
2013-01-10 03:02:47 +04:00
|
|
|
return transform.forget();
|
|
|
|
}
|
|
|
|
|
2013-04-02 23:17:41 +04:00
|
|
|
already_AddRefed<SVGTransform>
|
2013-01-12 00:30:21 +04:00
|
|
|
SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix)
|
2013-01-10 03:02:47 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SVGTransform> transform = new SVGTransform(matrix.GetMatrix());
|
2013-01-10 03:02:47 +04:00
|
|
|
return transform.forget();
|
|
|
|
}
|
|
|
|
|
2001-12-12 10:59:31 +03:00
|
|
|
//----------------------------------------------------------------------
|
2013-01-10 03:02:47 +04:00
|
|
|
|
2013-05-09 21:42:12 +04:00
|
|
|
already_AddRefed<SVGAnimatedRect>
|
2013-01-10 03:02:47 +04:00
|
|
|
SVGSVGElement::ViewBox()
|
|
|
|
{
|
2013-05-20 15:46:12 +04:00
|
|
|
return mViewBox.ToSVGAnimatedRect(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio>
|
|
|
|
SVGSVGElement::PreserveAspectRatio()
|
2001-12-12 10:59:31 +03:00
|
|
|
{
|
2015-01-27 12:51:34 +03:00
|
|
|
return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this);
|
2001-12-12 10:59:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
uint16_t
|
|
|
|
SVGSVGElement::ZoomAndPan()
|
2004-12-03 02:13:13 +03:00
|
|
|
{
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
2012-09-09 15:44:03 +04:00
|
|
|
if (viewElement && viewElement->mEnumAttributes[
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement::ZOOMANDPAN].IsExplicitlySet()) {
|
2013-01-10 03:02:47 +04:00
|
|
|
return viewElement->mEnumAttributes[
|
|
|
|
SVGViewElement::ZOOMANDPAN].GetAnimValue();
|
2012-09-09 15:44:03 +04:00
|
|
|
}
|
2013-01-10 03:02:47 +04:00
|
|
|
return mEnumAttributes[ZOOMANDPAN].GetAnimValue();
|
2004-12-03 02:13:13 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:47 +04:00
|
|
|
void
|
|
|
|
SVGSVGElement::SetZoomAndPan(uint16_t aZoomAndPan, ErrorResult& rv)
|
2004-12-03 02:13:13 +03:00
|
|
|
{
|
2013-01-10 09:24:37 +04:00
|
|
|
if (aZoomAndPan == SVG_ZOOMANDPAN_DISABLE ||
|
|
|
|
aZoomAndPan == SVG_ZOOMANDPAN_MAGNIFY) {
|
2011-10-09 19:25:07 +04:00
|
|
|
mEnumAttributes[ZOOMANDPAN].SetBaseValue(aZoomAndPan, this);
|
2013-01-10 03:02:47 +04:00
|
|
|
return;
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
2004-12-03 02:13:13 +03:00
|
|
|
|
2015-10-05 19:38:14 +03:00
|
|
|
rv.ThrowRangeError<MSG_INVALID_ZOOMANDPAN_VALUE_ERROR>();
|
2004-12-03 02:13:13 +03:00
|
|
|
}
|
2001-12-12 10:59:31 +03:00
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
2007-06-21 01:56:03 +04:00
|
|
|
// helper methods for implementing SVGZoomEvent:
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2013-02-08 23:55:07 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetCurrentScaleTranslate(float s, float x, float y)
|
2005-08-26 01:31:09 +04:00
|
|
|
{
|
2009-04-28 17:25:03 +04:00
|
|
|
if (s == mCurrentScale &&
|
|
|
|
x == mCurrentTranslate.GetX() && y == mCurrentTranslate.GetY()) {
|
2013-02-08 23:55:07 +04:00
|
|
|
return;
|
2005-08-26 01:31:09 +04:00
|
|
|
}
|
|
|
|
|
2009-04-28 17:25:03 +04:00
|
|
|
// Prevent bizarre behaviour and maxing out of CPU and memory by clamping
|
|
|
|
if (s < CURRENT_SCALE_MIN)
|
|
|
|
s = CURRENT_SCALE_MIN;
|
|
|
|
else if (s > CURRENT_SCALE_MAX)
|
|
|
|
s = CURRENT_SCALE_MAX;
|
|
|
|
|
|
|
|
// IMPORTANT: If either mCurrentTranslate *or* mCurrentScale is changed then
|
|
|
|
// mPreviousTranslate_x, mPreviousTranslate_y *and* mPreviousScale must all
|
|
|
|
// be updated otherwise SVGZoomEvents will end up with invalid data. I.e. an
|
|
|
|
// SVGZoomEvent's properties previousScale and previousTranslate must contain
|
|
|
|
// the state of currentScale and currentTranslate immediately before the
|
|
|
|
// change that caused the event's dispatch, which is *not* necessarily the
|
|
|
|
// same thing as the values of currentScale and currentTranslate prior to
|
|
|
|
// their own last change.
|
|
|
|
mPreviousScale = mCurrentScale;
|
|
|
|
mPreviousTranslate = mCurrentTranslate;
|
|
|
|
|
|
|
|
mCurrentScale = s;
|
2013-01-17 05:35:24 +04:00
|
|
|
mCurrentTranslate = SVGPoint(x, y);
|
2005-08-26 01:31:09 +04:00
|
|
|
|
2009-04-28 17:25:03 +04:00
|
|
|
// now dispatch the appropriate event if we are the root element
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetUncomposedDoc();
|
2005-08-26 01:31:09 +04:00
|
|
|
if (doc) {
|
2010-06-25 17:59:57 +04:00
|
|
|
nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
|
2007-12-12 05:26:09 +03:00
|
|
|
if (presShell && IsRoot()) {
|
2005-08-26 01:31:09 +04:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2014-07-30 21:16:57 +04:00
|
|
|
if (mPreviousScale != mCurrentScale) {
|
2015-09-07 17:55:52 +03:00
|
|
|
InternalSVGZoomEvent svgZoomEvent(true, eSVGZoom);
|
2014-07-30 21:16:57 +04:00
|
|
|
presShell->HandleDOMEventWithTarget(this, &svgZoomEvent, &status);
|
|
|
|
} else {
|
2015-09-07 17:55:52 +03:00
|
|
|
WidgetEvent svgScrollEvent(true, eSVGScroll);
|
2014-07-30 21:16:57 +04:00
|
|
|
presShell->HandleDOMEventWithTarget(this, &svgScrollEvent, &status);
|
|
|
|
}
|
2009-04-28 17:25:03 +04:00
|
|
|
InvalidateTransformNotifyFrame();
|
2005-08-26 01:31:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 23:55:07 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetCurrentTranslate(float x, float y)
|
2005-08-26 01:31:09 +04:00
|
|
|
{
|
2013-02-08 23:55:07 +04:00
|
|
|
SetCurrentScaleTranslate(mCurrentScale, x, y);
|
2005-08-26 01:31:09 +04:00
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
nsSMILTimeContainer*
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetTimedDocumentRoot()
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
|
|
|
if (mTimedDocumentRoot) {
|
2011-02-26 13:21:11 +03:00
|
|
|
return mTimedDocumentRoot;
|
|
|
|
}
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2011-02-26 13:21:11 +03:00
|
|
|
// We must not be the outermost <svg> element, try to find it
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement *outerSVGElement =
|
2012-09-22 23:26:05 +04:00
|
|
|
SVGContentUtils::GetOuterSVGElement(this);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2011-02-26 13:21:11 +03:00
|
|
|
if (outerSVGElement) {
|
|
|
|
return outerSVGElement->GetTimedDocumentRoot();
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2011-02-26 13:21:11 +03:00
|
|
|
// invalid structure
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
2005-11-02 03:41:51 +03:00
|
|
|
// nsIContent methods
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP_(bool)
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::IsAttributeMapped(const nsIAtom* name) const
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
{
|
2011-12-27 14:27:42 +04:00
|
|
|
// We want to map the 'width' and 'height' attributes into style for
|
|
|
|
// outer-<svg>, except when the attributes aren't set (since their default
|
|
|
|
// values of '100%' can cause unexpected and undesirable behaviour for SVG
|
|
|
|
// inline in HTML). We rely on nsSVGElement::UpdateContentStyleRule() to
|
|
|
|
// prevent mapping of the default values into style (it only maps attributes
|
|
|
|
// that are set). We also rely on a check in nsSVGElement::
|
|
|
|
// UpdateContentStyleRule() to prevent us mapping the attributes when they're
|
|
|
|
// given a <length> value that is not currently recognized by the SVG
|
|
|
|
// specification.
|
|
|
|
|
|
|
|
if (!IsInner() && (name == nsGkAtoms::width || name == nsGkAtoms::height)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-02-26 00:04:50 +03:00
|
|
|
static const MappedAttributeEntry* const map[] = {
|
2007-01-19 18:20:11 +03:00
|
|
|
sColorMap,
|
|
|
|
sFEFloodMap,
|
2004-02-09 23:48:20 +03:00
|
|
|
sFillStrokeMap,
|
2007-03-20 13:43:33 +03:00
|
|
|
sFiltersMap,
|
2004-10-27 04:25:08 +04:00
|
|
|
sFontSpecificationMap,
|
2006-10-20 03:48:12 +04:00
|
|
|
sGradientStopMap,
|
2007-01-19 18:20:11 +03:00
|
|
|
sGraphicsMap,
|
2007-07-26 10:57:42 +04:00
|
|
|
sLightingEffectsMap,
|
2006-10-20 03:48:12 +04:00
|
|
|
sMarkersMap,
|
2007-01-19 18:20:11 +03:00
|
|
|
sTextContentElementsMap,
|
|
|
|
sViewportsMap
|
2004-02-09 23:48:20 +03:00
|
|
|
};
|
|
|
|
|
2011-12-18 14:09:27 +04:00
|
|
|
return FindAttributeDependence(name, map) ||
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElementBase::IsAttributeMapped(name);
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods:
|
|
|
|
|
|
|
|
nsresult
|
2014-03-18 08:48:19 +04:00
|
|
|
SVGSVGElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2015-09-07 17:55:51 +03:00
|
|
|
if (aVisitor.mEvent->mMessage == eSVGLoad) {
|
2009-01-15 07:38:07 +03:00
|
|
|
if (mTimedDocumentRoot) {
|
|
|
|
mTimedDocumentRoot->Begin();
|
2010-07-22 23:19:46 +04:00
|
|
|
// Set 'resample needed' flag, so that if any script calls a DOM method
|
|
|
|
// that requires up-to-date animations before our first sample callback,
|
|
|
|
// we'll force a synchronous sample.
|
|
|
|
AnimationNeedsResample();
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
}
|
2013-01-10 03:02:45 +04:00
|
|
|
return SVGSVGElementBase::PreHandleEvent(aVisitor);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::IsEventAttributeName(nsIAtom* aName)
|
2004-07-22 20:38:05 +04:00
|
|
|
{
|
2007-04-02 21:17:36 +04:00
|
|
|
/* The events in EventNameType_SVGSVG are for events that are only
|
|
|
|
applicable to outermost 'svg' elements. We don't check if we're an outer
|
|
|
|
'svg' element in case we're not inserted into the document yet, but since
|
|
|
|
the target of the events in question will always be the outermost 'svg'
|
|
|
|
element, this shouldn't cause any real problems.
|
2005-08-26 01:31:09 +04:00
|
|
|
*/
|
2007-04-02 21:17:36 +04:00
|
|
|
return nsContentUtils::IsEventAttributeName(aName,
|
|
|
|
(EventNameType_SVGGraphic | EventNameType_SVGSVG));
|
2004-07-22 20:38:05 +04:00
|
|
|
}
|
|
|
|
|
2013-01-03 00:24:07 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement overrides
|
|
|
|
|
2011-02-09 23:13:18 +03:00
|
|
|
// Helper for GetViewBoxTransform on root <svg> node
|
|
|
|
// * aLength: internal value for our <svg> width or height attribute.
|
|
|
|
// * aViewportLength: length of the corresponding dimension of the viewport.
|
|
|
|
// * aSelf: the outermost <svg> node itself.
|
|
|
|
// NOTE: aSelf is not an ancestor viewport element, so it can't be used to
|
|
|
|
// resolve percentage lengths. (It can only be used to resolve
|
|
|
|
// 'em'/'ex'-valued units).
|
|
|
|
inline float
|
2011-06-16 14:53:13 +04:00
|
|
|
ComputeSynthesizedViewBoxDimension(const nsSVGLength2& aLength,
|
2011-02-09 23:13:18 +03:00
|
|
|
float aViewportLength,
|
2013-01-10 03:02:45 +04:00
|
|
|
const SVGSVGElement* aSelf)
|
2011-02-09 23:13:18 +03:00
|
|
|
{
|
|
|
|
if (aLength.IsPercentage()) {
|
|
|
|
return aViewportLength * aLength.GetAnimValInSpecifiedUnits() / 100.0f;
|
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
return aLength.GetAnimValue(const_cast<SVGSVGElement*>(aSelf));
|
2011-02-09 23:13:18 +03:00
|
|
|
}
|
|
|
|
|
2006-04-27 01:02:25 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// public helpers:
|
|
|
|
|
2013-12-30 10:50:17 +04:00
|
|
|
gfx::Matrix
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetViewBoxTransform() const
|
2006-04-27 01:02:25 +04:00
|
|
|
{
|
2007-03-09 19:27:01 +03:00
|
|
|
float viewportWidth, viewportHeight;
|
2011-02-26 13:21:11 +03:00
|
|
|
if (IsInner()) {
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement *ctx = GetCtx();
|
2013-01-10 03:02:47 +04:00
|
|
|
viewportWidth = mLengthAttributes[ATTR_WIDTH].GetAnimValue(ctx);
|
|
|
|
viewportHeight = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(ctx);
|
2009-07-23 12:35:59 +04:00
|
|
|
} else {
|
|
|
|
viewportWidth = mViewportWidth;
|
|
|
|
viewportHeight = mViewportHeight;
|
2007-03-09 19:27:01 +03:00
|
|
|
}
|
2006-04-27 01:02:25 +04:00
|
|
|
|
2012-02-19 15:17:12 +04:00
|
|
|
if (viewportWidth <= 0.0f || viewportHeight <= 0.0f) {
|
2013-12-30 10:50:17 +04:00
|
|
|
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
2012-02-19 15:17:12 +04:00
|
|
|
}
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
nsSVGViewBoxRect viewBox =
|
|
|
|
GetViewBoxWithSynthesis(viewportWidth, viewportHeight);
|
2006-04-27 01:02:25 +04:00
|
|
|
|
2009-07-23 12:35:59 +04:00
|
|
|
if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) {
|
2013-12-30 10:50:17 +04:00
|
|
|
return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular
|
2007-03-09 19:27:01 +03:00
|
|
|
}
|
|
|
|
|
2013-03-03 12:11:03 +04:00
|
|
|
return SVGContentUtils::GetViewBoxTransform(viewportWidth, viewportHeight,
|
2012-09-22 23:26:05 +04:00
|
|
|
viewBox.x, viewBox.y,
|
|
|
|
viewBox.width, viewBox.height,
|
|
|
|
GetPreserveAspectRatioWithOverride());
|
2006-04-27 01:02:25 +04:00
|
|
|
}
|
|
|
|
|
2012-12-18 06:25:16 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::UpdateHasChildrenOnlyTransform()
|
2012-12-18 06:25:16 +04:00
|
|
|
{
|
|
|
|
bool hasChildrenOnlyTransform =
|
|
|
|
HasViewBoxOrSyntheticViewBox() ||
|
2013-01-17 05:35:24 +04:00
|
|
|
(IsRoot() && (mCurrentTranslate != SVGPoint(0.0f, 0.0f) ||
|
2012-12-18 06:25:16 +04:00
|
|
|
mCurrentScale != 1.0f));
|
|
|
|
mHasChildrenOnlyTransform = hasChildrenOnlyTransform;
|
|
|
|
}
|
|
|
|
|
2012-05-17 08:05:09 +04:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ChildrenOnlyTransformChanged(uint32_t aFlags)
|
2012-05-17 08:05:09 +04:00
|
|
|
{
|
|
|
|
// Avoid wasteful calls:
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!(GetPrimaryFrame()->GetStateBits() & NS_FRAME_IS_NONDISPLAY),
|
|
|
|
"Non-display SVG frames don't maintain overflow rects");
|
2012-05-17 08:05:09 +04:00
|
|
|
|
2012-07-20 22:12:29 +04:00
|
|
|
nsChangeHint changeHint;
|
|
|
|
|
2012-12-18 06:25:16 +04:00
|
|
|
bool hadChildrenOnlyTransform = mHasChildrenOnlyTransform;
|
2012-05-17 08:05:09 +04:00
|
|
|
|
2012-12-18 06:25:16 +04:00
|
|
|
UpdateHasChildrenOnlyTransform();
|
|
|
|
|
|
|
|
if (hadChildrenOnlyTransform != mHasChildrenOnlyTransform) {
|
2012-07-20 22:12:29 +04:00
|
|
|
// Reconstruct the frame tree to handle stacking context changes:
|
2012-12-18 06:25:16 +04:00
|
|
|
// XXXjwatt don't do this for root-<svg> or even outer-<svg>?
|
2012-07-20 22:12:29 +04:00
|
|
|
changeHint = nsChangeHint_ReconstructFrame;
|
|
|
|
} else {
|
|
|
|
// We just assume the old and new transforms are different.
|
2013-05-08 21:13:29 +04:00
|
|
|
changeHint = nsChangeHint(nsChangeHint_UpdateOverflow |
|
|
|
|
nsChangeHint_ChildrenOnlyTransform);
|
2012-07-20 22:12:29 +04:00
|
|
|
}
|
2012-05-17 08:05:09 +04:00
|
|
|
|
2012-08-31 18:30:18 +04:00
|
|
|
// If we're not reconstructing the frame tree, then we only call
|
|
|
|
// PostRestyleEvent if we're not being called under reflow to avoid recursing
|
|
|
|
// to death. See bug 767056 comments 10 and 12. Since our nsSVGOuterSVGFrame
|
|
|
|
// is being reflowed we're going to invalidate and repaint its entire area
|
|
|
|
// anyway (which will include our children).
|
|
|
|
if ((changeHint & nsChangeHint_ReconstructFrame) ||
|
|
|
|
!(aFlags & eDuringReflow)) {
|
|
|
|
nsLayoutUtils::PostRestyleEvent(this, nsRestyleHint(0), changeHint);
|
|
|
|
}
|
2012-05-17 08:05:09 +04:00
|
|
|
}
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
nsresult
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::BindToTree(nsIDocument* aDocument,
|
|
|
|
nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
|
|
|
bool aCompileEventHandlers)
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
nsSMILAnimationController* smilController = nullptr;
|
2009-03-08 00:40:08 +03:00
|
|
|
|
|
|
|
if (aDocument) {
|
|
|
|
smilController = aDocument->GetAnimationController();
|
|
|
|
if (smilController) {
|
|
|
|
// SMIL is enabled in this document
|
|
|
|
if (WillBeOutermostSVG(aParent, aBindingParent)) {
|
|
|
|
// We'll be the outermost <svg> element. We'll need a time container.
|
|
|
|
if (!mTimedDocumentRoot) {
|
|
|
|
mTimedDocumentRoot = new nsSMILTimeContainer();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We're a child of some other <svg> element, so we don't need our own
|
|
|
|
// time container. However, we need to make sure that we'll get a
|
|
|
|
// kick-start if we get promoted to be outermost later on.
|
2012-07-30 18:20:58 +04:00
|
|
|
mTimedDocumentRoot = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mStartAnimationOnBindToTree = true;
|
2009-03-08 00:40:08 +03:00
|
|
|
}
|
|
|
|
}
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
nsresult rv = SVGSVGElementBase::BindToTree(aDocument, aParent,
|
|
|
|
aBindingParent,
|
|
|
|
aCompileEventHandlers);
|
2009-01-15 07:38:07 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
|
|
|
|
2014-09-18 14:54:00 +04:00
|
|
|
nsIDocument* doc = GetComposedDoc();
|
|
|
|
if (doc) {
|
2013-01-20 16:07:16 +04:00
|
|
|
// Setup the style sheet during binding, not element construction,
|
|
|
|
// because we could move the root SVG element from the document
|
|
|
|
// that created it to another document.
|
2014-09-18 14:54:00 +04:00
|
|
|
doc->EnsureOnDemandBuiltInUASheet(nsLayoutStylesheetCache::SVGSheet());
|
2013-01-20 16:07:16 +04:00
|
|
|
}
|
|
|
|
|
2009-03-08 00:40:08 +03:00
|
|
|
if (mTimedDocumentRoot && smilController) {
|
|
|
|
rv = mTimedDocumentRoot->SetParent(smilController);
|
2009-01-15 07:38:07 +03:00
|
|
|
if (mStartAnimationOnBindToTree) {
|
|
|
|
mTimedDocumentRoot->Begin();
|
2011-10-17 18:59:28 +04:00
|
|
|
mStartAnimationOnBindToTree = false;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::UnbindFromTree(bool aDeep, bool aNullParent)
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
|
|
|
if (mTimedDocumentRoot) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mTimedDocumentRoot->SetParent(nullptr);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElementBase::UnbindFromTree(aDeep, aNullParent);
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
Landing of SVG_20020806_BRANCH, Bug 182533. Refactoring of SVG backend, new GDI+ and Libart rendering
backends, text support on Windows (GDI+), rudimentary text support on Linux (libart/freetype2), presentation
attributes, lots of bug fixes (see bug 182533 for dependency list).
Not part of default build; code is #ifdef'ed out.
r=sicking, sr=jst for dom and htmlparser changes
r=bsmedberg, sr=tor for config changes
r=dbaron, sr=bzbarsky for content and layout changes
r=tor, sr=bzbarsky for gfx changes
2004-02-07 15:39:26 +03:00
|
|
|
//----------------------------------------------------------------------
|
2001-12-12 10:59:31 +03:00
|
|
|
// implementation helpers
|
2005-09-06 04:08:10 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::WillBeOutermostSVG(nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent) const
|
2009-01-15 07:38:07 +03:00
|
|
|
{
|
|
|
|
nsIContent* parent = aBindingParent ? aBindingParent : aParent;
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
while (parent && parent->IsSVGElement()) {
|
2015-03-03 14:09:00 +03:00
|
|
|
if (parent->IsSVGElement(nsGkAtoms::foreignObject)) {
|
2009-01-15 07:38:07 +03:00
|
|
|
// SVG in a foreignObject must have its own <svg> (nsSVGOuterSVGFrame).
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
2015-03-03 14:09:00 +03:00
|
|
|
if (parent->IsSVGElement(nsGkAtoms::svg)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
parent = parent->GetParent();
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-01-15 07:38:07 +03:00
|
|
|
}
|
|
|
|
|
2007-01-04 17:39:54 +03:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::InvalidateTransformNotifyFrame()
|
2007-01-04 17:39:54 +03:00
|
|
|
{
|
2014-03-25 19:36:49 +04:00
|
|
|
nsISVGSVGFrame* svgframe = do_QueryFrame(GetPrimaryFrame());
|
|
|
|
// might fail this check if we've failed conditional processing
|
|
|
|
if (svgframe) {
|
|
|
|
svgframe->NotifyViewportOrTransformChanged(
|
|
|
|
nsISVGChildFrame::TRANSFORM_CHANGED);
|
2007-01-04 17:39:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::HasPreserveAspectRatio()
|
2010-12-20 03:45:29 +03:00
|
|
|
{
|
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::preserveAspectRatio) ||
|
|
|
|
mPreserveAspectRatio.IsAnimated();
|
|
|
|
}
|
|
|
|
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement*
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetCurrentViewElement() const
|
2012-09-09 15:44:03 +04:00
|
|
|
{
|
|
|
|
if (mCurrentViewID) {
|
2014-10-03 16:32:26 +04:00
|
|
|
//XXXsmaug It is unclear how this should work in case we're in Shadow DOM.
|
|
|
|
nsIDocument* doc = GetUncomposedDoc();
|
2012-09-09 15:44:03 +04:00
|
|
|
if (doc) {
|
|
|
|
Element *element = doc->GetElementById(*mCurrentViewID);
|
2015-03-03 14:08:59 +03:00
|
|
|
if (element && element->IsSVGElement(nsGkAtoms::view)) {
|
2013-01-08 07:22:41 +04:00
|
|
|
return static_cast<SVGViewElement*>(element);
|
2012-09-09 15:44:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
nsSVGViewBoxRect
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetViewBoxWithSynthesis(
|
2012-05-17 14:02:41 +04:00
|
|
|
float aViewportWidth, float aViewportHeight) const
|
|
|
|
{
|
2013-02-26 20:58:06 +04:00
|
|
|
// The logic here should match HasViewBoxRect().
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
2013-02-26 20:58:06 +04:00
|
|
|
if (viewElement && viewElement->mViewBox.HasRect()) {
|
2012-09-09 15:44:03 +04:00
|
|
|
return viewElement->mViewBox.GetAnimValue();
|
|
|
|
}
|
2013-02-26 20:58:06 +04:00
|
|
|
if (mViewBox.HasRect()) {
|
2012-05-17 14:02:41 +04:00
|
|
|
return mViewBox.GetAnimValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ShouldSynthesizeViewBox()) {
|
|
|
|
// Special case -- fake a viewBox, using height & width attrs.
|
|
|
|
// (Use |this| as context, since if we get here, we're outermost <svg>.)
|
|
|
|
return nsSVGViewBoxRect(0, 0,
|
2013-01-10 03:02:47 +04:00
|
|
|
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
2012-05-17 14:02:41 +04:00
|
|
|
mViewportWidth, this),
|
2013-01-10 03:02:47 +04:00
|
|
|
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_HEIGHT],
|
2012-05-17 14:02:41 +04:00
|
|
|
mViewportHeight, this));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// No viewBox attribute, so we shouldn't auto-scale. This is equivalent
|
|
|
|
// to having a viewBox that exactly matches our viewport size.
|
|
|
|
return nsSVGViewBoxRect(0, 0, aViewportWidth, aViewportHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
SVGPreserveAspectRatio
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetPreserveAspectRatioWithOverride() const
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetUncomposedDoc();
|
2012-05-23 13:49:15 +04:00
|
|
|
if (doc && doc->IsBeingUsedAsImage()) {
|
2012-05-17 14:02:41 +04:00
|
|
|
const SVGPreserveAspectRatio *pAROverridePtr = GetPreserveAspectRatioProperty();
|
|
|
|
if (pAROverridePtr) {
|
|
|
|
return *pAROverridePtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
2012-09-09 15:44:03 +04:00
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
// This check is equivalent to "!HasViewBoxRect() && ShouldSynthesizeViewBox()".
|
|
|
|
// We're just holding onto the viewElement that HasViewBoxRect() would look up,
|
2012-09-09 15:44:03 +04:00
|
|
|
// so that we don't have to look it up again later.
|
2013-02-26 20:58:06 +04:00
|
|
|
if (!((viewElement && viewElement->mViewBox.HasRect()) ||
|
|
|
|
mViewBox.HasRect()) &&
|
2012-09-09 15:44:03 +04:00
|
|
|
ShouldSynthesizeViewBox()) {
|
2012-05-17 14:02:41 +04:00
|
|
|
// If we're synthesizing a viewBox, use preserveAspectRatio="none";
|
2012-12-23 08:54:21 +04:00
|
|
|
return SVGPreserveAspectRatio(SVG_PRESERVEASPECTRATIO_NONE, SVG_MEETORSLICE_SLICE);
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
|
|
|
|
2012-09-09 15:44:03 +04:00
|
|
|
if (viewElement && viewElement->mPreserveAspectRatio.IsExplicitlySet()) {
|
|
|
|
return viewElement->mPreserveAspectRatio.GetAnimValue();
|
|
|
|
}
|
2012-05-17 14:02:41 +04:00
|
|
|
return mPreserveAspectRatio.GetAnimValue();
|
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
//----------------------------------------------------------------------
|
2013-01-10 03:02:45 +04:00
|
|
|
// SVGSVGElement
|
2006-04-14 19:09:39 +04:00
|
|
|
|
2007-03-09 19:27:01 +03:00
|
|
|
float
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetLength(uint8_t aCtxType)
|
2007-07-02 13:54:11 +04:00
|
|
|
{
|
2007-03-09 19:27:01 +03:00
|
|
|
float h, w;
|
|
|
|
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
2012-09-09 15:44:03 +04:00
|
|
|
const nsSVGViewBoxRect* viewbox = nullptr;
|
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
// The logic here should match HasViewBoxRect().
|
|
|
|
if (viewElement && viewElement->mViewBox.HasRect()) {
|
2012-09-09 15:44:03 +04:00
|
|
|
viewbox = &viewElement->mViewBox.GetAnimValue();
|
2013-02-26 20:58:06 +04:00
|
|
|
} else if (mViewBox.HasRect()) {
|
2012-09-09 15:44:03 +04:00
|
|
|
viewbox = &mViewBox.GetAnimValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewbox) {
|
|
|
|
w = viewbox->width;
|
|
|
|
h = viewbox->height;
|
2011-02-26 13:21:11 +03:00
|
|
|
} else if (IsInner()) {
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement *ctx = GetCtx();
|
2013-01-10 03:02:47 +04:00
|
|
|
w = mLengthAttributes[ATTR_WIDTH].GetAnimValue(ctx);
|
|
|
|
h = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(ctx);
|
2011-02-09 23:13:18 +03:00
|
|
|
} else if (ShouldSynthesizeViewBox()) {
|
2013-01-10 03:02:47 +04:00
|
|
|
w = ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
2011-02-09 23:13:18 +03:00
|
|
|
mViewportWidth, this);
|
2013-01-10 03:02:47 +04:00
|
|
|
h = ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_HEIGHT],
|
2011-02-09 23:13:18 +03:00
|
|
|
mViewportHeight, this);
|
2007-01-04 17:39:54 +03:00
|
|
|
} else {
|
2011-02-09 23:13:18 +03:00
|
|
|
w = mViewportWidth;
|
|
|
|
h = mViewportHeight;
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2007-03-09 19:27:01 +03:00
|
|
|
|
2013-01-15 16:22:03 +04:00
|
|
|
w = std::max(w, 0.0f);
|
|
|
|
h = std::max(h, 0.0f);
|
2008-02-21 20:43:25 +03:00
|
|
|
|
2007-03-09 19:27:01 +03:00
|
|
|
switch (aCtxType) {
|
2012-09-22 23:26:05 +04:00
|
|
|
case SVGContentUtils::X:
|
2007-03-09 19:27:01 +03:00
|
|
|
return w;
|
2012-09-22 23:26:05 +04:00
|
|
|
case SVGContentUtils::Y:
|
2007-03-09 19:27:01 +03:00
|
|
|
return h;
|
2012-09-22 23:26:05 +04:00
|
|
|
case SVGContentUtils::XY:
|
|
|
|
return float(SVGContentUtils::ComputeNormalizedHypotenuse(w, h));
|
2007-03-09 19:27:01 +03:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
2013-12-27 00:13:57 +04:00
|
|
|
/* virtual */ gfxMatrix
|
|
|
|
SVGSVGElement::PrependLocalTransformsTo(const gfxMatrix &aMatrix,
|
2013-01-10 03:02:45 +04:00
|
|
|
TransformTypes aWhich) const
|
2009-04-29 08:31:34 +04:00
|
|
|
{
|
2013-05-05 11:20:25 +04:00
|
|
|
// 'transform' attribute:
|
2013-12-27 00:13:57 +04:00
|
|
|
gfxMatrix fromUserSpace =
|
2013-05-05 11:20:25 +04:00
|
|
|
SVGSVGElementBase::PrependLocalTransformsTo(aMatrix, aWhich);
|
|
|
|
if (aWhich == eUserSpaceToParent) {
|
|
|
|
return fromUserSpace;
|
|
|
|
}
|
|
|
|
|
2011-02-26 13:21:11 +03:00
|
|
|
if (IsInner()) {
|
2009-07-23 12:35:59 +04:00
|
|
|
float x, y;
|
2013-01-10 03:02:45 +04:00
|
|
|
const_cast<SVGSVGElement*>(this)->GetAnimatedLengthValues(&x, &y, nullptr);
|
2012-02-17 12:12:47 +04:00
|
|
|
if (aWhich == eAllTransforms) {
|
|
|
|
// the common case
|
2014-09-10 17:26:12 +04:00
|
|
|
return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix::Translation(x, y) * fromUserSpace;
|
2012-02-17 12:12:47 +04:00
|
|
|
}
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aWhich == eChildToUserSpace, "Unknown TransformTypes");
|
2014-09-10 17:26:12 +04:00
|
|
|
return ThebesMatrix(GetViewBoxTransform()) * gfxMatrix::Translation(x, y) * aMatrix;
|
2009-07-23 12:35:59 +04:00
|
|
|
}
|
2009-07-22 00:34:37 +04:00
|
|
|
|
2009-07-23 12:35:59 +04:00
|
|
|
if (IsRoot()) {
|
2013-12-27 00:13:57 +04:00
|
|
|
gfxMatrix zoomPanTM;
|
|
|
|
zoomPanTM.Translate(gfxPoint(mCurrentTranslate.GetX(), mCurrentTranslate.GetY()));
|
2009-07-23 12:35:59 +04:00
|
|
|
zoomPanTM.Scale(mCurrentScale, mCurrentScale);
|
2013-12-30 10:50:17 +04:00
|
|
|
return ThebesMatrix(GetViewBoxTransform()) * zoomPanTM * fromUserSpace;
|
2009-07-22 02:55:48 +04:00
|
|
|
}
|
2009-07-23 12:35:59 +04:00
|
|
|
|
|
|
|
// outer-<svg>, but inline in some other content:
|
2013-12-30 10:50:17 +04:00
|
|
|
return ThebesMatrix(GetViewBoxTransform()) * fromUserSpace;
|
2009-04-29 08:31:34 +04:00
|
|
|
}
|
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
/* virtual */ bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::HasValidDimensions() const
|
2012-03-03 13:21:09 +04:00
|
|
|
{
|
|
|
|
return !IsInner() ||
|
2013-01-10 03:02:47 +04:00
|
|
|
((!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) &&
|
|
|
|
(!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() ||
|
|
|
|
mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0));
|
2012-03-03 13:21:09 +04:00
|
|
|
}
|
|
|
|
|
2006-04-14 19:09:39 +04:00
|
|
|
nsSVGElement::LengthAttributesInfo
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetLengthInfo()
|
2006-04-14 19:09:39 +04:00
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sLengthInfo));
|
2006-04-14 19:09:39 +04:00
|
|
|
}
|
2007-08-28 03:11:14 +04:00
|
|
|
|
|
|
|
nsSVGElement::EnumAttributesInfo
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetEnumInfo()
|
2007-08-28 03:11:14 +04:00
|
|
|
{
|
|
|
|
return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
|
2011-10-11 09:50:08 +04:00
|
|
|
ArrayLength(sEnumInfo));
|
2007-08-28 03:11:14 +04:00
|
|
|
}
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2009-02-03 17:42:24 +03:00
|
|
|
nsSVGViewBox *
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetViewBox()
|
2009-02-03 17:42:24 +03:00
|
|
|
{
|
|
|
|
return &mViewBox;
|
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio *
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetPreserveAspectRatio()
|
2009-01-05 04:19:38 +03:00
|
|
|
{
|
|
|
|
return &mPreserveAspectRatio;
|
|
|
|
}
|
2010-11-17 02:19:21 +03:00
|
|
|
|
2012-09-09 15:44:03 +04:00
|
|
|
bool
|
2013-02-26 20:58:06 +04:00
|
|
|
SVGSVGElement::HasViewBoxRect() const
|
2012-09-09 15:44:03 +04:00
|
|
|
{
|
2013-01-08 07:22:41 +04:00
|
|
|
SVGViewElement* viewElement = GetCurrentViewElement();
|
2013-02-26 20:58:06 +04:00
|
|
|
if (viewElement && viewElement->mViewBox.HasRect()) {
|
2012-09-09 15:44:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
2013-02-26 20:58:06 +04:00
|
|
|
return mViewBox.HasRect();
|
2012-09-09 15:44:03 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ShouldSynthesizeViewBox() const
|
2011-02-09 23:13:18 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!HasViewBoxRect(),
|
|
|
|
"Should only be called if we lack a viewBox");
|
2011-02-09 23:13:18 +03:00
|
|
|
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = GetUncomposedDoc();
|
2011-02-09 23:13:18 +03:00
|
|
|
return doc &&
|
|
|
|
doc->IsBeingUsedAsImage() &&
|
|
|
|
!mIsPaintingSVGImageElement &&
|
|
|
|
!GetParent();
|
|
|
|
}
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetPreserveAspectRatioProperty(const SVGPreserveAspectRatio& aPAR)
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
SVGPreserveAspectRatio* pAROverridePtr = new SVGPreserveAspectRatio(aPAR);
|
|
|
|
nsresult rv = SetProperty(nsGkAtoms::overridePreserveAspectRatio,
|
|
|
|
pAROverridePtr,
|
2014-03-25 17:25:47 +04:00
|
|
|
nsINode::DeleteProperty<SVGPreserveAspectRatio>,
|
2012-06-06 12:15:53 +04:00
|
|
|
true);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(rv != NS_PROPTABLE_PROP_OVERWRITTEN,
|
|
|
|
"Setting override value when it's already set...?");
|
2012-05-17 14:02:41 +04:00
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(NS_FAILED(rv))) {
|
2012-05-17 14:02:41 +04:00
|
|
|
// property-insertion failed (e.g. OOM in property-table code)
|
|
|
|
delete pAROverridePtr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SVGPreserveAspectRatio*
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetPreserveAspectRatioProperty() const
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
void* valPtr = GetProperty(nsGkAtoms::overridePreserveAspectRatio);
|
|
|
|
if (valPtr) {
|
|
|
|
return static_cast<SVGPreserveAspectRatio*>(valPtr);
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ClearPreserveAspectRatioProperty()
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
void* valPtr = UnsetProperty(nsGkAtoms::overridePreserveAspectRatio);
|
|
|
|
delete static_cast<SVGPreserveAspectRatio*>(valPtr);
|
|
|
|
return valPtr;
|
|
|
|
}
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::
|
2010-12-20 03:45:29 +03:00
|
|
|
SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
|
|
|
"should only override preserveAspectRatio in images");
|
2010-12-20 03:45:29 +03:00
|
|
|
#endif
|
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
bool hasViewBoxRect = HasViewBoxRect();
|
|
|
|
if (!hasViewBoxRect && ShouldSynthesizeViewBox()) {
|
2011-02-09 23:13:18 +03:00
|
|
|
// My non-<svg:image> clients will have been painting me with a synthesized
|
|
|
|
// viewBox, but my <svg:image> client that's about to paint me now does NOT
|
|
|
|
// want that. Need to tell ourselves to flush our transform.
|
2011-10-17 18:59:28 +04:00
|
|
|
mImageNeedsTransformInvalidation = true;
|
2011-02-09 23:13:18 +03:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsPaintingSVGImageElement = true;
|
2011-02-09 23:13:18 +03:00
|
|
|
|
2013-02-26 20:58:06 +04:00
|
|
|
if (!hasViewBoxRect) {
|
2010-12-20 03:45:29 +03:00
|
|
|
return; // preserveAspectRatio irrelevant (only matters if we have viewBox)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aPAR.GetDefer() && HasPreserveAspectRatio()) {
|
|
|
|
return; // Referring element defers to my own preserveAspectRatio value.
|
|
|
|
}
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
if (SetPreserveAspectRatioProperty(aPAR)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mImageNeedsTransformInvalidation = true;
|
2010-12-20 03:45:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ClearImageOverridePreserveAspectRatio()
|
2010-12-20 03:45:29 +03:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
|
|
|
"should only override image preserveAspectRatio in images");
|
2010-12-20 03:45:29 +03:00
|
|
|
#endif
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mIsPaintingSVGImageElement = false;
|
2013-02-26 20:58:06 +04:00
|
|
|
if (!HasViewBoxRect() && ShouldSynthesizeViewBox()) {
|
2011-02-09 23:13:18 +03:00
|
|
|
// My non-<svg:image> clients will want to paint me with a synthesized
|
|
|
|
// viewBox, but my <svg:image> client that just painted me did NOT
|
|
|
|
// use that. Need to tell ourselves to flush our transform.
|
2011-10-17 18:59:28 +04:00
|
|
|
mImageNeedsTransformInvalidation = true;
|
2011-02-09 23:13:18 +03:00
|
|
|
}
|
|
|
|
|
2012-05-17 14:02:41 +04:00
|
|
|
if (ClearPreserveAspectRatioProperty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mImageNeedsTransformInvalidation = true;
|
2010-12-20 03:45:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::FlushImageTransformInvalidation()
|
2010-12-20 03:45:29 +03:00
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!GetParent(), "Should only be called on root node");
|
|
|
|
MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(),
|
|
|
|
"Should only be called on image documents");
|
2011-02-09 23:13:18 +03:00
|
|
|
|
|
|
|
if (mImageNeedsTransformInvalidation) {
|
2010-12-20 03:45:29 +03:00
|
|
|
InvalidateTransformNotifyFrame();
|
2011-10-17 18:59:28 +04:00
|
|
|
mImageNeedsTransformInvalidation = false;
|
2010-12-20 03:45:29 +03:00
|
|
|
}
|
|
|
|
}
|
2012-05-17 14:02:41 +04:00
|
|
|
|
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetViewBoxProperty(const nsSVGViewBoxRect& aViewBox)
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
nsSVGViewBoxRect* pViewBoxOverridePtr = new nsSVGViewBoxRect(aViewBox);
|
|
|
|
nsresult rv = SetProperty(nsGkAtoms::viewBox,
|
|
|
|
pViewBoxOverridePtr,
|
2014-03-25 17:25:47 +04:00
|
|
|
nsINode::DeleteProperty<nsSVGViewBoxRect>,
|
2012-06-06 12:15:53 +04:00
|
|
|
true);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(rv != NS_PROPTABLE_PROP_OVERWRITTEN,
|
|
|
|
"Setting override value when it's already set...?");
|
2012-05-17 14:02:41 +04:00
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(NS_FAILED(rv))) {
|
2012-05-17 14:02:41 +04:00
|
|
|
// property-insertion failed (e.g. OOM in property-table code)
|
|
|
|
delete pViewBoxOverridePtr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsSVGViewBoxRect*
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetViewBoxProperty() const
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
void* valPtr = GetProperty(nsGkAtoms::viewBox);
|
|
|
|
if (valPtr) {
|
|
|
|
return static_cast<nsSVGViewBoxRect*>(valPtr);
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ClearViewBoxProperty()
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
void* valPtr = UnsetProperty(nsGkAtoms::viewBox);
|
|
|
|
delete static_cast<nsSVGViewBoxRect*>(valPtr);
|
|
|
|
return valPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::SetZoomAndPanProperty(uint16_t aValue)
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
2012-06-06 12:15:53 +04:00
|
|
|
nsresult rv = SetProperty(nsGkAtoms::zoomAndPan,
|
|
|
|
reinterpret_cast<void*>(aValue),
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, true);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(rv != NS_PROPTABLE_PROP_OVERWRITTEN,
|
|
|
|
"Setting override value when it's already set...?");
|
2012-05-17 14:02:41 +04:00
|
|
|
|
|
|
|
return NS_SUCCEEDED(rv);
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::GetZoomAndPanProperty() const
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
|
|
|
void* valPtr = GetProperty(nsGkAtoms::zoomAndPan);
|
|
|
|
if (valPtr) {
|
2012-05-31 14:39:12 +04:00
|
|
|
return reinterpret_cast<uintptr_t>(valPtr);
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
2013-01-10 09:24:37 +04:00
|
|
|
return SVG_ZOOMANDPAN_UNKNOWN;
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-01-10 03:02:45 +04:00
|
|
|
SVGSVGElement::ClearZoomAndPanProperty()
|
2012-05-17 14:02:41 +04:00
|
|
|
{
|
2012-05-31 14:39:12 +04:00
|
|
|
return UnsetProperty(nsGkAtoms::zoomAndPan);
|
2012-05-17 14:02:41 +04:00
|
|
|
}
|
|
|
|
|
2013-05-05 11:20:25 +04:00
|
|
|
bool
|
|
|
|
SVGSVGElement::SetTransformProperty(const SVGTransformList& aTransform)
|
|
|
|
{
|
|
|
|
SVGTransformList* pTransformOverridePtr = new SVGTransformList(aTransform);
|
|
|
|
nsresult rv = SetProperty(nsGkAtoms::transform,
|
|
|
|
pTransformOverridePtr,
|
2014-03-25 17:25:47 +04:00
|
|
|
nsINode::DeleteProperty<SVGTransformList>,
|
2013-05-05 11:20:25 +04:00
|
|
|
true);
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(rv != NS_PROPTABLE_PROP_OVERWRITTEN,
|
|
|
|
"Setting override value when it's already set...?");
|
2013-05-05 11:20:25 +04:00
|
|
|
|
|
|
|
if (MOZ_UNLIKELY(NS_FAILED(rv))) {
|
|
|
|
// property-insertion failed (e.g. OOM in property-table code)
|
|
|
|
delete pTransformOverridePtr;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SVGTransformList*
|
|
|
|
SVGSVGElement::GetTransformProperty() const
|
|
|
|
{
|
|
|
|
void* valPtr = GetProperty(nsGkAtoms::transform);
|
|
|
|
if (valPtr) {
|
|
|
|
return static_cast<SVGTransformList*>(valPtr);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SVGSVGElement::ClearTransformProperty()
|
|
|
|
{
|
|
|
|
return UnsetProperty(nsGkAtoms::transform);
|
|
|
|
}
|
|
|
|
|
2015-01-20 22:12:54 +03:00
|
|
|
int32_t
|
2015-01-20 17:27:16 +03:00
|
|
|
SVGSVGElement::GetIntrinsicWidth()
|
|
|
|
{
|
|
|
|
if (mLengthAttributes[ATTR_WIDTH].IsPercentage()) {
|
2015-01-20 22:12:54 +03:00
|
|
|
return -1;
|
2015-01-20 17:27:16 +03:00
|
|
|
}
|
|
|
|
// Passing |this| as a SVGSVGElement* invokes the variant of GetAnimValue
|
|
|
|
// that uses the passed argument as the context, but that's fine since we
|
|
|
|
// know the length isn't a percentage so the context won't be used (and we
|
|
|
|
// need to pass the element to be able to resolve em/ex units).
|
2015-01-20 22:12:54 +03:00
|
|
|
float width = mLengthAttributes[ATTR_WIDTH].GetAnimValue(this);
|
|
|
|
return nsSVGUtils::ClampToInt(width);
|
2015-01-20 17:27:16 +03:00
|
|
|
}
|
|
|
|
|
2015-01-20 22:12:54 +03:00
|
|
|
int32_t
|
2015-01-20 17:27:16 +03:00
|
|
|
SVGSVGElement::GetIntrinsicHeight()
|
|
|
|
{
|
|
|
|
if (mLengthAttributes[ATTR_HEIGHT].IsPercentage()) {
|
2015-01-20 22:12:54 +03:00
|
|
|
return -1;
|
2015-01-20 17:27:16 +03:00
|
|
|
}
|
|
|
|
// Passing |this| as a SVGSVGElement* invokes the variant of GetAnimValue
|
|
|
|
// that uses the passed argument as the context, but that's fine since we
|
|
|
|
// know the length isn't a percentage so the context won't be used (and we
|
|
|
|
// need to pass the element to be able to resolve em/ex units).
|
2015-01-20 22:12:54 +03:00
|
|
|
float height = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(this);
|
|
|
|
return nsSVGUtils::ClampToInt(height);
|
2015-01-20 17:27:16 +03:00
|
|
|
}
|
|
|
|
|
2013-01-10 03:02:45 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|