2013-01-06 01:32:02 -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/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/SVGLineElement.h"
|
|
|
|
#include "mozilla/dom/SVGLineElementBinding.h"
|
2013-11-02 04:10:38 -07:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-01-06 01:32:02 -08:00
|
|
|
|
|
|
|
NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Line)
|
|
|
|
|
2013-11-02 04:10:38 -07:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
SVGLineElement::WrapNode(JSContext *aCx)
|
2013-01-06 01:32:02 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return SVGLineElementBinding::Wrap(aCx, this);
|
2013-01-06 01:32:02 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSVGElement::LengthInfo SVGLineElement::sLengthInfo[4] =
|
|
|
|
{
|
|
|
|
{ &nsGkAtoms::x1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y1, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
|
|
|
{ &nsGkAtoms::x2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
|
|
|
|
{ &nsGkAtoms::y2, 0, nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
SVGLineElement::SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2013-01-06 01:32:02 -08:00
|
|
|
: SVGLineElementBase(aNodeInfo)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIDOMNode methods
|
|
|
|
|
|
|
|
NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGLineElement)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 01:32:02 -08:00
|
|
|
SVGLineElement::X1()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 01:32:02 -08:00
|
|
|
SVGLineElement::Y1()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y1].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 01:32:02 -08:00
|
|
|
SVGLineElement::X2()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_X2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
2013-01-19 12:56:00 -08:00
|
|
|
already_AddRefed<SVGAnimatedLength>
|
2013-01-06 01:32:02 -08:00
|
|
|
SVGLineElement::Y2()
|
|
|
|
{
|
|
|
|
return mLengthAttributes[ATTR_Y2].ToDOMAnimatedLength(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIContent methods
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
SVGLineElement::IsAttributeMapped(const nsIAtom* name) const
|
|
|
|
{
|
|
|
|
static const MappedAttributeEntry* const map[] = {
|
|
|
|
sMarkersMap
|
|
|
|
};
|
|
|
|
|
|
|
|
return FindAttributeDependence(name, map) ||
|
|
|
|
SVGLineElementBase::IsAttributeMapped(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGElement methods
|
|
|
|
|
|
|
|
nsSVGElement::LengthAttributesInfo
|
|
|
|
SVGLineElement::GetLengthInfo()
|
|
|
|
{
|
|
|
|
return LengthAttributesInfo(mLengthAttributes, sLengthInfo,
|
|
|
|
ArrayLength(sLengthInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSVGPathGeometryElement methods
|
|
|
|
|
|
|
|
void
|
|
|
|
SVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
|
|
|
|
float x1, y1, x2, y2;
|
|
|
|
|
|
|
|
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
|
|
|
|
|
|
|
|
float angle = atan2(y2 - y1, x2 - x1);
|
|
|
|
|
2013-07-11 23:39:38 -07:00
|
|
|
aMarks->AppendElement(nsSVGMark(x1, y1, angle, nsSVGMark::eStart));
|
|
|
|
aMarks->AppendElement(nsSVGMark(x2, y2, angle, nsSVGMark::eEnd));
|
2013-01-06 01:32:02 -08:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:29:05 -07:00
|
|
|
void
|
|
|
|
SVGLineElement::GetAsSimplePath(SimplePath* aSimplePath)
|
|
|
|
{
|
|
|
|
float x1, y1, x2, y2;
|
|
|
|
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
|
|
|
|
aSimplePath->SetLine(x1, y1, x2, y2);
|
|
|
|
}
|
|
|
|
|
2013-11-02 04:10:38 -07:00
|
|
|
TemporaryRef<Path>
|
2014-07-05 13:53:04 -07:00
|
|
|
SVGLineElement::BuildPath(PathBuilder* aBuilder)
|
2013-11-02 04:10:38 -07:00
|
|
|
{
|
|
|
|
float x1, y1, x2, y2;
|
|
|
|
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr);
|
|
|
|
|
2014-10-04 04:13:30 -07:00
|
|
|
aBuilder->MoveTo(Point(x1, y1));
|
|
|
|
aBuilder->LineTo(Point(x2, y2));
|
2013-11-02 04:10:38 -07:00
|
|
|
|
2014-10-04 04:13:30 -07:00
|
|
|
return aBuilder->Finish();
|
2013-11-02 04:10:38 -07:00
|
|
|
}
|
|
|
|
|
2013-01-06 01:32:02 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|