Skip to content

Commit

Permalink
Bug 1395828 (part 2) - Rename nsHTMLTags methods. r=mrbkap.
Browse files Browse the repository at this point in the history
The patch uses the nsParserService method names (minus the "HTML" prefix)
because they are more descriptive. This will make it easier to replace
nsParserService method calls with nsHTMLTags method calls.

The patch also adds nsHTMLTags::AtomTagToId(), to match up with
nsParserService::HTMLAtomTagToId().

--HG--
extra : rebase_source : 278c53a0787a928de9477dd30a5fd037791d7990
  • Loading branch information
nnethercote committed Sep 1, 2017
1 parent e3e2532 commit 1e3e28c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
20 changes: 10 additions & 10 deletions parser/htmlparser/nsHTMLTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ nsHTMLTags::ReleaseTable(void)

// static
nsHTMLTag
nsHTMLTags::LookupTag(const nsAString& aTagName)
nsHTMLTags::StringTagToId(const nsAString& aTagName)
{
uint32_t length = aTagName.Length();

Expand Down Expand Up @@ -195,7 +195,7 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)

buf[i] = 0;

return CaseSensitiveLookupTag(buf);
return CaseSensitiveStringTagToId(buf);
}

#ifdef DEBUG
Expand All @@ -210,30 +210,30 @@ nsHTMLTags::TestTagTable()
// Make sure we can find everything we are supposed to
for (int i = 0; i < NS_HTML_TAG_MAX; ++i) {
tag = sTagUnicodeTable[i];
id = LookupTag(nsDependentString(tag));
id = StringTagToId(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");

nsAutoString uname(tag);
ToUpperCase(uname);
NS_ASSERTION(id == LookupTag(uname), "wrong id");
NS_ASSERTION(id == StringTagToId(uname), "wrong id");

NS_ASSERTION(id == CaseSensitiveLookupTag(tag), "wrong id");
NS_ASSERTION(id == CaseSensitiveStringTagToId(tag), "wrong id");

atom = NS_Atomize(tag);
NS_ASSERTION(id == CaseSensitiveLookupTag(atom), "wrong id");
NS_ASSERTION(id == CaseSensitiveAtomTagToId(atom), "wrong id");
}

// Make sure we don't find things that aren't there
id = LookupTag(NS_LITERAL_STRING("@"));
id = StringTagToId(NS_LITERAL_STRING("@"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found @");
id = LookupTag(NS_LITERAL_STRING("zzzzz"));
id = StringTagToId(NS_LITERAL_STRING("zzzzz"));
NS_ASSERTION(id == eHTMLTag_userdefined, "found zzzzz");

atom = NS_Atomize("@");
id = CaseSensitiveLookupTag(atom);
id = CaseSensitiveAtomTagToId(atom);
NS_ASSERTION(id == eHTMLTag_userdefined, "found @");
atom = NS_Atomize("zzzzz");
id = CaseSensitiveLookupTag(atom);
id = CaseSensitiveAtomTagToId(atom);
NS_ASSERTION(id == eHTMLTag_userdefined, "found zzzzz");

ReleaseTable();
Expand Down
11 changes: 8 additions & 3 deletions parser/htmlparser/nsHTMLTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ class nsHTMLTags {
static void ReleaseTable(void);

// Functions for converting string or atom to id
static nsHTMLTag LookupTag(const nsAString& aTagName);
static nsHTMLTag CaseSensitiveLookupTag(const char16_t* aTagName)
static nsHTMLTag StringTagToId(const nsAString& aTagName);
static nsHTMLTag AtomTagToId(nsIAtom* aTagName)
{
return StringTagToId(nsDependentAtomString(aTagName));
}

static nsHTMLTag CaseSensitiveStringTagToId(const char16_t* aTagName)
{
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
Expand All @@ -56,7 +61,7 @@ class nsHTMLTags {

return tag ? (nsHTMLTag)NS_PTR_TO_INT32(tag) : eHTMLTag_userdefined;
}
static nsHTMLTag CaseSensitiveLookupTag(nsIAtom* aTagName)
static nsHTMLTag CaseSensitiveAtomTagToId(nsIAtom* aTagName)
{
NS_ASSERTION(gTagAtomTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
Expand Down
6 changes: 3 additions & 3 deletions parser/htmlparser/nsParserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ NS_IMPL_ISUPPORTS(nsParserService, nsIParserService)
int32_t
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
{
return nsHTMLTags::LookupTag(nsDependentAtomString(aAtom));
return nsHTMLTags::StringTagToId(nsDependentAtomString(aAtom));
}

int32_t
nsParserService::HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const
{
return nsHTMLTags::CaseSensitiveLookupTag(aAtom);
return nsHTMLTags::CaseSensitiveAtomTagToId(aAtom);
}

int32_t
nsParserService::HTMLStringTagToId(const nsAString& aTag) const
{
return nsHTMLTags::LookupTag(aTag);
return nsHTMLTags::StringTagToId(aTag);
}

NS_IMETHODIMP
Expand Down

0 comments on commit 1e3e28c

Please sign in to comment.