mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968923 - part 5b - add nsIDOMWindowUtils::forceUseCounterFlush; r=bz
Use counter submission normally happens at document destruction. For testing use counters, however, we need to have use counters updated in telemetry at deterministic points. Therefore, we provide a method on nsIDOMWindowUtils that forces use counters out to telemetry so we can examine them.
This commit is contained in:
parent
4e191b2e1f
commit
bc01544a1c
@ -103,6 +103,9 @@
|
|||||||
#include "nsIStyleSheetService.h"
|
#include "nsIStyleSheetService.h"
|
||||||
#include "nsContentPermissionHelper.h"
|
#include "nsContentPermissionHelper.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "nsDocument.h"
|
||||||
|
#include "HTMLImageElement.h"
|
||||||
|
#include "mozilla/css/ImageLoader.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#undef GetClassName
|
#undef GetClassName
|
||||||
@ -3919,6 +3922,30 @@ nsDOMWindowUtils::LeaveChaosMode()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMWindowUtils::ForceUseCounterFlush(nsIDOMNode *aNode)
|
||||||
|
{
|
||||||
|
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
|
||||||
|
NS_ENSURE_ARG_POINTER(aNode);
|
||||||
|
|
||||||
|
if (nsCOMPtr<nsIDocument> doc = do_QueryInterface(aNode)) {
|
||||||
|
mozilla::css::ImageLoader* loader = doc->StyleImageLoader();
|
||||||
|
loader->FlushUseCounters();
|
||||||
|
|
||||||
|
static_cast<nsDocument*>(doc.get())->ReportUseCounters();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nsCOMPtr<nsIContent> content = do_QueryInterface(aNode)) {
|
||||||
|
if (HTMLImageElement* img = HTMLImageElement::FromContent(content)) {
|
||||||
|
img->FlushUseCounters();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMWindowUtils::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
|
nsDOMWindowUtils::HasRuleProcessorUsedByMultipleStyleSets(uint32_t aSheetType,
|
||||||
bool* aRetVal)
|
bool* aRetVal)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsMappedAttributes.h"
|
#include "nsMappedAttributes.h"
|
||||||
#include "nsSize.h"
|
#include "nsSize.h"
|
||||||
|
#include "nsDocument.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
#include "nsIDOMMutationEvent.h"
|
#include "nsIDOMMutationEvent.h"
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
#include "mozilla/dom/HTMLFormElement.h"
|
#include "mozilla/dom/HTMLFormElement.h"
|
||||||
#include "nsAttrValueOrString.h"
|
#include "nsAttrValueOrString.h"
|
||||||
#include "imgLoader.h"
|
#include "imgLoader.h"
|
||||||
|
#include "Image.h"
|
||||||
|
|
||||||
// Responsive images!
|
// Responsive images!
|
||||||
#include "mozilla/dom/HTMLSourceElement.h"
|
#include "mozilla/dom/HTMLSourceElement.h"
|
||||||
@ -1301,6 +1303,18 @@ HTMLImageElement::MediaFeatureValuesChanged()
|
|||||||
QueueImageLoadTask();
|
QueueImageLoadTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HTMLImageElement::FlushUseCounters()
|
||||||
|
{
|
||||||
|
nsCOMPtr<imgIRequest> request;
|
||||||
|
GetRequest(CURRENT_REQUEST, getter_AddRefs(request));
|
||||||
|
|
||||||
|
nsCOMPtr<imgIContainer> container;
|
||||||
|
request->GetImage(getter_AddRefs(container));
|
||||||
|
|
||||||
|
static_cast<image::Image*>(container.get())->ReportUseCounters();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
@ -265,6 +265,12 @@ public:
|
|||||||
const nsAString& aMediaAttr,
|
const nsAString& aMediaAttr,
|
||||||
nsAString& aResult);
|
nsAString& aResult);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this image's src pointers to an SVG document, flush the SVG document's
|
||||||
|
* use counters to telemetry. Only used for testing purposes.
|
||||||
|
*/
|
||||||
|
void FlushUseCounters();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~HTMLImageElement();
|
virtual ~HTMLImageElement();
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ LOCAL_INCLUDES += [
|
|||||||
'/dom/xul',
|
'/dom/xul',
|
||||||
'/editor/libeditor',
|
'/editor/libeditor',
|
||||||
'/editor/txmgr',
|
'/editor/txmgr',
|
||||||
|
'/image',
|
||||||
'/layout/forms',
|
'/layout/forms',
|
||||||
'/layout/generic',
|
'/layout/generic',
|
||||||
'/layout/style',
|
'/layout/style',
|
||||||
|
@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
|
|||||||
interface nsIContentPermissionRequest;
|
interface nsIContentPermissionRequest;
|
||||||
interface nsIObserver;
|
interface nsIObserver;
|
||||||
|
|
||||||
[scriptable, uuid(47fa312b-2ad1-4b80-8a0a-c9822e2d1ec9)]
|
[scriptable, uuid(e6d3ced6-fbce-4ea5-902a-c2055680d250)]
|
||||||
interface nsIDOMWindowUtils : nsISupports {
|
interface nsIDOMWindowUtils : nsISupports {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1847,6 +1847,17 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
* @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
|
* @param aSheetType One of the nsIStyleSheetService.*_SHEET constants.
|
||||||
*/
|
*/
|
||||||
bool hasRuleProcessorUsedByMultipleStyleSets(in unsigned long aSheetType);
|
bool hasRuleProcessorUsedByMultipleStyleSets(in unsigned long aSheetType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Force the use counters for the node's associated document(s) to be
|
||||||
|
* flushed to telemetry. For example, a document node will flush its own
|
||||||
|
* counters and an image node with an SVG source will flush the SVG
|
||||||
|
* document's counters. Normally, use counters are flushed to telemetry
|
||||||
|
* upon document destruction, but as document destruction is somewhat
|
||||||
|
* non-deterministic, we have this method here for more determinism when
|
||||||
|
* running tests.
|
||||||
|
*/
|
||||||
|
void forceUseCounterFlush(in nsIDOMNode aNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]
|
[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)]
|
||||||
|
@ -229,6 +229,8 @@ public:
|
|||||||
virtual void SetHasError() = 0;
|
virtual void SetHasError() = 0;
|
||||||
|
|
||||||
virtual ImageURL* GetURI() = 0;
|
virtual ImageURL* GetURI() = 0;
|
||||||
|
|
||||||
|
virtual void ReportUseCounters() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ImageResource : public Image
|
class ImageResource : public Image
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "SVGDocumentWrapper.h"
|
#include "SVGDocumentWrapper.h"
|
||||||
#include "nsIDOMEventListener.h"
|
#include "nsIDOMEventListener.h"
|
||||||
#include "SurfaceCache.h"
|
#include "SurfaceCache.h"
|
||||||
|
#include "nsDocument.h"
|
||||||
|
|
||||||
// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK
|
// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK
|
||||||
#undef GetCurrentTime
|
#undef GetCurrentTime
|
||||||
@ -1259,6 +1260,15 @@ VectorImage::PropagateUseCounters(nsIDocument* aParentDocument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VectorImage::ReportUseCounters()
|
||||||
|
{
|
||||||
|
nsIDocument* doc = mSVGDocumentWrapper->GetDocument();
|
||||||
|
if (doc) {
|
||||||
|
static_cast<nsDocument*>(doc)->ReportUseCounters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsIntSize
|
nsIntSize
|
||||||
VectorImage::OptimalImageSizeForDest(const gfxSize& aDest,
|
VectorImage::OptimalImageSizeForDest(const gfxSize& aDest,
|
||||||
uint32_t aWhichFrame,
|
uint32_t aWhichFrame,
|
||||||
|
@ -68,6 +68,8 @@ public:
|
|||||||
void OnSVGDocumentLoaded();
|
void OnSVGDocumentLoaded();
|
||||||
void OnSVGDocumentError();
|
void OnSVGDocumentError();
|
||||||
|
|
||||||
|
virtual void ReportUseCounters() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit VectorImage(ImageURL* aURI = nullptr);
|
explicit VectorImage(ImageURL* aURI = nullptr);
|
||||||
virtual ~VectorImage();
|
virtual ~VectorImage();
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "FrameLayerBuilder.h"
|
#include "FrameLayerBuilder.h"
|
||||||
#include "nsSVGEffects.h"
|
#include "nsSVGEffects.h"
|
||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
|
#include "Image.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace css {
|
namespace css {
|
||||||
@ -510,5 +511,22 @@ ImageLoader::UnblockOnload(imgIRequest* aRequest)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ImageLoader::FlushUseCounters()
|
||||||
|
{
|
||||||
|
for (auto iter = mImages.Iter(); !iter.Done(); iter.Next()) {
|
||||||
|
nsPtrHashKey<Image>* key = iter.Get();
|
||||||
|
ImageLoader::Image* image = key->GetKey();
|
||||||
|
|
||||||
|
imgIRequest* request = image->mRequests.GetWeak(mDocument);
|
||||||
|
|
||||||
|
nsCOMPtr<imgIContainer> container;
|
||||||
|
request->GetImage(getter_AddRefs(container));
|
||||||
|
if (container) {
|
||||||
|
static_cast<image::Image*>(container.get())->ReportUseCounters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace css
|
} // namespace css
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -70,6 +70,8 @@ public:
|
|||||||
|
|
||||||
void DestroyRequest(imgIRequest* aRequest);
|
void DestroyRequest(imgIRequest* aRequest);
|
||||||
|
|
||||||
|
void FlushUseCounters();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~ImageLoader() {}
|
~ImageLoader() {}
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ LOCAL_INCLUDES += [
|
|||||||
'/dom/html',
|
'/dom/html',
|
||||||
'/dom/xbl',
|
'/dom/xbl',
|
||||||
'/dom/xul',
|
'/dom/xul',
|
||||||
|
'/image',
|
||||||
]
|
]
|
||||||
|
|
||||||
JAR_MANIFESTS += ['jar.mn']
|
JAR_MANIFESTS += ['jar.mn']
|
||||||
|
Loading…
Reference in New Issue
Block a user