SVGFragmentIdentifier.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_SVGFRAGMENTIDENTIFIER_H__
  6. #define MOZILLA_SVGFRAGMENTIDENTIFIER_H__
  7. #include "nsString.h"
  8. class nsIDocument;
  9. namespace mozilla {
  10. namespace dom {
  11. class SVGSVGElement;
  12. } // namespace dom
  13. /**
  14. * Implements support for parsing SVG fragment identifiers
  15. * http://www.w3.org/TR/SVG/linking.html#SVGFragmentIdentifiers
  16. */
  17. class SVGFragmentIdentifier
  18. {
  19. // To prevent the class being instantiated
  20. SVGFragmentIdentifier() = delete;
  21. public:
  22. /**
  23. * Process the SVG fragment identifier, if there is one.
  24. * @return true if we found a valid svgView()-style fragment identifier,
  25. * in which case further processing by the caller can stop. Otherwise return
  26. * false as we may have an ordinary anchor which needs to be :target matched.
  27. */
  28. static bool ProcessFragmentIdentifier(nsIDocument *aDocument,
  29. const nsAString &aAnchorName);
  30. private:
  31. /**
  32. * Parse an SVG ViewSpec and set applicable attributes on the root element.
  33. * @return true if there is a valid ViewSpec
  34. */
  35. static bool ProcessSVGViewSpec(const nsAString &aViewSpec, dom::SVGSVGElement *root);
  36. };
  37. } // namespace mozilla
  38. #endif // MOZILLA_SVGFRAGMENTIDENTIFIER_H__