SVGFragmentIdentifier.h (1789B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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 7 #ifndef DOM_SVG_SVGFRAGMENTIDENTIFIER_H_ 8 #define DOM_SVG_SVGFRAGMENTIDENTIFIER_H_ 9 10 #include "nsString.h" 11 12 namespace mozilla { 13 14 namespace dom { 15 class Document; 16 class SVGSVGElement; 17 } // namespace dom 18 19 /** 20 * Implements support for parsing SVG fragment identifiers 21 * http://www.w3.org/TR/SVG/linking.html#SVGFragmentIdentifiers 22 */ 23 class SVGFragmentIdentifier { 24 // To prevent the class being instantiated 25 SVGFragmentIdentifier() = delete; 26 27 public: 28 /** 29 * Process the SVG fragment identifier, if there is one. 30 * @return true if we found a valid svgView()-style fragment identifier, 31 * in which case further processing by the caller can stop. Otherwise return 32 * false as we may have an ordinary anchor which needs to be :target matched. 33 */ 34 static bool ProcessFragmentIdentifier(dom::Document* aDocument, 35 const nsAString& aAnchorName); 36 37 private: 38 /** 39 * Parse an SVG ViewSpec and set applicable attributes on the root element. 40 * @return true if there is a valid ViewSpec 41 */ 42 static bool ProcessSVGViewSpec(const nsAString& aViewSpec, 43 dom::SVGSVGElement* root); 44 45 /** 46 * Parse a media fragment 47 * @return true if there is a valid media fragment. 48 */ 49 static bool ProcessMediaFragment(const nsAString& aMediaFragment, 50 dom::SVGSVGElement* root); 51 }; 52 53 } // namespace mozilla 54 55 #endif // DOM_SVG_SVGFRAGMENTIDENTIFIER_H_