Bug 1399853 - Identify the ID of the elements involved in SVG reference loops in the Web Console error messages. r=longsonr

MozReview-Commit-ID: 7SOk2pMEezK
This commit is contained in:
Jonathan Watt 2017-09-11 17:02:35 +01:00
parent 7aa80495f9
commit 6b07b2d402
3 changed files with 13 additions and 11 deletions

View File

@ -12,5 +12,5 @@
DOCUMENT_WARNING(IgnoringWillChangeOverBudget)
DOCUMENT_WARNING(PreventDefaultFromPassiveListener)
DOCUMENT_WARNING(SVGReferenceLoop)
DOCUMENT_WARNING(SVGReferenceChainLengthExceeded)
DOCUMENT_WARNING(SVGRefLoop)
DOCUMENT_WARNING(SVGRefChainLengthExceeded)

View File

@ -332,10 +332,10 @@ MozNoiseSuppressionWarning=mozNoiseSuppression is deprecated. Use noiseSuppressi
XMLBaseAttributeWarning=Use of xml:base attribute is deprecated and will be removed soon. Please remove any use of it.
# LOCALIZATION NOTE: Do not translate "content", "Window", and "window.top"
WindowContentUntrustedWarning=The content attribute of Window objects is deprecated. Please use window.top instead.
# LOCALIZATION NOTE: %S is the tag name of the element that starts the loop
SVGReferenceLoopWarning=There is an SVG <%S> reference loop in this document, which will prevent the document rendering correctly.
# LOCALIZATION NOTE: %S is the tag name of the element that starts the chain
SVGReferenceChainLengthExceededWarning=There is an SVG <%S> reference chain which is too long in this document, which will prevent the document rendering correctly.
# LOCALIZATION NOTE: The first %S is the tag name of the element that starts the loop, the second %S is the element's ID.
SVGRefLoopWarning=The SVG <%S> with ID “%S” has a reference loop.
# LOCALIZATION NOTE: The first %S is the tag name of the element in the chain where the chain was broken, the second %S is the element's ID.
SVGRefChainLengthExceededWarning=An SVG <%S> reference chain which is too long was abandoned at the element with ID “%S”.
# LOCALIZATION NOTE: Do not translate "<script>".
ScriptSourceEmpty=%S attribute of <script> element is empty.
# LOCALIZATION NOTE: Do not translate "<script>".

View File

@ -151,13 +151,15 @@ public:
private:
void ReportErrorToConsole() {
nsAutoString tag;
mFrame->GetContent()->AsElement()->GetTagName(tag);
const char16_t* params[] = { tag.get() };
nsAutoString tag, id;
dom::Element* element = mFrame->GetContent()->AsElement();
element->GetTagName(tag);
element->GetId(id);
const char16_t* params[] = { tag.get(), id.get() };
auto doc = mFrame->GetContent()->OwnerDoc();
auto warning = *mFrameInUse ?
nsIDocument::eSVGReferenceLoop :
nsIDocument::eSVGReferenceChainLengthExceeded;
nsIDocument::eSVGRefLoop :
nsIDocument::eSVGRefChainLengthExceeded;
doc->WarnOnceAbout(warning, /* asError */ true,
params, ArrayLength(params));
}