mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 696242 - Convert NS_RegisterStaticAtoms and nsCSSScanner::ReportUnexpectedParams to take an array-reference rather than a pointer and length, making it impossible to pass a pointer/length that are inconsistent. r=jwalden
--HG-- extra : rebase_source : 882b5b4d500b1fa242c0a3cfa3084e4171cbaa9d
This commit is contained in:
parent
08d94514e3
commit
86f648606c
@ -848,12 +848,23 @@ public:
|
||||
* Fill (with the parameters given) the localized string named |aKey| in
|
||||
* properties file |aFile|.
|
||||
*/
|
||||
private:
|
||||
static nsresult FormatLocalizedString(PropertiesFile aFile,
|
||||
const char* aKey,
|
||||
const PRUnichar** aParams,
|
||||
PRUint32 aParamsLength,
|
||||
nsXPIDLString& aResult);
|
||||
|
||||
public:
|
||||
template<PRUint32 N>
|
||||
static nsresult FormatLocalizedString(PropertiesFile aFile,
|
||||
const char* aKey,
|
||||
const PRUnichar* (&aParams)[N],
|
||||
nsXPIDLString& aResult)
|
||||
{
|
||||
return FormatLocalizedString(aFile, aKey, aParams, N, aResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if aDocument is a chrome document
|
||||
*/
|
||||
|
@ -65,6 +65,6 @@ static const nsStaticAtom GkAtoms_info[] = {
|
||||
|
||||
void nsGkAtoms::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(GkAtoms_info, ArrayLength(GkAtoms_info));
|
||||
NS_RegisterStaticAtoms(GkAtoms_info);
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,6 @@ HandleMailtoSubject(nsCString& aPath) {
|
||||
nsContentUtils::eFORMS_PROPERTIES,
|
||||
"DefaultFormSubject",
|
||||
formatStrings,
|
||||
ArrayLength(formatStrings),
|
||||
subjectStr);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
@ -3830,7 +3830,7 @@ nsHTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
const PRUnichar* params[] = { strMaxLength.get(), strTextLength.get() };
|
||||
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"FormValidationTextTooLong",
|
||||
params, 2, message);
|
||||
params, message);
|
||||
aValidationMessage = message;
|
||||
break;
|
||||
}
|
||||
@ -3889,7 +3889,7 @@ nsHTMLInputElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
const PRUnichar* params[] = { title.get() };
|
||||
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"FormValidationPatternMismatchWithTitle",
|
||||
params, 1, message);
|
||||
params, message);
|
||||
}
|
||||
aValidationMessage = message;
|
||||
break;
|
||||
|
@ -1423,7 +1423,7 @@ nsHTMLTextAreaElement::GetValidationMessage(nsAString& aValidationMessage,
|
||||
const PRUnichar* params[] = { strMaxLength.get(), strTextLength.get() };
|
||||
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"FormValidationTextTooLong",
|
||||
params, 2, message);
|
||||
params, message);
|
||||
aValidationMessage = message;
|
||||
}
|
||||
break;
|
||||
|
@ -4702,7 +4702,7 @@ nsGlobalWindow::MakeScriptDialogTitle(nsAString &aOutTitle)
|
||||
nsXPIDLString tempString;
|
||||
nsContentUtils::FormatLocalizedString(nsContentUtils::eCOMMON_DIALOG_PROPERTIES,
|
||||
"ScriptDlgHeading",
|
||||
formatStrings, ArrayLength(formatStrings),
|
||||
formatStrings,
|
||||
tempString);
|
||||
aOutTitle = tempString;
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ nsJSContext::DOMOperationCallback(JSContext *cx)
|
||||
const PRUnichar *formatParams[] = { filenameUTF16.get() };
|
||||
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
||||
"KillScriptLocation",
|
||||
formatParams, 1,
|
||||
formatParams,
|
||||
scriptLocation);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && scriptLocation) {
|
||||
|
@ -85,5 +85,5 @@ nsEditProperty::RegisterAtoms()
|
||||
#undef EDITOR_ATOM
|
||||
};
|
||||
|
||||
NS_RegisterStaticAtoms(property_atoms, ArrayLength(property_atoms));
|
||||
NS_RegisterStaticAtoms(property_atoms);
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ nsTextServicesDocument::RegisterAtoms()
|
||||
#undef TS_ATOM
|
||||
};
|
||||
|
||||
NS_RegisterStaticAtoms(ts_atoms, ArrayLength(ts_atoms));
|
||||
NS_RegisterStaticAtoms(ts_atoms);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTextServicesDocument)
|
||||
|
@ -58,5 +58,5 @@ static const nsStaticAtom atoms[] = {
|
||||
|
||||
void gfxAtoms::RegisterAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(atoms, ArrayLength(atoms));
|
||||
NS_RegisterStaticAtoms(atoms);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ inDOMView::~inDOMView()
|
||||
/* static */ void
|
||||
inDOMView::InitAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(Atoms_info, ArrayLength(Atoms_info));
|
||||
NS_RegisterStaticAtoms(Atoms_info);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -68,8 +68,7 @@ static const nsStaticAtom CSSAnonBoxes_info[] = {
|
||||
|
||||
void nsCSSAnonBoxes::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(CSSAnonBoxes_info,
|
||||
ArrayLength(CSSAnonBoxes_info));
|
||||
NS_RegisterStaticAtoms(CSSAnonBoxes_info);
|
||||
}
|
||||
|
||||
bool nsCSSAnonBoxes::IsAnonBox(nsIAtom *aAtom)
|
||||
|
@ -735,7 +735,7 @@ static void AppendRuleToSheet(css::Rule* aRule, void* aParser)
|
||||
mScanner.ReportUnexpected(#msg_)
|
||||
|
||||
#define REPORT_UNEXPECTED_P(msg_, params_) \
|
||||
mScanner.ReportUnexpectedParams(#msg_, params_, ArrayLength(params_))
|
||||
mScanner.ReportUnexpectedParams(#msg_, params_)
|
||||
|
||||
#define REPORT_UNEXPECTED_EOF(lf_) \
|
||||
mScanner.ReportUnexpectedEOF(#lf_)
|
||||
|
@ -66,8 +66,7 @@ static const nsStaticAtom CSSPseudoClasses_info[] = {
|
||||
|
||||
void nsCSSPseudoClasses::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(CSSPseudoClasses_info,
|
||||
ArrayLength(CSSPseudoClasses_info));
|
||||
NS_RegisterStaticAtoms(CSSPseudoClasses_info);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -80,8 +80,7 @@ static const PRUint32 CSSPseudoElements_flags[] = {
|
||||
|
||||
void nsCSSPseudoElements::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(CSSPseudoElements_info,
|
||||
ArrayLength(CSSPseudoElements_info));
|
||||
NS_RegisterStaticAtoms(CSSPseudoElements_info);
|
||||
}
|
||||
|
||||
bool nsCSSPseudoElements::IsPseudoElement(nsIAtom *aAtom)
|
||||
|
@ -547,7 +547,7 @@ nsCSSScanner::ReportUnexpectedToken(nsCSSToken& tok,
|
||||
tokenString.get()
|
||||
};
|
||||
|
||||
ReportUnexpectedParams(aMessage, params, ArrayLength(params));
|
||||
ReportUnexpectedParams(aMessage, params);
|
||||
}
|
||||
|
||||
// aParams's first entry must be null, and we'll fill in the token
|
||||
|
@ -160,9 +160,19 @@ class nsCSSScanner {
|
||||
|
||||
// aMessage must take no parameters
|
||||
void ReportUnexpected(const char* aMessage);
|
||||
|
||||
private:
|
||||
void ReportUnexpectedParams(const char* aMessage,
|
||||
const PRUnichar** aParams,
|
||||
PRUint32 aParamsLength);
|
||||
|
||||
public:
|
||||
template<PRUint32 N>
|
||||
void ReportUnexpectedParams(const char* aMessage,
|
||||
const PRUnichar* (&aParams)[N])
|
||||
{
|
||||
return ReportUnexpectedParams(aMessage, aParams, N);
|
||||
}
|
||||
// aLookingFor is a plain string, not a format string
|
||||
void ReportUnexpectedEOF(const char* aLookingFor);
|
||||
// aLookingFor is a single character
|
||||
|
@ -66,5 +66,5 @@ static const nsStaticAtom Html5Atoms_info[] = {
|
||||
|
||||
void nsHtml5Atoms::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(Html5Atoms_info, ArrayLength(Html5Atoms_info));
|
||||
NS_RegisterStaticAtoms(Html5Atoms_info);
|
||||
}
|
||||
|
@ -795,12 +795,12 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
const PRUnichar* params[] = { atom->GetUTF16String(),
|
||||
otherAtom->GetUTF16String() };
|
||||
rv = nsContentUtils::FormatLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 2, message);
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (atom) {
|
||||
const PRUnichar* params[] = { atom->GetUTF16String() };
|
||||
rv = nsContentUtils::FormatLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 1, message);
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
rv = nsContentUtils::GetLocalizedString(
|
||||
|
@ -374,7 +374,7 @@ nsHTMLTags::AddRefTable(void)
|
||||
|
||||
if (gTableRefCount++ == 0) {
|
||||
// Fill in our static atom pointers
|
||||
NS_RegisterStaticAtoms(sTagAtoms_info, ArrayLength(sTagAtoms_info));
|
||||
NS_RegisterStaticAtoms(sTagAtoms_info);
|
||||
|
||||
|
||||
NS_ASSERTION(!gTagTable && !gTagAtomTable, "pre existing hash!");
|
||||
|
@ -337,7 +337,7 @@ RDFContentSinkImpl::RDFContentSinkImpl()
|
||||
|
||||
rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
|
||||
|
||||
NS_RegisterStaticAtoms(rdf_atoms, ArrayLength(rdf_atoms));
|
||||
NS_RegisterStaticAtoms(rdf_atoms);
|
||||
}
|
||||
|
||||
mNodeIDMap.Init();
|
||||
|
@ -547,7 +547,7 @@ class CheckStaticAtomSizes
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
|
||||
RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
|
||||
{
|
||||
// this does three things:
|
||||
// 1) wraps each static atom in a wrapper, if necessary
|
||||
|
@ -76,8 +76,13 @@ struct nsFakeStringBuffer {
|
||||
nsStaticAtomStringType mStringData[size];
|
||||
};
|
||||
|
||||
// Register static atoms with the atom table
|
||||
// Register an array of static atoms with the atom table
|
||||
template<PRUint32 N>
|
||||
nsresult
|
||||
NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
|
||||
NS_RegisterStaticAtoms(const nsStaticAtom (&atoms)[N])
|
||||
{
|
||||
extern nsresult RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
|
||||
return RegisterStaticAtoms(atoms, N);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -307,7 +307,7 @@ nsDirectoryService::RealInit()
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_RegisterStaticAtoms(directory_atoms, ArrayLength(directory_atoms));
|
||||
NS_RegisterStaticAtoms(directory_atoms);
|
||||
|
||||
// Let the list hold the only reference to the provider.
|
||||
nsAppFileLocationProvider *defaultProvider = new nsAppFileLocationProvider;
|
||||
|
@ -59,6 +59,5 @@ static const nsStaticAtom MoreTestingAtoms_info[] = {
|
||||
|
||||
void MoreTestingAtoms::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(MoreTestingAtoms_info,
|
||||
mozilla::ArrayLength(MoreTestingAtoms_info));
|
||||
NS_RegisterStaticAtoms(MoreTestingAtoms_info);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ test_atomtable()
|
||||
if (!thirdNonPerm || NS_GetNumberOfAtoms() != count + 1)
|
||||
return false;
|
||||
|
||||
NS_RegisterStaticAtoms(sAtoms_info, ArrayLength(sAtoms_info));
|
||||
NS_RegisterStaticAtoms(sAtoms_info);
|
||||
|
||||
return sAtom1 &&
|
||||
sAtom1->Equals(NS_LITERAL_STRING(FIRST_ATOM_STR)) &&
|
||||
|
@ -58,5 +58,5 @@ static const nsStaticAtom TestingAtoms_info[] = {
|
||||
|
||||
void TestingAtoms::AddRefAtoms()
|
||||
{
|
||||
NS_RegisterStaticAtoms(TestingAtoms_info, mozilla::ArrayLength(TestingAtoms_info));
|
||||
NS_RegisterStaticAtoms(TestingAtoms_info);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user