Backed out changeset 6d81c1303daf (bug 1086284) for refest failures on a CLOSED TREE

This commit is contained in:
Carsten "Tomcat" Book 2014-12-17 13:21:07 +01:00
parent bd7aaf93b7
commit e57f3ff4ab
3 changed files with 25 additions and 39 deletions

View File

@ -7,7 +7,6 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Likely.h"
#include "nsGkAtoms.h"
@ -1248,29 +1247,5 @@ SVGSVGElement::ClearTransformProperty()
return UnsetProperty(nsGkAtoms::transform);
}
float
SVGSVGElement::GetIntrinsicWidth() const
{
if (mLengthAttributes[ATTR_WIDTH].IsPercentage()) {
return UnspecifiedNaN<float>();
}
// Context is only needed for percentage resolution. We already know we
// don't have a percentage, so no context is needed; hence, nullptr.
SVGSVGElement* context = nullptr;
return std::max(mLengthAttributes[ATTR_WIDTH].GetAnimValue(context), 0.f);
}
float
SVGSVGElement::GetIntrinsicHeight() const
{
if (mLengthAttributes[ATTR_HEIGHT].IsPercentage()) {
return UnspecifiedNaN<float>();
}
// Context is only needed for percentage resolution. We already know we
// don't have a percentage, so no context is needed; hence, nullptr.
SVGSVGElement* context = nullptr;
return std::max(mLengthAttributes[ATTR_HEIGHT].GetAnimValue(context), 0.f);
}
} // namespace dom
} // namespace mozilla

View File

@ -147,14 +147,6 @@ public:
// public helpers:
/**
* Returns the user-unit width/height if those dimensions are not specified
* as percentage values. If they are specified as percentage values then this
* element does not have intrinsic width/height and these methods return NaN.
*/
float GetIntrinsicWidth() const;
float GetIntrinsicHeight() const;
/**
* Returns true if this element has a base/anim value for its "viewBox"
* attribute that defines a viewBox rectangle with finite values, or

View File

@ -6,7 +6,6 @@
#include "SVGDocumentWrapper.h"
#include "mozilla/dom/Element.h"
#include "mozilla/FloatingPoint.h"
#include "nsICategoryManager.h"
#include "nsIChannel.h"
#include "nsIContentViewer.h"
@ -77,14 +76,34 @@ SVGDocumentWrapper::GetWidthOrHeight(Dimension aDimension,
NS_ABORT_IF_FALSE(rootElem, "root elem missing or of wrong type");
// Get the width or height SVG object
float length = (aDimension == eWidth) ? rootElem->GetIntrinsicWidth()
: rootElem->GetIntrinsicHeight();
nsRefPtr<SVGAnimatedLength> domAnimLength;
if (aDimension == eWidth) {
domAnimLength = rootElem->Width();
} else {
NS_ABORT_IF_FALSE(aDimension == eHeight, "invalid dimension");
domAnimLength = rootElem->Height();
}
NS_ENSURE_TRUE(domAnimLength, false);
if (!IsFinite(length)) {
return false; // Percentage size
// Get the animated value from the object
nsRefPtr<DOMSVGLength> domLength = domAnimLength->AnimVal();
NS_ENSURE_TRUE(domLength, false);
// Check if it's a percent value (and fail if so)
uint16_t unitType;
nsresult rv = domLength->GetUnitType(&unitType);
NS_ENSURE_SUCCESS(rv, false);
if (unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE) {
return false;
}
aResult = nsSVGUtils::ClampToInt(length);
// Non-percent value - woot! Grab it & return it.
float floatLength;
rv = domLength->GetValue(&floatLength);
NS_ENSURE_SUCCESS(rv, false);
aResult = nsSVGUtils::ClampToInt(floatLength);
return true;
}