mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 870021 - Part 4 - Move HTMLImageElement::GetNatural{Height,Width} up to ImageLoadingContent. r=jst
This commit is contained in:
parent
bca1dd9ab3
commit
4792841382
@ -37,7 +37,7 @@ interface nsIFrame;
|
||||
* interface to mirror this interface when changing it.
|
||||
*/
|
||||
|
||||
[scriptable, builtinclass, uuid(e3968acd-b796-4ca3-aec0-e7f0880f2219)]
|
||||
[scriptable, builtinclass, uuid(256a5283-ebb5-4430-8e15-5ada92156ef7)]
|
||||
interface nsIImageLoadingContent : imgINotificationObserver
|
||||
{
|
||||
/**
|
||||
@ -160,6 +160,13 @@ interface nsIImageLoadingContent : imgINotificationObserver
|
||||
*/
|
||||
void forceImageState(in boolean aForce, in unsigned long long aState);
|
||||
|
||||
/**
|
||||
* The intrinsic size and width of this content. May differ from actual image
|
||||
* size due to things like responsive image density.
|
||||
*/
|
||||
readonly attribute unsigned long naturalWidth;
|
||||
readonly attribute unsigned long naturalHeight;
|
||||
|
||||
/**
|
||||
* A visible count is stored, if it is non-zero then this image is considered
|
||||
* visible. These methods increment, decrement, or return the visible coount.
|
||||
|
@ -877,6 +877,46 @@ nsImageLoadingContent::ForceImageState(bool aForce,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageLoadingContent::GetNaturalWidth(uint32_t* aNaturalWidth)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNaturalWidth);
|
||||
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
if (mCurrentRequest) {
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
}
|
||||
|
||||
int32_t width;
|
||||
if (image && NS_SUCCEEDED(image->GetWidth(&width))) {
|
||||
*aNaturalWidth = width;
|
||||
} else {
|
||||
*aNaturalWidth = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageLoadingContent::GetNaturalHeight(uint32_t* aNaturalHeight)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNaturalHeight);
|
||||
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
if (mCurrentRequest) {
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
}
|
||||
|
||||
int32_t height;
|
||||
if (image && NS_SUCCEEDED(image->GetHeight(&height))) {
|
||||
*aNaturalHeight = height;
|
||||
} else {
|
||||
*aNaturalHeight = 0;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
EventStates
|
||||
nsImageLoadingContent::ImageState() const
|
||||
{
|
||||
|
@ -622,60 +622,42 @@ HTMLImageElement::Image(const GlobalObject& aGlobal,
|
||||
uint32_t
|
||||
HTMLImageElement::NaturalHeight()
|
||||
{
|
||||
if (!mCurrentRequest) {
|
||||
uint32_t height;
|
||||
nsresult rv = nsImageLoadingContent::GetNaturalHeight(&height);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_ASSERT(false, "GetNaturalHeight should not fail");
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
if (!image) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t height;
|
||||
if (NS_SUCCEEDED(image->GetHeight(&height))) {
|
||||
return height;
|
||||
}
|
||||
return 0;
|
||||
return height;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLImageElement::GetNaturalHeight(uint32_t* aNaturalHeight)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNaturalHeight);
|
||||
|
||||
*aNaturalHeight = NaturalHeight();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
HTMLImageElement::NaturalWidth()
|
||||
{
|
||||
if (!mCurrentRequest) {
|
||||
uint32_t width;
|
||||
nsresult rv = nsImageLoadingContent::GetNaturalWidth(&width);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_ASSERT(false, "GetNaturalWidth should not fail");
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
mCurrentRequest->GetImage(getter_AddRefs(image));
|
||||
if (!image) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t width;
|
||||
if (NS_SUCCEEDED(image->GetWidth(&width))) {
|
||||
return width;
|
||||
}
|
||||
return 0;
|
||||
return width;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLImageElement::GetNaturalWidth(uint32_t* aNaturalWidth)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNaturalWidth);
|
||||
|
||||
*aNaturalWidth = NaturalWidth();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user