Bug 1837487 - stop asserting when Q units are used r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D180384
This commit is contained in:
Robert Longson 2023-06-09 02:26:38 +00:00
Родитель 88f288a7b8
Коммит 96ace2bad1
6 изменённых файлов: 51 добавлений и 39 удалений

Просмотреть файл

@ -1061,8 +1061,8 @@ bool SVGElement::UpdateDeclarationBlockFromLength(
return false; return false;
} }
nsCSSUnit cssUnit = SVGGeometryProperty::SpecifiedUnitTypeToCSSUnit( nsCSSUnit cssUnit =
aLength.GetSpecifiedUnitType()); SVGLength::SpecifiedUnitTypeToCSSUnit(aLength.GetSpecifiedUnitType());
if (cssUnit == eCSSUnit_Percent) { if (cssUnit == eCSSUnit_Percent) {
Servo_DeclarationBlock_SetPercentValue(aBlock.Raw(), aPropId, Servo_DeclarationBlock_SetPercentValue(aBlock.Raw(), aPropId,

Просмотреть файл

@ -11,46 +11,9 @@
#include "SVGImageElement.h" #include "SVGImageElement.h"
#include "SVGRectElement.h" #include "SVGRectElement.h"
#include "SVGUseElement.h" #include "SVGUseElement.h"
#include "nsCSSValue.h"
namespace mozilla::dom::SVGGeometryProperty { namespace mozilla::dom::SVGGeometryProperty {
nsCSSUnit SpecifiedUnitTypeToCSSUnit(uint8_t aSpecifiedUnit) {
switch (aSpecifiedUnit) {
case SVGLength_Binding::SVG_LENGTHTYPE_NUMBER:
case SVGLength_Binding::SVG_LENGTHTYPE_PX:
return nsCSSUnit::eCSSUnit_Pixel;
case SVGLength_Binding::SVG_LENGTHTYPE_MM:
return nsCSSUnit::eCSSUnit_Millimeter;
case SVGLength_Binding::SVG_LENGTHTYPE_CM:
return nsCSSUnit::eCSSUnit_Centimeter;
case SVGLength_Binding::SVG_LENGTHTYPE_IN:
return nsCSSUnit::eCSSUnit_Inch;
case SVGLength_Binding::SVG_LENGTHTYPE_PT:
return nsCSSUnit::eCSSUnit_Point;
case SVGLength_Binding::SVG_LENGTHTYPE_PC:
return nsCSSUnit::eCSSUnit_Pica;
case SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE:
return nsCSSUnit::eCSSUnit_Percent;
case SVGLength_Binding::SVG_LENGTHTYPE_EMS:
return nsCSSUnit::eCSSUnit_EM;
case SVGLength_Binding::SVG_LENGTHTYPE_EXS:
return nsCSSUnit::eCSSUnit_XHeight;
default:
MOZ_ASSERT_UNREACHABLE("Unknown unit type");
return nsCSSUnit::eCSSUnit_Pixel;
}
}
nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement, nsCSSPropertyID AttrEnumToCSSPropId(const SVGElement* aElement,
uint8_t aAttrEnum) { uint8_t aAttrEnum) {
// This is a very trivial function only applied to a few elements, // This is a very trivial function only applied to a few elements,

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/dom/SVGElement.h" #include "mozilla/dom/SVGElement.h"
#include "mozilla/dom/SVGSVGElement.h" #include "mozilla/dom/SVGSVGElement.h"
#include "nsCSSValue.h"
#include "nsTextFormatter.h" #include "nsTextFormatter.h"
#include "SVGContentUtils.h" #include "SVGContentUtils.h"
#include <limits> #include <limits>
@ -169,6 +170,46 @@ float SVGLength::GetPixelsPerUnit(const UserSpaceMetrics& aMetrics,
} }
} }
/* static */
nsCSSUnit SVGLength::SpecifiedUnitTypeToCSSUnit(uint8_t aSpecifiedUnit) {
switch (aSpecifiedUnit) {
case SVG_LENGTHTYPE_NUMBER:
case SVG_LENGTHTYPE_PX:
return nsCSSUnit::eCSSUnit_Pixel;
case SVG_LENGTHTYPE_MM:
return nsCSSUnit::eCSSUnit_Millimeter;
case SVG_LENGTHTYPE_CM:
return nsCSSUnit::eCSSUnit_Centimeter;
case SVG_LENGTHTYPE_IN:
return nsCSSUnit::eCSSUnit_Inch;
case SVG_LENGTHTYPE_PT:
return nsCSSUnit::eCSSUnit_Point;
case SVG_LENGTHTYPE_PC:
return nsCSSUnit::eCSSUnit_Pica;
case SVG_LENGTHTYPE_PERCENTAGE:
return nsCSSUnit::eCSSUnit_Percent;
case SVG_LENGTHTYPE_EMS:
return nsCSSUnit::eCSSUnit_EM;
case SVG_LENGTHTYPE_EXS:
return nsCSSUnit::eCSSUnit_XHeight;
case SVG_LENGTHTYPE_Q:
return nsCSSUnit::eCSSUnit_Quarter;
default:
MOZ_ASSERT_UNREACHABLE("Unknown unit type");
return nsCSSUnit::eCSSUnit_Pixel;
}
}
/* static */ /* static */
void SVGLength::GetUnitString(nsAString& aUnit, uint16_t aUnitType) { void SVGLength::GetUnitString(nsAString& aUnit, uint16_t aUnitType) {
switch (aUnitType) { switch (aUnitType) {

Просмотреть файл

@ -13,6 +13,8 @@
#include "mozilla/dom/SVGAnimatedLength.h" #include "mozilla/dom/SVGAnimatedLength.h"
#include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGLengthBinding.h"
enum nsCSSUnit : uint32_t;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -109,6 +111,8 @@ class SVGLength {
static float GetAbsUnitsPerAbsUnit(uint8_t aUnits, uint8_t aPerUnit); static float GetAbsUnitsPerAbsUnit(uint8_t aUnits, uint8_t aPerUnit);
static nsCSSUnit SpecifiedUnitTypeToCSSUnit(uint8_t aSpecifiedUnit);
static void GetUnitString(nsAString& aUnit, uint16_t aUnitType); static void GetUnitString(nsAString& aUnit, uint16_t aUnitType);
static uint16_t GetUnitTypeForString(const nsAString& aUnit); static uint16_t GetUnitTypeForString(const nsAString& aUnit);

Просмотреть файл

@ -0,0 +1,3 @@
<svg>
<ellipse cx='5.0q'/>

После

Ширина:  |  Высота:  |  Размер: 28 B

Просмотреть файл

@ -97,3 +97,4 @@ load 1560179.html
load 1572904.html load 1572904.html
load 1683907.html load 1683907.html
pref(dom.svg.pathSeg.enabled,true) load 1715387.html pref(dom.svg.pathSeg.enabled,true) load 1715387.html
load 1837487.html