mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 482921 part 10 - Support parametrized error messages in new View Source. r=Olli.Pettay.
This commit is contained in:
parent
f65e867d6d
commit
7506879167
@ -816,7 +816,7 @@ nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
||||
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->Init(mCurrentRun, aMsgId);
|
||||
treeOp->Init(mCurrentRun, aMsgId, aName);
|
||||
}
|
||||
|
||||
void
|
||||
@ -827,7 +827,7 @@ nsHtml5Highlighter::AddErrorToCurrentRun(const char* aMsgId,
|
||||
NS_PRECONDITION(mCurrentRun, "Adding error to run without one!");
|
||||
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
|
||||
NS_ASSERTION(treeOp, "Tree op allocation failed.");
|
||||
treeOp->Init(mCurrentRun, aMsgId);
|
||||
treeOp->Init(mCurrentRun, aMsgId, aName, aOther);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -372,7 +372,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpCreateElementNetwork:
|
||||
case eTreeOpCreateElementNotNetwork: {
|
||||
nsIContent** target = mOne.node;
|
||||
PRInt32 ns = mInt;
|
||||
PRInt32 ns = mFour.integer;
|
||||
nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
|
||||
nsHtml5HtmlAttributes* attributes = mThree.attributes;
|
||||
|
||||
@ -501,7 +501,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpAppendText: {
|
||||
nsIContent* parent = *mOne.node;
|
||||
PRUnichar* buffer = mTwo.unicharPtr;
|
||||
PRUint32 length = mInt;
|
||||
PRUint32 length = mFour.integer;
|
||||
return AppendText(buffer, length, parent, aBuilder);
|
||||
}
|
||||
case eTreeOpAppendIsindexPrompt: {
|
||||
@ -523,7 +523,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpFosterParentText: {
|
||||
nsIContent* stackParent = *mOne.node;
|
||||
PRUnichar* buffer = mTwo.unicharPtr;
|
||||
PRUint32 length = mInt;
|
||||
PRUint32 length = mFour.integer;
|
||||
nsIContent* table = *mThree.node;
|
||||
|
||||
nsIContent* foster = table->GetParent();
|
||||
@ -561,7 +561,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpAppendComment: {
|
||||
nsIContent* parent = *mOne.node;
|
||||
PRUnichar* buffer = mTwo.unicharPtr;
|
||||
PRInt32 length = mInt;
|
||||
PRInt32 length = mFour.integer;
|
||||
|
||||
nsCOMPtr<nsIContent> comment;
|
||||
NS_NewCommentNode(getter_AddRefs(comment), aBuilder->GetNodeInfoManager());
|
||||
@ -573,7 +573,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
}
|
||||
case eTreeOpAppendCommentToDocument: {
|
||||
PRUnichar* buffer = mTwo.unicharPtr;
|
||||
PRInt32 length = mInt;
|
||||
PRInt32 length = mFour.integer;
|
||||
|
||||
nsCOMPtr<nsIContent> comment;
|
||||
NS_NewCommentNode(getter_AddRefs(comment), aBuilder->GetNodeInfoManager());
|
||||
@ -613,7 +613,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
nsIContent* node = *(mOne.node);
|
||||
nsAHtml5TreeBuilderState* snapshot = mTwo.state;
|
||||
if (snapshot) {
|
||||
aBuilder->InitializeDocWriteParserState(snapshot, mInt);
|
||||
aBuilder->InitializeDocWriteParserState(snapshot, mFour.integer);
|
||||
}
|
||||
*aScriptElement = node;
|
||||
return rv;
|
||||
@ -639,14 +639,14 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
}
|
||||
case eTreeOpSetDocumentCharset: {
|
||||
char* str = mOne.charPtr;
|
||||
PRInt32 charsetSource = mInt;
|
||||
PRInt32 charsetSource = mFour.integer;
|
||||
nsDependentCString dependentString(str);
|
||||
aBuilder->SetDocumentCharsetAndSource(dependentString, charsetSource);
|
||||
return rv;
|
||||
}
|
||||
case eTreeOpNeedsCharsetSwitchTo: {
|
||||
char* str = mOne.charPtr;
|
||||
PRInt32 charsetSource = mInt;
|
||||
PRInt32 charsetSource = mFour.integer;
|
||||
aBuilder->NeedsCharsetSwitchTo(str, charsetSource);
|
||||
return rv;
|
||||
}
|
||||
@ -692,14 +692,14 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
nsIContent* node = *(mOne.node);
|
||||
nsCOMPtr<nsIStyleSheetLinkingElement> ssle = do_QueryInterface(node);
|
||||
NS_ASSERTION(ssle, "Node didn't QI to style.");
|
||||
ssle->SetLineNumber(mInt);
|
||||
ssle->SetLineNumber(mFour.integer);
|
||||
return rv;
|
||||
}
|
||||
case eTreeOpSetScriptLineNumberAndFreeze: {
|
||||
nsIContent* node = *(mOne.node);
|
||||
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(node);
|
||||
NS_ASSERTION(sele, "Node didn't QI to script.");
|
||||
sele->SetScriptLineNumber(mInt);
|
||||
sele->SetScriptLineNumber(mFour.integer);
|
||||
sele->FreezeUriAsyncDefer();
|
||||
return rv;
|
||||
}
|
||||
@ -728,7 +728,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
}
|
||||
case eTreeOpAddLineNumberId: {
|
||||
nsIContent* node = *(mOne.node);
|
||||
PRInt32 lineNumber = mInt;
|
||||
PRInt32 lineNumber = mFour.integer;
|
||||
nsAutoString val(NS_LITERAL_STRING("line"));
|
||||
val.AppendInt(lineNumber);
|
||||
node->SetAttr(kNameSpaceID_None, nsGkAtoms::id, val, true);
|
||||
@ -737,7 +737,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpAddViewSourceHref: {
|
||||
nsIContent* node = *mOne.node;
|
||||
PRUnichar* buffer = mTwo.unicharPtr;
|
||||
PRInt32 length = mInt;
|
||||
PRInt32 length = mFour.integer;
|
||||
|
||||
nsDependentString relative(buffer, length);
|
||||
|
||||
@ -793,6 +793,8 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
case eTreeOpAddError: {
|
||||
nsIContent* node = *(mOne.node);
|
||||
char* msgId = mTwo.charPtr;
|
||||
nsCOMPtr<nsIAtom> atom = Reget(mThree.atom);
|
||||
nsCOMPtr<nsIAtom> otherAtom = Reget(mFour.atom);
|
||||
nsAutoString klass;
|
||||
node->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, klass);
|
||||
if (!klass.IsEmpty()) {
|
||||
@ -806,14 +808,27 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
}
|
||||
|
||||
nsXPIDLString message;
|
||||
rv = nsContentUtils::GetLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (otherAtom) {
|
||||
const PRUnichar* params[] = { atom->GetUTF16String(),
|
||||
otherAtom->GetUTF16String() };
|
||||
rv = nsContentUtils::FormatLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 2, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (atom) {
|
||||
const PRUnichar* params[] = { atom->GetUTF16String() };
|
||||
rv = nsContentUtils::FormatLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, 1, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
rv = nsContentUtils::GetLocalizedString(
|
||||
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, message);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsAutoString title;
|
||||
node->GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
|
||||
if (!title.IsEmpty()) {
|
||||
title.Append(' ');
|
||||
title.Append('\n');
|
||||
title.Append(message);
|
||||
node->SetAttr(kNameSpaceID_None, nsGkAtoms::title, title, true);
|
||||
} else {
|
||||
|
@ -88,6 +88,8 @@ enum eHtml5TreeOperation {
|
||||
eTreeOpAddViewSourceHref,
|
||||
eTreeOpAddError,
|
||||
eTreeOpAddLineNumberId,
|
||||
eTreeOpAddErrorAtom,
|
||||
eTreeOpAddErrorTwoAtoms,
|
||||
eTreeOpStartLayout
|
||||
};
|
||||
|
||||
@ -162,7 +164,7 @@ class nsHtml5TreeOperation {
|
||||
|
||||
mOpCode = aOpCode;
|
||||
mOne.charPtr = str;
|
||||
mInt = aInt32;
|
||||
mFour.integer = aInt32;
|
||||
}
|
||||
|
||||
inline void Init(eHtml5TreeOperation aOpCode,
|
||||
@ -208,7 +210,7 @@ class nsHtml5TreeOperation {
|
||||
mOpCode = aFromNetwork ?
|
||||
eTreeOpCreateElementNetwork :
|
||||
eTreeOpCreateElementNotNetwork;
|
||||
mInt = aNamespace;
|
||||
mFour.integer = aNamespace;
|
||||
mOne.node = aTarget;
|
||||
mTwo.atom = aName;
|
||||
if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
|
||||
@ -230,7 +232,7 @@ class nsHtml5TreeOperation {
|
||||
mOne.node = aStackParent;
|
||||
mTwo.unicharPtr = aBuffer;
|
||||
mThree.node = aTable;
|
||||
mInt = aLength;
|
||||
mFour.integer = aLength;
|
||||
}
|
||||
|
||||
inline void Init(eHtml5TreeOperation aOpCode,
|
||||
@ -243,7 +245,7 @@ class nsHtml5TreeOperation {
|
||||
mOpCode = aOpCode;
|
||||
mOne.node = aParent;
|
||||
mTwo.unicharPtr = aBuffer;
|
||||
mInt = aLength;
|
||||
mFour.integer = aLength;
|
||||
}
|
||||
|
||||
inline void Init(eHtml5TreeOperation aOpCode,
|
||||
@ -254,7 +256,7 @@ class nsHtml5TreeOperation {
|
||||
NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
|
||||
mOpCode = aOpCode;
|
||||
mTwo.unicharPtr = aBuffer;
|
||||
mInt = aLength;
|
||||
mFour.integer = aLength;
|
||||
}
|
||||
|
||||
inline void Init(nsIContent** aElement,
|
||||
@ -278,12 +280,27 @@ class nsHtml5TreeOperation {
|
||||
}
|
||||
|
||||
inline void Init(nsIContent** aElement,
|
||||
const char* aMsgId) {
|
||||
const char* aMsgId,
|
||||
nsIAtom* aAtom,
|
||||
nsIAtom* aOtherAtom) {
|
||||
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
|
||||
"Op code must be uninitialized when initializing.");
|
||||
mOpCode = eTreeOpAddError;
|
||||
mOne.node = aElement;
|
||||
mTwo.charPtr = (char*)aMsgId;
|
||||
mThree.atom = aAtom;
|
||||
mFour.atom = aOtherAtom;
|
||||
}
|
||||
|
||||
inline void Init(nsIContent** aElement,
|
||||
const char* aMsgId,
|
||||
nsIAtom* aAtom) {
|
||||
Init(aElement, aMsgId, aAtom, nsnull);
|
||||
}
|
||||
|
||||
inline void Init(nsIContent** aElement,
|
||||
const char* aMsgId) {
|
||||
Init(aElement, aMsgId, nsnull, nsnull);
|
||||
}
|
||||
|
||||
inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString) {
|
||||
@ -303,7 +320,7 @@ class nsHtml5TreeOperation {
|
||||
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
|
||||
mOpCode = aOpCode;
|
||||
mOne.node = aNode;
|
||||
mInt = aInt;
|
||||
mFour.integer = aInt;
|
||||
}
|
||||
|
||||
inline void InitAddClass(nsIContent** aNode, const PRUnichar* aClass) {
|
||||
@ -326,7 +343,7 @@ class nsHtml5TreeOperation {
|
||||
// aClass must be a literal string that does not need freeing
|
||||
mOpCode = eTreeOpAddLineNumberId;
|
||||
mOne.node = aNode;
|
||||
mInt = aLineNumber;
|
||||
mFour.integer = aLineNumber;
|
||||
}
|
||||
|
||||
inline bool IsRunScript() {
|
||||
@ -338,7 +355,7 @@ class nsHtml5TreeOperation {
|
||||
"Setting a snapshot for a tree operation other than eTreeOpRunScript!");
|
||||
NS_PRECONDITION(aSnapshot, "Initialized tree op with null snapshot.");
|
||||
mTwo.state = aSnapshot;
|
||||
mInt = aLine;
|
||||
mFour.integer = aLine;
|
||||
}
|
||||
|
||||
nsresult Perform(nsHtml5TreeOpExecutor* aBuilder, nsIContent** aScriptElement);
|
||||
@ -384,11 +401,8 @@ class nsHtml5TreeOperation {
|
||||
char* charPtr;
|
||||
nsHtml5TreeOperationStringPair* stringPair;
|
||||
nsAHtml5TreeBuilderState* state;
|
||||
} mOne, mTwo, mThree;
|
||||
PRInt32 mInt; // optimize this away later by using an end
|
||||
// pointer instead of string length and distinct
|
||||
// element creation opcodes for HTML, MathML and
|
||||
// SVG.
|
||||
PRInt32 integer;
|
||||
} mOne, mTwo, mThree, mFour;
|
||||
};
|
||||
|
||||
#endif // nsHtml5TreeOperation_h__
|
||||
|
Loading…
Reference in New Issue
Block a user