ScriptElement.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef mozilla_dom_ScriptElement_h
  6. #define mozilla_dom_ScriptElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "nsIScriptLoaderObserver.h"
  9. #include "nsIScriptElement.h"
  10. #include "nsStubMutationObserver.h"
  11. namespace mozilla {
  12. namespace dom {
  13. /**
  14. * Baseclass useful for script elements (such as <xhtml:script> and
  15. * <svg:script>). Currently the class assumes that only the 'src'
  16. * attribute and the children of the class affect what script to execute.
  17. */
  18. class ScriptElement : public nsIScriptElement,
  19. public nsStubMutationObserver
  20. {
  21. public:
  22. // nsIScriptLoaderObserver
  23. NS_DECL_NSISCRIPTLOADEROBSERVER
  24. // nsIMutationObserver
  25. NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
  26. NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
  27. NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
  28. NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
  29. explicit ScriptElement(FromParser aFromParser)
  30. : nsIScriptElement(aFromParser)
  31. {
  32. }
  33. virtual nsresult FireErrorEvent() override;
  34. protected:
  35. // Internal methods
  36. /**
  37. * Check if this element contains any script, linked or inline
  38. */
  39. virtual bool HasScriptContent() = 0;
  40. virtual bool MaybeProcessScript() override;
  41. };
  42. } // dom namespace
  43. } // mozilla namespace
  44. #endif // mozilla_dom_ScriptElement_h