Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsError.h" |
michael@0 | 8 | #include "nsIAtom.h" |
michael@0 | 9 | #include "nsParserService.h" |
michael@0 | 10 | #include "nsHTMLEntities.h" |
michael@0 | 11 | #include "nsElementTable.h" |
michael@0 | 12 | #include "nsICategoryManager.h" |
michael@0 | 13 | #include "nsCategoryManagerUtils.h" |
michael@0 | 14 | |
michael@0 | 15 | nsParserService::nsParserService() |
michael@0 | 16 | { |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | nsParserService::~nsParserService() |
michael@0 | 20 | { |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | NS_IMPL_ISUPPORTS(nsParserService, nsIParserService) |
michael@0 | 24 | |
michael@0 | 25 | int32_t |
michael@0 | 26 | nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const |
michael@0 | 27 | { |
michael@0 | 28 | return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom)); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | int32_t |
michael@0 | 32 | nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const |
michael@0 | 33 | { |
michael@0 | 34 | return nsHTMLTags::CaseSensitiveLookupTag(aAtom); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | int32_t |
michael@0 | 38 | nsParserService::HTMLStringTagToId(const nsAString& aTag) const |
michael@0 | 39 | { |
michael@0 | 40 | return nsHTMLTags::LookupTag(aTag); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | const char16_t* |
michael@0 | 44 | nsParserService::HTMLIdToStringTag(int32_t aId) const |
michael@0 | 45 | { |
michael@0 | 46 | return nsHTMLTags::GetStringValue((nsHTMLTag)aId); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | nsIAtom* |
michael@0 | 50 | nsParserService::HTMLIdToAtomTag(int32_t aId) const |
michael@0 | 51 | { |
michael@0 | 52 | return nsHTMLTags::GetAtom((nsHTMLTag)aId); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | NS_IMETHODIMP |
michael@0 | 56 | nsParserService::HTMLConvertEntityToUnicode(const nsAString& aEntity, |
michael@0 | 57 | int32_t* aUnicode) const |
michael@0 | 58 | { |
michael@0 | 59 | *aUnicode = nsHTMLEntities::EntityToUnicode(aEntity); |
michael@0 | 60 | |
michael@0 | 61 | return NS_OK; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | NS_IMETHODIMP |
michael@0 | 65 | nsParserService::HTMLConvertUnicodeToEntity(int32_t aUnicode, |
michael@0 | 66 | nsCString& aEntity) const |
michael@0 | 67 | { |
michael@0 | 68 | const char* str = nsHTMLEntities::UnicodeToEntity(aUnicode); |
michael@0 | 69 | if (str) { |
michael@0 | 70 | aEntity.Assign(str); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | return NS_OK; |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | NS_IMETHODIMP |
michael@0 | 77 | nsParserService::IsContainer(int32_t aId, bool& aIsContainer) const |
michael@0 | 78 | { |
michael@0 | 79 | aIsContainer = nsHTMLElement::IsContainer((eHTMLTags)aId); |
michael@0 | 80 | |
michael@0 | 81 | return NS_OK; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | NS_IMETHODIMP |
michael@0 | 85 | nsParserService::IsBlock(int32_t aId, bool& aIsBlock) const |
michael@0 | 86 | { |
michael@0 | 87 | if((aId>eHTMLTag_unknown) && (aId<eHTMLTag_userdefined)) { |
michael@0 | 88 | aIsBlock=((gHTMLElements[aId].IsMemberOf(kBlock)) || |
michael@0 | 89 | (gHTMLElements[aId].IsMemberOf(kBlockEntity)) || |
michael@0 | 90 | (gHTMLElements[aId].IsMemberOf(kHeading)) || |
michael@0 | 91 | (gHTMLElements[aId].IsMemberOf(kPreformatted))|| |
michael@0 | 92 | (gHTMLElements[aId].IsMemberOf(kList))); |
michael@0 | 93 | } |
michael@0 | 94 | else { |
michael@0 | 95 | aIsBlock = false; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | return NS_OK; |
michael@0 | 99 | } |