Bug 997010 (Part 1) - Support dynamic changes to the image-orientation property. r=dbaron

This commit is contained in:
Seth Fowler 2014-06-27 20:50:26 -07:00
parent 9997cd7aef
commit a9aee866f3
7 changed files with 58 additions and 1 deletions

View File

@ -54,6 +54,7 @@ native Orientation(mozilla::image::Orientation);
[ref] native TimeStamp(mozilla::TimeStamp);
[ptr] native SVGImageContext(mozilla::SVGImageContext);
native TempRefSourceSurface(mozilla::TemporaryRef<mozilla::gfx::SourceSurface>);
native TempRefImgIContainer(already_AddRefed<imgIContainer>);
/**
@ -63,7 +64,7 @@ native TempRefSourceSurface(mozilla::TemporaryRef<mozilla::gfx::SourceSurface>);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(48590bac-a5b3-45b1-bd4e-57ab938eab9e)]
[scriptable, builtinclass, uuid(c9bd1257-45fb-4ea6-a669-6da212479191)]
interface imgIContainer : nsISupports
{
/**
@ -359,4 +360,9 @@ interface imgIContainer : nsISupports
* or orientation.
*/
[notxpcom] nsIntRectByVal getImageSpaceInvalidationRect([const] in nsIntRect aRect);
/*
* Removes any ImageWrappers and returns the unwrapped base image.
*/
[notxpcom, nostdcall] TempRefImgIContainer unwrap();
};

View File

@ -323,5 +323,11 @@ ImageWrapper::GetImageSpaceInvalidationRect(const nsIntRect& aRect)
return mInnerImage->GetImageSpaceInvalidationRect(aRect);
}
already_AddRefed<imgIContainer>
ImageWrapper::Unwrap()
{
return mInnerImage->Unwrap();
}
} // namespace image
} // namespace mozilla

View File

@ -3166,6 +3166,13 @@ RasterImage::FinishedSomeDecoding(eShutdownIntent aIntent /* = eShutdownIntent_D
return RequestDecodeIfNeeded(rv, aIntent, done, wasSize);
}
already_AddRefed<imgIContainer>
RasterImage::Unwrap()
{
nsCOMPtr<imgIContainer> self(this);
return self.forget();
}
NS_IMPL_ISUPPORTS(RasterImage::DecodePool,
nsIObserver)

View File

@ -1214,5 +1214,12 @@ VectorImage::InvalidateObserversOnNextRefreshDriverTick()
}
}
already_AddRefed<imgIContainer>
VectorImage::Unwrap()
{
nsCOMPtr<imgIContainer> self(this);
return self.forget();
}
} // namespace image
} // namespace mozilla

View File

@ -216,6 +216,34 @@ nsImageFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsSplittableFrame::DestroyFrom(aDestructRoot);
}
void
nsImageFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
{
ImageFrameSuper::DidSetStyleContext(aOldStyleContext);
if (!mImage) {
// We'll pick this change up whenever we do get an image.
return;
}
nsStyleImageOrientation newOrientation = StyleVisibility()->mImageOrientation;
// We need to update our orientation either if we had no style context before
// because this is the first time it's been set, or if the image-orientation
// property changed from its previous value.
bool shouldUpdateOrientation =
!aOldStyleContext ||
aOldStyleContext->StyleVisibility()->mImageOrientation != newOrientation;
if (shouldUpdateOrientation) {
nsCOMPtr<imgIContainer> image(mImage->Unwrap());
mImage = nsLayoutUtils::OrientImage(image, newOrientation);
UpdateIntrinsicSize(mImage);
UpdateIntrinsicRatio(mImage);
}
}
void
nsImageFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,

View File

@ -73,6 +73,8 @@ public:
NS_DECL_QUERYFRAME
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext) MOZ_OVERRIDE;
virtual void Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow) MOZ_OVERRIDE;

View File

@ -2654,6 +2654,7 @@ nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther)
} else {
if ((mImageOrientation != aOther.mImageOrientation)) {
NS_UpdateHint(hint, nsChangeHint_AllReflowHints);
NS_UpdateHint(hint, nsChangeHint_RepaintFrame);
}
if (mVisible != aOther.mVisible) {
if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) ||