Skip to content

Commit

Permalink
Bug 1404422 - Part 4. Remove imgIOnloadBlocker and related from tree …
Browse files Browse the repository at this point in the history
…as redundant. r=tnikkel
  • Loading branch information
aosmond committed Nov 1, 2017
1 parent fa1b4c4 commit c1204e3
Show file tree
Hide file tree
Showing 29 changed files with 12 additions and 341 deletions.
3 changes: 1 addition & 2 deletions dom/base/nsGenConImageContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class nsGenConImageContent final : public nsXMLElement,
NS_IMPL_ISUPPORTS_INHERITED(nsGenConImageContent,
nsXMLElement,
nsIImageLoadingContent,
imgINotificationObserver,
imgIOnloadBlocker)
imgINotificationObserver)

nsresult
NS_NewGenConImageContent(nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
Expand Down
52 changes: 0 additions & 52 deletions dom/base/nsImageLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,52 +843,6 @@ nsImageLoadingContent::ForceReload(bool aNotify /* = true */,
return result.StealNSResult();
}

NS_IMETHODIMP
nsImageLoadingContent::BlockOnload(imgIRequest* aRequest)
{
if (aRequest == mCurrentRequest) {
NS_ASSERTION(!(mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD),
"Double BlockOnload!?");
mCurrentRequestFlags |= REQUEST_BLOCKS_ONLOAD;
} else if (aRequest == mPendingRequest) {
NS_ASSERTION(!(mPendingRequestFlags & REQUEST_BLOCKS_ONLOAD),
"Double BlockOnload!?");
mPendingRequestFlags |= REQUEST_BLOCKS_ONLOAD;
} else {
return NS_OK;
}

nsIDocument* doc = GetOurCurrentDoc();
if (doc) {
doc->BlockOnload();
}

return NS_OK;
}

NS_IMETHODIMP
nsImageLoadingContent::UnblockOnload(imgIRequest* aRequest)
{
if (aRequest == mCurrentRequest) {
NS_ASSERTION(mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD,
"Double UnblockOnload!?");
mCurrentRequestFlags &= ~REQUEST_BLOCKS_ONLOAD;
} else if (aRequest == mPendingRequest) {
NS_ASSERTION(mPendingRequestFlags & REQUEST_BLOCKS_ONLOAD,
"Double UnblockOnload!?");
mPendingRequestFlags &= ~REQUEST_BLOCKS_ONLOAD;
} else {
return NS_OK;
}

nsIDocument* doc = GetOurCurrentDoc();
if (doc) {
doc->UnblockOnload(false);
}

return NS_OK;
}

/*
* Non-interface methods
*/
Expand Down Expand Up @@ -1607,9 +1561,6 @@ nsImageLoadingContent::BindToTree(nsIDocument* aDocument, nsIContent* aParent,

TrackImage(mCurrentRequest);
TrackImage(mPendingRequest);

if (mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD)
aDocument->BlockOnload();
}

void
Expand All @@ -1622,9 +1573,6 @@ nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent)

UntrackImage(mCurrentRequest);
UntrackImage(mPendingRequest);

if (mCurrentRequestFlags & REQUEST_BLOCKS_ONLOAD)
doc->UnblockOnload(false);
}

void
Expand Down
7 changes: 1 addition & 6 deletions dom/base/nsImageLoadingContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define nsImageLoadingContent_h__

#include "imgINotificationObserver.h"
#include "imgIOnloadBlocker.h"
#include "mozilla/CORSMode.h"
#include "mozilla/EventStates.h"
#include "mozilla/TimeStamp.h"
Expand All @@ -41,8 +40,7 @@ class AsyncEventDispatcher;
#undef LoadImage
#endif

class nsImageLoadingContent : public nsIImageLoadingContent,
public imgIOnloadBlocker
class nsImageLoadingContent : public nsIImageLoadingContent
{
template <typename T> using Maybe = mozilla::Maybe<T>;
using Nothing = mozilla::Nothing;
Expand All @@ -56,7 +54,6 @@ class nsImageLoadingContent : public nsIImageLoadingContent,

NS_DECL_IMGINOTIFICATIONOBSERVER
NS_DECL_NSIIMAGELOADINGCONTENT
NS_DECL_IMGIONLOADBLOCKER

// Web IDL binding methods.
// Note that the XPCOM SetLoadingEnabled, AddObserver, RemoveObserver,
Expand Down Expand Up @@ -421,8 +418,6 @@ class nsImageLoadingContent : public nsIImageLoadingContent,
enum {
// Set if the request needs ResetAnimation called on it.
REQUEST_NEEDS_ANIMATION_RESET = 0x00000001U,
// Set if the request is blocking onload.
REQUEST_BLOCKS_ONLOAD = 0x00000002U,
// Set if the request is currently tracked with the document.
REQUEST_IS_TRACKED = 0x00000004U,
// Set if this is an imageset request, such as from <img srcset> or
Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLEmbedElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLEmbedElement,
nsIObjectLoadingContent,
imgINotificationObserver,
nsIImageLoadingContent,
imgIOnloadBlocker,
nsIChannelEventSink)

NS_IMPL_ELEMENT_CLONE(HTMLEmbedElement)
Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLImageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLImageElement,
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLImageElement,
nsGenericHTMLElement,
nsIImageLoadingContent,
imgIOnloadBlocker,
imgINotificationObserver)

NS_IMPL_ELEMENT_CLONE(HTMLImageElement)
Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLImageElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "mozilla/Attributes.h"
#include "nsGenericHTMLElement.h"
#include "nsImageLoadingContent.h"
#include "imgRequestProxy.h"
#include "Units.h"
#include "nsCycleCollectionParticipant.h"

Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,6 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLInputElement,
nsITextControlElement,
imgINotificationObserver,
nsIImageLoadingContent,
imgIOnloadBlocker,
nsIDOMNSEditableElement,
nsIConstraintValidation)

Expand Down
1 change: 0 additions & 1 deletion dom/html/HTMLObjectElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLObjectElement,
nsIFrameLoaderOwner,
nsIObjectLoadingContent,
nsIImageLoadingContent,
imgIOnloadBlocker,
nsIChannelEventSink,
nsIConstraintValidation)

Expand Down
3 changes: 1 addition & 2 deletions dom/svg/SVGFEImageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ nsSVGElement::StringInfo SVGFEImageElement::sStringInfo[3] =

NS_IMPL_ISUPPORTS_INHERITED(SVGFEImageElement, SVGFEImageElementBase,
nsIDOMNode, nsIDOMElement, nsIDOMSVGElement,
imgINotificationObserver, nsIImageLoadingContent,
imgIOnloadBlocker)
imgINotificationObserver, nsIImageLoadingContent)

//----------------------------------------------------------------------
// Implementation
Expand Down
2 changes: 1 addition & 1 deletion dom/svg/SVGImageElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ NS_IMPL_ISUPPORTS_INHERITED(SVGImageElement, SVGImageElementBase,
nsIDOMNode, nsIDOMElement,
nsIDOMSVGElement,
imgINotificationObserver,
nsIImageLoadingContent, imgIOnloadBlocker)
nsIImageLoadingContent)

//----------------------------------------------------------------------
// Implementation
Expand Down
4 changes: 0 additions & 4 deletions image/IProgressObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ class IProgressObserver : public SupportsWeakPtr<IProgressObserver>
virtual void Notify(int32_t aType, const nsIntRect* aRect = nullptr) = 0;
virtual void OnLoadComplete(bool aLastPart) = 0;

// imgIOnloadBlocker methods:
virtual void BlockOnload() = 0;
virtual void UnblockOnload() = 0;

// Other, internal-only methods:
virtual void SetHasImage() = 0;
virtual bool NotificationsDeferred() const = 0;
Expand Down
4 changes: 1 addition & 3 deletions image/MultipartImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class NextPartObserver : public IProgressObserver
}

// Other notifications are ignored.
virtual void BlockOnload() override { }
virtual void UnblockOnload() override { }
virtual void SetHasImage() override { }
virtual bool NotificationsDeferred() const override { return false; }
virtual void SetNotificationsDeferred(bool) override { }
Expand Down Expand Up @@ -177,7 +175,7 @@ FilterProgress(Progress aProgress)
// onload for multipart images.
// Filter out errors, since we don't want errors in one part to error out
// the whole stream.
return aProgress & ~(FLAG_ONLOAD_BLOCKED | FLAG_ONLOAD_UNBLOCKED | FLAG_HAS_ERROR);
return aProgress & ~FLAG_HAS_ERROR;
}

void
Expand Down
5 changes: 0 additions & 5 deletions image/MultipartImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class MultipartImage
virtual bool NotificationsDeferred() const override;
virtual void SetNotificationsDeferred(bool aDeferNotifications) override;

// We don't allow multipart images to block onload, so we override these
// methods to do nothing.
virtual void BlockOnload() override { }
virtual void UnblockOnload() override { }

protected:
virtual ~MultipartImage();

Expand Down
21 changes: 0 additions & 21 deletions image/ProgressTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ CheckProgressConsistency(Progress aOldProgress, Progress aNewProgress, bool aIsM
if (aNewProgress & FLAG_LOAD_COMPLETE) {
MOZ_ASSERT(aIsMultipart || aNewProgress & (FLAG_SIZE_AVAILABLE | FLAG_HAS_ERROR));
}
if (aNewProgress & FLAG_ONLOAD_BLOCKED) {
// No preconditions.
}
if (aNewProgress & FLAG_ONLOAD_UNBLOCKED) {
MOZ_ASSERT(aNewProgress & FLAG_ONLOAD_BLOCKED);
MOZ_ASSERT(aIsMultipart || aNewProgress & (FLAG_SIZE_AVAILABLE | FLAG_HAS_ERROR));
}
if (aNewProgress & FLAG_IS_ANIMATED) {
// No preconditions; like FLAG_HAS_TRANSPARENCY, we should normally never
// discover this *after* FLAG_SIZE_AVAILABLE, but unfortunately some corrupt
Expand Down Expand Up @@ -376,23 +369,9 @@ ProgressTracker::SyncNotifyProgress(Progress aProgress,
{
MOZ_ASSERT(NS_IsMainThread(), "Use mObservers on main thread only");

// Don't unblock onload if we're not blocked.
Progress progress = Difference(aProgress);
if (!((mProgress | progress) & FLAG_ONLOAD_BLOCKED)) {
progress &= ~FLAG_ONLOAD_UNBLOCKED;
}

CheckProgressConsistency(mProgress, mProgress | progress, mIsMultipart);

// XXX(seth): Hack to work around the fact that some observers have bugs and
// need to get onload blocking notifications multiple times. We should fix
// those observers and remove this.
if ((aProgress & FLAG_DECODE_COMPLETE) &&
(mProgress & FLAG_ONLOAD_BLOCKED) &&
(mProgress & FLAG_ONLOAD_UNBLOCKED)) {
progress |= FLAG_ONLOAD_BLOCKED | FLAG_ONLOAD_UNBLOCKED;
}

// Apply the changes.
mProgress |= progress;

Expand Down
2 changes: 0 additions & 2 deletions image/ProgressTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ enum {
FLAG_DECODE_COMPLETE = 1u << 1, // STATUS_DECODE_COMPLETE
FLAG_FRAME_COMPLETE = 1u << 2, // STATUS_FRAME_COMPLETE
FLAG_LOAD_COMPLETE = 1u << 3, // STATUS_LOAD_COMPLETE
FLAG_ONLOAD_BLOCKED = 1u << 4,
FLAG_ONLOAD_UNBLOCKED = 1u << 5,
FLAG_IS_ANIMATED = 1u << 6, // STATUS_IS_ANIMATED
FLAG_HAS_TRANSPARENCY = 1u << 7, // STATUS_HAS_TRANSPARENCY
FLAG_LAST_PART_COMPLETE = 1u << 8,
Expand Down
2 changes: 0 additions & 2 deletions image/RasterImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
// We don't have our size yet, so we'll fire the load event in SetSize().
MOZ_ASSERT(!canSyncDecodeMetadata,
"Firing load async after metadata sync decode?");
NotifyProgress(FLAG_ONLOAD_BLOCKED);
mLoadProgress = Some(loadProgress);
return finalStatus;
}
Expand Down Expand Up @@ -1843,7 +1842,6 @@ RasterImage::NotifyDecodeComplete(const DecoderFinalStatus& aStatus,
if (mLoadProgress) {
NotifyForLoadEvent(*mLoadProgress);
mLoadProgress = Nothing();
NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
}

// If we were a metadata decode and a full decode was requested, do it.
Expand Down
15 changes: 2 additions & 13 deletions image/VectorImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,16 +1197,6 @@ VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
return rv;
}

// ProgressTracker::SyncNotifyProgress may release us, so ensure we
// stick around long enough to complete our work.
RefPtr<VectorImage> kungFuDeathGrip(this);

// Block page load until the document's ready. (We unblock it in
// OnSVGDocumentLoaded or OnSVGDocumentError.)
if (mProgressTracker) {
mProgressTracker->SyncNotifyProgress(FLAG_ONLOAD_BLOCKED);
}

// Create a listener to wait until the SVG document is fully loaded, which
// will signal that this image is ready to render. Certain error conditions
// will prevent us from ever getting this notification, so we also create a
Expand Down Expand Up @@ -1290,8 +1280,7 @@ VectorImage::OnSVGDocumentLoaded()
Progress progress = FLAG_SIZE_AVAILABLE |
FLAG_HAS_TRANSPARENCY |
FLAG_FRAME_COMPLETE |
FLAG_DECODE_COMPLETE |
FLAG_ONLOAD_UNBLOCKED;
FLAG_DECODE_COMPLETE;

if (mHaveAnimations) {
progress |= FLAG_IS_ANIMATED;
Expand All @@ -1318,7 +1307,7 @@ VectorImage::OnSVGDocumentError()

if (mProgressTracker) {
// Notify observers about the error and unblock page load.
Progress progress = FLAG_ONLOAD_UNBLOCKED | FLAG_HAS_ERROR;
Progress progress = FLAG_HAS_ERROR;

// Merge in any saved progress from OnImageDataComplete.
if (mLoadProgress) {
Expand Down
32 changes: 0 additions & 32 deletions image/imgIOnloadBlocker.idl

This file was deleted.

2 changes: 1 addition & 1 deletion image/imgRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ imgRequest::ContinueCancel(nsresult aStatus)
MOZ_ASSERT(NS_IsMainThread());

RefPtr<ProgressTracker> progressTracker = GetProgressTracker();
progressTracker->SyncNotifyProgress(FLAG_HAS_ERROR | FLAG_ONLOAD_UNBLOCKED);
progressTracker->SyncNotifyProgress(FLAG_HAS_ERROR);

RemoveFromCache();

Expand Down
Loading

0 comments on commit c1204e3

Please sign in to comment.