| |
1 /* -*- Mode: C++; tab-width: 2; 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 |
| |
6 #ifndef nsIParserService_h__ |
| |
7 #define nsIParserService_h__ |
| |
8 |
| |
9 #include "nsISupports.h" |
| |
10 #include "nsString.h" |
| |
11 #include "nsHTMLTags.h" |
| |
12 |
| |
13 class nsIParser; |
| |
14 |
| |
15 #define NS_PARSERSERVICE_CONTRACTID "@mozilla.org/parser/parser-service;1" |
| |
16 |
| |
17 // {90a92e37-abd6-441b-9b39-4064d98e1ede} |
| |
18 #define NS_IPARSERSERVICE_IID \ |
| |
19 { 0x90a92e37, 0xabd6, 0x441b, { 0x9b, 0x39, 0x40, 0x64, 0xd9, 0x8e, 0x1e, 0xde } } |
| |
20 |
| |
21 class nsIParserService : public nsISupports { |
| |
22 public: |
| |
23 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPARSERSERVICE_IID) |
| |
24 |
| |
25 /** |
| |
26 * Looks up the nsHTMLTag enum value corresponding to the tag in aAtom. The |
| |
27 * lookup happens case insensitively. |
| |
28 * |
| |
29 * @param aAtom The tag to look up. |
| |
30 * |
| |
31 * @return int32_t The nsHTMLTag enum value corresponding to the tag in aAtom |
| |
32 * or eHTMLTag_userdefined if the tag does not correspond to |
| |
33 * any of the tag nsHTMLTag enum values. |
| |
34 */ |
| |
35 virtual int32_t HTMLAtomTagToId(nsIAtom* aAtom) const = 0; |
| |
36 |
| |
37 /** |
| |
38 * Looks up the nsHTMLTag enum value corresponding to the tag in aAtom. |
| |
39 * |
| |
40 * @param aAtom The tag to look up. |
| |
41 * |
| |
42 * @return int32_t The nsHTMLTag enum value corresponding to the tag in aAtom |
| |
43 * or eHTMLTag_userdefined if the tag does not correspond to |
| |
44 * any of the tag nsHTMLTag enum values. |
| |
45 */ |
| |
46 virtual int32_t HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const = 0; |
| |
47 |
| |
48 /** |
| |
49 * Looks up the nsHTMLTag enum value corresponding to the tag in aTag. The |
| |
50 * lookup happens case insensitively. |
| |
51 * |
| |
52 * @param aTag The tag to look up. |
| |
53 * |
| |
54 * @return int32_t The nsHTMLTag enum value corresponding to the tag in aTag |
| |
55 * or eHTMLTag_userdefined if the tag does not correspond to |
| |
56 * any of the tag nsHTMLTag enum values. |
| |
57 */ |
| |
58 virtual int32_t HTMLStringTagToId(const nsAString& aTag) const = 0; |
| |
59 |
| |
60 /** |
| |
61 * Gets the tag corresponding to the nsHTMLTag enum value in aId. The |
| |
62 * returned tag will be in lowercase. |
| |
63 * |
| |
64 * @param aId The nsHTMLTag enum value to get the tag for. |
| |
65 * |
| |
66 * @return const char16_t* The tag corresponding to the nsHTMLTag enum |
| |
67 * value, or nullptr if the enum value doesn't |
| |
68 * correspond to a tag (eHTMLTag_unknown, |
| |
69 * eHTMLTag_userdefined, eHTMLTag_text, ...). |
| |
70 */ |
| |
71 virtual const char16_t *HTMLIdToStringTag(int32_t aId) const = 0; |
| |
72 |
| |
73 /** |
| |
74 * Gets the tag corresponding to the nsHTMLTag enum value in aId. The |
| |
75 * returned tag will be in lowercase. |
| |
76 * |
| |
77 * @param aId The nsHTMLTag enum value to get the tag for. |
| |
78 * |
| |
79 * @return nsIAtom* The tag corresponding to the nsHTMLTag enum value, or |
| |
80 * nullptr if the enum value doesn't correspond to a tag |
| |
81 * (eHTMLTag_unknown, eHTMLTag_userdefined, eHTMLTag_text, |
| |
82 * ...). |
| |
83 */ |
| |
84 virtual nsIAtom *HTMLIdToAtomTag(int32_t aId) const = 0; |
| |
85 |
| |
86 NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity, |
| |
87 int32_t* aUnicode) const = 0; |
| |
88 |
| |
89 NS_IMETHOD HTMLConvertUnicodeToEntity(int32_t aUnicode, |
| |
90 nsCString& aEntity) const = 0; |
| |
91 |
| |
92 NS_IMETHOD IsContainer(int32_t aId, bool& aIsContainer) const = 0; |
| |
93 NS_IMETHOD IsBlock(int32_t aId, bool& aIsBlock) const = 0; |
| |
94 }; |
| |
95 |
| |
96 NS_DEFINE_STATIC_IID_ACCESSOR(nsIParserService, NS_IPARSERSERVICE_IID) |
| |
97 |
| |
98 #endif // nsIParserService_h__ |