зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1872241 - Remove svgFloatSize and use gfx::Size instead r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D197371
This commit is contained in:
Родитель
ea36a87c56
Коммит
0e8866544c
|
@ -53,8 +53,6 @@ SVGElement::LengthInfo SVGViewportElement::sLengthInfo[4] = {
|
|||
SVGViewportElement::SVGViewportElement(
|
||||
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
||||
: SVGGraphicsElement(std::move(aNodeInfo)),
|
||||
mViewportWidth(0),
|
||||
mViewportHeight(0),
|
||||
mHasChildrenOnlyTransform(false) {}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -160,8 +158,8 @@ gfx::Matrix SVGViewportElement::GetViewBoxTransform() const {
|
|||
viewportWidth = mLengthAttributes[ATTR_WIDTH].GetAnimValue(metrics);
|
||||
viewportHeight = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(metrics);
|
||||
} else {
|
||||
viewportWidth = mViewportWidth;
|
||||
viewportHeight = mViewportHeight;
|
||||
viewportWidth = mViewportSize.width;
|
||||
viewportHeight = mViewportSize.height;
|
||||
}
|
||||
|
||||
if (!std::isfinite(viewportWidth) || viewportWidth <= 0.0f ||
|
||||
|
@ -211,15 +209,15 @@ float SVGViewportElement::GetLength(uint8_t aCtxType) const {
|
|||
} else if (ShouldSynthesizeViewBox()) {
|
||||
if (shouldComputeWidth) {
|
||||
w = ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
||||
mViewportWidth, this);
|
||||
mViewportSize.width, this);
|
||||
}
|
||||
if (shouldComputeHeight) {
|
||||
h = ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_HEIGHT],
|
||||
mViewportHeight, this);
|
||||
mViewportSize.height, this);
|
||||
}
|
||||
} else {
|
||||
w = mViewportWidth;
|
||||
h = mViewportHeight;
|
||||
w = mViewportSize.width;
|
||||
h = mViewportSize.height;
|
||||
}
|
||||
|
||||
w = std::max(w, 0.0f);
|
||||
|
@ -328,9 +326,9 @@ SVGViewBox SVGViewportElement::GetViewBoxWithSynthesis(
|
|||
return SVGViewBox(
|
||||
0, 0,
|
||||
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH],
|
||||
mViewportWidth, this),
|
||||
mViewportSize.width, this),
|
||||
ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_HEIGHT],
|
||||
mViewportHeight, this));
|
||||
mViewportSize.height, this));
|
||||
}
|
||||
|
||||
// No viewBox attribute, so we shouldn't auto-scale. This is equivalent
|
||||
|
|
|
@ -31,16 +31,6 @@ class SVGAnimatedRect;
|
|||
class SVGViewElement;
|
||||
class SVGViewportElement;
|
||||
|
||||
class svgFloatSize {
|
||||
public:
|
||||
svgFloatSize(float aWidth, float aHeight) : width(aWidth), height(aHeight) {}
|
||||
bool operator!=(const svgFloatSize& rhs) {
|
||||
return width != rhs.width || height != rhs.height;
|
||||
}
|
||||
float width;
|
||||
float height;
|
||||
};
|
||||
|
||||
class SVGViewportElement : public SVGGraphicsElement {
|
||||
friend class mozilla::SVGOuterSVGFrame;
|
||||
friend class mozilla::SVGViewportFrame;
|
||||
|
@ -114,14 +104,9 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||
|
||||
gfx::Matrix GetViewBoxTransform() const;
|
||||
|
||||
svgFloatSize GetViewportSize() const {
|
||||
return svgFloatSize(mViewportWidth, mViewportHeight);
|
||||
}
|
||||
gfx::Size GetViewportSize() const { return mViewportSize; }
|
||||
|
||||
void SetViewportSize(const svgFloatSize& aSize) {
|
||||
mViewportWidth = aSize.width;
|
||||
mViewportHeight = aSize.height;
|
||||
}
|
||||
void SetViewportSize(const gfx::Size& aSize) { mViewportSize = aSize; }
|
||||
|
||||
/**
|
||||
* Returns true if either this is an SVG <svg> element that is the child of
|
||||
|
@ -188,8 +173,8 @@ class SVGViewportElement : public SVGGraphicsElement {
|
|||
//
|
||||
// XXXjwatt Currently only used for outer <svg>, but maybe we could use -1 to
|
||||
// flag this as an inner <svg> to save the overhead of GetCtx calls?
|
||||
// XXXjwatt our frame should probably reset these when it's destroyed.
|
||||
float mViewportWidth, mViewportHeight;
|
||||
// XXXjwatt our frame should probably reset this when it's destroyed.
|
||||
gfx::Size mViewportSize;
|
||||
|
||||
bool mHasChildrenOnlyTransform;
|
||||
};
|
||||
|
|
|
@ -9596,7 +9596,7 @@ nsRect nsLayoutUtils::ComputeSVGOriginBox(SVGViewportElement* aElement) {
|
|||
|
||||
// No viewBox is specified, uses the nearest SVG viewport as reference
|
||||
// box.
|
||||
svgFloatSize viewportSize = aElement->GetViewportSize();
|
||||
auto viewportSize = aElement->GetViewportSize();
|
||||
return nsRect(0, 0, nsPresContext::CSSPixelsToAppUnits(viewportSize.width),
|
||||
nsPresContext::CSSPixelsToAppUnits(viewportSize.height));
|
||||
}
|
||||
|
|
|
@ -356,14 +356,12 @@ void SVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
|
|||
// If our SVG viewport has changed, update our content and notify.
|
||||
// http://www.w3.org/TR/SVG11/coords.html#ViewportSpace
|
||||
|
||||
svgFloatSize newViewportSize(
|
||||
gfx::Size newViewportSize(
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(aReflowInput.ComputedWidth()),
|
||||
nsPresContext::AppUnitsToFloatCSSPixels(aReflowInput.ComputedHeight()));
|
||||
|
||||
svgFloatSize oldViewportSize = svgElem->GetViewportSize();
|
||||
|
||||
uint32_t changeBits = 0;
|
||||
if (newViewportSize != oldViewportSize) {
|
||||
if (newViewportSize != svgElem->GetViewportSize()) {
|
||||
// When our viewport size changes, we may need to update the overflow rects
|
||||
// of our child frames. This is the case if:
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче