void ProgressTracker::SyncNotify(IProgressObserver* aObserver) { MOZ_ASSERT(NS_IsMainThread()); nsRefPtr<Image> image = GetImage(); nsAutoCString spec; if (image && image->GetURI()) { image->GetURI()->GetSpec(spec); } LOG_SCOPE_WITH_PARAM(GetImgLog(), "ProgressTracker::SyncNotify", "uri", spec.get()); nsIntRect rect; if (image) { if (NS_FAILED(image->GetWidth(&rect.width)) || NS_FAILED(image->GetHeight(&rect.height))) { // Either the image has no intrinsic size, or it has an error. rect = GetMaxSizedIntRect(); } } ObserverArray array; array.AppendElement(aObserver); SyncNotifyInternal(array, !!image, mProgress, rect); }
void ProgressTracker::SyncNotifyProgress(Progress aProgress, const nsIntRect& aInvalidRect /* = nsIntRect() */) { 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; } // 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; CheckProgressConsistency(mProgress); // Send notifications. SyncNotifyInternal(mObservers, HasImage(), progress, aInvalidRect); if (progress & FLAG_HAS_ERROR) { FireFailureNotification(); } }
void ProgressTracker::SyncNotify(imgRequestProxy* proxy) { MOZ_ASSERT(NS_IsMainThread(), "imgRequestProxy is not threadsafe"); #ifdef PR_LOGGING nsRefPtr<ImageURL> uri; proxy->GetURI(getter_AddRefs(uri)); nsAutoCString spec; uri->GetSpec(spec); LOG_SCOPE_WITH_PARAM(GetImgLog(), "ProgressTracker::SyncNotify", "uri", spec.get()); #endif nsIntRect r; if (mImage) { // XXX - Should only send partial rects here, but that needs to // wait until we fix up the observer interface r = mImage->FrameRect(imgIContainer::FRAME_CURRENT); } ProxyArray array; array.AppendElement(proxy); SyncNotifyInternal(array, !!mImage, mProgress, r); }
void ProgressTracker::SyncNotifyProgress(Progress aProgress, const nsIntRect& aInvalidRect /* = nsIntRect() */) { MOZ_ASSERT(NS_IsMainThread(), "Use mConsumers 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; } // Apply the changes. mProgress |= progress; CheckProgressConsistency(mProgress); // Send notifications. SyncNotifyInternal(mConsumers, !!mImage, progress, aInvalidRect); if (progress & FLAG_HAS_ERROR) { FireFailureNotification(); } }