mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 1462272: Introduce nsImageFrame::GetCurrentRequest. r=dholbert
MozReview-Commit-ID: IXXtYClyY2z
This commit is contained in:
parent
6332002ac0
commit
f981370133
@ -113,11 +113,6 @@ interface nsIImageLoadingContent : imgINotificationObserver
|
||||
*/
|
||||
[notxpcom, nostdcall] void setBlockedRequest(in int16_t aContentDecision);
|
||||
|
||||
/**
|
||||
* @return true if the current request's size is available.
|
||||
*/
|
||||
[noscript, notxpcom] boolean currentRequestHasSize();
|
||||
|
||||
/**
|
||||
* Used to notify the image loading content node that a frame has been
|
||||
* created.
|
||||
|
@ -629,12 +629,6 @@ nsImageLoadingContent::GetRequest(int32_t aRequestType,
|
||||
return result.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsImageLoadingContent::CurrentRequestHasSize()
|
||||
{
|
||||
return HaveSize(mCurrentRequest);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
nsImageLoadingContent::FrameCreated(nsIFrame* aFrame)
|
||||
{
|
||||
|
@ -273,16 +273,12 @@ nsImageFrame::Init(nsIContent* aContent,
|
||||
|
||||
imageLoader->AddNativeObserver(mListener);
|
||||
|
||||
// We have a PresContext now, so we need to notify the image content node
|
||||
// that it can register images.
|
||||
// We have a PresContext now, so we need to notify the image content node that
|
||||
// it can register images.
|
||||
imageLoader->FrameCreated(this);
|
||||
|
||||
// Give image loads associated with an image frame a small priority boost!
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
|
||||
if (currentRequest) {
|
||||
// Give image loads associated with an image frame a small priority boost.
|
||||
if (nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest()) {
|
||||
uint32_t categoryToBoostPriority = imgIRequest::CATEGORY_FRAME_INIT;
|
||||
|
||||
// Increase load priority further if intrinsic size might be important for layout.
|
||||
@ -853,26 +849,22 @@ nsImageFrame::EnsureIntrinsicSizeAndRatio()
|
||||
// invalid image specified
|
||||
if (!(GetStateBits() & NS_FRAME_GENERATED_CONTENT)) {
|
||||
bool imageInvalid = false;
|
||||
|
||||
// check for broken images. valid null images (eg. img src="") are
|
||||
// not considered broken because they have no image requests
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
if (imageLoader) {
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
if (currentRequest) {
|
||||
uint32_t imageStatus;
|
||||
imageInvalid =
|
||||
NS_SUCCEEDED(currentRequest->GetImageStatus(&imageStatus)) &&
|
||||
(imageStatus & imgIRequest::STATUS_ERROR);
|
||||
} else {
|
||||
// check if images are user-disabled (or blocked for other
|
||||
// reasons)
|
||||
int16_t imageBlockingStatus;
|
||||
imageLoader->GetImageBlockingStatus(&imageBlockingStatus);
|
||||
imageInvalid = imageBlockingStatus != nsIContentPolicy::ACCEPT;
|
||||
}
|
||||
if (nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest()) {
|
||||
uint32_t imageStatus;
|
||||
imageInvalid =
|
||||
NS_SUCCEEDED(currentRequest->GetImageStatus(&imageStatus)) &&
|
||||
(imageStatus & imgIRequest::STATUS_ERROR);
|
||||
} else if (nsCOMPtr<nsIImageLoadingContent> loader = do_QueryInterface(mContent)) {
|
||||
// check if images are user-disabled (or blocked for other
|
||||
// reasons)
|
||||
int16_t imageBlockingStatus;
|
||||
loader->GetImageBlockingStatus(&imageBlockingStatus);
|
||||
imageInvalid = imageBlockingStatus != nsIContentPolicy::ACCEPT;
|
||||
}
|
||||
|
||||
// invalid image specified. make the image big enough for the "broken" icon
|
||||
if (imageInvalid) {
|
||||
nscoord edgeLengthToUse =
|
||||
@ -1024,16 +1016,10 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
|
||||
// we have to split images if we are:
|
||||
// in Paginated mode, we need to have a constrained height, and have a height larger than our available height
|
||||
uint32_t loadStatus = imgIRequest::STATUS_NONE;
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(imageLoader, "No content node??");
|
||||
if (imageLoader) {
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
if (currentRequest) {
|
||||
currentRequest->GetImageStatus(&loadStatus);
|
||||
}
|
||||
if (nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest()) {
|
||||
currentRequest->GetImageStatus(&loadStatus);
|
||||
}
|
||||
|
||||
if (aPresContext->IsPaginated() &&
|
||||
((loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) || (mState & IMAGE_SIZECONSTRAINED)) &&
|
||||
NS_UNCONSTRAINEDSIZE != aReflowInput.AvailableHeight() &&
|
||||
@ -1812,6 +1798,20 @@ nsImageFrame::PaintImage(gfxContext& aRenderingContext, nsPoint aPt,
|
||||
return result;
|
||||
}
|
||||
|
||||
already_AddRefed<imgIRequest>
|
||||
nsImageFrame::GetCurrentRequest() const
|
||||
{
|
||||
nsCOMPtr<imgIRequest> request;
|
||||
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
MOZ_ASSERT(imageLoader);
|
||||
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(request));
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
void
|
||||
nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
const nsDisplayListSet& aLists)
|
||||
@ -1829,18 +1829,11 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
clip(aBuilder, this, clipFlags);
|
||||
|
||||
if (mComputedSize.width != 0 && mComputedSize.height != 0) {
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
NS_ASSERTION(imageLoader, "Not an image loading content?");
|
||||
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
if (imageLoader) {
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
}
|
||||
|
||||
EventStates contentState = mContent->AsElement()->State();
|
||||
bool imageOK = IMAGE_OK(contentState, true);
|
||||
|
||||
nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest();
|
||||
|
||||
// XXX(seth): The SizeIsAvailable check here should not be necessary - the
|
||||
// intention is that a non-null mImage means we have a size, but there is
|
||||
// currently some code that violates this invariant.
|
||||
@ -2177,18 +2170,12 @@ nsImageFrame::List(FILE* out, const char* aPrefix, uint32_t aFlags) const
|
||||
ListGeneric(str, aPrefix, aFlags);
|
||||
|
||||
// output the img src url
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
if (imageLoader) {
|
||||
nsCOMPtr<imgIRequest> currentRequest;
|
||||
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(currentRequest));
|
||||
if (currentRequest) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
currentRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString uristr;
|
||||
uri->GetAsciiSpec(uristr);
|
||||
str += nsPrintfCString(" [src=%s]", uristr.get());
|
||||
}
|
||||
if (nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest()) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
currentRequest->GetURI(getter_AddRefs(uri));
|
||||
nsAutoCString uristr;
|
||||
uri->GetAsciiSpec(uristr);
|
||||
str += nsPrintfCString(" [src=%s]", uristr.get());
|
||||
}
|
||||
fprintf_stderr(out, "%s\n", str.get());
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ public:
|
||||
NS_IF_RELEASE(sIOService);
|
||||
}
|
||||
|
||||
already_AddRefed<imgIRequest> GetCurrentRequest() const;
|
||||
nsresult Notify(imgIRequest *aRequest, int32_t aType, const nsIntRect* aData);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user