Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : *
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 : #include "nsError.h"
8 : #include "nsIAtom.h"
9 : #include "nsParserService.h"
10 : #include "nsHTMLEntities.h"
11 : #include "nsElementTable.h"
12 : #include "nsICategoryManager.h"
13 : #include "nsCategoryManagerUtils.h"
14 :
15 2 : nsParserService::nsParserService()
16 : {
17 2 : }
18 :
19 0 : nsParserService::~nsParserService()
20 : {
21 0 : }
22 :
23 13 : NS_IMPL_ISUPPORTS(nsParserService, nsIParserService)
24 :
25 : int32_t
26 0 : nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
27 : {
28 0 : return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom));
29 : }
30 :
31 : int32_t
32 74 : nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
33 : {
34 74 : return nsHTMLTags::CaseSensitiveLookupTag(aAtom);
35 : }
36 :
37 : int32_t
38 0 : nsParserService::HTMLStringTagToId(const nsAString& aTag) const
39 : {
40 0 : return nsHTMLTags::LookupTag(aTag);
41 : }
42 :
43 : const char16_t*
44 0 : nsParserService::HTMLIdToStringTag(int32_t aId) const
45 : {
46 0 : return nsHTMLTags::GetStringValue((nsHTMLTag)aId);
47 : }
48 :
49 : nsIAtom*
50 0 : nsParserService::HTMLIdToAtomTag(int32_t aId) const
51 : {
52 0 : return nsHTMLTags::GetAtom((nsHTMLTag)aId);
53 : }
54 :
55 : NS_IMETHODIMP
56 0 : nsParserService::HTMLConvertUnicodeToEntity(int32_t aUnicode,
57 : nsCString& aEntity) const
58 : {
59 0 : const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode);
60 0 : if (str) {
61 0 : aEntity.Assign(str);
62 : }
63 :
64 0 : return NS_OK;
65 : }
66 :
67 : NS_IMETHODIMP
68 0 : nsParserService::IsContainer(int32_t aId, bool& aIsContainer) const
69 : {
70 0 : aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId);
71 :
72 0 : return NS_OK;
73 : }
74 :
75 : NS_IMETHODIMP
76 0 : nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const
77 : {
78 0 : if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
79 0 : aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock)) ||
80 0 : (gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
81 0 : (gHTMLElements[aId].IsMemberOf(kHeading)) ||
82 0 : (gHTMLElements[aId].IsMemberOf(kPreformatted))||
83 0 : (gHTMLElements[aId].IsMemberOf(kList)));
84 : }
85 : else {
86 0 : aIsBlock = false;
87 : }
88 :
89 0 : return NS_OK;
90 : }
|