ScriptedNotificationObserver.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "ScriptedNotificationObserver.h"
  7. #include "imgIScriptedNotificationObserver.h"
  8. #include "nsCycleCollectionParticipant.h"
  9. namespace mozilla {
  10. namespace image {
  11. NS_IMPL_CYCLE_COLLECTION(ScriptedNotificationObserver, mInner)
  12. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ScriptedNotificationObserver)
  13. NS_INTERFACE_MAP_ENTRY(imgINotificationObserver)
  14. NS_INTERFACE_MAP_ENTRY(nsISupports)
  15. NS_INTERFACE_MAP_END
  16. NS_IMPL_CYCLE_COLLECTING_ADDREF(ScriptedNotificationObserver)
  17. NS_IMPL_CYCLE_COLLECTING_RELEASE(ScriptedNotificationObserver)
  18. ScriptedNotificationObserver::ScriptedNotificationObserver(
  19. imgIScriptedNotificationObserver* aInner)
  20. : mInner(aInner)
  21. { }
  22. NS_IMETHODIMP
  23. ScriptedNotificationObserver::Notify(imgIRequest* aRequest,
  24. int32_t aType,
  25. const nsIntRect* /*aUnused*/)
  26. {
  27. if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
  28. return mInner->SizeAvailable(aRequest);
  29. }
  30. if (aType == imgINotificationObserver::FRAME_UPDATE) {
  31. return mInner->FrameUpdate(aRequest);
  32. }
  33. if (aType == imgINotificationObserver::FRAME_COMPLETE) {
  34. return mInner->FrameComplete(aRequest);
  35. }
  36. if (aType == imgINotificationObserver::DECODE_COMPLETE) {
  37. return mInner->DecodeComplete(aRequest);
  38. }
  39. if (aType == imgINotificationObserver::LOAD_COMPLETE) {
  40. return mInner->LoadComplete(aRequest);
  41. }
  42. if (aType == imgINotificationObserver::DISCARD) {
  43. return mInner->Discard(aRequest);
  44. }
  45. if (aType == imgINotificationObserver::IS_ANIMATED) {
  46. return mInner->IsAnimated(aRequest);
  47. }
  48. if (aType == imgINotificationObserver::HAS_TRANSPARENCY) {
  49. return mInner->HasTransparency(aRequest);
  50. }
  51. return NS_OK;
  52. }
  53. } // namespace image
  54. } // namespace mozilla