diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-12 18:56:16 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-12 18:56:16 +0200 |
commit | 53cf12d6d808c80c4ce240cbbf8d29344c8ce644 (patch) | |
tree | 4d187651b4548fa1a97065a732a20eec0fe5e473 /dom/base/nsImageLoadingContent.cpp | |
parent | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (diff) | |
download | UXP-53cf12d6d808c80c4ce240cbbf8d29344c8ce644.tar UXP-53cf12d6d808c80c4ce240cbbf8d29344c8ce644.tar.gz UXP-53cf12d6d808c80c4ce240cbbf8d29344c8ce644.tar.lz UXP-53cf12d6d808c80c4ce240cbbf8d29344c8ce644.tar.xz UXP-53cf12d6d808c80c4ce240cbbf8d29344c8ce644.zip |
Bug 1346501. Don't mark every image as visible when a frame is created for it
Diffstat (limited to 'dom/base/nsImageLoadingContent.cpp')
-rw-r--r-- | dom/base/nsImageLoadingContent.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index d25dd6319..b76bc533f 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -491,8 +491,8 @@ nsImageLoadingContent::FrameCreated(nsIFrame* aFrame) mFrameCreateCalled = true; - TrackImage(mCurrentRequest); - TrackImage(mPendingRequest); + TrackImage(mCurrentRequest, aFrame); + TrackImage(mPendingRequest, aFrame); // We need to make sure that our image request is registered, if it should // be registered. @@ -1486,7 +1486,8 @@ nsImageLoadingContent::OnVisibilityChange(Visibility aNewVisibility, } void -nsImageLoadingContent::TrackImage(imgIRequest* aImage) +nsImageLoadingContent::TrackImage(imgIRequest* aImage, + nsIFrame* aFrame /*= nullptr */) { if (!aImage) return; @@ -1499,13 +1500,21 @@ nsImageLoadingContent::TrackImage(imgIRequest* aImage) return; } - // We only want to track this request if we're visible. Ordinarily we check - // the visible count, but that requires a frame; in cases where - // GetOurPrimaryFrame() cannot obtain a frame (e.g. <feImage>), we assume - // we're visible if FrameCreated() was called. - nsIFrame* frame = GetOurPrimaryFrame(); - if ((frame && frame->GetVisibility() == Visibility::APPROXIMATELY_NONVISIBLE) || - (!frame && !mFrameCreateCalled)) { + if (!aFrame) { + aFrame = GetOurPrimaryFrame(); + } + + /* This line is deceptively simple. It hides a lot of subtlety. Before we + * create an nsImageFrame we call nsImageFrame::ShouldCreateImageFrameFor + * to determine if we should create an nsImageFrame or create a frame based + * on the display of the element (ie inline, block, etc). Inline, block, etc + * frames don't register for visibility tracking so they will return UNTRACKED + * from GetVisibility(). So this line is choosing to mark such images as + * visible. Once the image loads we will get an nsImageFrame and the proper + * visibility. This is a pitfall of tracking the visibility on the frames + * instead of the content node. + */ + if (!aFrame || aFrame->GetVisibility() == Visibility::APPROXIMATELY_NONVISIBLE) { return; } |