SVGMotionSMILAttr.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /* representation of a dummy attribute targeted by <animateMotion> element */
  6. #include "SVGMotionSMILAttr.h"
  7. #include "SVGMotionSMILType.h"
  8. #include "mozilla/dom/SVGAnimationElement.h"
  9. #include "nsSMILValue.h"
  10. #include "nsDebug.h"
  11. #include "nsSVGElement.h"
  12. #include "gfx2DGlue.h"
  13. namespace mozilla {
  14. nsresult
  15. SVGMotionSMILAttr::ValueFromString(const nsAString& aStr,
  16. const dom::SVGAnimationElement* aSrcElement,
  17. nsSMILValue& aValue,
  18. bool& aPreventCachingOfSandwich) const
  19. {
  20. NS_NOTREACHED("Shouldn't using nsISMILAttr::ValueFromString for parsing "
  21. "animateMotion's SMIL values.");
  22. return NS_ERROR_FAILURE;
  23. }
  24. nsSMILValue
  25. SVGMotionSMILAttr::GetBaseValue() const
  26. {
  27. return nsSMILValue(&SVGMotionSMILType::sSingleton);
  28. }
  29. void
  30. SVGMotionSMILAttr::ClearAnimValue()
  31. {
  32. mSVGElement->SetAnimateMotionTransform(nullptr);
  33. }
  34. nsresult
  35. SVGMotionSMILAttr::SetAnimValue(const nsSMILValue& aValue)
  36. {
  37. gfx::Matrix matrix = SVGMotionSMILType::CreateMatrix(aValue);
  38. mSVGElement->SetAnimateMotionTransform(&matrix);
  39. return NS_OK;
  40. }
  41. const nsIContent*
  42. SVGMotionSMILAttr::GetTargetNode() const
  43. {
  44. return mSVGElement;
  45. }
  46. } // namespace mozilla