Skip to content

Commit

Permalink
Bug 1387325 - Part1. Refactor nsImageBoxFrame::PaintImage to make it …
Browse files Browse the repository at this point in the history
…easier to add WR support. r=mattwoodrow

MozReview-Commit-ID: AmHPifpVAHZ

--HG--
extra : rebase_source : 8c87b569d068a539c1c9d27ac7e43bfde4671058
  • Loading branch information
demo99 committed Aug 17, 2017
1 parent 18bbbd4 commit a43edfa
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
37 changes: 29 additions & 8 deletions layout/xul/nsImageBoxFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,32 +341,53 @@ nsImageBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
aLists.Content()->AppendToTop(&list);
}

DrawResult
nsImageBoxFrame::PaintImage(gfxContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags)
already_AddRefed<imgIContainer>
nsImageBoxFrame::GetImageContainerForPainting(const nsPoint& aPt,
DrawResult& aDrawResult,
Maybe<nsPoint>& aAnchorPoint,
nsRect& aDest)
{
if (!mImageRequest) {
// This probably means we're drawn by a native theme.
return DrawResult::SUCCESS;
aDrawResult = DrawResult::SUCCESS;
return nullptr;
}

// Don't draw if the image's size isn't available.
uint32_t imgStatus;
if (!NS_SUCCEEDED(mImageRequest->GetImageStatus(&imgStatus)) ||
!(imgStatus & imgIRequest::STATUS_SIZE_AVAILABLE)) {
return DrawResult::NOT_READY;
aDrawResult = DrawResult::NOT_READY;
return nullptr;
}

nsCOMPtr<imgIContainer> imgCon;
mImageRequest->GetImage(getter_AddRefs(imgCon));

if (!imgCon) {
return DrawResult::NOT_READY;
aDrawResult = DrawResult::NOT_READY;
return nullptr;
}

aDest = GetDestRect(aPt, aAnchorPoint);
aDrawResult = DrawResult::SUCCESS;
return imgCon.forget();
}

DrawResult
nsImageBoxFrame::PaintImage(gfxContext& aRenderingContext,
const nsRect& aDirtyRect, nsPoint aPt,
uint32_t aFlags)
{
DrawResult result;
Maybe<nsPoint> anchorPoint;
nsRect dest = GetDestRect(aPt, anchorPoint);
nsRect dest;
nsCOMPtr<imgIContainer> imgCon = GetImageContainerForPainting(aPt, result,
anchorPoint,
dest);
if (!imgCon) {
return result;
}

// don't draw if the image is not dirty
// XXX(seth): Can this actually happen anymore?
Expand Down
5 changes: 5 additions & 0 deletions layout/xul/nsImageBoxFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class nsImageBoxFrame final : public nsLeafBoxFrame

virtual ~nsImageBoxFrame();

already_AddRefed<imgIContainer> GetImageContainerForPainting(const nsPoint& aPt,
DrawResult& aDrawResult,
Maybe<nsPoint>& aAnchorPoint,
nsRect& aDest);

DrawResult PaintImage(gfxContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt, uint32_t aFlags);
Expand Down

0 comments on commit a43edfa

Please sign in to comment.