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/. */
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
#ifndef mozilla_dom_SVGImageElement_h
|
|
|
|
#define mozilla_dom_SVGImageElement_h
|
2009-01-05 04:19:38 +03:00
|
|
|
|
|
|
|
#include "nsImageLoadingContent.h"
|
2019-04-09 23:04:33 +03:00
|
|
|
#include "SVGAnimatedLength.h"
|
2019-04-04 20:40:56 +03:00
|
|
|
#include "SVGAnimatedString.h"
|
2016-12-18 14:11:47 +03:00
|
|
|
#include "SVGGeometryElement.h"
|
2010-12-20 03:45:29 +03:00
|
|
|
#include "SVGAnimatedPreserveAspectRatio.h"
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
nsresult NS_NewSVGImageElement(
|
2014-06-20 06:01:40 +04:00
|
|
|
nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
class nsSVGImageFrame;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMSVGAnimatedPreserveAspectRatio;
|
|
|
|
|
2016-12-18 14:11:47 +03:00
|
|
|
typedef SVGGeometryElement SVGImageElementBase;
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
class SVGImageElement : public SVGImageElementBase,
|
|
|
|
public nsImageLoadingContent {
|
|
|
|
friend class ::nsSVGImageFrame;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
|
|
|
protected:
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit SVGImageElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
2013-01-06 13:32:01 +04:00
|
|
|
virtual ~SVGImageElement();
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-01-06 13:32:01 +04:00
|
|
|
friend nsresult(::NS_NewSVGImageElement(
|
|
|
|
nsIContent** aResult,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
|
2009-01-05 04:19:38 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
// interfaces:
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2009-01-05 04:19:38 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2016-10-06 07:30:35 +03:00
|
|
|
// EventTarget
|
|
|
|
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
|
|
|
|
|
2009-01-05 04:19:38 +03:00
|
|
|
// nsIContent interface
|
2018-08-08 14:56:01 +03:00
|
|
|
bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
|
|
|
nsAttrValue& aResult) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-05-19 00:09:01 +03:00
|
|
|
bool aNotify) override;
|
2019-06-20 16:14:08 +03:00
|
|
|
bool IsNodeOfType(uint32_t aFlags) const override {
|
|
|
|
// <imag> is not really a SVGGeometryElement, we should
|
|
|
|
// ignore eSHAPE flag accepted by SVGGeometryElement.
|
|
|
|
return SVGGraphicsElement::IsNodeOfType(aFlags);
|
|
|
|
}
|
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
virtual void UnbindFromTree(bool aNullParent) override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EventStates IntrinsicState() const override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2016-12-18 14:11:47 +03:00
|
|
|
// SVGGeometryElement methods:
|
2015-02-03 21:36:32 +03:00
|
|
|
virtual bool GetGeometryBounds(
|
|
|
|
Rect* aBounds, const StrokeOptions& aStrokeOptions,
|
2015-09-01 07:17:00 +03:00
|
|
|
const Matrix& aToBoundsSpace,
|
|
|
|
const Matrix* aToNonScalingStrokeSpace = nullptr) override;
|
2015-06-17 17:00:52 +03:00
|
|
|
virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2012-03-03 13:21:09 +04:00
|
|
|
// nsSVGSVGElement methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool HasValidDimensions() const override;
|
2012-03-03 13:21:09 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult CopyInnerTo(mozilla::dom::Element* aDest);
|
2009-12-11 07:02:13 +03:00
|
|
|
|
2009-05-20 12:00:04 +04:00
|
|
|
void MaybeLoadSVGImage();
|
2010-07-23 13:49:57 +04:00
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
// WebIDL
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedLength> X();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Y();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Width();
|
|
|
|
already_AddRefed<DOMSVGAnimatedLength> Height();
|
2013-01-06 13:32:01 +04:00
|
|
|
already_AddRefed<DOMSVGAnimatedPreserveAspectRatio> PreserveAspectRatio();
|
2019-03-19 03:01:03 +03:00
|
|
|
already_AddRefed<DOMSVGAnimatedString> Href();
|
2013-01-06 13:32:01 +04:00
|
|
|
|
2018-08-08 14:56:01 +03:00
|
|
|
void SetDecoding(const nsAString& aDecoding, ErrorResult& aError) {
|
|
|
|
SetAttr(nsGkAtoms::decoding, aDecoding, aError);
|
|
|
|
}
|
|
|
|
void GetDecoding(nsAString& aValue);
|
|
|
|
|
2018-11-08 20:45:50 +03:00
|
|
|
already_AddRefed<Promise> Decode(ErrorResult& aRv);
|
|
|
|
|
2019-05-24 15:40:12 +03:00
|
|
|
static nsCSSPropertyID GetCSSPropertyIdForAttrEnum(uint8_t aAttrEnum);
|
|
|
|
|
2009-01-05 04:19:38 +03:00
|
|
|
protected:
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult LoadSVGImage(bool aForce, bool aNotify);
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual LengthAttributesInfo GetLengthInfo() override;
|
2019-04-10 07:08:14 +03:00
|
|
|
virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio()
|
|
|
|
override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual StringAttributesInfo GetStringInfo() override;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2017-03-17 00:43:34 +03:00
|
|
|
// Override for nsImageLoadingContent.
|
|
|
|
nsIContent* AsContent() override { return this; }
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT };
|
2019-04-09 23:04:33 +03:00
|
|
|
SVGAnimatedLength mLengthAttributes[4];
|
2009-01-05 04:19:38 +03:00
|
|
|
static LengthInfo sLengthInfo[4];
|
|
|
|
|
2010-12-20 03:45:29 +03:00
|
|
|
SVGAnimatedPreserveAspectRatio mPreserveAspectRatio;
|
2009-01-05 04:19:38 +03:00
|
|
|
|
2016-07-05 12:35:24 +03:00
|
|
|
enum { HREF, XLINK_HREF };
|
2019-04-04 20:40:56 +03:00
|
|
|
SVGAnimatedString mStringAttributes[2];
|
2016-07-05 12:35:24 +03:00
|
|
|
static StringInfo sStringInfo[2];
|
2009-01-05 04:19:38 +03:00
|
|
|
};
|
|
|
|
|
2013-01-06 13:32:01 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_SVGImageElement_h
|