зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1913382 - counting SVG unusual child elements r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D221323
This commit is contained in:
Родитель
3fc443a83e
Коммит
98eae49958
|
@ -0,0 +1,24 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Adding a new metric? We have docs for that!
|
||||
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
|
||||
|
||||
---
|
||||
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
|
||||
$tags:
|
||||
- 'Core :: DOM: HTML Parser'
|
||||
|
||||
parsing:
|
||||
svg_unusual_pcdata:
|
||||
type: rate
|
||||
description: |
|
||||
The rate of svg elements that have child elements during parsing, where their HTML counterpart would not have children.
|
||||
notification_emails:
|
||||
- seceng-telemetry@mozilla.com
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1913382
|
||||
data_reviews:
|
||||
- https://phabricator.services.mozilla.com/D219290#7592177
|
||||
expires: 136
|
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/ShadowRootBinding.h"
|
||||
#include "mozilla/glean/GleanMetrics.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
|
@ -1139,6 +1140,8 @@ void nsHtml5TreeBuilder::markMalformedIfScript(nsIContentHandle* aElement) {
|
|||
|
||||
void nsHtml5TreeBuilder::start(bool fragment) {
|
||||
mCurrentHtmlScriptCannotDocumentWriteOrBlock = false;
|
||||
mozilla::glean::parsing::svg_unusual_pcdata.AddToDenominator(1);
|
||||
|
||||
#ifdef DEBUG
|
||||
mActive = true;
|
||||
#endif
|
||||
|
@ -1206,6 +1209,21 @@ void nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsAtom* aName,
|
|||
* table elements shouldn't be used as surrogate parents for user experience
|
||||
* reasons.
|
||||
*/
|
||||
|
||||
if (MOZ_UNLIKELY(isInSVGOddPCData)) {
|
||||
// We are seeing an element that has children, which could not have child
|
||||
// elements in HTML, i.e., is parsed as PCDATA in SVG but CDATA in HTML.
|
||||
mozilla::glean::parsing::svg_unusual_pcdata.AddToNumerator(1);
|
||||
}
|
||||
if (MOZ_UNLIKELY(aNamespace == kNameSpaceID_SVG)) {
|
||||
if ((aName == nsGkAtoms::style) || (aName == nsGkAtoms::xmp) ||
|
||||
(aName == nsGkAtoms::iframe) || (aName == nsGkAtoms::noembed) ||
|
||||
(aName == nsGkAtoms::noframes) || (aName == nsGkAtoms::noscript) ||
|
||||
(aName == nsGkAtoms::script)) {
|
||||
isInSVGOddPCData++;
|
||||
}
|
||||
}
|
||||
|
||||
if (aNamespace != kNameSpaceID_XHTML) {
|
||||
return;
|
||||
}
|
||||
|
@ -1255,6 +1273,14 @@ void nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsAtom* aName,
|
|||
if (aNamespace == kNameSpaceID_MathML) {
|
||||
return;
|
||||
}
|
||||
if (MOZ_UNLIKELY(aNamespace == kNameSpaceID_SVG)) {
|
||||
if ((aName == nsGkAtoms::style) || (aName == nsGkAtoms::xmp) ||
|
||||
(aName == nsGkAtoms::iframe) || (aName == nsGkAtoms::noembed) ||
|
||||
(aName == nsGkAtoms::noframes) || (aName == nsGkAtoms::noscript) ||
|
||||
(aName == nsGkAtoms::script)) {
|
||||
isInSVGOddPCData--;
|
||||
}
|
||||
}
|
||||
// we now have only SVG and HTML
|
||||
if (aName == nsGkAtoms::script) {
|
||||
if (mPreventScriptExecution) {
|
||||
|
|
|
@ -23,6 +23,7 @@ int32_t mHandlesUsed;
|
|||
nsTArray<mozilla::UniquePtr<nsIContent*[]>> mOldHandles;
|
||||
nsHtml5TreeOpStage* mSpeculativeLoadStage;
|
||||
nsresult mBroken;
|
||||
int32_t isInSVGOddPCData = 0;
|
||||
// Controls whether the current HTML script goes through the more complex
|
||||
// path that accommodates the possibility of the script becoming a
|
||||
// parser-blocking script and the possibility of the script inserting
|
||||
|
|
|
@ -28,6 +28,7 @@ gecko_metrics = [
|
|||
"dom/security/metrics.yaml",
|
||||
"dom/webauthn/metrics.yaml",
|
||||
"gfx/metrics.yaml",
|
||||
"parser/html/metrics.yaml",
|
||||
"image/decoders/metrics.yaml",
|
||||
"js/xpconnect/metrics.yaml",
|
||||
"layout/base/metrics.yaml",
|
||||
|
|
Загрузка…
Ссылка в новой задаче