michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsError.h" michael@0: #include "nsIAtom.h" michael@0: #include "nsParserService.h" michael@0: #include "nsHTMLEntities.h" michael@0: #include "nsElementTable.h" michael@0: #include "nsICategoryManager.h" michael@0: #include "nsCategoryManagerUtils.h" michael@0: michael@0: nsParserService::nsParserService() michael@0: { michael@0: } michael@0: michael@0: nsParserService::~nsParserService() michael@0: { michael@0: } michael@0: michael@0: NS_IMPL_ISUPPORTS(nsParserService, nsIParserService) michael@0: michael@0: int32_t michael@0: nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const michael@0: { michael@0: return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom)); michael@0: } michael@0: michael@0: int32_t michael@0: nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const michael@0: { michael@0: return nsHTMLTags::CaseSensitiveLookupTag(aAtom); michael@0: } michael@0: michael@0: int32_t michael@0: nsParserService::HTMLStringTagToId(const nsAString& aTag) const michael@0: { michael@0: return nsHTMLTags::LookupTag(aTag); michael@0: } michael@0: michael@0: const char16_t* michael@0: nsParserService::HTMLIdToStringTag(int32_t aId) const michael@0: { michael@0: return nsHTMLTags::GetStringValue((nsHTMLTag)aId); michael@0: } michael@0: michael@0: nsIAtom* michael@0: nsParserService::HTMLIdToAtomTag(int32_t aId) const michael@0: { michael@0: return nsHTMLTags::GetAtom((nsHTMLTag)aId); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsParserService::HTMLConvertEntityToUnicode(const nsAString& aEntity, michael@0: int32_t* aUnicode) const michael@0: { michael@0: *aUnicode = nsHTMLEntities::EntityToUnicode(aEntity); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsParserService::HTMLConvertUnicodeToEntity(int32_t aUnicode, michael@0: nsCString& aEntity) const michael@0: { michael@0: const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode); michael@0: if (str) { michael@0: aEntity.Assign(str); michael@0: } michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsParserService::IsContainer(int32_t aId, bool& aIsContainer) const michael@0: { michael@0: aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const michael@0: { michael@0: if((aId>eHTMLTag_unknown) && (aId