зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358794, part 1 - If necessary, synthesize a viewBox for SVG embedded via SVG <image>. r=longsonr
MozReview-Commit-ID: DuKOqfxCUW8
This commit is contained in:
Родитель
b91438bf36
Коммит
80319e98e0
|
@ -183,7 +183,6 @@ SVGSVGElement::SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo
|
|||
aFromParser == FROM_PARSER_FRAGMENT ||
|
||||
aFromParser == FROM_PARSER_XSLT),
|
||||
mImageNeedsTransformInvalidation(false),
|
||||
mIsPaintingSVGImageElement(false),
|
||||
mHasChildrenOnlyTransform(false)
|
||||
{
|
||||
}
|
||||
|
@ -1061,14 +1060,9 @@ SVGSVGElement::HasViewBoxRect() const
|
|||
bool
|
||||
SVGSVGElement::ShouldSynthesizeViewBox() const
|
||||
{
|
||||
MOZ_ASSERT(!HasViewBoxRect(),
|
||||
"Should only be called if we lack a viewBox");
|
||||
MOZ_ASSERT(!HasViewBoxRect(), "Should only be called if we lack a viewBox");
|
||||
|
||||
nsIDocument* doc = GetUncomposedDoc();
|
||||
return doc &&
|
||||
doc->IsBeingUsedAsImage() &&
|
||||
!mIsPaintingSVGImageElement &&
|
||||
!GetParent();
|
||||
return IsRoot() && OwnerDoc()->IsBeingUsedAsImage();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1108,12 +1102,6 @@ SVGSVGElement::ClearPreserveAspectRatioProperty()
|
|||
return valPtr;
|
||||
}
|
||||
|
||||
void
|
||||
SVGSVGElement::SetIsPaintingForSVGImageElement(bool aIsPaintingSVGImageElement)
|
||||
{
|
||||
mIsPaintingSVGImageElement = aIsPaintingSVGImageElement;
|
||||
}
|
||||
|
||||
void
|
||||
SVGSVGElement::
|
||||
SetImageOverridePreserveAspectRatio(const SVGPreserveAspectRatio& aPAR)
|
||||
|
|
|
@ -317,8 +317,6 @@ private:
|
|||
const SVGPreserveAspectRatio* GetPreserveAspectRatioProperty() const;
|
||||
bool ClearPreserveAspectRatioProperty();
|
||||
|
||||
void SetIsPaintingForSVGImageElement(bool aIsPaintingSVGImageElement);
|
||||
|
||||
bool IsRoot() const {
|
||||
NS_ASSERTION((IsInUncomposedDoc() && !GetParent()) ==
|
||||
(OwnerDoc() && (OwnerDoc()->GetRootElement() == this)),
|
||||
|
@ -420,7 +418,6 @@ private:
|
|||
// to manually kick off animation when they are bound to the tree.
|
||||
bool mStartAnimationOnBindToTree;
|
||||
bool mImageNeedsTransformInvalidation;
|
||||
bool mIsPaintingSVGImageElement;
|
||||
bool mHasChildrenOnlyTransform;
|
||||
};
|
||||
|
||||
|
@ -447,8 +444,6 @@ public:
|
|||
// and overflow properties here, too. See bug 272288 comment 36.
|
||||
mRootElem->SetImageOverridePreserveAspectRatio(
|
||||
*aSVGContext->GetPreserveAspectRatio());
|
||||
mRootElem->SetIsPaintingForSVGImageElement(
|
||||
aSVGContext->IsPaintingForSVGImageElement());
|
||||
}
|
||||
|
||||
mOriginalTime = mRootElem->GetCurrentTime();
|
||||
|
@ -460,7 +455,6 @@ public:
|
|||
mRootElem->SetCurrentTime(mOriginalTime);
|
||||
if (mHaveOverrides) {
|
||||
mRootElem->ClearImageOverridePreserveAspectRatio();
|
||||
mRootElem->SetIsPaintingForSVGImageElement(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,7 @@ namespace mozilla {
|
|||
class SVGImageContext
|
||||
{
|
||||
public:
|
||||
SVGImageContext()
|
||||
: mIsPaintingSVGImageElement(false)
|
||||
{ }
|
||||
SVGImageContext() {}
|
||||
|
||||
/**
|
||||
* Currently it seems that the aViewportSize parameter ends up being used
|
||||
|
@ -42,16 +40,11 @@ public:
|
|||
* in order to get the size that's created for |fallbackContext|. At some
|
||||
* point we need to clean this code up, make our abstractions clear, create
|
||||
* that utility and stop using Maybe for this parameter.
|
||||
*
|
||||
* Note: 'aIsPaintingSVGImageElement' should be used to indicate whether
|
||||
* the SVG image in question is being painted for an SVG <image> element.
|
||||
*/
|
||||
explicit SVGImageContext(const Maybe<CSSIntSize>& aViewportSize,
|
||||
const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio = Nothing(),
|
||||
bool aIsPaintingSVGImageElement = false)
|
||||
const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio = Nothing())
|
||||
: mViewportSize(aViewportSize)
|
||||
, mPreserveAspectRatio(aPreserveAspectRatio)
|
||||
, mIsPaintingSVGImageElement(aIsPaintingSVGImageElement)
|
||||
{ }
|
||||
|
||||
static void MaybeInitAndStoreContextPaint(Maybe<SVGImageContext>& aContext,
|
||||
|
@ -78,10 +71,6 @@ public:
|
|||
return mContextPaint.get();
|
||||
}
|
||||
|
||||
bool IsPaintingForSVGImageElement() const {
|
||||
return mIsPaintingSVGImageElement;
|
||||
}
|
||||
|
||||
bool operator==(const SVGImageContext& aOther) const {
|
||||
bool contextPaintIsEqual =
|
||||
// neither have context paint, or they have the same object:
|
||||
|
@ -92,8 +81,7 @@ public:
|
|||
|
||||
return contextPaintIsEqual &&
|
||||
mViewportSize == aOther.mViewportSize &&
|
||||
mPreserveAspectRatio == aOther.mPreserveAspectRatio &&
|
||||
mIsPaintingSVGImageElement == aOther.mIsPaintingSVGImageElement;
|
||||
mPreserveAspectRatio == aOther.mPreserveAspectRatio;
|
||||
}
|
||||
|
||||
bool operator!=(const SVGImageContext& aOther) const {
|
||||
|
@ -107,8 +95,7 @@ public:
|
|||
}
|
||||
return HashGeneric(hash,
|
||||
mViewportSize.map(HashSize).valueOr(0),
|
||||
mPreserveAspectRatio.map(HashPAR).valueOr(0),
|
||||
mIsPaintingSVGImageElement);
|
||||
mPreserveAspectRatio.map(HashPAR).valueOr(0));
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -123,7 +110,6 @@ private:
|
|||
RefPtr<SVGEmbeddingContextPaint> mContextPaint;
|
||||
Maybe<CSSIntSize> mViewportSize;
|
||||
Maybe<SVGPreserveAspectRatio> mPreserveAspectRatio;
|
||||
bool mIsPaintingSVGImageElement;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -406,8 +406,7 @@ nsSVGImageFrame::PaintSVG(gfxContext& aContext,
|
|||
// with preserveAspectRatio and viewBox.
|
||||
const Maybe<SVGImageContext> context(
|
||||
Some(SVGImageContext(Some(CSSIntSize::Truncate(width, height)),
|
||||
Some(imgElem->mPreserveAspectRatio.GetAnimValue()),
|
||||
/* aIsPaintingSVGImageElement */ true)));
|
||||
Some(imgElem->mPreserveAspectRatio.GetAnimValue()))));
|
||||
|
||||
// For the actual draw operation to draw crisply (and at the right size),
|
||||
// our destination rect needs to be |width|x|height|, *in dev pixels*.
|
||||
|
|
Загрузка…
Ссылка в новой задаче