2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsParserService.h"
|
|
|
|
#include "nsHTMLEntities.h"
|
|
|
|
#include "nsElementTable.h"
|
|
|
|
#include "nsICategoryManager.h"
|
|
|
|
#include "nsCategoryManagerUtils.h"
|
|
|
|
|
2012-01-11 07:49:56 -08:00
|
|
|
nsParserService::nsParserService()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsParserService::~nsParserService()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsParserService, nsIParserService)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
|
|
|
|
{
|
2010-03-08 07:45:00 -08:00
|
|
|
return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
|
|
|
|
{
|
|
|
|
return nsHTMLTags::CaseSensitiveLookupTag(aAtom);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsParserService::HTMLStringTagToId(const nsAString& aTag) const
|
|
|
|
{
|
|
|
|
return nsHTMLTags::LookupTag(aTag);
|
|
|
|
}
|
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t*
|
2012-08-22 08:56:38 -07:00
|
|
|
nsParserService::HTMLIdToStringTag(int32_t aId) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsHTMLTags::GetStringValue((nsHTMLTag)aId);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
2012-08-22 08:56:38 -07:00
|
|
|
nsParserService::HTMLIdToAtomTag(int32_t aId) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
return nsHTMLTags::GetAtom((nsHTMLTag)aId);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsParserService::HTMLConvertEntityToUnicode(const nsAString& aEntity,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aUnicode) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
*aUnicode = nsHTMLEntities::EntityToUnicode(aEntity);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsParserService::HTMLConvertUnicodeToEntity(int32_t aUnicode,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCString& aEntity) const
|
|
|
|
{
|
|
|
|
const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode);
|
|
|
|
if (str) {
|
|
|
|
aEntity.Assign(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsParserService::IsContainer(int32_t aId, bool& aIsContainer) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) {
|
|
|
|
aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock)) ||
|
|
|
|
(gHTMLElements[aId].IsMemberOf(kBlockEntity)) ||
|
|
|
|
(gHTMLElements[aId].IsMemberOf(kHeading)) ||
|
|
|
|
(gHTMLElements[aId].IsMemberOf(kPreformatted))||
|
|
|
|
(gHTMLElements[aId].IsMemberOf(kList)));
|
|
|
|
}
|
|
|
|
else {
|
2011-10-17 07:59:28 -07:00
|
|
|
aIsBlock = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|