Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit a3adabe

Browse files
committed
Bug 1568950 - Part 5: Remove nsIDOMWindowUtils::forceUseCounterFlush; r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D42818 --HG-- extra : moz-landing-system : lando
1 parent 46e571d commit a3adabe

11 files changed

Lines changed: 2 additions & 105 deletions

File tree

dom/base/Document.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14397,26 +14397,14 @@ bool Document::InlineScriptAllowedByCSP() {
1439714397
return allowsInlineScript;
1439814398
}
1439914399

14400-
static bool ReportExternalResourceUseCounters(Document* aDocument,
14401-
void* aData) {
14402-
const auto reportKind =
14403-
Document::UseCounterReportKind::eIncludeExternalResources;
14404-
aDocument->ReportUseCounters(reportKind);
14405-
return true;
14406-
}
14407-
14408-
void Document::ReportUseCounters(UseCounterReportKind aKind) {
14400+
void Document::ReportUseCounters() {
1440914401
static const bool sDebugUseCounters = false;
1441014402
if (mReportedUseCounters) {
1441114403
return;
1441214404
}
1441314405

1441414406
mReportedUseCounters = true;
1441514407

14416-
if (aKind == UseCounterReportKind::eIncludeExternalResources) {
14417-
EnumerateExternalResources(ReportExternalResourceUseCounters, nullptr);
14418-
}
14419-
1442014408
if (Telemetry::HistogramUseCounterCount > 0 &&
1442114409
(IsContentDocument() || IsResourceDoc())) {
1442214410
nsCOMPtr<nsIURI> uri;

dom/base/Document.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3770,20 +3770,7 @@ class Document : public nsINode,
37703770

37713771
bool IsSynthesized();
37723772

3773-
enum class UseCounterReportKind {
3774-
// Flush the document's use counters only; the use counters for any
3775-
// external resource documents will be flushed when the external
3776-
// resource documents themselves are destroyed.
3777-
eDefault,
3778-
3779-
// Flush use counters for the document and for its external resource
3780-
// documents. (Should only be necessary for tests, where we need
3781-
// flushing to happen synchronously and deterministically.)
3782-
eIncludeExternalResources,
3783-
};
3784-
3785-
void ReportUseCounters(
3786-
UseCounterReportKind aKind = UseCounterReportKind::eDefault);
3773+
void ReportUseCounters();
37873774

37883775
void SetDocumentUseCounter(UseCounter aUseCounter) {
37893776
if (!mUseCounters[aUseCounter]) {

dom/base/nsDOMWindowUtils.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,31 +3816,6 @@ nsDOMWindowUtils::TriggerDeviceReset() {
38163816
return NS_OK;
38173817
}
38183818

3819-
NS_IMETHODIMP
3820-
nsDOMWindowUtils::ForceUseCounterFlush(nsINode* aNode) {
3821-
NS_ENSURE_ARG_POINTER(aNode);
3822-
3823-
if (nsCOMPtr<Document> doc = do_QueryInterface(aNode)) {
3824-
mozilla::css::ImageLoader* loader = doc->StyleImageLoader();
3825-
loader->FlushUseCounters();
3826-
3827-
// Flush the document and any external documents that it depends on.
3828-
const auto reportKind =
3829-
Document::UseCounterReportKind::eIncludeExternalResources;
3830-
doc->ReportUseCounters(reportKind);
3831-
return NS_OK;
3832-
}
3833-
3834-
if (nsCOMPtr<nsIContent> content = do_QueryInterface(aNode)) {
3835-
if (HTMLImageElement* img = HTMLImageElement::FromNode(content)) {
3836-
img->FlushUseCounters();
3837-
return NS_OK;
3838-
}
3839-
}
3840-
3841-
return NS_OK;
3842-
}
3843-
38443819
NS_IMETHODIMP
38453820
nsDOMWindowUtils::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
38463821
bool* aRetVal) {

dom/html/HTMLImageElement.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,15 +1208,5 @@ void HTMLImageElement::MediaFeatureValuesChanged() {
12081208
QueueImageLoadTask(false);
12091209
}
12101210

1211-
void HTMLImageElement::FlushUseCounters() {
1212-
nsCOMPtr<imgIRequest> request;
1213-
GetRequest(CURRENT_REQUEST, getter_AddRefs(request));
1214-
1215-
nsCOMPtr<imgIContainer> container;
1216-
request->GetImage(getter_AddRefs(container));
1217-
1218-
static_cast<image::Image*>(container.get())->ReportUseCounters();
1219-
}
1220-
12211211
} // namespace dom
12221212
} // namespace mozilla

dom/html/HTMLImageElement.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,6 @@ class HTMLImageElement final : public nsGenericHTMLElement,
247247
const nsAString& aTypeAttr, const nsAString& aMediaAttr,
248248
nsAString& aResult);
249249

250-
/**
251-
* If this image's src pointers to an SVG document, flush the SVG document's
252-
* use counters to telemetry. Only used for testing purposes.
253-
*/
254-
void FlushUseCounters();
255-
256250
protected:
257251
virtual ~HTMLImageElement();
258252

dom/interfaces/base/nsIDOMWindowUtils.idl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,17 +1836,6 @@ interface nsIDOMWindowUtils : nsISupports {
18361836
*/
18371837
bool hasRuleProcessorUsedByMultipleStyleSets(in unsigned long aSheetType);
18381838

1839-
/*
1840-
* Force the use counters for the node's associated document(s) to be
1841-
* flushed to telemetry. For example, a document node will flush its own
1842-
* counters and an image node with an SVG source will flush the SVG
1843-
* document's counters. Normally, use counters are flushed to telemetry
1844-
* upon document destruction, but as document destruction is somewhat
1845-
* non-deterministic, we have this method here for more determinism when
1846-
* running tests.
1847-
*/
1848-
void forceUseCounterFlush(in Node aNode);
1849-
18501839
/**
18511840
* Enable or disable displayport suppression. This is intended to be used by
18521841
* testing code, to provide more deterministic behaviour over the displayport

image/Image.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ class Image : public imgIContainer {
225225
virtual void SetHasError() = 0;
226226

227227
virtual nsIURI* GetURI() const = 0;
228-
229-
virtual void ReportUseCounters() {}
230228
};
231229

232230
class ImageResource : public Image {

image/VectorImage.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,12 +1509,6 @@ void VectorImage::PropagateUseCounters(Document* aParentDocument) {
15091509
}
15101510
}
15111511

1512-
void VectorImage::ReportUseCounters() {
1513-
if (Document* doc = mSVGDocumentWrapper->GetDocument()) {
1514-
doc->ReportUseCounters();
1515-
}
1516-
}
1517-
15181512
nsIntSize VectorImage::OptimalImageSizeForDest(const gfxSize& aDest,
15191513
uint32_t aWhichFrame,
15201514
SamplingFilter aSamplingFilter,

image/VectorImage.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ class VectorImage final : public ImageResource, public nsIStreamListener {
6767
void OnSVGDocumentLoaded();
6868
void OnSVGDocumentError();
6969

70-
virtual void ReportUseCounters() override;
71-
7270
protected:
7371
explicit VectorImage(nsIURI* aURI = nullptr);
7472
virtual ~VectorImage();

layout/style/ImageLoader.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -790,20 +790,6 @@ nsresult ImageLoader::OnLoadComplete(imgIRequest* aRequest) {
790790
return NS_OK;
791791
}
792792

793-
void ImageLoader::FlushUseCounters() {
794-
MOZ_ASSERT(NS_IsMainThread());
795-
796-
for (auto iter = mRegisteredImages.Iter(); !iter.Done(); iter.Next()) {
797-
if (imgRequestProxy* request = iter.Data()) {
798-
nsCOMPtr<imgIContainer> container;
799-
request->GetImage(getter_AddRefs(container));
800-
if (container) {
801-
static_cast<image::Image*>(container.get())->ReportUseCounters();
802-
}
803-
}
804-
}
805-
}
806-
807793
bool ImageLoader::ImageReflowCallback::ReflowFinished() {
808794
// Check that the frame is still valid. If it isn't, then onload was
809795
// unblocked when the frame was removed from the FrameSet in

0 commit comments

Comments
 (0)