Backed out 4 changesets (bug 1825722) for causing reftest failures CLOSED TREE
[gecko.git] / dom / svg / SVGGeometryProperty.cpp
blob79c87df470a18ff17409d6c3ef6461b40f4f2bba
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "SVGGeometryProperty.h"
8 #include "SVGCircleElement.h"
9 #include "SVGEllipseElement.h"
10 #include "SVGForeignObjectElement.h"
11 #include "SVGImageElement.h"
12 #include "SVGRectElement.h"
13 #include "SVGUseElement.h"
15 namespace mozilla::dom::SVGGeometryProperty {
17 nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement,
18 uint8_t aAttrEnum) {
19 // This is a very trivial function only applied to a few elements,
20 // so we want to avoid making it virtual.
21 if (aElement->IsSVGElement(nsGkAtoms::rect)) {
22 return SVGRectElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
24 if (aElement->IsSVGElement(nsGkAtoms::circle)) {
25 return SVGCircleElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
27 if (aElement->IsSVGElement(nsGkAtoms::ellipse)) {
28 return SVGEllipseElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
30 if (aElement->IsSVGElement(nsGkAtoms::image)) {
31 return SVGImageElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
33 if (aElement->IsSVGElement(nsGkAtoms::foreignObject)) {
34 return SVGForeignObjectElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
36 if (aElement->IsSVGElement(nsGkAtoms::use)) {
37 return SVGUseElement::GetCSSPropertyIdForAttrEnum(aAttrEnum);
39 return eCSSProperty_UNKNOWN;
42 bool IsNonNegativeGeometryProperty(nsCSSPropertyID aProp) {
43 return aProp == eCSSProperty_r || aProp == eCSSProperty_rx ||
44 aProp == eCSSProperty_ry || aProp == eCSSProperty_width ||
45 aProp == eCSSProperty_height;
48 bool ElementMapsLengthsToStyle(SVGElement const* aElement) {
49 return aElement->IsAnyOfSVGElements(nsGkAtoms::rect, nsGkAtoms::circle,
50 nsGkAtoms::ellipse, nsGkAtoms::image,
51 nsGkAtoms::foreignObject, nsGkAtoms::use);
54 } // namespace mozilla::dom::SVGGeometryProperty