зеркало из https://github.com/mozilla/gecko-dev.git
Bug 826961 - Revise SVGPreserveAspectRatio so that the silly cast is not needed. r=longsonr
This commit is contained in:
Родитель
d9f2a41f28
Коммит
562567aa74
|
@ -19,7 +19,7 @@ class nsSMILValue;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
class SVGAnimatedPreserveAspectRatio
|
||||
class SVGAnimatedPreserveAspectRatio MOZ_FINAL
|
||||
{
|
||||
public:
|
||||
void Init() {
|
||||
|
@ -44,7 +44,8 @@ public:
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
SetBaseValue(SVGPreserveAspectRatio(
|
||||
aAlign, mBaseVal.GetMeetOrSlice(), mBaseVal.GetDefer()),
|
||||
static_cast<SVGAlign>(aAlign), mBaseVal.GetMeetOrSlice(),
|
||||
mBaseVal.GetDefer()),
|
||||
aSVGElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -54,7 +55,8 @@ public:
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
SetBaseValue(SVGPreserveAspectRatio(
|
||||
mBaseVal.GetAlign(), aMeetOrSlice, mBaseVal.GetDefer()),
|
||||
mBaseVal.GetAlign(), static_cast<SVGMeetOrSlice>(aMeetOrSlice),
|
||||
mBaseVal.GetDefer()),
|
||||
aSVGElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -303,8 +303,8 @@ SVGContentUtils::GetViewBoxTransform(const nsSVGElement* aElement,
|
|||
NS_ASSERTION(aViewboxWidth > 0, "viewBox width must be greater than zero!");
|
||||
NS_ASSERTION(aViewboxHeight > 0, "viewBox height must be greater than zero!");
|
||||
|
||||
uint16_t align = aPreserveAspectRatio.GetAlign();
|
||||
uint16_t meetOrSlice = aPreserveAspectRatio.GetMeetOrSlice();
|
||||
SVGAlign align = aPreserveAspectRatio.GetAlign();
|
||||
SVGMeetOrSlice meetOrSlice = aPreserveAspectRatio.GetMeetOrSlice();
|
||||
|
||||
// default to the defaults
|
||||
if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN)
|
||||
|
|
|
@ -12,42 +12,47 @@
|
|||
|
||||
class nsSVGElement;
|
||||
|
||||
namespace mozilla {
|
||||
// Alignment Types
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
|
||||
static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
|
||||
enum SVGAlign MOZ_ENUM_TYPE(uint8_t) {
|
||||
SVG_PRESERVEASPECTRATIO_UNKNOWN = 0,
|
||||
SVG_PRESERVEASPECTRATIO_NONE = 1,
|
||||
SVG_PRESERVEASPECTRATIO_XMINYMIN = 2,
|
||||
SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3,
|
||||
SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4,
|
||||
SVG_PRESERVEASPECTRATIO_XMINYMID = 5,
|
||||
SVG_PRESERVEASPECTRATIO_XMIDYMID = 6,
|
||||
SVG_PRESERVEASPECTRATIO_XMAXYMID = 7,
|
||||
SVG_PRESERVEASPECTRATIO_XMINYMAX = 8,
|
||||
SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9,
|
||||
SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10
|
||||
};
|
||||
|
||||
// Meet-or-slice Types
|
||||
static const unsigned short SVG_MEETORSLICE_UNKNOWN = 0;
|
||||
static const unsigned short SVG_MEETORSLICE_MEET = 1;
|
||||
static const unsigned short SVG_MEETORSLICE_SLICE = 2;
|
||||
enum SVGMeetOrSlice MOZ_ENUM_TYPE(uint8_t) {
|
||||
SVG_MEETORSLICE_UNKNOWN = 0,
|
||||
SVG_MEETORSLICE_MEET = 1,
|
||||
SVG_MEETORSLICE_SLICE = 2
|
||||
};
|
||||
|
||||
namespace mozilla {
|
||||
class SVGAnimatedPreserveAspectRatio;
|
||||
|
||||
class SVGPreserveAspectRatio
|
||||
class SVGPreserveAspectRatio MOZ_FINAL
|
||||
{
|
||||
friend class SVGAnimatedPreserveAspectRatio;
|
||||
public:
|
||||
SVGPreserveAspectRatio(uint16_t aAlign, uint16_t aMeetOrSlice, bool aDefer = false)
|
||||
: mAlign(static_cast<uint8_t>(aAlign))
|
||||
, mMeetOrSlice(static_cast<uint8_t>(aMeetOrSlice))
|
||||
SVGPreserveAspectRatio(SVGAlign aAlign, SVGMeetOrSlice aMeetOrSlice,
|
||||
bool aDefer = false)
|
||||
: mAlign(aAlign)
|
||||
, mMeetOrSlice(aMeetOrSlice)
|
||||
, mDefer(aDefer)
|
||||
{}
|
||||
|
||||
bool operator==(const SVGPreserveAspectRatio& aOther) const;
|
||||
|
||||
explicit SVGPreserveAspectRatio()
|
||||
: mAlign(0)
|
||||
, mMeetOrSlice(0)
|
||||
: mAlign(SVG_PRESERVEASPECTRATIO_UNKNOWN)
|
||||
, mMeetOrSlice(SVG_MEETORSLICE_UNKNOWN)
|
||||
, mDefer(false)
|
||||
{}
|
||||
|
||||
|
@ -59,8 +64,8 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
uint16_t GetAlign() const {
|
||||
return mAlign;
|
||||
SVGAlign GetAlign() const {
|
||||
return static_cast<SVGAlign>(mAlign);
|
||||
}
|
||||
|
||||
nsresult SetMeetOrSlice(uint16_t aMeetOrSlice) {
|
||||
|
@ -71,8 +76,8 @@ public:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
uint16_t GetMeetOrSlice() const {
|
||||
return mMeetOrSlice;
|
||||
SVGMeetOrSlice GetMeetOrSlice() const {
|
||||
return static_cast<SVGMeetOrSlice>(mMeetOrSlice);
|
||||
}
|
||||
|
||||
void SetDefer(bool aDefer) {
|
||||
|
@ -84,11 +89,15 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
// We can't use enum types here because some compilers fail to pack them.
|
||||
uint8_t mAlign;
|
||||
uint8_t mMeetOrSlice;
|
||||
bool mDefer;
|
||||
};
|
||||
|
||||
MOZ_STATIC_ASSERT(sizeof(SVGPreserveAspectRatio) <= 4,
|
||||
"The compiler didn't pack SVGPreserveAspectRatio well");
|
||||
|
||||
namespace dom {
|
||||
|
||||
class DOMSVGPreserveAspectRatio MOZ_FINAL : public nsISupports,
|
||||
|
|
Загрузка…
Ссылка в новой задаче