From 0990f16fa99d8276cdb07311477fea7915bd7ff9 Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 23 Jun 2013 12:57:47 +0200 Subject: [PATCH 01/45] Bug 798914 (part 1) - Introduce mozilla::MallocSizeOf in mfbt. r=Waldo. --HG-- extra : rebase_source : 45cb28264b1aa3fe9adc9bdc9ed73bead4332af6 --- mfbt/MemoryReporting.h | 30 ++++++++++++++++++++++++++++++ mfbt/exported_headers.mk | 1 + 2 files changed, 31 insertions(+) create mode 100644 mfbt/MemoryReporting.h diff --git a/mfbt/MemoryReporting.h b/mfbt/MemoryReporting.h new file mode 100644 index 000000000000..65bc8b4510f9 --- /dev/null +++ b/mfbt/MemoryReporting.h @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +/* Memory reporting infrastructure. */ + +#ifndef mozilla_MemoryReporting_h_ +#define mozilla_MemoryReporting_h_ + +#include + +#ifdef __cplusplus + +namespace mozilla { + +/* + * This is for functions that are like malloc_usable_size. Such functions are + * used for measuring the size of data structures. + */ +typedef size_t (*MallocSizeOf)(const void* p); + +} /* namespace mozilla */ + +#endif /* __cplusplus */ + +typedef size_t (*MozMallocSizeOf)(const void* p); + +#endif /* mozilla_MemoryReporting_h_ */ diff --git a/mfbt/exported_headers.mk b/mfbt/exported_headers.mk index 63709363cf33..809ab8e7f622 100644 --- a/mfbt/exported_headers.mk +++ b/mfbt/exported_headers.mk @@ -29,6 +29,7 @@ EXPORTS_mozilla += \ LinkedList.h \ MathAlgorithms.h \ MemoryChecking.h \ + MemoryReporting.h \ MSStdInt.h \ NullPtr.h \ PodOperations.h \ From 09cfbe927e50389392405164b15983bbef708961 Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 16 Jun 2013 14:12:19 +0200 Subject: [PATCH 02/45] Bug 798914 (part 2) - Use newly introduced mozilla::MallocSizeOf in chromium. r=njn. --HG-- extra : rebase_source : 3488c0e9140919a78b9a8658f54a6dc162935653 --- ipc/chromium/src/base/histogram.cc | 4 ++-- ipc/chromium/src/base/histogram.h | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 819d901772a8..57581a2dc504 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -409,7 +409,7 @@ bool Histogram::HasValidRangeChecksum() const { return CalculateRangeChecksum() == range_checksum_; } -size_t Histogram::SizeOfIncludingThis(size_t (*aMallocSizeOf)(const void*)) +size_t Histogram::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = 0; n += aMallocSizeOf(this); @@ -420,7 +420,7 @@ size_t Histogram::SizeOfIncludingThis(size_t (*aMallocSizeOf)(const void*)) return n; } -size_t Histogram::SampleSet::SizeOfExcludingThis(size_t (*aMallocSizeOf)(const void*)) +size_t Histogram::SampleSet::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { // We're not allowed to do deep dives into STL data structures. This // is as close as we can get to measuring this array. diff --git a/ipc/chromium/src/base/histogram.h b/ipc/chromium/src/base/histogram.h index 960984ec5274..b316094fa72f 100644 --- a/ipc/chromium/src/base/histogram.h +++ b/ipc/chromium/src/base/histogram.h @@ -41,6 +41,8 @@ #define BASE_METRICS_HISTOGRAM_H_ #pragma once +#include "mozilla/MemoryReporting.h" + #include #include #include @@ -316,10 +318,7 @@ class Histogram { const char* description; // Null means end of a list of pairs. }; - // To avoid depending on XPCOM headers, we define our own MallocSizeOf type. - typedef size_t (*MallocSizeOf)(const void*); - - size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); //---------------------------------------------------------------------------- // Statistic values, developed over the life of the histogram. @@ -357,7 +356,7 @@ class Histogram { bool Serialize(Pickle* pickle) const; bool Deserialize(void** iter, const Pickle& pickle); - size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf); + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); protected: // Actual histogram data is stored in buckets, showing the count of values From 0fc2c54e7b756136784d1173622720377d993e5e Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Thu, 20 Jun 2013 21:17:44 +0200 Subject: [PATCH 03/45] Bug 798914 (part 3) - Use newly introduced MozMallocSizeOf in xpt. r=njn. --HG-- extra : rebase_source : 6c3d707727bd1448acb26317cab2c64c82aa896c --- xpcom/typelib/xpt/public/xpt_arena.h | 6 ++---- xpcom/typelib/xpt/src/xpt_arena.c | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xpcom/typelib/xpt/public/xpt_arena.h b/xpcom/typelib/xpt/public/xpt_arena.h index c4f208806a80..1192aada7f3c 100644 --- a/xpcom/typelib/xpt/public/xpt_arena.h +++ b/xpcom/typelib/xpt/public/xpt_arena.h @@ -12,6 +12,7 @@ #include "prtypes.h" #include +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" @@ -53,11 +54,8 @@ XPT_NotifyDoneLoading(XPTArena *arena); XPT_PUBLIC_API(void) XPT_ArenaFree(XPTArena *arena, void* block); -/* A synonym of |nsMallocSizeOfFun|, because we don't #include nscore.h. */ -typedef size_t(*xptMallocSizeOfFun)(const void *p); - XPT_PUBLIC_API(size_t) -XPT_SizeOfArena(XPTArena *arena, xptMallocSizeOfFun mallocSizeOf); +XPT_SizeOfArena(XPTArena *arena, MozMallocSizeOf mallocSizeOf); /* --------------------------------------------------------- */ diff --git a/xpcom/typelib/xpt/src/xpt_arena.c b/xpcom/typelib/xpt/src/xpt_arena.c index 8efaa08b5609..c4bb161c5d4b 100644 --- a/xpcom/typelib/xpt/src/xpt_arena.c +++ b/xpcom/typelib/xpt/src/xpt_arena.c @@ -12,6 +12,7 @@ */ #include "xpt_arena.h" +#include "mozilla/MemoryReporting.h" #include #include #include @@ -306,7 +307,7 @@ XPT_AssertFailed(const char *s, const char *file, uint32_t lineno) #endif XPT_PUBLIC_API(size_t) -XPT_SizeOfArena(XPTArena *arena, xptMallocSizeOfFun mallocSizeOf) +XPT_SizeOfArena(XPTArena *arena, MozMallocSizeOf mallocSizeOf) { size_t n = mallocSizeOf(arena); From d1755d1c96db2a7e1899dbda8ce308e30fe9330e Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 23 Jun 2013 13:21:01 +0200 Subject: [PATCH 04/45] Bug 798914 (part 4) - Use newly introduced mozilla::MallocSizeOf in js. r=njn. --HG-- extra : rebase_source : d1c063b94c7ec58729150cbea602bb4c9f2a0e24 --- js/public/HashTable.h | 13 +++++++------ js/public/MemoryMetrics.h | 6 ++++-- js/public/Utility.h | 5 ----- js/public/Vector.h | 9 +++++---- js/src/ctypes/CTypes.cpp | 3 ++- js/src/ds/LifoAlloc.h | 7 ++++--- js/src/gc/Zone.h | 3 ++- js/src/ion/BaselineJIT.cpp | 4 +++- js/src/ion/BaselineJIT.h | 6 ++++-- js/src/ion/Ion.cpp | 4 +++- js/src/ion/Ion.h | 4 +++- js/src/ion/IonCode.h | 3 ++- js/src/ion/IonCompartment.h | 4 +++- js/src/jsapi.h | 9 +++++---- js/src/jscntxt.cpp | 5 +++-- js/src/jscntxt.h | 5 +++-- js/src/jscompartment.cpp | 3 ++- js/src/jscompartment.h | 5 +++-- js/src/jsfriendapi.h | 4 +++- js/src/jsgc.cpp | 3 ++- js/src/jsgc.h | 5 +++-- js/src/jsinfer.cpp | 9 +++++---- js/src/jsinfer.h | 4 +++- js/src/jsiter.cpp | 3 ++- js/src/jsiter.h | 5 ++++- js/src/jsmath.cpp | 3 ++- js/src/jsmath.h | 4 +++- js/src/jsobj.cpp | 3 ++- js/src/jsobj.h | 5 ++++- js/src/jsscript.cpp | 5 +++-- js/src/jsscript.h | 7 ++++--- js/src/vm/ArgumentsObject-inl.h | 4 +++- js/src/vm/ArgumentsObject.h | 4 +++- js/src/vm/RegExpObject.cpp | 4 +++- js/src/vm/RegExpObject.h | 3 ++- js/src/vm/RegExpStatics-inl.h | 4 +++- js/src/vm/RegExpStatics.h | 4 +++- js/src/vm/Shape.h | 5 +++-- js/src/vm/Stack.h | 4 +++- js/src/vm/String.cpp | 3 ++- js/src/vm/String.h | 3 ++- js/xpconnect/src/XPCMaps.cpp | 9 +++++---- js/xpconnect/src/XPCMaps.h | 10 ++++++---- 43 files changed, 136 insertions(+), 79 deletions(-) diff --git a/js/public/HashTable.h b/js/public/HashTable.h index b9b7ef8a3c92..5bd772b8aa7d 100644 --- a/js/public/HashTable.h +++ b/js/public/HashTable.h @@ -11,6 +11,7 @@ #include "mozilla/Attributes.h" #include "mozilla/Casting.h" #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" @@ -204,10 +205,10 @@ class HashMap // Don't just call |impl.sizeOfExcludingThis()| because there's no // guarantee that |impl| is the first field in HashMap. - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); } @@ -412,10 +413,10 @@ class HashSet // Don't just call |impl.sizeOfExcludingThis()| because there's no // guarantee that |impl| is the first field in HashSet. - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return impl.sizeOfExcludingThis(mallocSizeOf); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); } @@ -1340,12 +1341,12 @@ class HashTable : private AllocPolicy return gen; } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(table); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index 7fdf0d39d0a9..848a1f46f5d0 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -10,6 +10,8 @@ // These declarations are not within jsapi.h because they are highly likely to // change in the future. Depend on them at your own risk. +#include "mozilla/MemoryReporting.h" + #include #include "jsalloc.h" @@ -363,7 +365,7 @@ struct CompartmentStats struct RuntimeStats { - RuntimeStats(JSMallocSizeOfFun mallocSizeOf) + RuntimeStats(mozilla::MallocSizeOf mallocSizeOf) : runtime(), gcHeapChunkTotal(0), gcHeapDecommittedArenas(0), @@ -420,7 +422,7 @@ struct RuntimeStats ZoneStats *currZoneStats; - JSMallocSizeOfFun mallocSizeOf_; + mozilla::MallocSizeOf mallocSizeOf_; virtual void initExtraCompartmentStats(JSCompartment *c, CompartmentStats *cstats) = 0; virtual void initExtraZoneStats(JS::Zone *zone, ZoneStats *zstats) = 0; diff --git a/js/public/Utility.h b/js/public/Utility.h index 436374ecbf5f..3983a513a07f 100644 --- a/js/public/Utility.h +++ b/js/public/Utility.h @@ -814,11 +814,6 @@ inline bool IsPoisonedPtr(T *v) } -/* - * This is SpiderMonkey's equivalent to |nsMallocSizeOfFun|. - */ -typedef size_t(*JSMallocSizeOfFun)(const void *p); - /* sixgill annotation defines */ #ifndef HAVE_STATIC_ANNOTATIONS # define HAVE_STATIC_ANNOTATIONS diff --git a/js/public/Vector.h b/js/public/Vector.h index 8982ad37674b..d01ba76198d3 100644 --- a/js/public/Vector.h +++ b/js/public/Vector.h @@ -8,6 +8,7 @@ #define js_Vector_h #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TypeTraits.h" #include "TemplateLib.h" @@ -504,13 +505,13 @@ class Vector : private AllocPolicy /* * Measure the size of the Vector's heap-allocated storage. */ - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const; + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; /* * Like sizeOfExcludingThis, but also measures the size of the Vector * object (which must be heap-allocated) itself. */ - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const; + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const; void swap(Vector &other); }; @@ -1059,14 +1060,14 @@ Vector::replaceRawBuffer(T *p, size_t aLength) template inline size_t -Vector::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const +Vector::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); } template inline size_t -Vector::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const +Vector::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index c371f3eef04c..d0439c93f7a9 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -7,6 +7,7 @@ #include "ctypes/CTypes.h" #include "mozilla/FloatingPoint.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" #include @@ -1337,7 +1338,7 @@ JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks* callbacks) namespace js { JS_FRIEND_API(size_t) -SizeOfDataIfCDataObject(JSMallocSizeOfFun mallocSizeOf, JSObject *obj) +SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject *obj) { if (!CData::IsCData(obj)) return 0; diff --git a/js/src/ds/LifoAlloc.h b/js/src/ds/LifoAlloc.h index f2fbb5a58622..9d359a3a1f56 100644 --- a/js/src/ds/LifoAlloc.h +++ b/js/src/ds/LifoAlloc.h @@ -9,6 +9,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/MemoryChecking.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "mozilla/TypeTraits.h" @@ -89,7 +90,7 @@ class BumpChunk size_t used() const { return bump - bumpBase(); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(this); } @@ -347,7 +348,7 @@ class LifoAlloc } // Get the total size of the arena chunks (including unused space). - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { size_t n = 0; for (BumpChunk *chunk = first; chunk; chunk = chunk->next()) n += chunk->sizeOfIncludingThis(mallocSizeOf); @@ -355,7 +356,7 @@ class LifoAlloc } // Like sizeOfExcludingThis(), but includes the size of the LifoAlloc itself. - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); } diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index cb51a1b98da4..12a96ec39bad 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -9,6 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "jscntxt.h" @@ -259,7 +260,7 @@ struct Zone : private JS::shadow::Zone, void discardJitCode(js::FreeOp *fop, bool discardConstraints); - void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *typePool); + void sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *typePool); void setGCLastBytes(size_t lastBytes, js::JSGCInvocationKind gckind); void reduceGCTriggerBytes(size_t amount); diff --git a/js/src/ion/BaselineJIT.cpp b/js/src/ion/BaselineJIT.cpp index 2ef86886a47d..0eebd756f781 100644 --- a/js/src/ion/BaselineJIT.cpp +++ b/js/src/ion/BaselineJIT.cpp @@ -4,6 +4,8 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" + #include "BaselineCompiler.h" #include "BaselineIC.h" #include "BaselineJIT.h" @@ -843,7 +845,7 @@ ion::IonCompartment::toggleBaselineStubBarriers(bool enabled) } void -ion::SizeOfBaselineData(JSScript *script, JSMallocSizeOfFun mallocSizeOf, size_t *data, +ion::SizeOfBaselineData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf, size_t *data, size_t *fallbackStubs) { *data = 0; diff --git a/js/src/ion/BaselineJIT.h b/js/src/ion/BaselineJIT.h index f32b71925a14..c0d326fb265c 100644 --- a/js/src/ion/BaselineJIT.h +++ b/js/src/ion/BaselineJIT.h @@ -9,6 +9,8 @@ #ifdef JS_ION +#include "mozilla/MemoryReporting.h" + #include "jscntxt.h" #include "jscompartment.h" @@ -157,7 +159,7 @@ struct BaselineScript return offsetof(BaselineScript, method_); } - void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *data, + void sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *data, size_t *fallbackStubs) const { *data = mallocSizeOf(this); @@ -278,7 +280,7 @@ void FinishDiscardBaselineScript(FreeOp *fop, JSScript *script); void -SizeOfBaselineData(JSScript *script, JSMallocSizeOfFun mallocSizeOf, size_t *data, +SizeOfBaselineData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf, size_t *data, size_t *fallbackStubs); void diff --git a/js/src/ion/Ion.cpp b/js/src/ion/Ion.cpp index 2ac4a1c2215a..fb6e553f429e 100644 --- a/js/src/ion/Ion.cpp +++ b/js/src/ion/Ion.cpp @@ -4,6 +4,8 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" + #include "BaselineJIT.h" #include "BaselineCompiler.h" #include "BaselineInspector.h" @@ -2402,7 +2404,7 @@ ion::PurgeCaches(JSScript *script, Zone *zone) } size_t -ion::SizeOfIonData(JSScript *script, JSMallocSizeOfFun mallocSizeOf) +ion::SizeOfIonData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf) { size_t result = 0; diff --git a/js/src/ion/Ion.h b/js/src/ion/Ion.h index 5a8adfc7dd8b..998d7c339a8f 100644 --- a/js/src/ion/Ion.h +++ b/js/src/ion/Ion.h @@ -9,6 +9,8 @@ #ifdef JS_ION +#include "mozilla/MemoryReporting.h" + #include "jscntxt.h" #include "jscompartment.h" #include "IonCode.h" @@ -349,7 +351,7 @@ void ForbidCompilation(JSContext *cx, JSScript *script, ExecutionMode mode); uint32_t UsesBeforeIonRecompile(JSScript *script, jsbytecode *pc); void PurgeCaches(JSScript *script, JS::Zone *zone); -size_t SizeOfIonData(JSScript *script, JSMallocSizeOfFun mallocSizeOf); +size_t SizeOfIonData(JSScript *script, mozilla::MallocSizeOf mallocSizeOf); void DestroyIonScripts(FreeOp *fop, JSScript *script); void TraceIonScripts(JSTracer* trc, JSScript *script); diff --git a/js/src/ion/IonCode.h b/js/src/ion/IonCode.h index cf54862e88a8..9cde5e486c52 100644 --- a/js/src/ion/IonCode.h +++ b/js/src/ion/IonCode.h @@ -7,6 +7,7 @@ #ifndef ion_IonCode_h #define ion_IonCode_h +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "IonTypes.h" @@ -435,7 +436,7 @@ struct IonScript size_t callTargetEntries() const { return callTargetEntries_; } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this); } EncapsulatedValue &getConstant(size_t index) { diff --git a/js/src/ion/IonCompartment.h b/js/src/ion/IonCompartment.h index 14deee8a3c27..a8e72e054b2f 100644 --- a/js/src/ion/IonCompartment.h +++ b/js/src/ion/IonCompartment.h @@ -9,6 +9,8 @@ #ifdef JS_ION +#include "mozilla/MemoryReporting.h" + #include "IonCode.h" #include "jsweakcache.h" #include "js/Value.h" @@ -80,7 +82,7 @@ struct ICStubSpace JS_DECLARE_NEW_METHODS(allocate, alloc, inline) - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return allocator_.sizeOfExcludingThis(mallocSizeOf); } }; diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 3e7fc0422ec7..b3a9a6630995 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -10,6 +10,7 @@ #define jsapi_h #include "mozilla/FloatingPoint.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/RangedPtr.h" #include "mozilla/StandardInteger.h" #include "mozilla/ThreadLocal.h" @@ -378,10 +379,10 @@ class AutoHashMapRooter : protected AutoGCRooter return map.capacity(); } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfExcludingThis(mallocSizeOf); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return map.sizeOfIncludingThis(mallocSizeOf); } @@ -493,10 +494,10 @@ class AutoHashSetRooter : protected AutoGCRooter return set.capacity(); } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfExcludingThis(mallocSizeOf); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return set.sizeOfIncludingThis(mallocSizeOf); } diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index b388316b4377..16380d00951a 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -22,6 +22,7 @@ # include #endif // ANDROID +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "jstypes.h" @@ -106,7 +107,7 @@ NewObjectCache::clearNurseryObjects(JSRuntime *rt) } void -JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, JS::RuntimeSizes *rtSizes) +JSRuntime::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes *rtSizes) { rtSizes->object = mallocSizeOf(this); @@ -1492,7 +1493,7 @@ JSContext::updateJITEnabled() } size_t -JSContext::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const +JSContext::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { /* * There are other JSContext members that could be measured; the following diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index eb0b88779d39..7ca2506a47ab 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -10,6 +10,7 @@ #define jscntxt_h #include "mozilla/LinkedList.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include @@ -1442,7 +1443,7 @@ struct JSRuntime : public JS::shadow::Runtime, return jitHardening; } - void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, JS::RuntimeSizes *runtime); + void sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::RuntimeSizes *runtime); private: @@ -1933,7 +1934,7 @@ struct JSContext : js::ThreadSafeContext, */ bool runningWithTrustedPrincipals() const; - JS_FRIEND_API(size_t) sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const; + JS_FRIEND_API(size_t) sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const; void mark(JSTracer *trc); diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 29ace433fcce..38a1d0d7a5b9 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -7,6 +7,7 @@ #include "jscompartment.h" #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "jscntxt.h" #include "jsgc.h" @@ -825,7 +826,7 @@ JSCompartment::clearTraps(FreeOp *fop) } void -JSCompartment::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *compartmentObject, +JSCompartment::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *compartmentObject, JS::TypeInferenceSizes *tiSizes, size_t *shapesCompartmentTables, size_t *crossCompartmentWrappersArg, size_t *regexpCompartment, size_t *debuggeesSet, size_t *baselineStubsOptimized) diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index 9d22b50eee5c..71daba5c9528 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -7,6 +7,7 @@ #ifndef jscompartment_h #define jscompartment_h +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "jscntxt.h" @@ -191,10 +192,10 @@ struct JSCompartment js::RegExpCompartment regExps; private: - void sizeOfTypeInferenceData(JS::TypeInferenceSizes *stats, JSMallocSizeOfFun mallocSizeOf); + void sizeOfTypeInferenceData(JS::TypeInferenceSizes *stats, mozilla::MallocSizeOf mallocSizeOf); public: - void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *compartmentObject, + void sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *compartmentObject, JS::TypeInferenceSizes *tiSizes, size_t *shapesCompartmentTables, size_t *crossCompartmentWrappers, size_t *regexpCompartment, size_t *debuggeesSet, diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 1aef77c0e5e5..027233831890 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -7,6 +7,8 @@ #ifndef jsfriendapi_h #define jsfriendapi_h +#include "mozilla/MemoryReporting.h" + #include "jsclass.h" #include "jspubtd.h" #include "jsprvtd.h" @@ -307,7 +309,7 @@ IterateGrayObjects(JS::Zone *zone, GCThingCallback cellCallback, void *data); #ifdef JS_HAS_CTYPES extern JS_FRIEND_API(size_t) -SizeOfDataIfCDataObject(JSMallocSizeOfFun mallocSizeOf, JSObject *obj); +SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject *obj); #endif extern JS_FRIEND_API(JSCompartment *) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 7ad8e1db5c63..59c08488ddbb 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -11,6 +11,7 @@ #include "prmjtime.h" #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" /* @@ -1865,7 +1866,7 @@ GCMarker::GrayCallback(JSTracer *trc, void **thingp, JSGCTraceKind kind) } size_t -GCMarker::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const +GCMarker::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { size_t size = stack.sizeOfExcludingThis(mallocSizeOf); for (ZonesIter zone(runtime); !zone.done(); zone.next()) diff --git a/js/src/jsgc.h b/js/src/jsgc.h index bea442c3722b..b0e13895db6b 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -10,6 +10,7 @@ #define jsgc_h #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "jsalloc.h" @@ -919,7 +920,7 @@ struct MarkStack { return true; } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { size_t n = 0; if (stack != ballast) n += mallocSizeOf(stack); @@ -1089,7 +1090,7 @@ struct GCMarker : public JSTracer { static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind); - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const; + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; MarkStack stack; diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 88916894275e..cd9077c1a26f 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -7,6 +7,7 @@ #include "jsinfer.h" #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "jsapi.h" @@ -6693,7 +6694,7 @@ TypeCompartment::maybePurgeAnalysis(JSContext *cx, bool force) static void SizeOfScriptTypeInferenceData(JSScript *script, JS::TypeInferenceSizes *sizes, - JSMallocSizeOfFun mallocSizeOf) + mozilla::MallocSizeOf mallocSizeOf) { TypeScript *typeScript = script->types; if (!typeScript) @@ -6715,13 +6716,13 @@ SizeOfScriptTypeInferenceData(JSScript *script, JS::TypeInferenceSizes *sizes, } void -Zone::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *typePool) +Zone::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *typePool) { *typePool += types.typeLifoAlloc.sizeOfExcludingThis(mallocSizeOf); } void -JSCompartment::sizeOfTypeInferenceData(JS::TypeInferenceSizes *sizes, JSMallocSizeOfFun mallocSizeOf) +JSCompartment::sizeOfTypeInferenceData(JS::TypeInferenceSizes *sizes, mozilla::MallocSizeOf mallocSizeOf) { sizes->analysisPool += analysisLifoAlloc.sizeOfExcludingThis(mallocSizeOf); @@ -6760,7 +6761,7 @@ JSCompartment::sizeOfTypeInferenceData(JS::TypeInferenceSizes *sizes, JSMallocSi } size_t -TypeObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) +TypeObject::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { if (singleton) { /* diff --git a/js/src/jsinfer.h b/js/src/jsinfer.h index 6a467e3c9db9..3da1972471e1 100644 --- a/js/src/jsinfer.h +++ b/js/src/jsinfer.h @@ -9,6 +9,8 @@ #ifndef jsinfer_h #define jsinfer_h +#include "mozilla/MemoryReporting.h" + #include "jsalloc.h" #include "jsfriendapi.h" @@ -1086,7 +1088,7 @@ struct TypeObject : gc::Cell inline void clearProperties(); inline void sweep(FreeOp *fop); - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf); /* * Type objects don't have explicit finalizers. Memory owned by a type diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 04308767367d..b2101a2c8309 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -8,6 +8,7 @@ #include "jsiter.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "mozilla/Util.h" @@ -813,7 +814,7 @@ iterator_iteratorObject(JSContext *cx, HandleObject obj, JSBool keysonly) } size_t -PropertyIteratorObject::sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const +PropertyIteratorObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(getPrivate()); } diff --git a/js/src/jsiter.h b/js/src/jsiter.h index 9844760c40c7..d95765a6d01f 100644 --- a/js/src/jsiter.h +++ b/js/src/jsiter.h @@ -10,6 +10,9 @@ /* * JavaScript iterators. */ + +#include "mozilla/MemoryReporting.h" + #include "jscntxt.h" #include "gc/Barrier.h" @@ -119,7 +122,7 @@ class PropertyIteratorObject : public JSObject inline NativeIterator *getNativeIterator() const; inline void setNativeIterator(js::NativeIterator *ni); - size_t sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const; + size_t sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const; private: static void trace(JSTracer *trc, JSObject *obj); diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index a2286fe3f3bb..c02f468b6d97 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -20,6 +20,7 @@ #include "mozilla/Constants.h" #include "mozilla/FloatingPoint.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/MemoryReporting.h" #include @@ -94,7 +95,7 @@ MathCache::MathCache() { } size_t -MathCache::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) +MathCache::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(this); } diff --git a/js/src/jsmath.h b/js/src/jsmath.h index a7eb3f4c854f..ff373de05cba 100644 --- a/js/src/jsmath.h +++ b/js/src/jsmath.h @@ -7,6 +7,8 @@ #ifndef jsmath_h #define jsmath_h +#include "mozilla/MemoryReporting.h" + #include "jsapi.h" namespace js { @@ -44,7 +46,7 @@ class MathCache return (e.out = f(x)); } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); }; } /* namespace js */ diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 0cf3a62aae50..6df6a1743be0 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -11,6 +11,7 @@ #include +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "jstypes.h" @@ -5308,7 +5309,7 @@ js_DumpBacktrace(JSContext *cx) fprintf(stdout, "%s", sprinter.string()); } void -JSObject::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, JS::ObjectsExtraSizes *sizes) +JSObject::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::ObjectsExtraSizes *sizes) { if (hasDynamicSlots()) sizes->slots = mallocSizeOf(slots); diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 50b7ce6046fc..b6706a354418 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -15,6 +15,9 @@ * values, called slots. The map/slot pointer pair is GC'ed, while the map * is reference counted and the slot vector is malloc'ed. */ + +#include "mozilla/MemoryReporting.h" + #include "jsapi.h" #include "jsatom.h" #include "jsclass.h" @@ -336,7 +339,7 @@ class JSObject : public js::ObjectImpl inline bool hasShapeTable() const; - void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, JS::ObjectsExtraSizes *sizes); + void sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::ObjectsExtraSizes *sizes); bool hasIdempotentProtoChain() const; diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index bd5778f8b401..b58e4638bd3b 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -12,6 +12,7 @@ #include +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "jstypes.h" @@ -1356,7 +1357,7 @@ ScriptSource::destroy() } size_t -ScriptSource::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) +ScriptSource::sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { // |data| is a union, but both members are pointers to allocated memory, // |emptySource|, or NULL, so just using |data.compressed| will work. @@ -1953,7 +1954,7 @@ JSScript::computedSizeOfData() } size_t -JSScript::sizeOfData(JSMallocSizeOfFun mallocSizeOf) +JSScript::sizeOfData(mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(data); } diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 79a66a16e62e..a0c95014c2e7 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -9,6 +9,7 @@ #ifndef jsscript_h #define jsscript_h +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "jsdbgapi.h" @@ -346,7 +347,7 @@ struct ScriptSource } const jschar *chars(JSContext *cx); JSStableString *substring(JSContext *cx, uint32_t start, uint32_t stop); - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); // XDR handling template @@ -851,7 +852,7 @@ class JSScript : public js::gc::Cell * (which can be larger than the in-use size). */ size_t computedSizeOfData(); - size_t sizeOfData(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfData(mozilla::MallocSizeOf mallocSizeOf); uint32_t numNotes(); /* Number of srcnote slots in the srcnotes section */ @@ -1258,7 +1259,7 @@ class LazyScript : public js::gc::Cell void markChildren(JSTracer *trc); void finalize(js::FreeOp *fop); - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(table_); } diff --git a/js/src/vm/ArgumentsObject-inl.h b/js/src/vm/ArgumentsObject-inl.h index fefefc876488..a95694617b11 100644 --- a/js/src/vm/ArgumentsObject-inl.h +++ b/js/src/vm/ArgumentsObject-inl.h @@ -9,6 +9,8 @@ #include "vm/ArgumentsObject.h" +#include "mozilla/MemoryReporting.h" + #include "vm/ScopeObject.h" namespace js { @@ -142,7 +144,7 @@ ArgumentsObject::maybeGetElements(uint32_t start, uint32_t count, Value *vp) } inline size_t -ArgumentsObject::sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const +ArgumentsObject::sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(data()); } diff --git a/js/src/vm/ArgumentsObject.h b/js/src/vm/ArgumentsObject.h index 26767d7c7e93..8d29afdeaf9f 100644 --- a/js/src/vm/ArgumentsObject.h +++ b/js/src/vm/ArgumentsObject.h @@ -7,6 +7,8 @@ #ifndef vm_ArgumentsObject_h #define vm_ArgumentsObject_h +#include "mozilla/MemoryReporting.h" + #include "jsfun.h" namespace js { @@ -203,7 +205,7 @@ class ArgumentsObject : public JSObject * Measures things hanging off this ArgumentsObject that are counted by the * |miscSize| argument in JSObject::sizeOfExcludingThis(). */ - inline size_t sizeOfMisc(JSMallocSizeOfFun mallocSizeOf) const; + inline size_t sizeOfMisc(mozilla::MallocSizeOf mallocSizeOf) const; static void finalize(FreeOp *fop, JSObject *obj); static void trace(JSTracer *trc, JSObject *obj); diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index 4ed84963b5c2..86ca20abfac2 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -6,6 +6,8 @@ #include "vm/RegExpObject.h" +#include "mozilla/MemoryReporting.h" + #include "frontend/TokenStream.h" #include "vm/MatchPairs.h" @@ -724,7 +726,7 @@ RegExpCompartment::get(JSContext *cx, HandleAtom atom, JSString *opt, RegExpGuar } size_t -RegExpCompartment::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) +RegExpCompartment::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += map_.sizeOfExcludingThis(mallocSizeOf); diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h index 2d70d66c5ad3..dc2dca7885be 100644 --- a/js/src/vm/RegExpObject.h +++ b/js/src/vm/RegExpObject.h @@ -8,6 +8,7 @@ #define vm_RegExpObject_h #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include #include "jscntxt.h" @@ -279,7 +280,7 @@ class RegExpCompartment /* Like 'get', but compile 'maybeOpt' (if non-null). */ bool get(JSContext *cx, HandleAtom source, JSString *maybeOpt, RegExpGuard *g); - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf); }; class RegExpObject : public JSObject diff --git a/js/src/vm/RegExpStatics-inl.h b/js/src/vm/RegExpStatics-inl.h index f33e008e882a..e7c69b41ad9b 100644 --- a/js/src/vm/RegExpStatics-inl.h +++ b/js/src/vm/RegExpStatics-inl.h @@ -7,6 +7,8 @@ #ifndef vm_RegExpStatics_inl_h #define vm_RegExpStatics_inl_h +#include "mozilla/MemoryReporting.h" + #include "vm/RegExpStatics.h" #include "gc/Marking.h" @@ -211,7 +213,7 @@ js::GlobalObject::getRegExpStatics() const } inline size_t -SizeOfRegExpStaticsData(const JSObject *obj, JSMallocSizeOfFun mallocSizeOf) +SizeOfRegExpStaticsData(const JSObject *obj, mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(obj->getPrivate()); } diff --git a/js/src/vm/RegExpStatics.h b/js/src/vm/RegExpStatics.h index 4778d00a1713..491972bf95b7 100644 --- a/js/src/vm/RegExpStatics.h +++ b/js/src/vm/RegExpStatics.h @@ -7,6 +7,8 @@ #ifndef vm_RegExpStatics_h #define vm_RegExpStatics_h +#include "mozilla/MemoryReporting.h" + #include #include "jspubtd.h" @@ -18,7 +20,7 @@ namespace js { class PreserveRegExpStatics; class RegExpStatics; -size_t SizeOfRegExpStaticsData(const JSObject *obj, JSMallocSizeOfFun mallocSizeOf); +size_t SizeOfRegExpStaticsData(const JSObject *obj, mozilla::MallocSizeOf mallocSizeOf); } /* namespace js */ diff --git a/js/src/vm/Shape.h b/js/src/vm/Shape.h index d1f5ed9fb9a0..71d12dcb32ef 100644 --- a/js/src/vm/Shape.h +++ b/js/src/vm/Shape.h @@ -9,6 +9,7 @@ #include "mozilla/Attributes.h" #include "mozilla/GuardObjects.h" +#include "mozilla/MemoryReporting.h" #include "jsobj.h" #include "jspropertytree.h" @@ -144,7 +145,7 @@ struct ShapeTable { * This counts the ShapeTable object itself (which must be * heap-allocated) and its |entries| array. */ - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + mallocSizeOf(entries); } @@ -548,7 +549,7 @@ class Shape : public js::gc::Cell bool hasTable() const { return base()->hasTable(); } ShapeTable &table() const { return base()->table(); } - void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf, + void sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t *propTableSize, size_t *kidsSize) const { *propTableSize = hasTable() ? table().sizeOfIncludingThis(mallocSizeOf) : 0; *kidsSize = !inDictionary() && kids.isHash() diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index 900ded1c7f95..abd97d21c4eb 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -7,6 +7,8 @@ #ifndef vm_Stack_h #define vm_Stack_h +#include "mozilla/MemoryReporting.h" + #include "jsautooplen.h" #include "jsfun.h" #include "jsscript.h" @@ -1074,7 +1076,7 @@ class InterpreterStack inline void purge(JSRuntime *rt); - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return allocator_.sizeOfExcludingThis(mallocSizeOf); } }; diff --git a/js/src/vm/String.cpp b/js/src/vm/String.cpp index 34de8b730a0e..d2b8d8633637 100644 --- a/js/src/vm/String.cpp +++ b/js/src/vm/String.cpp @@ -6,6 +6,7 @@ #include "vm/String.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "mozilla/RangedPtr.h" @@ -40,7 +41,7 @@ JSString::isExternal() const } size_t -JSString::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) +JSString::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { // JSRope: do nothing, we'll count all children chars when we hit the leaf strings. if (isRope()) diff --git a/js/src/vm/String.h b/js/src/vm/String.h index 1e29fbfb6894..b6823605d870 100644 --- a/js/src/vm/String.h +++ b/js/src/vm/String.h @@ -7,6 +7,7 @@ #ifndef vm_String_h #define vm_String_h +#include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" #include "jsapi.h" @@ -396,7 +397,7 @@ class JSString : public js::gc::Cell /* Gets the number of bytes that the chars take on the heap. */ - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf); + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf); /* Offsets for direct field from jit code. */ diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 963c9960ef60..bca9068de7c5 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -6,6 +6,7 @@ /* Private maps (hashtables). */ +#include "mozilla/MemoryReporting.h" #include "xpcprivate.h" #include "js/HashTable.h" @@ -148,7 +149,7 @@ Native2WrappedNativeMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) /* static */ size_t Native2WrappedNativeMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, - JSMallocSizeOfFun mallocSizeOf, void *) + mozilla::MallocSizeOf mallocSizeOf, void *) { return mallocSizeOf(((Native2WrappedNativeMap::Entry*)hdr)->value); } @@ -237,7 +238,7 @@ IID2NativeInterfaceMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) /* static */ size_t IID2NativeInterfaceMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, - JSMallocSizeOfFun mallocSizeOf, void *) + mozilla::MallocSizeOf mallocSizeOf, void *) { XPCNativeInterface *iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value; return iface->SizeOfIncludingThis(mallocSizeOf); @@ -320,7 +321,7 @@ ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSiz /* static */ size_t ClassInfo2WrappedNativeProtoMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, - JSMallocSizeOfFun mallocSizeOf, void *) + mozilla::MallocSizeOf mallocSizeOf, void *) { return mallocSizeOf(((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value); } @@ -443,7 +444,7 @@ NativeSetMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) } /* static */ size_t -NativeSetMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *) +NativeSetMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *) { XPCNativeSet *set = ((NativeSetMap::Entry*)hdr)->key_value; return set->SizeOfIncludingThis(mallocSizeOf); diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 168acaec67c2..725885fcf435 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -9,6 +9,8 @@ #ifndef xpcmaps_h___ #define xpcmaps_h___ +#include "mozilla/MemoryReporting.h" + #include "js/HashTable.h" // Maps... @@ -143,7 +145,7 @@ private: Native2WrappedNativeMap(); // no implementation Native2WrappedNativeMap(int size); - static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *); + static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *); private: PLDHashTable *mTable; @@ -262,7 +264,7 @@ private: IID2NativeInterfaceMap(); // no implementation IID2NativeInterfaceMap(int size); - static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *); + static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *); private: PLDHashTable *mTable; @@ -381,7 +383,7 @@ private: ClassInfo2WrappedNativeProtoMap(); // no implementation ClassInfo2WrappedNativeProtoMap(int size); - static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *); + static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *); private: PLDHashTable *mTable; @@ -454,7 +456,7 @@ private: NativeSetMap(); // no implementation NativeSetMap(int size); - static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, JSMallocSizeOfFun mallocSizeOf, void *); + static size_t SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *); private: PLDHashTable *mTable; From 6f4758d23e9a1939814ba49827805670a75fae5b Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 23 Jun 2013 14:03:39 +0200 Subject: [PATCH 05/45] Bug 798914 (part 5) - Use newly introduced mozilla::MallocSizeOf instead of nsMallocSizeOfFun. r=njn. --HG-- extra : rebase_source : fc472490dd978d165f02f77ed37f07aed6e5bb61 --- caps/src/nsNullPrincipalURI.cpp | 5 ++- caps/src/nsNullPrincipalURI.h | 5 ++- content/base/public/FragmentOrElement.h | 3 +- content/base/public/nsINode.h | 3 +- content/base/src/FragmentOrElement.cpp | 5 ++- content/base/src/Link.cpp | 3 +- content/base/src/Link.h | 3 +- content/base/src/nsAttrAndChildArray.cpp | 3 +- content/base/src/nsAttrAndChildArray.h | 3 +- content/base/src/nsAttrValue.cpp | 3 +- content/base/src/nsAttrValue.h | 3 +- content/base/src/nsDOMAttributeMap.cpp | 5 ++- content/base/src/nsDOMAttributeMap.h | 3 +- content/base/src/nsDocument.cpp | 7 ++-- content/base/src/nsDocument.h | 3 +- content/base/src/nsGenericDOMDataNode.cpp | 3 +- content/base/src/nsINode.cpp | 3 +- content/base/src/nsMappedAttributes.cpp | 3 +- content/base/src/nsMappedAttributes.h | 3 +- content/base/src/nsPropertyTable.cpp | 7 ++-- content/base/src/nsPropertyTable.h | 3 +- content/base/src/nsTextFragment.cpp | 3 +- content/base/src/nsTextFragment.h | 3 +- content/base/src/nsXMLHttpRequest.cpp | 3 +- content/base/src/nsXMLHttpRequest.h | 3 +- content/canvas/src/WebGLBuffer.h | 3 +- content/canvas/src/WebGLElementArrayCache.cpp | 5 ++- content/canvas/src/WebGLElementArrayCache.h | 3 +- content/canvas/src/WebGLShader.cpp | 3 +- content/canvas/src/WebGLShader.h | 3 +- content/events/src/nsEventListenerManager.cpp | 3 +- content/events/src/nsEventListenerManager.h | 3 +- .../html/content/src/HTMLAnchorElement.cpp | 3 +- content/html/content/src/HTMLAreaElement.cpp | 3 +- content/html/content/src/HTMLLinkElement.cpp | 3 +- dom/base/Navigator.cpp | 3 +- dom/base/Navigator.h | 3 +- dom/base/nsGlobalWindow.cpp | 3 +- dom/base/nsIJSEventListener.h | 5 ++- dom/base/nsISizeOfEventTarget.h | 3 +- dom/base/nsScriptNameSpaceManager.cpp | 7 ++-- dom/base/nsScriptNameSpaceManager.h | 3 +- dom/base/nsWindowMemoryReporter.h | 7 ++-- dom/src/events/nsJSEventListener.h | 3 +- gfx/thebes/gfxASurface.cpp | 5 ++- gfx/thebes/gfxASurface.h | 5 ++- gfx/thebes/gfxDWriteFontList.cpp | 13 ++++--- gfx/thebes/gfxDWriteFontList.h | 13 ++++--- gfx/thebes/gfxDWriteFonts.cpp | 5 ++- gfx/thebes/gfxDWriteFonts.h | 5 ++- gfx/thebes/gfxFT2FontList.cpp | 5 ++- gfx/thebes/gfxFT2FontList.h | 6 ++- gfx/thebes/gfxFT2Fonts.cpp | 5 ++- gfx/thebes/gfxFT2Fonts.h | 5 ++- gfx/thebes/gfxFont.cpp | 37 +++++++++--------- gfx/thebes/gfxFont.h | 39 ++++++++++--------- gfx/thebes/gfxFontUtils.h | 5 ++- gfx/thebes/gfxGDIFont.cpp | 5 ++- gfx/thebes/gfxGDIFont.h | 5 ++- gfx/thebes/gfxGDIFontList.cpp | 7 ++-- gfx/thebes/gfxGDIFontList.h | 7 ++-- gfx/thebes/gfxImageSurface.cpp | 5 ++- gfx/thebes/gfxImageSurface.h | 5 ++- gfx/thebes/gfxMacFont.cpp | 5 ++- gfx/thebes/gfxMacFont.h | 5 ++- gfx/thebes/gfxMacPlatformFontList.h | 3 +- gfx/thebes/gfxMacPlatformFontList.mm | 3 +- gfx/thebes/gfxPlatformFontList.cpp | 21 +++++----- gfx/thebes/gfxPlatformFontList.h | 7 ++-- image/src/FrameBlender.cpp | 3 +- image/src/FrameBlender.h | 3 +- image/src/Image.h | 5 ++- image/src/ImageWrapper.cpp | 5 ++- image/src/ImageWrapper.h | 5 ++- image/src/RasterImage.cpp | 7 ++-- image/src/RasterImage.h | 7 ++-- image/src/VectorImage.cpp | 5 ++- image/src/VectorImage.h | 5 ++- image/src/imgFrame.cpp | 3 +- image/src/imgFrame.h | 3 +- js/xpconnect/src/XPCJSRuntime.cpp | 3 +- js/xpconnect/src/XPCMaps.cpp | 10 ++--- js/xpconnect/src/XPCMaps.h | 12 +++--- js/xpconnect/src/XPCWrappedNativeInfo.cpp | 5 ++- js/xpconnect/src/XPCWrappedNativeScope.cpp | 5 ++- js/xpconnect/src/xpcprivate.h | 11 +++--- layout/base/FramePropertyTable.cpp | 5 ++- layout/base/FramePropertyTable.h | 7 ++-- layout/base/StackArena.cpp | 3 +- layout/base/StackArena.h | 3 +- layout/base/nsIPresShell.h | 3 +- layout/base/nsLayoutUtils.cpp | 3 +- layout/base/nsLayoutUtils.h | 3 +- layout/base/nsPresArena.cpp | 5 ++- layout/base/nsPresArena.h | 5 ++- layout/base/nsPresContext.cpp | 5 ++- layout/base/nsPresContext.h | 9 +++-- layout/base/nsPresShell.cpp | 5 ++- layout/base/nsPresShell.h | 5 ++- layout/base/nsStyleSheetService.cpp | 7 ++-- layout/base/nsStyleSheetService.h | 5 ++- layout/generic/nsTextRunTransformations.cpp | 5 ++- layout/generic/nsTextRunTransformations.h | 5 ++- layout/style/AnimationCommon.cpp | 5 ++- layout/style/AnimationCommon.h | 5 ++- layout/style/Declaration.cpp | 3 +- layout/style/Declaration.h | 3 +- layout/style/GroupRule.h | 5 ++- layout/style/ImportRule.h | 3 +- layout/style/Loader.cpp | 7 ++-- layout/style/Loader.h | 3 +- layout/style/NameSpaceRule.h | 3 +- layout/style/Rule.h | 5 ++- layout/style/StyleRule.cpp | 11 +++--- layout/style/StyleRule.h | 11 +++--- layout/style/nsAnimationManager.cpp | 5 ++- layout/style/nsAnimationManager.h | 5 ++- layout/style/nsCSSDataBlock.cpp | 3 +- layout/style/nsCSSDataBlock.h | 3 +- layout/style/nsCSSRuleProcessor.cpp | 21 +++++----- layout/style/nsCSSRuleProcessor.h | 5 ++- layout/style/nsCSSRules.cpp | 27 ++++++------- layout/style/nsCSSRules.h | 19 ++++----- layout/style/nsCSSStyleSheet.cpp | 5 ++- layout/style/nsCSSStyleSheet.h | 5 ++- layout/style/nsCSSValue.cpp | 27 ++++++------- layout/style/nsCSSValue.h | 27 ++++++------- layout/style/nsHTMLCSSStyleSheet.cpp | 5 ++- layout/style/nsHTMLCSSStyleSheet.h | 5 ++- layout/style/nsHTMLStyleSheet.cpp | 9 +++-- layout/style/nsHTMLStyleSheet.h | 7 ++-- layout/style/nsIStyleRuleProcessor.h | 5 ++- layout/style/nsIStyleSheet.h | 3 +- layout/style/nsLayoutStylesheetCache.cpp | 5 ++- layout/style/nsLayoutStylesheetCache.h | 5 ++- layout/style/nsStyleSet.cpp | 3 +- layout/style/nsStyleSet.h | 3 +- layout/style/nsTransitionManager.cpp | 5 ++- layout/style/nsTransitionManager.h | 5 ++- memory/replace/dmd/DMD.cpp | 3 +- modules/libpref/src/Preferences.cpp | 3 +- modules/libpref/src/nsPrefBranch.h | 3 +- modules/libpref/src/prefapi.cpp | 3 +- modules/libpref/src/prefapi_private_data.h | 4 +- netwerk/base/src/nsSimpleURI.cpp | 5 ++- netwerk/base/src/nsSimpleURI.h | 5 ++- netwerk/base/src/nsStandardURL.cpp | 5 ++- netwerk/base/src/nsStandardURL.h | 5 ++- netwerk/cache/nsDiskCacheBinding.cpp | 5 ++- netwerk/cache/nsDiskCacheBinding.h | 3 +- netwerk/cache/nsDiskCacheBlockFile.cpp | 3 +- netwerk/cache/nsDiskCacheBlockFile.h | 3 +- netwerk/cache/nsDiskCacheDevice.cpp | 3 +- netwerk/cache/nsDiskCacheDevice.h | 3 +- netwerk/cache/nsDiskCacheMap.cpp | 3 +- netwerk/cache/nsDiskCacheMap.h | 3 +- netwerk/cache/nsDiskCacheStreams.cpp | 3 +- netwerk/cache/nsDiskCacheStreams.h | 3 +- netwerk/dns/nsEffectiveTLDService.cpp | 3 +- netwerk/dns/nsEffectiveTLDService.h | 3 +- startupcache/StartupCache.cpp | 5 ++- startupcache/StartupCache.h | 7 ++-- toolkit/components/places/History.cpp | 5 ++- toolkit/components/places/History.h | 5 ++- .../components/places/tests/cpp/mock_Link.h | 5 ++- toolkit/components/telemetry/Telemetry.cpp | 7 ++-- .../nsUrlClassifierPrefixSet.cpp | 3 +- .../url-classifier/nsUrlClassifierPrefixSet.h | 3 +- xpcom/base/CycleCollectedJSRuntime.cpp | 3 +- xpcom/base/CycleCollectedJSRuntime.h | 3 +- xpcom/base/nsCycleCollector.cpp | 13 ++++--- xpcom/base/nsISizeOf.h | 5 ++- xpcom/base/nscore.h | 6 --- xpcom/components/nsCategoryManager.cpp | 7 ++-- xpcom/components/nsCategoryManager.h | 5 ++- xpcom/components/nsComponentManager.cpp | 9 +++-- xpcom/components/nsComponentManager.h | 5 ++- xpcom/ds/nsAtomTable.cpp | 11 +++--- xpcom/ds/nsAtomTable.h | 3 +- xpcom/glue/nsBaseHashtable.h | 11 +++--- xpcom/glue/nsCOMArray.cpp | 3 +- xpcom/glue/nsCOMArray.h | 9 +++-- xpcom/glue/nsTArray.h | 5 ++- xpcom/glue/nsTHashtable.h | 9 +++-- xpcom/glue/nsTObserverArray.h | 3 +- xpcom/glue/nsVoidArray.cpp | 5 ++- xpcom/glue/nsVoidArray.h | 5 ++- xpcom/glue/pldhash.cpp | 7 ++-- xpcom/glue/pldhash.h | 7 ++-- .../xptinfo/public/XPTInterfaceInfoManager.h | 3 +- .../xptinfo/src/xptiInterfaceInfoManager.cpp | 3 +- xpcom/string/public/nsStringBuffer.h | 8 ++-- xpcom/string/public/nsTSubstring.h | 14 ++++--- xpcom/string/src/nsSubstring.cpp | 8 ++-- xpcom/string/src/nsTSubstring.cpp | 13 ++++--- 195 files changed, 665 insertions(+), 474 deletions(-) diff --git a/caps/src/nsNullPrincipalURI.cpp b/caps/src/nsNullPrincipalURI.cpp index 5c9405488be4..bf52ecab7ebb 100644 --- a/caps/src/nsNullPrincipalURI.cpp +++ b/caps/src/nsNullPrincipalURI.cpp @@ -4,6 +4,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "nsNullPrincipalURI.h" #include "nsNetUtil.h" #include "nsEscape.h" @@ -272,14 +273,14 @@ nsNullPrincipalURI::SchemeIs(const char *aScheme, bool *_schemeIs) //// nsISizeOf size_t -nsNullPrincipalURI::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsNullPrincipalURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf); } size_t -nsNullPrincipalURI::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { +nsNullPrincipalURI::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/caps/src/nsNullPrincipalURI.h b/caps/src/nsNullPrincipalURI.h index f4c3b27c23f7..7ab5d8b9be47 100644 --- a/caps/src/nsNullPrincipalURI.h +++ b/caps/src/nsNullPrincipalURI.h @@ -16,6 +16,7 @@ #include "nsAutoPtr.h" #include "nsString.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" // {51fcd543-3b52-41f7-b91b-6b54102236e6} #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \ @@ -30,8 +31,8 @@ public: NS_DECL_NSIURI // nsISizeOf - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsNullPrincipalURI(const nsCString &aSpec); diff --git a/content/base/public/FragmentOrElement.h b/content/base/public/FragmentOrElement.h index 98135e93b85e..acecd0d5522b 100644 --- a/content/base/public/FragmentOrElement.h +++ b/content/base/public/FragmentOrElement.h @@ -13,6 +13,7 @@ #define FragmentOrElement_h___ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsAttrAndChildArray.h" // member #include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_* #include "nsIContent.h" // base class @@ -298,7 +299,7 @@ public: void Traverse(nsCycleCollectionTraversalCallback &cb, bool aIsXUL); void Unlink(bool aIsXUL); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; /** * The .style attribute (an interface that forwards to the actual diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 8d725a5e8306..da9895466eb4 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -17,6 +17,7 @@ #include "nsPropertyTable.h" // for typedefs #include "nsTObserverArray.h" // for member #include "nsWindowMemoryReporter.h" // for NS_DECL_SIZEOF_EXCLUDING_THIS +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/EventTarget.h" // for base class // Including 'windows.h' will #define GetClassInfo to something else. @@ -299,7 +300,7 @@ public: // way that |this| points to the start of the allocated object, even in // methods of nsINode's sub-classes, and so |aMallocSizeOf(this)| is always // safe to call no matter which object it was invoked on. - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index 226d7e3ce07f..2d81a2b01630 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -10,6 +10,7 @@ * utility methods for subclasses, and so forth. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/Likely.h" @@ -593,7 +594,7 @@ FragmentOrElement::nsDOMSlots::Unlink(bool aIsXUL) } size_t -FragmentOrElement::nsDOMSlots::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +FragmentOrElement::nsDOMSlots::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); @@ -1834,7 +1835,7 @@ FragmentOrElement::FireNodeRemovedForChildren() } size_t -FragmentOrElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +FragmentOrElement::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; n += nsIContent::SizeOfExcludingThis(aMallocSizeOf); diff --git a/content/base/src/Link.cpp b/content/base/src/Link.cpp index f3299250b40c..6d9848ccd2a0 100644 --- a/content/base/src/Link.cpp +++ b/content/base/src/Link.cpp @@ -6,6 +6,7 @@ #include "Link.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsEventStates.h" #include "nsIURL.h" @@ -500,7 +501,7 @@ Link::SetHrefAttribute(nsIURI *aURI) } size_t -Link::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; diff --git a/content/base/src/Link.h b/content/base/src/Link.h index a07408ad452a..4edceb0cada0 100644 --- a/content/base/src/Link.h +++ b/content/base/src/Link.h @@ -12,6 +12,7 @@ #define mozilla_dom_Link_h__ #include "mozilla/IHistory.h" +#include "mozilla/MemoryReporting.h" #include "nsIContent.h" namespace mozilla { @@ -98,7 +99,7 @@ public: virtual bool HasDeferredDNSPrefetchRequest() { return true; } virtual size_t - SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; bool ElementHasHref() const; diff --git a/content/base/src/nsAttrAndChildArray.cpp b/content/base/src/nsAttrAndChildArray.cpp index af0aa6959398..cb9ff3786bab 100644 --- a/content/base/src/nsAttrAndChildArray.cpp +++ b/content/base/src/nsAttrAndChildArray.cpp @@ -8,6 +8,7 @@ * the two is unified to minimize footprint. */ +#include "mozilla/MemoryReporting.h" #include "nsAttrAndChildArray.h" #include "nsMappedAttributeElement.h" #include "prbit.h" @@ -836,7 +837,7 @@ nsAttrAndChildArray::SetChildAtPos(void** aPos, nsIContent* aChild, } size_t -nsAttrAndChildArray::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsAttrAndChildArray::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; if (mImpl) { diff --git a/content/base/src/nsAttrAndChildArray.h b/content/base/src/nsAttrAndChildArray.h index fc260dbba32e..442de27925d7 100644 --- a/content/base/src/nsAttrAndChildArray.h +++ b/content/base/src/nsAttrAndChildArray.h @@ -12,6 +12,7 @@ #define nsAttrAndChildArray_h___ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nscore.h" #include "nsAttrName.h" @@ -116,7 +117,7 @@ public: !AttrSlotIsTaken(ATTRCHILD_ARRAY_MAX_ATTR_COUNT - 1); } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; bool HasMappedAttrs() const { return MappedAttrCount(); diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp index 932fad10002b..70fd5b78cc8a 100644 --- a/content/base/src/nsAttrValue.cpp +++ b/content/base/src/nsAttrValue.cpp @@ -15,6 +15,7 @@ #include "nsAttrValueInlines.h" #include "nsIAtom.h" #include "nsUnicharUtils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" #include "mozilla/css/Declaration.h" #include "nsContentUtils.h" @@ -1949,7 +1950,7 @@ nsAttrValue::StringToInteger(const nsAString& aValue, bool* aStrict, } size_t -nsAttrValue::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsAttrValue::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; diff --git a/content/base/src/nsAttrValue.h b/content/base/src/nsAttrValue.h index 7298a66e7991..473bd74b82b1 100644 --- a/content/base/src/nsAttrValue.h +++ b/content/base/src/nsAttrValue.h @@ -21,6 +21,7 @@ #include "SVGAttrValueWrapper.h" #include "nsTArrayForwardDeclare.h" #include "nsIAtom.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/BindingDeclarations.h" class nsAString; @@ -371,7 +372,7 @@ public: bool ParseStyleAttribute(const nsAString& aString, nsStyledElementNotElementCSSInlineStyle* aElement); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: // These have to be the same as in ValueType diff --git a/content/base/src/nsDOMAttributeMap.cpp b/content/base/src/nsDOMAttributeMap.cpp index 2a2628070579..7c4faa3b5056 100644 --- a/content/base/src/nsDOMAttributeMap.cpp +++ b/content/base/src/nsDOMAttributeMap.cpp @@ -9,6 +9,7 @@ #include "nsDOMAttributeMap.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Attr.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/MozNamedAttrMapBinding.h" @@ -533,14 +534,14 @@ nsDOMAttributeMap::Enumerate(AttrCache::EnumReadFunction aFunc, size_t AttrCacheSizeEnumerator(const nsAttrKey& aKey, const nsRefPtr& aValue, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { return aMallocSizeOf(aValue.get()); } size_t -nsDOMAttributeMap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsDOMAttributeMap::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mAttributeCache.SizeOfExcludingThis(AttrCacheSizeEnumerator, diff --git a/content/base/src/nsDOMAttributeMap.h b/content/base/src/nsDOMAttributeMap.h index f4fb093fe5fd..f4db2a8a4e85 100644 --- a/content/base/src/nsDOMAttributeMap.h +++ b/content/base/src/nsDOMAttributeMap.h @@ -10,6 +10,7 @@ #ifndef nsDOMAttributeMap_h #define nsDOMAttributeMap_h +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Attr.h" #include "mozilla/ErrorResult.h" #include "nsCycleCollectionParticipant.h" @@ -181,7 +182,7 @@ public: // No supported names we want to show up in iteration. } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsCOMPtr mContent; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index df40c4b787d2..f73ad50fa6d7 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -9,6 +9,7 @@ */ #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/Likely.h" #include @@ -452,7 +453,7 @@ nsIdentifierMapEntry::HasIdElementExposedAsHTMLDocumentProperty() // static size_t nsIdentifierMapEntry::SizeOfExcludingThis(nsIdentifierMapEntry* aEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void*) { return aEntry->GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf); @@ -11066,14 +11067,14 @@ nsIDocument::DocSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const static size_t SizeOfStyleSheetsElementIncludingThis(nsIStyleSheet* aStyleSheet, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aData) { return aStyleSheet->SizeOfIncludingThis(aMallocSizeOf); } size_t -nsDocument::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsDocument::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { // This SizeOfExcludingThis() overrides the one from nsINode. But // nsDocuments can only appear at the top of the DOM tree, and we use the diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 507a0710b66b..77e2c1a859d7 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -62,6 +62,7 @@ #include "nsISecurityEventSink.h" #include "nsIChannelEventSink.h" #include "imgIRequest.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/DOMImplementation.h" #include "nsIDOMTouchEvent.h" #include "nsIInlineEventHandlers.h" @@ -224,7 +225,7 @@ public: }; static size_t SizeOfExcludingThis(nsIdentifierMapEntry* aEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aArg); private: diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 2efc6cd62a0d..8807b7410533 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -11,6 +11,7 @@ #include "mozilla/DebugOnly.h" #include "nsGenericDOMDataNode.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsIDocument.h" #include "nsEventListenerManager.h" @@ -920,7 +921,7 @@ nsGenericDOMDataNode::GetClassAttributeName() const } size_t -nsGenericDOMDataNode::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsGenericDOMDataNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = nsIContent::SizeOfExcludingThis(aMallocSizeOf); n += mText.SizeOfExcludingThis(aMallocSizeOf); diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 4601dd6892ba..d1e4f617e195 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -15,6 +15,7 @@ #include "mozAutoDocUpdate.h" #include "mozilla/CORSMode.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" #include "mozilla/Util.h" #include "nsAsyncDOMEvent.h" @@ -2074,7 +2075,7 @@ nsINode::UnbindObject(nsISupports* aObject) } size_t -nsINode::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; nsEventListenerManager* elm = diff --git a/content/base/src/nsMappedAttributes.cpp b/content/base/src/nsMappedAttributes.cpp index bd5dbeb00631..6b5f93527373 100644 --- a/content/base/src/nsMappedAttributes.cpp +++ b/content/base/src/nsMappedAttributes.cpp @@ -12,6 +12,7 @@ #include "nsHTMLStyleSheet.h" #include "nsRuleWalker.h" #include "mozilla/HashFunctions.h" +#include "mozilla/MemoryReporting.h" using namespace mozilla; @@ -248,7 +249,7 @@ nsMappedAttributes::IndexOfAttr(nsIAtom* aLocalName) const } size_t -nsMappedAttributes::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsMappedAttributes::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { NS_ASSERTION(mAttrCount == mBufferSize, "mBufferSize and mAttrCount are expected to be the same."); diff --git a/content/base/src/nsMappedAttributes.h b/content/base/src/nsMappedAttributes.h index 5477a0361a91..4954495e1326 100644 --- a/content/base/src/nsMappedAttributes.h +++ b/content/base/src/nsMappedAttributes.h @@ -15,6 +15,7 @@ #include "nsMappedAttributeElement.h" #include "nsIStyleRule.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class nsIAtom; class nsHTMLStyleSheet; @@ -77,7 +78,7 @@ public: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; #endif - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsMappedAttributes(const nsMappedAttributes& aCopy); diff --git a/content/base/src/nsPropertyTable.cpp b/content/base/src/nsPropertyTable.cpp index 61823bc3e803..af4b504f9192 100644 --- a/content/base/src/nsPropertyTable.cpp +++ b/content/base/src/nsPropertyTable.cpp @@ -20,6 +20,7 @@ * nsIAtom pointers, and the values are void pointers. */ +#include "mozilla/MemoryReporting.h" #include "nsPropertyTable.h" #include "pldhash.h" #include "nsError.h" @@ -52,7 +53,7 @@ public: return mName == aPropertyName; } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); nsCOMPtr mName; // property name PLDHashTable mObjectValueMap; // map of object/value pairs @@ -340,7 +341,7 @@ nsPropertyTable::PropertyList::DeletePropertyFor(nsPropertyOwner aObject) } size_t -nsPropertyTable::PropertyList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsPropertyTable::PropertyList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); n += PL_DHashTableSizeOfExcludingThis(&mObjectValueMap, nullptr, aMallocSizeOf); @@ -348,7 +349,7 @@ nsPropertyTable::PropertyList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSize } size_t -nsPropertyTable::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsPropertyTable::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; diff --git a/content/base/src/nsPropertyTable.h b/content/base/src/nsPropertyTable.h index 7ca2646f5235..849122cddd09 100644 --- a/content/base/src/nsPropertyTable.h +++ b/content/base/src/nsPropertyTable.h @@ -23,6 +23,7 @@ #ifndef nsPropertyTable_h_ #define nsPropertyTable_h_ +#include "mozilla/MemoryReporting.h" #include "nscore.h" class nsIAtom; @@ -176,7 +177,7 @@ class nsPropertyTable class PropertyList; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: NS_HIDDEN_(void) DestroyPropertyList(); diff --git a/content/base/src/nsTextFragment.cpp b/content/base/src/nsTextFragment.cpp index 8aa630702125..1641ef5b7f90 100644 --- a/content/base/src/nsTextFragment.cpp +++ b/content/base/src/nsTextFragment.cpp @@ -16,6 +16,7 @@ #include "nsBidiUtils.h" #include "nsUnicharUtils.h" #include "nsUTF8Utils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/SSE.h" #include "nsTextFragmentImpl.h" #include @@ -392,7 +393,7 @@ nsTextFragment::Append(const PRUnichar* aBuffer, uint32_t aLength, bool aUpdateB } /* virtual */ size_t -nsTextFragment::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsTextFragment::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { if (Is2b()) { return aMallocSizeOf(m2b); diff --git a/content/base/src/nsTextFragment.h b/content/base/src/nsTextFragment.h index 1a9d74429bdf..93bf86675407 100644 --- a/content/base/src/nsTextFragment.h +++ b/content/base/src/nsTextFragment.h @@ -12,6 +12,7 @@ #define nsTextFragment_h___ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsString.h" #include "nsReadableUtils.h" @@ -174,7 +175,7 @@ public: uint32_t mLength : 29; }; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: void ReleaseText(); diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 38748de674ac..7055d4b9844b 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -4,6 +4,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "nsXMLHttpRequest.h" @@ -534,7 +535,7 @@ nsXMLHttpRequest::DisconnectFromOwner() size_t nsXMLHttpRequest::SizeOfEventTargetIncludingThis( - nsMallocSizeOfFun aMallocSizeOf) const + MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mResponseBody.SizeOfExcludingThisIfUnshared(aMallocSizeOf); diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index 76a3a9948a79..c1ff64048a90 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -37,6 +37,7 @@ #include "nsISizeOfEventTarget.h" #include "mozilla/Assertions.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/dom/XMLHttpRequestBinding.h" @@ -227,7 +228,7 @@ public: // nsISizeOfEventTarget virtual size_t - SizeOfEventTargetIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + SizeOfEventTargetIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsXHREventTarget) diff --git a/content/canvas/src/WebGLBuffer.h b/content/canvas/src/WebGLBuffer.h index 718011e57684..cd4060dcb27a 100644 --- a/content/canvas/src/WebGLBuffer.h +++ b/content/canvas/src/WebGLBuffer.h @@ -13,6 +13,7 @@ #include "nsWrapperCache.h" #include "mozilla/LinkedList.h" +#include "mozilla/MemoryReporting.h" namespace mozilla { @@ -32,7 +33,7 @@ public: void Delete(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t sizeOfCache = mCache ? mCache->SizeOfIncludingThis(aMallocSizeOf) : 0; return aMallocSizeOf(this) + sizeOfCache; } diff --git a/content/canvas/src/WebGLElementArrayCache.cpp b/content/canvas/src/WebGLElementArrayCache.cpp index 5780935500b8..e40099666ab6 100644 --- a/content/canvas/src/WebGLElementArrayCache.cpp +++ b/content/canvas/src/WebGLElementArrayCache.cpp @@ -7,6 +7,7 @@ #include "nsTArray.h" #include "mozilla/Assertions.h" +#include "mozilla/MemoryReporting.h" #include #include @@ -306,7 +307,7 @@ public: void Update(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + mTreeData.SizeOfExcludingThis(aMallocSizeOf); } @@ -558,7 +559,7 @@ bool WebGLElementArrayCache::Validate(GLenum type, uint32_t maxAllowed, size_t f return false; } -size_t WebGLElementArrayCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { +size_t WebGLElementArrayCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t uint8TreeSize = mUint8Tree ? mUint8Tree->SizeOfIncludingThis(aMallocSizeOf) : 0; size_t uint16TreeSize = mUint16Tree ? mUint16Tree->SizeOfIncludingThis(aMallocSizeOf) : 0; size_t uint32TreeSize = mUint32Tree ? mUint32Tree->SizeOfIncludingThis(aMallocSizeOf) : 0; diff --git a/content/canvas/src/WebGLElementArrayCache.h b/content/canvas/src/WebGLElementArrayCache.h index 68d1f582ea64..19276a1eaa57 100644 --- a/content/canvas/src/WebGLElementArrayCache.h +++ b/content/canvas/src/WebGLElementArrayCache.h @@ -6,6 +6,7 @@ #ifndef WEBGLELEMENTARRAYCACHE_H #define WEBGLELEMENTARRAYCACHE_H +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" #include "nscore.h" #include "GLDefs.h" @@ -47,7 +48,7 @@ public: ~WebGLElementArrayCache(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: diff --git a/content/canvas/src/WebGLShader.cpp b/content/canvas/src/WebGLShader.cpp index 1a0aae7430cb..fe02d6563a5c 100644 --- a/content/canvas/src/WebGLShader.cpp +++ b/content/canvas/src/WebGLShader.cpp @@ -6,6 +6,7 @@ #include "WebGLObjectModel.h" #include "WebGLShader.h" #include "WebGLContext.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" #include "nsContentUtils.h" @@ -39,7 +40,7 @@ WebGLShader::Delete() { } size_t -WebGLShader::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { +WebGLShader::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + mSource.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + mTranslationLog.SizeOfExcludingThisIfUnshared(aMallocSizeOf); diff --git a/content/canvas/src/WebGLShader.h b/content/canvas/src/WebGLShader.h index 4cc73862c6db..fb6ce919d20e 100644 --- a/content/canvas/src/WebGLShader.h +++ b/content/canvas/src/WebGLShader.h @@ -14,6 +14,7 @@ #include "angle/ShaderLang.h" #include "mozilla/LinkedList.h" +#include "mozilla/MemoryReporting.h" namespace mozilla { @@ -39,7 +40,7 @@ public: DeleteOnce(); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; WebGLuint GLName() { return mGLName; } WebGLenum ShaderType() { return mType; } diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 08561413be50..328ebfc1f7df 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -24,6 +24,7 @@ #include "nsLayoutUtils.h" #include "nsINameSpaceManager.h" #include "nsIContent.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsIFrame.h" #include "nsView.h" @@ -1275,7 +1276,7 @@ nsEventListenerManager::GetEventHandlerInternal(nsIAtom *aEventName) } size_t -nsEventListenerManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsEventListenerManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); diff --git a/content/events/src/nsEventListenerManager.h b/content/events/src/nsEventListenerManager.h index 28babc0d741b..b4778f129efb 100644 --- a/content/events/src/nsEventListenerManager.h +++ b/content/events/src/nsEventListenerManager.h @@ -18,6 +18,7 @@ #include "nsTObserverArray.h" #include "nsGUIEvent.h" #include "nsIJSEventListener.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventListenerBinding.h" @@ -400,7 +401,7 @@ public: bool MayHaveMouseEnterLeaveEventListener() { return mMayHaveMouseEnterLeaveEventListener; } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; void MarkForCC(); diff --git a/content/html/content/src/HTMLAnchorElement.cpp b/content/html/content/src/HTMLAnchorElement.cpp index e03854a9fcdd..d2d7515de3c7 100644 --- a/content/html/content/src/HTMLAnchorElement.cpp +++ b/content/html/content/src/HTMLAnchorElement.cpp @@ -4,6 +4,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLAnchorElement.h" #include "mozilla/dom/HTMLAnchorElementBinding.h" @@ -413,7 +414,7 @@ HTMLAnchorElement::IntrinsicState() const } size_t -HTMLAnchorElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +HTMLAnchorElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) + Link::SizeOfExcludingThis(aMallocSizeOf); diff --git a/content/html/content/src/HTMLAreaElement.cpp b/content/html/content/src/HTMLAreaElement.cpp index 741520bd3dd8..b5df88361c30 100644 --- a/content/html/content/src/HTMLAreaElement.cpp +++ b/content/html/content/src/HTMLAreaElement.cpp @@ -4,6 +4,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLAreaElement.h" #include "mozilla/dom/HTMLAreaElementBinding.h" #include "base/compiler_specific.h" @@ -232,7 +233,7 @@ HTMLAreaElement::IntrinsicState() const } size_t -HTMLAreaElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +HTMLAreaElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) + Link::SizeOfExcludingThis(aMallocSizeOf); diff --git a/content/html/content/src/HTMLLinkElement.cpp b/content/html/content/src/HTMLLinkElement.cpp index 065d24def1ab..320b6894f31d 100644 --- a/content/html/content/src/HTMLLinkElement.cpp +++ b/content/html/content/src/HTMLLinkElement.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/HTMLLinkElement.h" #include "mozilla/dom/HTMLLinkElementBinding.h" @@ -404,7 +405,7 @@ HTMLLinkElement::IntrinsicState() const } size_t -HTMLLinkElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +HTMLLinkElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) + Link::SizeOfExcludingThis(aMallocSizeOf); diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 9723211bd426..a92cf03d42fe 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -11,6 +11,7 @@ #include "nsIXULAppInfo.h" #include "nsPluginArray.h" #include "nsMimeTypeArray.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/DesktopNotification.h" #include "nsGeolocation.h" #include "nsIHttpProtocolHandler.h" @@ -1536,7 +1537,7 @@ Navigator::GetMozCameras(nsISupports** aCameraManager) } size_t -Navigator::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +Navigator::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 24bc76c9c2fe..0646ac62c885 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_Navigator_h #define mozilla_dom_Navigator_h +#include "mozilla/MemoryReporting.h" #include "nsIDOMNavigator.h" #include "nsIDOMNavigatorGeolocation.h" #include "nsIDOMNavigatorDeviceStorage.h" @@ -200,7 +201,7 @@ public: static bool HasDesktopNotificationSupport(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; /** * For use during document.write where our inner window changes. diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 134b54922057..ebf48a4da480 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8,6 +8,7 @@ #include /* This must occur *after* base/basictypes.h to avoid typedefs conflicts. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" // Local Includes @@ -11224,7 +11225,7 @@ nsGlobalWindow::HasIndexedDBSupport() static size_t SizeOfEventTargetObjectsEntryExcludingThisFun( nsPtrHashKey *aEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void *arg) { nsISupports *supports = aEntry->GetKey(); diff --git a/dom/base/nsIJSEventListener.h b/dom/base/nsIJSEventListener.h index 1fc9e50e16a4..c7395d9cb960 100644 --- a/dom/base/nsIJSEventListener.h +++ b/dom/base/nsIJSEventListener.h @@ -11,6 +11,7 @@ #include "xpcpublic.h" #include "nsIDOMEventListener.h" #include "nsIAtom.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/EventHandlerBinding.h" #define NS_IJSEVENTLISTENER_IID \ @@ -236,7 +237,7 @@ public: mHandler.SetHandler(aHandler); } - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return 0; @@ -252,7 +253,7 @@ public: // - mEventName: shared with others } - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/dom/base/nsISizeOfEventTarget.h b/dom/base/nsISizeOfEventTarget.h index 6a9d0405f2f0..718b5cac8df6 100644 --- a/dom/base/nsISizeOfEventTarget.h +++ b/dom/base/nsISizeOfEventTarget.h @@ -7,6 +7,7 @@ #ifndef nsISizeOfEventTarget_h___ #define nsISizeOfEventTarget_h___ +#include "mozilla/MemoryReporting.h" #include "nsISupports.h" #define NS_ISIZEOFEVENTTARGET_IID \ @@ -31,7 +32,7 @@ public: * itself. */ virtual size_t - SizeOfEventTargetIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const = 0; + SizeOfEventTargetIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsISizeOfEventTarget, NS_ISIZEOFEVENTTARGET_IID) diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index ac32f4cd1881..b1b0bf4a85e0 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -27,6 +27,7 @@ #include "nsCRT.h" #include "nsIObserverService.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" @@ -43,7 +44,7 @@ public: nsString mKey; nsGlobalNameStruct mGlobalName; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) { // Measurement of the following members may be added later if DMD finds it // is worthwhile: // - mGlobalName @@ -877,7 +878,7 @@ nsScriptNameSpaceManager::EnumerateGlobalNames(GlobalNameEnumerator aEnumerator, } static size_t -SizeOfEntryExcludingThis(PLDHashEntryHdr *aHdr, nsMallocSizeOfFun aMallocSizeOf, +SizeOfEntryExcludingThis(PLDHashEntryHdr *aHdr, MallocSizeOf aMallocSizeOf, void *aArg) { GlobalNameMapEntry* entry = static_cast(aHdr); @@ -885,7 +886,7 @@ SizeOfEntryExcludingThis(PLDHashEntryHdr *aHdr, nsMallocSizeOfFun aMallocSizeOf, } size_t -nsScriptNameSpaceManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsScriptNameSpaceManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = 0; n += PL_DHashTableSizeOfExcludingThis(&mGlobalNames, diff --git a/dom/base/nsScriptNameSpaceManager.h b/dom/base/nsScriptNameSpaceManager.h index a8adc4fbdfb3..02d922937d67 100644 --- a/dom/base/nsScriptNameSpaceManager.h +++ b/dom/base/nsScriptNameSpaceManager.h @@ -21,6 +21,7 @@ #ifndef nsScriptNameSpaceManager_h__ #define nsScriptNameSpaceManager_h__ +#include "mozilla/MemoryReporting.h" #include "nsIScriptNameSpaceManager.h" #include "nsString.h" #include "nsID.h" @@ -156,7 +157,7 @@ public: void EnumerateGlobalNames(GlobalNameEnumerator aEnumerator, void* aClosure); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: // Adds a new entry to the hash and returns the nsGlobalNameStruct diff --git a/dom/base/nsWindowMemoryReporter.h b/dom/base/nsWindowMemoryReporter.h index 2ea5ca01ec81..77b37d88b8fe 100644 --- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -12,6 +12,7 @@ #include "nsDataHashtable.h" #include "nsWeakReference.h" #include "nsAutoPtr.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "nsArenaMemoryStats.h" #include "mozilla/Attributes.h" @@ -21,15 +22,15 @@ // SizeOfExcludingThis from its super-class. SizeOfIncludingThis() need not be // defined, it is inherited from nsINode. #define NS_DECL_SIZEOF_EXCLUDING_THIS \ - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; class nsWindowSizes { public: - nsWindowSizes(nsMallocSizeOfFun aMallocSizeOf) { + nsWindowSizes(mozilla::MallocSizeOf aMallocSizeOf) { memset(this, 0, sizeof(nsWindowSizes)); mMallocSizeOf = aMallocSizeOf; } - nsMallocSizeOfFun mMallocSizeOf; + mozilla::MallocSizeOf mMallocSizeOf; nsArenaMemoryStats mArenaStats; size_t mDOMElementNodes; size_t mDOMTextNodes; diff --git a/dom/src/events/nsJSEventListener.h b/dom/src/events/nsJSEventListener.h index 5570b6e81878..bc8e83e5763e 100644 --- a/dom/src/events/nsJSEventListener.h +++ b/dom/src/events/nsJSEventListener.h @@ -7,6 +7,7 @@ #define nsJSEventListener_h__ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsIDOMKeyEvent.h" #include "nsIJSEventListener.h" #include "nsIDOMEventListener.h" @@ -33,7 +34,7 @@ public: // nsIJSEventListener - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index f7d189b1e5db..884837c476b9 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -8,6 +8,7 @@ #include "mozilla/Base64.h" #include "mozilla/CheckedInt.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "gfxASurface.h" #include "gfxContext.h" @@ -671,14 +672,14 @@ gfxASurface::RecordMemoryFreed() } size_t -gfxASurface::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxASurface::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { // We don't measure mSurface because cairo doesn't allow it. return 0; } size_t -gfxASurface::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxASurface::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/thebes/gfxASurface.h b/gfx/thebes/gfxASurface.h index 53b2bd755655..a4af6c161f37 100644 --- a/gfx/thebes/gfxASurface.h +++ b/gfx/thebes/gfxASurface.h @@ -10,6 +10,7 @@ #define MOZ_DUMP_IMAGES #endif +#include "mozilla/MemoryReporting.h" #include "gfxTypes.h" #include "gfxRect.h" #include "nsAutoPtr.h" @@ -210,8 +211,8 @@ public: virtual int32_t KnownMemoryUsed() { return mBytesRecorded; } - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; // gfxASurface has many sub-classes. This method indicates if a sub-class // is capable of measuring its own size accurately. If not, the caller // must fall back to a computed size. (Note that gfxASurface can actually diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index bef515fe5b19..f8e3b728e42e 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #ifdef MOZ_LOGGING @@ -213,7 +214,7 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName) } void -gfxDWriteFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontFamily::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { gfxFontFamily::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -222,7 +223,7 @@ gfxDWriteFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxDWriteFontFamily::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontFamily::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); @@ -555,7 +556,7 @@ gfxDWriteFontEntry::IsCJKFont() } void -gfxDWriteFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -564,7 +565,7 @@ gfxDWriteFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxDWriteFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); @@ -1218,7 +1219,7 @@ gfxDWriteFontList::ResolveFontName(const nsAString& aFontName, } void -gfxDWriteFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -1236,7 +1237,7 @@ gfxDWriteFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxDWriteFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 7c56ec1b6430..1a1c17372307 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -6,6 +6,7 @@ #ifndef GFX_DWRITEFONTLIST_H #define GFX_DWRITEFONTLIST_H +#include "mozilla/MemoryReporting.h" #include "gfxDWriteCommon.h" #include "gfxFont.h" @@ -48,9 +49,9 @@ public: void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; } - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; protected: @@ -152,9 +153,9 @@ public: void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; } bool GetForceGDIClassic() { return mForceGDIClassic; } - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; protected: @@ -365,9 +366,9 @@ public: gfxFloat GetForceGDIClassicMaxFontSize() { return mForceGDIClassicMaxFontSize; } - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; private: diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index c43870a94ac5..47fb0363128a 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "gfxDWriteFonts.h" #include "gfxDWriteShaper.h" #include "gfxHarfBuzzShaper.h" @@ -668,7 +669,7 @@ gfxDWriteFont::MeasureGlyphWidth(uint16_t aGlyph) } void -gfxDWriteFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -677,7 +678,7 @@ gfxDWriteFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxDWriteFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxDWriteFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxDWriteFonts.h b/gfx/thebes/gfxDWriteFonts.h index 660c2a955680..6d3e365b112c 100644 --- a/gfx/thebes/gfxDWriteFonts.h +++ b/gfx/thebes/gfxDWriteFonts.h @@ -6,6 +6,7 @@ #ifndef GFX_WINDOWSDWRITEFONTS_H #define GFX_WINDOWSDWRITEFONTS_H +#include "mozilla/MemoryReporting.h" #include #include "gfxFont.h" @@ -58,9 +59,9 @@ public: virtual mozilla::TemporaryRef GetGlyphRenderingOptions(); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; virtual FontType GetType() const { return FONT_TYPE_DWRITE; } diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 409b80660e1c..9c4bc642f5cc 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #if defined(MOZ_WIDGET_GTK2) @@ -464,7 +465,7 @@ FT2FontEntry::CopyFontTable(uint32_t aTableTag, } void -FT2FontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +FT2FontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { gfxFontEntry::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -473,7 +474,7 @@ FT2FontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -FT2FontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +FT2FontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index ddfedbee703b..098ba9658dbc 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -6,6 +6,8 @@ #ifndef GFX_FT2FONTLIST_H #define GFX_FT2FONTLIST_H +#include "mozilla/MemoryReporting.h" + #ifdef XP_WIN #include "gfxWindowsPlatform.h" #include @@ -74,9 +76,9 @@ public: // accordingly so that we avoid using bad font tables void CheckForBrokenFont(gfxFontFamily *aFamily); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; FT_Face mFTFace; diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index 3da4ad6f3579..02209d8615cf 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -35,6 +35,7 @@ #include "prlog.h" #include "prinit.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" // rounding and truncation functions for a Freetype floating point number @@ -642,7 +643,7 @@ gfxFT2Font::FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd) } void -gfxFT2Font::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFT2Font::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -651,7 +652,7 @@ gfxFT2Font::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxFT2Font::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFT2Font::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxFT2Fonts.h b/gfx/thebes/gfxFT2Fonts.h index fd64e76817e0..014b1f03b353 100644 --- a/gfx/thebes/gfxFT2Fonts.h +++ b/gfx/thebes/gfxFT2Fonts.h @@ -6,6 +6,7 @@ #ifndef GFX_FT2FONTS_H #define GFX_FT2FONTS_H +#include "mozilla/MemoryReporting.h" #include "cairo.h" #include "gfxTypes.h" #include "gfxFont.h" @@ -63,9 +64,9 @@ public: // new functions return &entry->mData; } - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; protected: diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 4ab5214a7c5e..79dada4b97a8 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -35,6 +35,7 @@ #include "nsStyleConsts.h" #include "mozilla/FloatingPoint.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" #include "mozilla/Telemetry.h" @@ -325,10 +326,10 @@ public: mHashKey = 0; } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return mTableData.SizeOfExcludingThis(aMallocSizeOf); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } @@ -576,7 +577,7 @@ gfxFontEntry::CheckForGraphiteTables() /* static */ size_t gfxFontEntry::FontTableHashEntry::SizeOfEntryExcludingThis (FontTableHashEntry *aEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { FontListSizes *sizes = static_cast(aUserArg); @@ -594,7 +595,7 @@ gfxFontEntry::FontTableHashEntry::SizeOfEntryExcludingThis } void -gfxFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf); @@ -611,7 +612,7 @@ gfxFontEntry::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); @@ -1197,7 +1198,7 @@ gfxFontFamily::FindFont(const nsAString& aPostscriptName) } void -gfxFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontFamily::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += @@ -1216,7 +1217,7 @@ gfxFontFamily::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxFontFamily::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontFamily::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); @@ -1476,7 +1477,7 @@ gfxFontCache::ClearCachedWordsForFont(HashEntry* aHashEntry, void* aUserData) /*static*/ size_t gfxFontCache::SizeOfFontEntryExcludingThis(HashEntry* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { HashEntry *entry = static_cast(aHashEntry); @@ -1489,7 +1490,7 @@ gfxFontCache::SizeOfFontEntryExcludingThis(HashEntry* aHashEntry, } void -gfxFontCache::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontCache::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { // TODO: add the overhead of the expiration tracker (generation arrays) @@ -1499,7 +1500,7 @@ gfxFontCache::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxFontCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFontCache::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); @@ -3671,14 +3672,14 @@ gfxFont::SynthesizeSpaceWidth(uint32_t aCh) /*static*/ size_t gfxFont::WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { return aMallocSizeOf(aHashEntry->mShapedWord.get()); } void -gfxFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { for (uint32_t i = 0; i < mGlyphExtentsArray.Length(); ++i) { @@ -3691,7 +3692,7 @@ gfxFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); @@ -3748,7 +3749,7 @@ gfxGlyphExtents::GlyphWidths::~GlyphWidths() } uint32_t -gfxGlyphExtents::GlyphWidths::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxGlyphExtents::GlyphWidths::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { uint32_t i; uint32_t size = mBlocks.SizeOfExcludingThis(aMallocSizeOf); @@ -3812,14 +3813,14 @@ gfxGlyphExtents::SetTightGlyphExtents(uint32_t aGlyphID, const gfxRect& aExtents } size_t -gfxGlyphExtents::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxGlyphExtents::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return mContainedGlyphWidths.SizeOfExcludingThis(aMallocSizeOf) + mTightGlyphExtents.SizeOfExcludingThis(nullptr, aMallocSizeOf); } size_t -gfxGlyphExtents::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxGlyphExtents::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } @@ -6547,7 +6548,7 @@ gfxTextRun::ClusterIterator::ClusterAdvance(PropertyProvider *aProvider) const } size_t -gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +gfxTextRun::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) { // The second arg is how much gfxTextRun::AllocateStorage would have // allocated. @@ -6561,7 +6562,7 @@ gfxTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) } size_t -gfxTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +gfxTextRun::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 6eecca8584c2..631652b03271 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -25,6 +25,7 @@ #include "mozilla/HashFunctions.h" #include "nsIMemoryReporter.h" #include "gfxFontFeatures.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/gfx/Types.h" #include "mozilla/Attributes.h" #include @@ -196,7 +197,7 @@ public: void CalcHash() { mHash = GetChecksum(); } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return gfxSparseBitSet::SizeOfExcludingThis(aMallocSizeOf); } @@ -411,9 +412,9 @@ public: virtual void ReleaseGrFace(gr_face* aFace); // For memory reporting - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; nsString mName; @@ -620,7 +621,7 @@ private: static size_t SizeOfEntryExcludingThis(FontTableHashEntry *aEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aUserArg); private: @@ -781,9 +782,9 @@ public: void CheckForSimpleFamily(); // For memory reporter - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; // Only used for debugging checks - does a linear search @@ -949,9 +950,9 @@ public: mFonts.EnumerateEntries(ClearCachedWordsForFont, nullptr); } - void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; protected: @@ -996,7 +997,7 @@ protected: }; static size_t SizeOfFontEntryExcludingThis(HashEntry* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aUserArg); nsTHashtable mFonts; @@ -1170,8 +1171,8 @@ public: int32_t GetAppUnitsPerDevUnit() { return mAppUnitsPerDevUnit; } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: class HashEntry : public nsUint32HashKey { @@ -1208,7 +1209,7 @@ private: return widths[indexInBlock]; } - uint32_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + uint32_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; ~GlyphWidths(); @@ -1675,9 +1676,9 @@ public: } } - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; typedef enum { @@ -1885,7 +1886,7 @@ protected: static size_t WordCacheEntrySizeOfExcludingThis(CacheHashEntry* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aUserArg); nsTHashtable mWordCache; @@ -2378,7 +2379,7 @@ protected: return details; } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { return aMallocSizeOf(this) + mDetails.SizeOfExcludingThis(aMallocSizeOf) + mOffsetToIndex.SizeOfExcludingThis(aMallocSizeOf); @@ -3136,13 +3137,13 @@ public: // return storage used by this run, for memory reporter; // nsTransformedTextRun needs to override this as it holds additional data - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) MOZ_MUST_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) MOZ_MUST_OVERRIDE; // Get the size, if it hasn't already been gotten, marking as it goes. - size_t MaybeSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { + size_t MaybeSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { if (mFlags & gfxTextRunFactory::TEXT_RUN_SIZE_ACCOUNTED) { return 0; } diff --git a/gfx/thebes/gfxFontUtils.h b/gfx/thebes/gfxFontUtils.h index 3651f7796256..e7de1cf9f240 100644 --- a/gfx/thebes/gfxFontUtils.h +++ b/gfx/thebes/gfxFontUtils.h @@ -23,6 +23,7 @@ #include "nsAutoPtr.h" #include "mozilla/Likely.h" #include "mozilla/Endian.h" +#include "mozilla/MemoryReporting.h" #include "zlib.h" #include @@ -257,7 +258,7 @@ public: } } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t total = mBlocks.SizeOfExcludingThis(aMallocSizeOf); for (uint32_t i = 0; i < mBlocks.Length(); i++) { if (mBlocks[i]) { @@ -267,7 +268,7 @@ public: return total; } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 91d0e6019df0..2550823bbe45 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "gfxGDIFont.h" #include "gfxGDIShaper.h" #include "gfxUniscribeShaper.h" @@ -551,7 +552,7 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID) } void -gfxGDIFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxGDIFont::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -560,7 +561,7 @@ gfxGDIFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxGDIFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxGDIFont::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxGDIFont.h b/gfx/thebes/gfxGDIFont.h index 26f9a2e00b5a..ea331c4420ba 100644 --- a/gfx/thebes/gfxGDIFont.h +++ b/gfx/thebes/gfxGDIFont.h @@ -6,6 +6,7 @@ #ifndef GFX_GDIFONT_H #define GFX_GDIFONT_H +#include "mozilla/MemoryReporting.h" #include "gfxFont.h" #include "gfxGDIFontList.h" @@ -53,9 +54,9 @@ public: // get hinted glyph width in pixels as 16.16 fixed-point value virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; virtual FontType GetType() const { return FONT_TYPE_GDI; } diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 2378b0e90b64..6cb11a8c944a 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -27,6 +27,7 @@ #include "nsISimpleEnumerator.h" #include "nsIWindowsRegKey.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" #include @@ -444,7 +445,7 @@ GDIFontEntry::CreateFontEntry(const nsAString& aName, } void -GDIFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +GDIFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); @@ -1065,7 +1066,7 @@ gfxGDIFontList::ResolveFontName(const nsAString& aFontName, nsAString& aResolved } void -gfxGDIFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxGDIFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { gfxPlatformFontList::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -1081,7 +1082,7 @@ gfxGDIFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxGDIFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxGDIFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index af6f70d6b13c..5268d69a6372 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -6,6 +6,7 @@ #ifndef GFX_GDIFONTLIST_H #define GFX_GDIFONTLIST_H +#include "mozilla/MemoryReporting.h" #include "gfxWindowsPlatform.h" #include "gfxPlatformFontList.h" #include "nsGkAtoms.h" @@ -239,7 +240,7 @@ public: virtual bool TestCharacterMap(uint32_t aCh); - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; // create a font entry for a font with a given name @@ -321,9 +322,9 @@ public: virtual bool ResolveFontName(const nsAString& aFontName, nsAString& aResolvedFontName); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; private: diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index a1a27110ec64..d2e45b162176 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/MemoryReporting.h" #include "gfxAlphaRecovery.h" #include "gfxImageSurface.h" @@ -197,7 +198,7 @@ gfxImageSurface::ComputeStride(const gfxIntSize& aSize, gfxImageFormat aFormat) } size_t -gfxImageSurface::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxImageSurface::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = gfxASurface::SizeOfExcludingThis(aMallocSizeOf); if (mOwnsData) { @@ -207,7 +208,7 @@ gfxImageSurface::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -gfxImageSurface::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +gfxImageSurface::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/gfx/thebes/gfxImageSurface.h b/gfx/thebes/gfxImageSurface.h index 16651535f26e..de1696f8dfe8 100644 --- a/gfx/thebes/gfxImageSurface.h +++ b/gfx/thebes/gfxImageSurface.h @@ -6,6 +6,7 @@ #ifndef GFX_IMAGESURFACE_H #define GFX_IMAGESURFACE_H +#include "mozilla/MemoryReporting.h" #include "gfxASurface.h" #include "gfxPoint.h" @@ -113,9 +114,9 @@ public: static long ComputeStride(const gfxIntSize&, gfxImageFormat); - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; virtual bool SizeOfIsMeasured() const MOZ_OVERRIDE; diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 51f3e4c4ba0c..7bae46d125ac 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "gfxMacFont.h" #include "gfxCoreTextShaper.h" #include "gfxHarfBuzzShaper.h" @@ -410,7 +411,7 @@ gfxMacFont::GetScaledFont(DrawTarget *aTarget) } void -gfxMacFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxMacFont::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { gfxFont::SizeOfExcludingThis(aMallocSizeOf, aSizes); @@ -419,7 +420,7 @@ gfxMacFont::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxMacFont::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +gfxMacFont::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const { aSizes->mFontInstances += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxMacFont.h b/gfx/thebes/gfxMacFont.h index 4cc36668acbd..5d55be21d803 100644 --- a/gfx/thebes/gfxMacFont.h +++ b/gfx/thebes/gfxMacFont.h @@ -6,6 +6,7 @@ #ifndef GFX_MACFONT_H #define GFX_MACFONT_H +#include "mozilla/MemoryReporting.h" #include "gfxFont.h" #include "gfxMacPlatformFontList.h" #include "mozilla/gfx/2D.h" @@ -42,9 +43,9 @@ public: virtual mozilla::TemporaryRef GetScaledFont(mozilla::gfx::DrawTarget *aTarget); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontCacheSizes* aSizes) const; virtual FontType GetType() const { return FONT_TYPE_MAC; } diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index cd39de3b0ca7..f3f7be7f78a0 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -6,6 +6,7 @@ #ifndef gfxMacPlatformFontList_H_ #define gfxMacPlatformFontList_H_ +#include "mozilla/MemoryReporting.h" #include "nsDataHashtable.h" #include "nsRefPtrHashtable.h" @@ -44,7 +45,7 @@ public: // use CGFontRef API to get direct access to system font data virtual hb_blob_t *GetFontTable(uint32_t aTag) MOZ_OVERRIDE; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; nsresult ReadCMAP(); diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index edd2b92a77eb..c0725ccb0d7f 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -63,6 +63,7 @@ #include "nsISimpleEnumerator.h" #include "nsCharTraits.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" @@ -423,7 +424,7 @@ MacOSFontEntry::HasFontTable(uint32_t aTableTag) } void -MacOSFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +MacOSFontEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index c95338102e23..60584906c0c2 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -16,6 +16,7 @@ #include "mozilla/Attributes.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" @@ -764,7 +765,7 @@ gfxPlatformFontList::GetPrefsAndStartLoader() static size_t SizeOfFamilyEntryExcludingThis(const nsAString& aKey, const nsRefPtr& aFamily, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { FontListSizes *sizes = static_cast(aUserArg); @@ -782,7 +783,7 @@ SizeOfFamilyEntryExcludingThis(const nsAString& aKey, gfxPlatformFontList::SizeOfFamilyNameEntryExcludingThis (const nsAString& aKey, const nsRefPtr& aFamily, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { // we don't count the size of the family here, because this is an *extra* @@ -793,7 +794,7 @@ gfxPlatformFontList::SizeOfFamilyNameEntryExcludingThis static size_t SizeOfFontNameEntryExcludingThis(const nsAString& aKey, const nsRefPtr& aFont, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { // the font itself is counted by its owning family; here we only care about @@ -805,7 +806,7 @@ static size_t SizeOfPrefFontEntryExcludingThis (const uint32_t& aKey, const nsTArray >& aList, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { // again, we only care about the size of the array itself; we don't follow @@ -816,7 +817,7 @@ SizeOfPrefFontEntryExcludingThis static size_t SizeOfStringEntryExcludingThis(nsStringHashKey* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { return aHashEntry->GetKey().SizeOfExcludingThisIfUnshared(aMallocSizeOf); @@ -824,7 +825,7 @@ SizeOfStringEntryExcludingThis(nsStringHashKey* aHashEntry, static size_t SizeOfSharedCmapExcludingThis(CharMapHashKey* aHashEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { FontListSizes *sizes = static_cast(aUserArg); @@ -838,8 +839,8 @@ SizeOfSharedCmapExcludingThis(CharMapHashKey* aHashEntry, } void -gfxPlatformFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, - FontListSizes* aSizes) const +gfxPlatformFontList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, + FontListSizes* aSizes) const { aSizes->mFontListSize += mFontFamilies.SizeOfExcludingThis(SizeOfFamilyEntryExcludingThis, @@ -877,8 +878,8 @@ gfxPlatformFontList::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, } void -gfxPlatformFontList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, - FontListSizes* aSizes) const +gfxPlatformFontList::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, + FontListSizes* aSizes) const { aSizes->mFontListSize += aMallocSizeOf(this); SizeOfExcludingThis(aMallocSizeOf, aSizes); diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index 8364303f8bcb..53c1c9474594 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -16,6 +16,7 @@ #include "nsIMemoryReporter.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class CharMapHashKey : public PLDHashEntryHdr { @@ -161,9 +162,9 @@ public: // (platforms may override, eg Mac) virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); - virtual void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const; // search for existing cmap that matches the input @@ -252,7 +253,7 @@ protected: static size_t SizeOfFamilyNameEntryExcludingThis(const nsAString& aKey, const nsRefPtr& aFamily, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aUserArg); // canonical family name ==> family entry (unique, one name per family entry) diff --git a/image/src/FrameBlender.cpp b/image/src/FrameBlender.cpp index 351583cbaa24..f427f43dc88e 100644 --- a/image/src/FrameBlender.cpp +++ b/image/src/FrameBlender.cpp @@ -5,6 +5,7 @@ #include "FrameBlender.h" +#include "mozilla/MemoryReporting.h" #include "RasterImage.h" #include "imgFrame.h" @@ -573,7 +574,7 @@ FrameBlender::Discard() size_t FrameBlender::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, - nsMallocSizeOfFun aMallocSizeOf) const + MallocSizeOf aMallocSizeOf) const { size_t n = 0; for (uint32_t i = 0; i < mFrames.Length(); ++i) { diff --git a/image/src/FrameBlender.h b/image/src/FrameBlender.h index ff2c89757c9b..f94c18c26481 100644 --- a/image/src/FrameBlender.h +++ b/image/src/FrameBlender.h @@ -8,6 +8,7 @@ #define mozilla_imagelib_FrameBlender_h_ #include "nsTArray.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "gfxASurface.h" @@ -57,7 +58,7 @@ public: void SetSize(nsIntSize aSize) { mSize = aSize; } size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, - nsMallocSizeOfFun aMallocSizeOf) const; + mozilla::MallocSizeOf aMallocSizeOf) const; void ResetAnimation(); diff --git a/image/src/Image.h b/image/src/Image.h index bf0b078d64d6..94919ae4735c 100644 --- a/image/src/Image.h +++ b/image/src/Image.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_IMAGELIB_IMAGE_H_ #define MOZILLA_IMAGELIB_IMAGE_H_ +#include "mozilla/MemoryReporting.h" #include "imgIContainer.h" #include "imgStatusTracker.h" #include "nsIURI.h" @@ -77,8 +78,8 @@ public: /** * The components that make up SizeOfData(). */ - virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const = 0; - virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const = 0; + virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const = 0; + virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const = 0; virtual size_t NonHeapSizeOfDecoded() const = 0; virtual size_t OutOfProcessSizeOfDecoded() const = 0; diff --git a/image/src/ImageWrapper.cpp b/image/src/ImageWrapper.cpp index 60e5f79a67bb..332a7f8e8318 100644 --- a/image/src/ImageWrapper.cpp +++ b/image/src/ImageWrapper.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "ImageWrapper.h" using mozilla::layers::LayerManager; @@ -38,13 +39,13 @@ ImageWrapper::SizeOfData() } size_t -ImageWrapper::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +ImageWrapper::HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const { return mInnerImage->HeapSizeOfSourceWithComputedFallback(aMallocSizeOf); } size_t -ImageWrapper::HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +ImageWrapper::HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const { return mInnerImage->HeapSizeOfDecodedWithComputedFallback(aMallocSizeOf); } diff --git a/image/src/ImageWrapper.h b/image/src/ImageWrapper.h index 068de35d7d5a..4283d4f99ab8 100644 --- a/image/src/ImageWrapper.h +++ b/image/src/ImageWrapper.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_IMAGELIB_IMAGEWRAPPER_H_ #define MOZILLA_IMAGELIB_IMAGEWRAPPER_H_ +#include "mozilla/MemoryReporting.h" #include "Image.h" namespace mozilla { @@ -29,8 +30,8 @@ public: virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; virtual uint32_t SizeOfData() MOZ_OVERRIDE; - virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; - virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; virtual size_t NonHeapSizeOfDecoded() const MOZ_OVERRIDE; virtual size_t OutOfProcessSizeOfDecoded() const MOZ_OVERRIDE; diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 526e3be3e8d7..db708742c726 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -38,6 +38,7 @@ #include "gfxContext.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" #include "mozilla/StandardInteger.h" @@ -1182,7 +1183,7 @@ RasterImage::UpdateImageContainer() } size_t -RasterImage::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +RasterImage::HeapSizeOfSourceWithComputedFallback(MallocSizeOf aMallocSizeOf) const { // n == 0 is possible for two reasons. // - This is a zero-length image. @@ -1197,7 +1198,7 @@ RasterImage::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeO size_t RasterImage::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, - nsMallocSizeOfFun aMallocSizeOf) const + MallocSizeOf aMallocSizeOf) const { size_t n = mFrameBlender.SizeOfDecodedWithComputedFallbackIfHeap(aLocation, aMallocSizeOf); @@ -1209,7 +1210,7 @@ RasterImage::SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation } size_t -RasterImage::HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +RasterImage::HeapSizeOfDecodedWithComputedFallback(MallocSizeOf aMallocSizeOf) const { return SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MEMORY_IN_PROCESS_HEAP, aMallocSizeOf); diff --git a/image/src/RasterImage.h b/image/src/RasterImage.h index b67898ed7476..596365707b78 100644 --- a/image/src/RasterImage.h +++ b/image/src/RasterImage.h @@ -29,6 +29,7 @@ #include "nsThreadUtils.h" #include "DiscardTracker.h" #include "nsISupportsImpl.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "mozilla/Telemetry.h" #include "mozilla/LinkedList.h" @@ -176,8 +177,8 @@ public: /* The total number of frames in this image. */ uint32_t GetNumFrames() const; - virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; virtual size_t NonHeapSizeOfDecoded() const; virtual size_t OutOfProcessSizeOfDecoded() const; @@ -589,7 +590,7 @@ private: mozilla::TimeStamp GetCurrentImgFrameEndTime() const; size_t SizeOfDecodedWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, - nsMallocSizeOfFun aMallocSizeOf) const; + mozilla::MallocSizeOf aMallocSizeOf) const; inline void EnsureAnimExists() { diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index c884bc8eca0c..63260e621e68 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -13,6 +13,7 @@ #include "gfxUtils.h" #include "imgDecoderObserver.h" #include "mozilla/AutoRestore.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/SVGSVGElement.h" #include "nsComponentManagerUtils.h" #include "nsIObserverService.h" @@ -341,7 +342,7 @@ VectorImage::FrameRect(uint32_t aWhichFrame) } size_t -VectorImage::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +VectorImage::HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const { // We're not storing the source data -- we just feed that directly to // our helper SVG document as we receive it, for it to parse. @@ -350,7 +351,7 @@ VectorImage::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeO } size_t -VectorImage::HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const +VectorImage::HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const { // XXXdholbert TODO: return num bytes used by helper SVG doc. (bug 590790) return 0; diff --git a/image/src/VectorImage.h b/image/src/VectorImage.h index 80746ddf9ffd..fbc21ba081f7 100644 --- a/image/src/VectorImage.h +++ b/image/src/VectorImage.h @@ -9,6 +9,7 @@ #include "Image.h" #include "nsIStreamListener.h" #include "nsIRequest.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "mozilla/WeakPtr.h" @@ -43,8 +44,8 @@ public: uint32_t aFlags); virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; - virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t HeapSizeOfSourceWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t HeapSizeOfDecodedWithComputedFallback(mozilla::MallocSizeOf aMallocSizeOf) const; virtual size_t NonHeapSizeOfDecoded() const; virtual size_t OutOfProcessSizeOfDecoded() const; diff --git a/image/src/imgFrame.cpp b/image/src/imgFrame.cpp index c1b4022396a0..ff20e3ce7bba 100644 --- a/image/src/imgFrame.cpp +++ b/image/src/imgFrame.cpp @@ -19,6 +19,7 @@ static bool gDisableOptimize = false; #include "cairo.h" #include "GeckoProfiler.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" #if defined(XP_WIN) @@ -801,7 +802,7 @@ void imgFrame::SetCompositingFailed(bool val) // |aMallocSizeOf|. If that fails (because the platform doesn't support it) or // it's non-heap memory, we fall back to computing the size analytically. size_t -imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, nsMallocSizeOfFun aMallocSizeOf) const +imgFrame::SizeOfExcludingThisWithComputedFallbackIfHeap(gfxASurface::MemoryLocation aLocation, mozilla::MallocSizeOf aMallocSizeOf) const { // aMallocSizeOf is only used if aLocation==MEMORY_IN_PROCESS_HEAP. It // should be NULL otherwise. diff --git a/image/src/imgFrame.h b/image/src/imgFrame.h index 440aa33ce70a..b667c4d381d3 100644 --- a/image/src/imgFrame.h +++ b/image/src/imgFrame.h @@ -7,6 +7,7 @@ #ifndef imgFrame_h #define imgFrame_h +#include "mozilla/MemoryReporting.h" #include "nsRect.h" #include "nsPoint.h" #include "nsSize.h" @@ -104,7 +105,7 @@ public: size_t SizeOfExcludingThisWithComputedFallbackIfHeap( gfxASurface::MemoryLocation aLocation, - nsMallocSizeOfFun aMallocSizeOf) const; + mozilla::MallocSizeOf aMallocSizeOf) const; uint8_t GetPaletteDepth() const { return mPaletteDepth; } uint32_t PaletteDataLength() const { diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index f6a6dbc6fcfc..0fc1baacba9f 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -6,6 +6,7 @@ /* Per JSRuntime object */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "xpcprivate.h" @@ -1116,7 +1117,7 @@ XPCJSRuntime::CTypesActivityCallback(JSContext *cx, js::CTypesActivityType type) } size_t -XPCJSRuntime::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +XPCJSRuntime::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index bca9068de7c5..2fe53f177fe7 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -139,7 +139,7 @@ Native2WrappedNativeMap::~Native2WrappedNativeMap() } size_t -Native2WrappedNativeMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +Native2WrappedNativeMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); @@ -228,7 +228,7 @@ IID2NativeInterfaceMap::~IID2NativeInterfaceMap() } size_t -IID2NativeInterfaceMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +IID2NativeInterfaceMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); @@ -271,7 +271,7 @@ ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap() } size_t -ClassInfo2NativeSetMap::ShallowSizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +ClassInfo2NativeSetMap::ShallowSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); @@ -311,7 +311,7 @@ ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap() } size_t -ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); @@ -435,7 +435,7 @@ NativeSetMap::~NativeSetMap() } size_t -NativeSetMap::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +NativeSetMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 725885fcf435..b921bd263130 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -70,7 +70,7 @@ public: void ShutdownMarker(JSRuntime* rt); - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) { + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { size_t n = mallocSizeOf(this); n += mTable.sizeOfExcludingThis(mallocSizeOf); return n; @@ -138,7 +138,7 @@ public: inline uint32_t Enumerate(PLDHashEnumerator f, void *arg) {return PL_DHashTableEnumerate(mTable, f, arg);} - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); ~Native2WrappedNativeMap(); private: @@ -257,7 +257,7 @@ public: inline uint32_t Enumerate(PLDHashEnumerator f, void *arg) {return PL_DHashTableEnumerate(mTable, f, arg);} - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); ~IID2NativeInterfaceMap(); private: @@ -320,7 +320,7 @@ public: // So we don't want to count those XPCNativeSets, because they are better // counted elsewhere (i.e. in XPCJSRuntime::mNativeSetMap, which holds // pointers to *all* XPCNativeSets). Hence the "Shallow". - size_t ShallowSizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t ShallowSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); ~ClassInfo2NativeSetMap(); private: @@ -376,7 +376,7 @@ public: inline uint32_t Enumerate(PLDHashEnumerator f, void *arg) {return PL_DHashTableEnumerate(mTable, f, arg);} - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); ~ClassInfo2WrappedNativeProtoMap(); private: @@ -449,7 +449,7 @@ public: inline uint32_t Enumerate(PLDHashEnumerator f, void *arg) {return PL_DHashTableEnumerate(mTable, f, arg);} - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); ~NativeSetMap(); private: diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index a900b78d48d4..8d51952d1b3e 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -9,6 +9,7 @@ #include "xpcprivate.h" #include "nsCxPusher.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/XPTInterfaceInfoManager.h" using namespace JS; @@ -388,7 +389,7 @@ XPCNativeInterface::DestroyInstance(XPCNativeInterface* inst) } size_t -XPCNativeInterface::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +XPCNativeInterface::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) { return mallocSizeOf(this); } @@ -798,7 +799,7 @@ XPCNativeSet::DestroyInstance(XPCNativeSet* inst) } size_t -XPCNativeSet::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +XPCNativeSet::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) { return mallocSizeOf(this); } diff --git a/js/xpconnect/src/XPCWrappedNativeScope.cpp b/js/xpconnect/src/XPCWrappedNativeScope.cpp index d477f3049c69..e89f4a015461 100644 --- a/js/xpconnect/src/XPCWrappedNativeScope.cpp +++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp @@ -11,6 +11,7 @@ #include "nsContentUtils.h" #include "nsCycleCollectionNoteRootCallback.h" #include "nsPrincipal.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/dom/BindingUtils.h" @@ -775,7 +776,7 @@ XPCWrappedNativeScope::DebugDump(int16_t depth) } size_t -XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(nsMallocSizeOfFun mallocSizeOf) +XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(MallocSizeOf mallocSizeOf) { XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance(); XPCAutoLock lock(rt->GetMapLock()); @@ -788,7 +789,7 @@ XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(nsMallocSizeOfFun mallocSize } size_t -XPCWrappedNativeScope::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) +XPCWrappedNativeScope::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) { size_t n = 0; n += mallocSizeOf(this); diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 5501034f17f3..0687f0755123 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -77,6 +77,7 @@ #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" #include "mozilla/Util.h" @@ -837,7 +838,7 @@ public: static void CTypesActivityCallback(JSContext *cx, js::CTypesActivityType type); - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); AutoMarkingPtr** GetAutoRootsAdr() {return &mAutoRoots;} @@ -1408,10 +1409,10 @@ public: DebugDump(int16_t depth); static size_t - SizeOfAllScopesIncludingThis(nsMallocSizeOfFun mallocSizeOf); + SizeOfAllScopesIncludingThis(mozilla::MallocSizeOf mallocSizeOf); size_t - SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); JSBool IsValid() const {return mRuntime != nullptr;} @@ -1635,7 +1636,7 @@ class XPCNativeInterface static void DestroyInstance(XPCNativeInterface* inst); - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); protected: static XPCNativeInterface* NewInstance(nsIInterfaceInfo* aInfo); @@ -1803,7 +1804,7 @@ class XPCNativeSet static void DestroyInstance(XPCNativeSet* inst); - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); protected: static XPCNativeSet* NewInstance(XPCNativeInterface** array, diff --git a/layout/base/FramePropertyTable.cpp b/layout/base/FramePropertyTable.cpp index f9ffc5566b8e..b387ce9769d0 100644 --- a/layout/base/FramePropertyTable.cpp +++ b/layout/base/FramePropertyTable.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "FramePropertyTable.h" #include "prlog.h" @@ -228,7 +229,7 @@ FramePropertyTable::DeleteAll() } size_t -FramePropertyTable::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +FramePropertyTable::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return mEntries.SizeOfExcludingThis(SizeOfPropertyTableEntryExcludingThis, aMallocSizeOf); @@ -236,7 +237,7 @@ FramePropertyTable::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const /* static */ size_t FramePropertyTable::SizeOfPropertyTableEntryExcludingThis(Entry* aEntry, - nsMallocSizeOfFun aMallocSizeOf, void *) + mozilla::MallocSizeOf aMallocSizeOf, void *) { return aEntry->mProp.SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/base/FramePropertyTable.h b/layout/base/FramePropertyTable.h index acfaa927b51d..7fa11de2fed9 100644 --- a/layout/base/FramePropertyTable.h +++ b/layout/base/FramePropertyTable.h @@ -6,6 +6,7 @@ #ifndef FRAMEPROPERTYTABLE_H_ #define FRAMEPROPERTYTABLE_H_ +#include "mozilla/MemoryReporting.h" #include "nsTArray.h" #include "nsTHashtable.h" #include "nsHashKeys.h" @@ -123,7 +124,7 @@ public: */ void DeleteAll(); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; protected: /** @@ -150,7 +151,7 @@ protected: } } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = 0; // We don't need to measure mProperty because it always points to static // memory. As for mValue: if it's a single value we can't measure it, @@ -203,7 +204,7 @@ protected: static PLDHashOperator DeleteEnumerator(Entry* aEntry, void* aArg); static size_t SizeOfPropertyTableEntryExcludingThis(Entry* aEntry, - nsMallocSizeOfFun aMallocSizeOf, void *); + mozilla::MallocSizeOf aMallocSizeOf, void *); nsTHashtable mEntries; nsIFrame* mLastFrame; diff --git a/layout/base/StackArena.cpp b/layout/base/StackArena.cpp index c26fe7f35df3..c709538d21d3 100644 --- a/layout/base/StackArena.cpp +++ b/layout/base/StackArena.cpp @@ -2,6 +2,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "StackArena.h" namespace mozilla { @@ -67,7 +68,7 @@ StackArena::~StackArena() } size_t -StackArena::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +StackArena::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; StackBlock *block = mBlocks; diff --git a/layout/base/StackArena.h b/layout/base/StackArena.h index d9f39f4025f6..018258d2d62d 100644 --- a/layout/base/StackArena.h +++ b/layout/base/StackArena.h @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/Assertions.h" +#include "mozilla/MemoryReporting.h" #include "nsAlgorithm.h" #include "nsDebug.h" @@ -28,7 +29,7 @@ private: void Push(); void Pop(); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; // our current position in memory size_t mPos; diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index fb9cf0dc5a33..4242846bb956 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -20,6 +20,7 @@ #ifndef nsIPresShell_h___ #define nsIPresShell_h___ +#include "mozilla/MemoryReporting.h" #include "nsTHashtable.h" #include "nsHashKeys.h" #include "nsISupports.h" @@ -1283,7 +1284,7 @@ public: virtual bool IsVisible() = 0; virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange) = 0; - virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, nsArenaMemoryStats *aArenaObjectsSize, size_t *aPresShellSize, size_t *aStyleSetsSize, diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 887c5d916938..794dec4099be 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "base/basictypes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "nsLayoutUtils.h" @@ -4877,7 +4878,7 @@ nsLayoutUtils::GetFontFacesForText(nsIFrame* aFrame, /* static */ size_t nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, bool clear) { NS_PRECONDITION(aFrame, "NULL frame pointer"); diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 9c56fd815385..8756c8606216 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -20,6 +20,7 @@ class nsClientRectList; class nsFontFaceList; class nsIImageLoadingContent; +#include "mozilla/MemoryReporting.h" #include "nsChangeHint.h" #include "nsStyleContext.h" #include "nsAutoPtr.h" @@ -1569,7 +1570,7 @@ public: * total = SizeOfTextRunsForFrames(rootFrame, mallocSizeOf, false); */ static size_t SizeOfTextRunsForFrames(nsIFrame* aFrame, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, bool clear); /** diff --git a/layout/base/nsPresArena.cpp b/layout/base/nsPresArena.cpp index be0f0f57fbda..0e6128b43d76 100644 --- a/layout/base/nsPresArena.cpp +++ b/layout/base/nsPresArena.cpp @@ -19,6 +19,7 @@ #include "nsPresArena.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Poison.h" #include "nsCRT.h" #include "nsDebug.h" @@ -116,7 +117,7 @@ nsPresArena::Free(uint32_t aCode, void* aPtr) /* static */ size_t nsPresArena::SizeOfFreeListEntryExcludingThis( - FreeList* aEntry, nsMallocSizeOfFun aMallocSizeOf, void*) + FreeList* aEntry, mozilla::MallocSizeOf aMallocSizeOf, void*) { return aEntry->mEntries.SizeOfExcludingThis(aMallocSizeOf); } @@ -179,7 +180,7 @@ nsPresArena::FreeListEnumerator(FreeList* aEntry, void* aData) } void -nsPresArena::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, +nsPresArena::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, nsArenaMemoryStats* aArenaStats) { // We do a complicated dance here because we want to measure the diff --git a/layout/base/nsPresArena.h b/layout/base/nsPresArena.h index a3a3ad4d028d..af586272a882 100644 --- a/layout/base/nsPresArena.h +++ b/layout/base/nsPresArena.h @@ -11,6 +11,7 @@ #define nsPresArena_h___ #include "mozilla/MemoryChecking.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" #include "nscore.h" #include "nsQueryFrame.h" @@ -84,7 +85,7 @@ public: * Fill aArenaStats with sizes of interesting objects allocated in * this arena and its mOther field with the size of everything else. */ - void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, nsArenaMemoryStats* aArenaStats); private: @@ -125,7 +126,7 @@ private: #endif static PLDHashOperator FreeListEnumerator(FreeList* aEntry, void* aData); static size_t SizeOfFreeListEntryExcludingThis(FreeList* aEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void*); nsTHashtable mFreeLists; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 8b3a894a72da..aee27ec602ef 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -59,6 +59,7 @@ #include "nsObjectFrame.h" #include "nsTransitionManager.h" #include "nsAnimationManager.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsIMessageManager.h" #include "FrameLayerBuilder.h" @@ -2524,7 +2525,7 @@ nsPresContext::GetPrimaryFrameFor(nsIContent* aContent) size_t -nsPresContext::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsPresContext::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return mPropertyTable.SizeOfExcludingThis(aMallocSizeOf); mLangGroupFontPrefs.SizeOfExcludingThis(aMallocSizeOf); @@ -2860,7 +2861,7 @@ nsRootPresContext::FlushWillPaintObservers() } size_t -nsRootPresContext::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsRootPresContext::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return nsPresContext::SizeOfExcludingThis(aMallocSizeOf); diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index d02c0898646b..a5c4b7446318 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -31,6 +31,7 @@ #include "nsTArray.h" #include "nsAutoPtr.h" #include "nsIWidget.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "prclist.h" #include "Layers.h" @@ -962,8 +963,8 @@ public: PropertyTable()->DeleteAllFor(aFrame); } - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } @@ -1057,7 +1058,7 @@ protected: NS_FONT_STRETCH_NORMAL, 0, 0) {} - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; LangGroupFontPrefs *curr = mNext; while (curr) { @@ -1419,7 +1420,7 @@ public: */ void FlushWillPaintObservers(); - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; protected: /** diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 3314b88ef368..60a03c5daaad 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -18,6 +18,7 @@ /* a presentation of a document, part 2 */ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/PBrowserChild.h" #include "mozilla/dom/TabChild.h" #include "mozilla/Likely.h" @@ -9444,7 +9445,7 @@ PresShell::GetRootPresShell() } void -PresShell::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +PresShell::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, nsArenaMemoryStats *aArenaObjectsSize, size_t *aPresShellSize, size_t *aStyleSetsSize, @@ -9463,7 +9464,7 @@ PresShell::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, } size_t -PresShell::SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const +PresShell::SizeOfTextRuns(MallocSizeOf aMallocSizeOf) const { nsIFrame* rootFrame = mFrameConstructor->GetRootFrame(); if (!rootFrame) { diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index e2532441d708..4dbb48be7edc 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -36,6 +36,7 @@ #include "nsContentUtils.h" // For AddScriptBlocker(). #include "nsRefreshDriver.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class nsRange; class nsIDragService; @@ -312,13 +313,13 @@ public: IsLayoutFlushObserver(this); } - void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, nsArenaMemoryStats *aArenaObjectsSize, size_t *aPresShellSize, size_t *aStyleSetsSize, size_t *aTextRunsSize, size_t *aPresContextSize) MOZ_OVERRIDE; - size_t SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfTextRuns(mozilla::MallocSizeOf aMallocSizeOf) const; virtual void AddInvalidateHiddenPresShellObserver(nsRefreshDriver *aDriver) MOZ_OVERRIDE; diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index 6eab68a05e9a..a335fc307270 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -8,6 +8,7 @@ #include "prlog.h" #include "nsStyleSheetService.h" #include "nsIStyleSheet.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Loader.h" #include "nsCSSStyleSheet.h" #include "nsIURI.h" @@ -255,7 +256,7 @@ nsStyleSheetService::GetInstance() } size_t -nsStyleSheetService::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsStyleSheetService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { if (!nsStyleSheetService::gInstance) { return 0; @@ -267,13 +268,13 @@ nsStyleSheetService::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) static size_t SizeOfElementIncludingThis(nsIStyleSheet* aElement, - nsMallocSizeOfFun aMallocSizeOf, void *aData) + mozilla::MallocSizeOf aMallocSizeOf, void *aData) { return aElement->SizeOfIncludingThis(aMallocSizeOf); } size_t -nsStyleSheetService::SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const +nsStyleSheetService::SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mSheets[AGENT_SHEET].SizeOfExcludingThis(SizeOfElementIncludingThis, diff --git a/layout/base/nsStyleSheetService.h b/layout/base/nsStyleSheetService.h index fa7d4be04a2d..31434e1eb9d0 100644 --- a/layout/base/nsStyleSheetService.h +++ b/layout/base/nsStyleSheetService.h @@ -12,6 +12,7 @@ #include "nsCOMArray.h" #include "nsIStyleSheet.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class nsISimpleEnumerator; class nsICategoryManager; @@ -39,7 +40,7 @@ class nsStyleSheetService MOZ_FINAL : public nsIStyleSheetService nsCOMArray* UserStyleSheets() { return &mSheets[USER_SHEET]; } nsCOMArray* AuthorStyleSheets() { return &mSheets[AUTHOR_SHEET]; } - static size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + static size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); static nsStyleSheetService *GetInstance(); static nsStyleSheetService *gInstance; @@ -59,7 +60,7 @@ class nsStyleSheetService MOZ_FINAL : public nsIStyleSheetService NS_HIDDEN_(nsresult) LoadAndRegisterSheetInternal(nsIURI *aSheetURI, uint32_t aSheetType); - size_t SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf) const; nsCOMArray mSheets[3]; diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index faf3d4656a15..f684f7d2554f 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "nsTextRunTransformations.h" #include "nsTextFrameUtils.h" @@ -357,7 +358,7 @@ nsTransformedTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength, } size_t -nsTransformedTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsTransformedTextRun::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t total = gfxTextRun::SizeOfExcludingThis(aMallocSizeOf); total += mStyles.SizeOfExcludingThis(aMallocSizeOf); @@ -369,7 +370,7 @@ nsTransformedTextRun::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) } size_t -nsTransformedTextRun::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsTransformedTextRun::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/generic/nsTextRunTransformations.h b/layout/generic/nsTextRunTransformations.h index 200f5dfe6746..b04d1f4467fa 100644 --- a/layout/generic/nsTextRunTransformations.h +++ b/layout/generic/nsTextRunTransformations.h @@ -7,6 +7,7 @@ #define NSTEXTRUNTRANSFORMATIONS_H_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "gfxFont.h" class nsTransformedTextRun; @@ -102,8 +103,8 @@ public: } // override the gfxTextRun impls to account for additional members here - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) MOZ_MUST_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) MOZ_MUST_OVERRIDE; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) MOZ_MUST_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) MOZ_MUST_OVERRIDE; nsTransformingTextRunFactory *mFactory; nsTArray > mStyles; diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 4aa948204bd6..64c05f01b692 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -15,6 +15,7 @@ #include "Layers.h" #include "FrameLayerBuilder.h" #include "nsDisplayList.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" using namespace mozilla::layers; @@ -121,7 +122,7 @@ CommonAnimationManager::MediumFeaturesChanged(nsPresContext* aPresContext) } /* virtual */ size_t -CommonAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +CommonAnimationManager::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { // Measurement of the following members may be added later if DMD finds it is // worthwhile: @@ -134,7 +135,7 @@ CommonAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) con } /* virtual */ size_t -CommonAnimationManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +CommonAnimationManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index 7a4fb7bf51e9..a247ddd09ccb 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -12,6 +12,7 @@ #include "prclist.h" #include "nsStyleAnimation.h" #include "nsCSSProperty.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsSMILKeySpline.h" #include "nsStyleStruct.h" @@ -42,9 +43,9 @@ public: virtual nsRestyleHint HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE; virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; /** diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index f6bc1a23bd2f..5e8ca1eaaa00 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -8,6 +8,7 @@ * stylesheet */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/css/Declaration.h" @@ -1068,7 +1069,7 @@ Declaration::EnsureMutable() } size_t -Declaration::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +Declaration::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mOrder.SizeOfExcludingThis(aMallocSizeOf); diff --git a/layout/style/Declaration.h b/layout/style/Declaration.h index b1edad385554..d83fb348c53a 100644 --- a/layout/style/Declaration.h +++ b/layout/style/Declaration.h @@ -12,6 +12,7 @@ #define mozilla_css_Declaration_h #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" // This header is in EXPORTS because it's used in several places in content/, // but it's not really a public interface. @@ -227,7 +228,7 @@ public: return nsCSSProperty(mOrder.ElementAt(aValue)); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsAutoTArray mOrder; diff --git a/layout/style/GroupRule.h b/layout/style/GroupRule.h index c9c980c6df6f..649437ee1571 100644 --- a/layout/style/GroupRule.h +++ b/layout/style/GroupRule.h @@ -12,6 +12,7 @@ #define mozilla_css_GroupRule_h__ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Rule.h" #include "nsCOMArray.h" #include "nsAutoPtr.h" @@ -69,8 +70,8 @@ public: nsMediaQueryResultCacheKey& aKey) = 0; // non-virtual -- it is only called by subclasses - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const = 0; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0; protected: // to help implement nsIDOMCSSRule diff --git a/layout/style/ImportRule.h b/layout/style/ImportRule.h index e8df0bf63509..f5b0d77b6c39 100644 --- a/layout/style/ImportRule.h +++ b/layout/style/ImportRule.h @@ -10,6 +10,7 @@ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Rule.h" #include "nsIDOMCSSImportRule.h" #include "nsCSSRules.h" @@ -49,7 +50,7 @@ public: void SetSheet(nsCSSStyleSheet*); - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; // nsIDOMCSSRule interface NS_DECL_NSIDOMCSSRULE diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 18db4eb40440..4d332395b5fb 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -16,6 +16,7 @@ /* loading of CSS style sheets using the network APIs */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/css/Loader.h" @@ -2442,13 +2443,13 @@ Loader::UnlinkCachedSheets() struct SheetMemoryCounter { size_t size; - nsMallocSizeOfFun mallocSizeOf; + mozilla::MallocSizeOf mallocSizeOf; }; static size_t CountSheetMemory(URIPrincipalAndCORSModeHashKey* /* unused */, const nsRefPtr& aSheet, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* /* unused */) { // If aSheet has a parent, then its parent will report it so we don't @@ -2462,7 +2463,7 @@ CountSheetMemory(URIPrincipalAndCORSModeHashKey* /* unused */, } size_t -Loader::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +Loader::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t s = aMallocSizeOf(this); diff --git a/layout/style/Loader.h b/layout/style/Loader.h index 034fed5e88f0..81d4e0be5f30 100644 --- a/layout/style/Loader.h +++ b/layout/style/Loader.h @@ -20,6 +20,7 @@ #include "nsURIHashKey.h" #include "mozilla/Attributes.h" #include "mozilla/CORSMode.h" +#include "mozilla/MemoryReporting.h" class nsIAtom; class nsICSSLoaderObserver; @@ -368,7 +369,7 @@ public: void UnlinkCachedSheets(); // Measure our size. - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: friend class SheetLoadData; diff --git a/layout/style/NameSpaceRule.h b/layout/style/NameSpaceRule.h index b49505af2ccd..1df6212da397 100644 --- a/layout/style/NameSpaceRule.h +++ b/layout/style/NameSpaceRule.h @@ -9,6 +9,7 @@ #define mozilla_css_NameSpaceRule_h__ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Rule.h" #include "nsIDOMCSSRule.h" @@ -52,7 +53,7 @@ public: void GetURLSpec(nsString& aURLSpec) const { aURLSpec = mURLSpec; } - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE; // nsIDOMCSSRule interface diff --git a/layout/style/Rule.h b/layout/style/Rule.h index 900040533727..fce3043d3fd1 100644 --- a/layout/style/Rule.h +++ b/layout/style/Rule.h @@ -8,6 +8,7 @@ #ifndef mozilla_css_Rule_h___ #define mozilla_css_Rule_h___ +#include "mozilla/MemoryReporting.h" #include "nsIStyleRule.h" #include "nsIDOMCSSRule.h" #include "nsCSSStyleSheet.h" @@ -111,12 +112,12 @@ public: // This is pure virtual because all of Rule's data members are non-owning and // thus measured elsewhere. - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE = 0; // This is used to measure nsCOMArrays. static size_t SizeOfCOMArrayElementIncludingThis(css::Rule* aElement, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void* aData); protected: diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index 69f67a61f2b5..680096a027d4 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -9,6 +9,7 @@ * declarations */ +#include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" #include "mozilla/css/GroupRule.h" #include "mozilla/css/Declaration.h" @@ -82,7 +83,7 @@ nsAtomList::Clone(bool aDeep) const } size_t -nsAtomList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsAtomList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsAtomList* a = this; @@ -177,7 +178,7 @@ nsPseudoClassList::Clone(bool aDeep) const } size_t -nsPseudoClassList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsPseudoClassList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsPseudoClassList* p = this; @@ -809,7 +810,7 @@ nsCSSSelector::CanBeNamespaced(bool aIsNegated) const } size_t -nsCSSSelector::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSSelector::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsCSSSelector* s = this; @@ -899,7 +900,7 @@ nsCSSSelectorList::Clone(bool aDeep) const } size_t -nsCSSSelectorList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSSelectorList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsCSSSelectorList* s = this; @@ -1501,7 +1502,7 @@ StyleRule::SetSelectorText(const nsAString& aSelectorText) } /* virtual */ size_t -StyleRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +StyleRule::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mSelector ? mSelector->SizeOfIncludingThis(aMallocSizeOf) : 0; diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index cd50bd902865..a0949f163da3 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -14,6 +14,7 @@ #include "mozilla/Attributes.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Rule.h" #include "nsString.h" @@ -36,7 +37,7 @@ public: /** Do a deep clone. Should be used only on the first in the linked list. */ nsAtomList* Clone() const { return Clone(true); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsCOMPtr mAtom; nsAtomList* mNext; @@ -59,7 +60,7 @@ public: /** Do a deep clone. Should be used only on the first in the linked list. */ nsPseudoClassList* Clone() const { return Clone(true); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; union { // For a given value of mType, we have either: @@ -189,7 +190,7 @@ public: mPseudoType = static_cast(aType); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; // For case-sensitive documents, mLowercaseTag is the same as mCasedTag, // but in case-insensitive documents (HTML) mLowercaseTag is lowercase. @@ -247,7 +248,7 @@ struct nsCSSSelectorList { */ nsCSSSelectorList* Clone() const { return Clone(true); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsCSSSelector* mSelectors; int32_t mWeight; @@ -365,7 +366,7 @@ public: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const MOZ_OVERRIDE; #endif - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: ~StyleRule(); diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index a90b2728d7a7..1a9fb163466a 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "nsAnimationManager.h" #include "nsPresContext.h" #include "nsRuleProcessorData.h" @@ -519,7 +520,7 @@ nsAnimationManager::RulesMatching(XULTreeRuleProcessorData* aData) #endif /* virtual */ size_t -nsAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsAnimationManager::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return CommonAnimationManager::SizeOfExcludingThis(aMallocSizeOf); @@ -530,7 +531,7 @@ nsAnimationManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } /* virtual */ size_t -nsAnimationManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsAnimationManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 5f990f21552b..9239792f6da9 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -11,6 +11,7 @@ #include "nsStyleContext.h" #include "nsDataHashtable.h" #include "nsGUIEvent.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "mozilla/Preferences.h" #include "nsThreadUtils.h" @@ -233,9 +234,9 @@ public: #ifdef MOZ_XUL virtual void RulesMatching(XULTreeRuleProcessorData* aData) MOZ_OVERRIDE; #endif - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; // nsARefreshObserver diff --git a/layout/style/nsCSSDataBlock.cpp b/layout/style/nsCSSDataBlock.cpp index d3fe76b14ef7..c08b0af3bb30 100644 --- a/layout/style/nsCSSDataBlock.cpp +++ b/layout/style/nsCSSDataBlock.cpp @@ -9,6 +9,7 @@ */ #include "nsCSSDataBlock.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Declaration.h" #include "mozilla/css/ImageLoader.h" #include "nsRuleData.h" @@ -226,7 +227,7 @@ nsCSSCompressedDataBlock::CreateEmptyBlock() } size_t -nsCSSCompressedDataBlock::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSCompressedDataBlock::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); for (uint32_t i = 0; i < mNumProps; i++) { diff --git a/layout/style/nsCSSDataBlock.h b/layout/style/nsCSSDataBlock.h index e12a119ec3e2..12d328666c66 100644 --- a/layout/style/nsCSSDataBlock.h +++ b/layout/style/nsCSSDataBlock.h @@ -11,6 +11,7 @@ #ifndef nsCSSDataBlock_h__ #define nsCSSDataBlock_h__ +#include "mozilla/MemoryReporting.h" #include "nsCSSProps.h" #include "nsCSSPropertySet.h" @@ -81,7 +82,7 @@ public: */ static nsCSSCompressedDataBlock* CreateEmptyBlock(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; bool HasDefaultBorderImageSlice() const; bool HasDefaultBorderImageWidth() const; diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 1d80afe13739..000179668f1f 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -23,6 +23,7 @@ #include "nsIAtom.h" #include "pldhash.h" #include "nsICSSPseudoComparator.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" #include "mozilla/css/GroupRule.h" #include "nsIDocument.h" @@ -456,8 +457,8 @@ public: void EnumerateAllRules(Element* aElement, ElementDependentRuleProcessorData* aData, NodeMatchContext& aNodeMatchContext); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; protected: typedef nsTArray RuleValueList; @@ -794,14 +795,14 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso } static size_t -SizeOfRuleHashTableEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf, void *) +SizeOfRuleHashTableEntry(PLDHashEntryHdr* aHdr, MallocSizeOf aMallocSizeOf, void *) { RuleHashTableEntry* entry = static_cast(aHdr); return entry->mRules.SizeOfExcludingThis(aMallocSizeOf); } size_t -RuleHash::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +RuleHash::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; @@ -835,7 +836,7 @@ RuleHash::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -RuleHash::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +RuleHash::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } @@ -959,7 +960,7 @@ struct RuleCascadeData { } } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; RuleHash mRuleHash; RuleHash* @@ -992,14 +993,14 @@ struct RuleCascadeData { }; static size_t -SizeOfSelectorsEntry(PLDHashEntryHdr* aHdr, nsMallocSizeOfFun aMallocSizeOf, void *) +SizeOfSelectorsEntry(PLDHashEntryHdr* aHdr, MallocSizeOf aMallocSizeOf, void *) { AtomSelectorEntry* entry = static_cast(aHdr); return entry->mSelectors.SizeOfExcludingThis(aMallocSizeOf); } size_t -RuleCascadeData::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +RuleCascadeData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); @@ -2700,7 +2701,7 @@ nsCSSRuleProcessor::MediumFeaturesChanged(nsPresContext* aPresContext) } /* virtual */ size_t -nsCSSRuleProcessor::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSRuleProcessor::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; n += mSheets.SizeOfExcludingThis(aMallocSizeOf); @@ -2713,7 +2714,7 @@ nsCSSRuleProcessor::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } /* virtual */ size_t -nsCSSRuleProcessor::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSRuleProcessor::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/style/nsCSSRuleProcessor.h b/layout/style/nsCSSRuleProcessor.h index 11f00abf8704..c209f3645eec 100644 --- a/layout/style/nsCSSRuleProcessor.h +++ b/layout/style/nsCSSRuleProcessor.h @@ -13,6 +13,7 @@ #define nsCSSRuleProcessor_h_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsIStyleRuleProcessor.h" #include "nsCSSStyleSheet.h" #include "nsTArray.h" @@ -112,9 +113,9 @@ public: virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; // Append all the currently-active font face rules to aArray. Return diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index c74b9f5ad304..f7743ed9b7f3 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -9,6 +9,7 @@ #include "nsCSSRules.h" #include "nsCSSValue.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/ImportRule.h" #include "mozilla/css/NameSpaceRule.h" @@ -117,7 +118,7 @@ Rule::GetParentStyleSheet(nsIDOMCSSStyleSheet** aSheet) size_t Rule::SizeOfCOMArrayElementIncludingThis(css::Rule* aElement, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aData) { return aElement->SizeOfIncludingThis(aMallocSizeOf); @@ -328,7 +329,7 @@ CharsetRule::GetParentRule(nsIDOMCSSRule** aParentRule) } /* virtual */ size_t -CharsetRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +CharsetRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); @@ -504,7 +505,7 @@ ImportRule::GetStyleSheet(nsIDOMCSSStyleSheet * *aStyleSheet) } /* virtual */ size_t -ImportRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +ImportRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); @@ -766,7 +767,7 @@ GroupRule::DeleteRule(uint32_t aIndex) } /* virtual */ size_t -GroupRule::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +GroupRule::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return mRules.SizeOfExcludingThis(Rule::SizeOfCOMArrayElementIncludingThis, aMallocSizeOf); @@ -970,7 +971,7 @@ MediaRule::UseForPresentation(nsPresContext* aPresContext, } /* virtual */ size_t -MediaRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +MediaRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += GroupRule::SizeOfExcludingThis(aMallocSizeOf); @@ -1200,7 +1201,7 @@ DocumentRule::URL::~URL() } /* virtual */ size_t -DocumentRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +DocumentRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += GroupRule::SizeOfExcludingThis(aMallocSizeOf); @@ -1361,7 +1362,7 @@ NameSpaceRule::GetParentRule(nsIDOMCSSRule** aParentRule) } /* virtual */ size_t -NameSpaceRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +NameSpaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); @@ -1901,7 +1902,7 @@ nsCSSFontFaceRule::GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue) } /* virtual */ size_t -nsCSSFontFaceRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSFontFaceRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); @@ -2155,7 +2156,7 @@ nsCSSFontFeatureValuesRule::AddValueList(int32_t aVariantAlternate, size_t nsCSSFontFeatureValuesRule::SizeOfIncludingThis( - nsMallocSizeOfFun aMallocSizeOf) const + MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); } @@ -2424,7 +2425,7 @@ nsCSSKeyframeRule::ChangeDeclaration(css::Declaration* aDeclaration) } /* virtual */ size_t -nsCSSKeyframeRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSKeyframeRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); @@ -2639,7 +2640,7 @@ nsCSSKeyframesRule::UseForPresentation(nsPresContext* aPresContext, } /* virtual */ size_t -nsCSSKeyframesRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSKeyframesRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += GroupRule::SizeOfExcludingThis(aMallocSizeOf); @@ -2870,7 +2871,7 @@ nsCSSPageRule::ChangeDeclaration(css::Declaration* aDeclaration) } /* virtual */ size_t -nsCSSPageRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSPageRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); } @@ -3005,7 +3006,7 @@ CSSSupportsRule::SetConditionText(const nsAString& aConditionText) } /* virtual */ size_t -CSSSupportsRule::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +CSSSupportsRule::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += css::GroupRule::SizeOfExcludingThis(aMallocSizeOf); diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index 1c637ceb38ab..58d0ab1ad251 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -11,6 +11,7 @@ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/GroupRule.h" #include "mozilla/Preferences.h" #include "nsIDOMCSSConditionRule.h" @@ -91,7 +92,7 @@ public: // @media rule methods nsresult SetMedia(nsMediaList* aMedia); - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE; protected: @@ -169,7 +170,7 @@ public: void SetURLs(URL *aURLs) { mURLs = aURLs; } - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE; protected: @@ -259,7 +260,7 @@ public: void SetDesc(nsCSSFontDesc aDescID, nsCSSValue const & aValue); void GetDesc(nsCSSFontDesc aDescID, nsCSSValue & aValue); - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; protected: friend class nsCSSFontFaceStyleDecl; @@ -330,7 +331,7 @@ public: return mFeatureValues; } - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; static bool PrefEnabled() { @@ -376,7 +377,7 @@ public: NS_IMETHOD GetEncoding(nsAString& aEncoding) MOZ_OVERRIDE; NS_IMETHOD SetEncoding(const nsAString& aEncoding) MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsString mEncoding; @@ -451,7 +452,7 @@ public: void ChangeDeclaration(mozilla::css::Declaration* aDeclaration); - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; void DoGetKeyText(nsAString &aKeyText) const; @@ -505,7 +506,7 @@ public: const nsString& GetName() { return mName; } - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; private: uint32_t FindRuleIndexForKey(const nsAString& aKey); @@ -579,7 +580,7 @@ public: mozilla::css::ImportantRule* GetImportantRule(); - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; private: nsAutoPtr mDeclaration; // lazily created when needed: @@ -629,7 +630,7 @@ public: // nsIDOMCSSSupportsRule interface NS_DECL_NSIDOMCSSSUPPORTSRULE - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; static bool PrefEnabled() { diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index 4dbe5bd85e01..e6ee7b645ea5 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -10,6 +10,7 @@ #include "nsIAtom.h" #include "nsCSSRuleProcessor.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "mozilla/css/NameSpaceRule.h" #include "mozilla/css/GroupRule.h" @@ -845,7 +846,7 @@ nsCSSStyleSheet::RebuildChildList(css::Rule* aRule, void* aBuilder) } size_t -nsCSSStyleSheet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsCSSStyleSheet* s = this; @@ -987,7 +988,7 @@ nsCSSStyleSheetInner::CreateNamespaceMap() } size_t -nsCSSStyleSheetInner::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mOrderedRules.SizeOfExcludingThis(css::Rule::SizeOfCOMArrayElementIncludingThis, diff --git a/layout/style/nsCSSStyleSheet.h b/layout/style/nsCSSStyleSheet.h index ab22fd3d5f13..4944c5bf8a5e 100644 --- a/layout/style/nsCSSStyleSheet.h +++ b/layout/style/nsCSSStyleSheet.h @@ -10,6 +10,7 @@ #define nsCSSStyleSheet_h_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nscore.h" @@ -66,7 +67,7 @@ private: // Create a new namespace map nsresult CreateNamespaceMap(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsAutoTArray mSheets; nsCOMPtr mSheetURI; // for error reports, etc. @@ -243,7 +244,7 @@ public: // list after we clone a unique inner for ourselves. static bool RebuildChildList(mozilla::css::Rule* aRule, void* aBuilder); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE; // Get this style sheet's CORS mode mozilla::CORSMode GetCORSMode() const { return mInner->mCORSMode; } diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index d8a8905264ba..436e0dc225fb 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -16,6 +16,7 @@ #include "nsStyleUtil.h" #include "CSSCalc.h" #include "nsNetUtil.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/ImageLoader.h" #include "mozilla/Likely.h" @@ -1235,7 +1236,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const } size_t -nsCSSValue::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; @@ -1436,7 +1437,7 @@ nsCSSValueList::operator==(const nsCSSValueList& aOther) const } size_t -nsCSSValueList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValueList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsCSSValueList* v = this; @@ -1449,7 +1450,7 @@ nsCSSValueList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -nsCSSValueList_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValueList_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mValue.SizeOfExcludingThis(aMallocSizeOf); @@ -1522,7 +1523,7 @@ void nsCSSRect::SetAllSidesTo(const nsCSSValue& aValue) } size_t -nsCSSRect_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSRect_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mTop .SizeOfExcludingThis(aMallocSizeOf); @@ -1557,7 +1558,7 @@ nsCSSValuePair::AppendToString(nsCSSProperty aProperty, } size_t -nsCSSValuePair::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValuePair::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; n += mXValue.SizeOfExcludingThis(aMallocSizeOf); @@ -1566,7 +1567,7 @@ nsCSSValuePair::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -nsCSSValuePair_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValuePair_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mXValue.SizeOfExcludingThis(aMallocSizeOf); @@ -1592,7 +1593,7 @@ nsCSSValueTriplet::AppendToString(nsCSSProperty aProperty, } size_t -nsCSSValueTriplet_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValueTriplet_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mXValue.SizeOfExcludingThis(aMallocSizeOf); @@ -1665,7 +1666,7 @@ nsCSSValuePairList::operator==(const nsCSSValuePairList& aOther) const } size_t -nsCSSValuePairList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValuePairList::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; const nsCSSValuePairList* v = this; @@ -1679,7 +1680,7 @@ nsCSSValuePairList::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -nsCSSValuePairList_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValuePairList_heap::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mXValue.SizeOfExcludingThis(aMallocSizeOf); @@ -1689,7 +1690,7 @@ nsCSSValuePairList_heap::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) co } size_t -nsCSSValue::Array::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValue::Array::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); for (size_t i = 0; i < mCount; i++) { @@ -1776,7 +1777,7 @@ css::URLValue::GetURI() const } size_t -css::URLValue::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +css::URLValue::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); @@ -1867,7 +1868,7 @@ nsCSSValueGradientStop::~nsCSSValueGradientStop() } size_t -nsCSSValueGradientStop::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValueGradientStop::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0; n += mLocation.SizeOfExcludingThis(aMallocSizeOf); @@ -1889,7 +1890,7 @@ nsCSSValueGradient::nsCSSValueGradient(bool aIsRadial, } size_t -nsCSSValueGradient::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsCSSValueGradient::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); n += mBgPos.SizeOfExcludingThis(aMallocSizeOf); diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index 14f1960edd0b..bcc3846785ee 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -10,6 +10,7 @@ #include "mozilla/Attributes.h" #include "mozilla/FloatingPoint.h" +#include "mozilla/MemoryReporting.h" #include "nsCOMPtr.h" #include "nsCRTGlue.h" @@ -92,7 +93,7 @@ struct URLValue { nsIURI* GetURI() const; - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: // If mURIResolved is false, mURI stores the base URI. @@ -518,7 +519,7 @@ public: static already_AddRefed BufferFromString(const nsString& aValue); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: static const PRUnichar* GetBufferValue(nsStringBuffer* aBuffer) { @@ -643,7 +644,7 @@ private: } } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; #undef CSSVALUE_LIST_FOR_EXTRA_VALUES @@ -665,7 +666,7 @@ struct nsCSSValueList { bool operator!=(const nsCSSValueList& aOther) const { return !(*this == aOther); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsCSSValue mValue; nsCSSValueList* mNext; @@ -684,7 +685,7 @@ private: struct nsCSSValueList_heap : public nsCSSValueList { NS_INLINE_DECL_REFCOUNTING(nsCSSValueList_heap) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; // This has to be here so that the relationship between nsCSSValueList @@ -771,7 +772,7 @@ struct nsCSSRect { struct nsCSSRect_heap : public nsCSSRect { NS_INLINE_DECL_REFCOUNTING(nsCSSRect_heap) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; // This has to be here so that the relationship between nsCSSRect @@ -847,7 +848,7 @@ struct nsCSSValuePair { void AppendToString(nsCSSProperty aProperty, nsAString& aResult) const; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsCSSValue mXValue; nsCSSValue mYValue; @@ -864,7 +865,7 @@ struct nsCSSValuePair_heap : public nsCSSValuePair { NS_INLINE_DECL_REFCOUNTING(nsCSSValuePair_heap) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; struct nsCSSValueTriplet { @@ -948,7 +949,7 @@ struct nsCSSValueTriplet_heap : public nsCSSValueTriplet { NS_INLINE_DECL_REFCOUNTING(nsCSSValueTriplet_heap) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; // This has to be here so that the relationship between nsCSSValuePair @@ -993,7 +994,7 @@ struct nsCSSValuePairList { bool operator!=(const nsCSSValuePairList& aOther) const { return !(*this == aOther); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsCSSValue mXValue; nsCSSValue mYValue; @@ -1013,7 +1014,7 @@ private: struct nsCSSValuePairList_heap : public nsCSSValuePairList { NS_INLINE_DECL_REFCOUNTING(nsCSSValuePairList_heap) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; // This has to be here so that the relationship between nsCSSValuePairList @@ -1062,7 +1063,7 @@ public: return !(*this == aOther); } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; }; struct nsCSSValueGradient { @@ -1122,7 +1123,7 @@ public: NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient) - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; private: nsCSSValueGradient(const nsCSSValueGradient& aOther) MOZ_DELETE; diff --git a/layout/style/nsHTMLCSSStyleSheet.cpp b/layout/style/nsHTMLCSSStyleSheet.cpp index c3d3882b8bd0..5ff8075e654f 100644 --- a/layout/style/nsHTMLCSSStyleSheet.cpp +++ b/layout/style/nsHTMLCSSStyleSheet.cpp @@ -8,6 +8,7 @@ */ #include "nsHTMLCSSStyleSheet.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/StyleRule.h" #include "nsIStyleRuleProcessor.h" #include "nsPresContext.h" @@ -133,13 +134,13 @@ nsHTMLCSSStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext) } /* virtual */ size_t -nsHTMLCSSStyleSheet::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsHTMLCSSStyleSheet::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return 0; } /* virtual */ size_t -nsHTMLCSSStyleSheet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsHTMLCSSStyleSheet::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/style/nsHTMLCSSStyleSheet.h b/layout/style/nsHTMLCSSStyleSheet.h index b3e8a16c6fe2..25ea29f5ac68 100644 --- a/layout/style/nsHTMLCSSStyleSheet.h +++ b/layout/style/nsHTMLCSSStyleSheet.h @@ -11,6 +11,7 @@ #define nsHTMLCSSStyleSheet_h_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsCOMPtr.h" #include "nsDataHashtable.h" @@ -39,9 +40,9 @@ public: virtual nsRestyleHint HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE; virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; void CacheStyleAttr(const nsAString& aSerialized, MiscContainer* aValue); diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index e91f71da60ad..e4b36310e44e 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -30,6 +30,7 @@ #include "nsError.h" #include "nsRuleProcessorData.h" #include "nsCSSRuleProcessor.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" #include "nsCSSFrameConstructor.h" #include "nsHashKeys.h" @@ -372,13 +373,13 @@ nsHTMLStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext) } /* virtual */ size_t -nsHTMLStyleSheet::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsHTMLStyleSheet::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return 0; // nsHTMLStyleSheets are charged to the DOM, not layout } /* virtual */ size_t -nsHTMLStyleSheet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsHTMLStyleSheet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return 0; // nsHTMLStyleSheets are charged to the DOM, not layout } @@ -527,7 +528,7 @@ nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage) static size_t SizeOfAttributesEntryExcludingThis(PLDHashEntryHdr* aEntry, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aArg) { NS_PRECONDITION(aEntry, "The entry should not be null!"); @@ -538,7 +539,7 @@ SizeOfAttributesEntryExcludingThis(PLDHashEntryHdr* aEntry, } size_t -nsHTMLStyleSheet::DOMSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsHTMLStyleSheet::DOMSizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); diff --git a/layout/style/nsHTMLStyleSheet.h b/layout/style/nsHTMLStyleSheet.h index 886745df66e7..9e5623a8e0db 100644 --- a/layout/style/nsHTMLStyleSheet.h +++ b/layout/style/nsHTMLStyleSheet.h @@ -20,6 +20,7 @@ #include "nsIStyleSheet.h" #include "pldhash.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsString.h" class nsMappedAttributes; @@ -45,11 +46,11 @@ public: virtual nsRestyleHint HasAttributeDependentStyle(AttributeRuleProcessorData* aData) MOZ_OVERRIDE; virtual bool MediumFeaturesChanged(nsPresContext* aPresContext) MOZ_OVERRIDE; - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - size_t DOMSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t DOMSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; void Reset(); nsresult SetLinkColor(nscolor aColor); diff --git a/layout/style/nsIStyleRuleProcessor.h b/layout/style/nsIStyleRuleProcessor.h index f50aba4e712d..67dbbf408e06 100644 --- a/layout/style/nsIStyleRuleProcessor.h +++ b/layout/style/nsIStyleRuleProcessor.h @@ -12,6 +12,7 @@ #ifndef nsIStyleRuleProcessor_h___ #define nsIStyleRuleProcessor_h___ +#include "mozilla/MemoryReporting.h" #include "nsISupports.h" #include "nsChangeHint.h" @@ -125,8 +126,8 @@ public: * Report the size of this style rule processor to about:memory. A * processor may return 0. */ - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const = 0; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleRuleProcessor, diff --git a/layout/style/nsIStyleSheet.h b/layout/style/nsIStyleSheet.h index 36a0a05e6408..b61d9d5c80fa 100644 --- a/layout/style/nsIStyleSheet.h +++ b/layout/style/nsIStyleSheet.h @@ -11,6 +11,7 @@ #ifndef nsIStyleSheet_h___ #define nsIStyleSheet_h___ +#include "mozilla/MemoryReporting.h" #include #include "nsISupports.h" @@ -78,7 +79,7 @@ public: virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0; #endif - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const = 0; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIStyleSheet, NS_ISTYLE_SHEET_IID) diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 0a49797f450b..a4113c25cb62 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -6,6 +6,7 @@ #include "nsLayoutStylesheetCache.h" #include "nsAppDirectoryServiceDefs.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/css/Loader.h" #include "nsIFile.h" #include "nsIMemoryReporter.h" @@ -157,7 +158,7 @@ nsLayoutStylesheetCache::Shutdown() } size_t -nsLayoutStylesheetCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { if (!nsLayoutStylesheetCache::gStyleCache) { return 0; @@ -168,7 +169,7 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) } size_t -nsLayoutStylesheetCache::SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const +nsLayoutStylesheetCache::SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); diff --git a/layout/style/nsLayoutStylesheetCache.h b/layout/style/nsLayoutStylesheetCache.h index 7a3ce99f4bda..61bdaffb8d8a 100644 --- a/layout/style/nsLayoutStylesheetCache.h +++ b/layout/style/nsLayoutStylesheetCache.h @@ -9,6 +9,7 @@ #include "nsIObserver.h" #include "nsAutoPtr.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class nsIFile; class nsCSSStyleSheet; @@ -38,7 +39,7 @@ class nsLayoutStylesheetCache MOZ_FINAL static void Shutdown(); - static size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + static size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: nsLayoutStylesheetCache(); @@ -50,7 +51,7 @@ private: static void LoadSheet(nsIURI* aURI, nsRefPtr &aSheet, bool aEnableUnsafeRules); - size_t SizeOfIncludingThisHelper(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThisHelper(mozilla::MallocSizeOf aMallocSizeOf) const; static nsLayoutStylesheetCache* gStyleCache; static mozilla::css::Loader* gCSSLoader; diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index 4f5dff656783..1bc8da76babc 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -9,6 +9,7 @@ * potentially re-creating) style contexts */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "nsStyleSet.h" @@ -119,7 +120,7 @@ nsStyleSet::nsStyleSet() } size_t -nsStyleSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsStyleSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); diff --git a/layout/style/nsStyleSet.h b/layout/style/nsStyleSet.h index 1e46261d5a4b..e7df877ebf09 100644 --- a/layout/style/nsStyleSet.h +++ b/layout/style/nsStyleSet.h @@ -13,6 +13,7 @@ #define nsStyleSet_h_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsIStyleRuleProcessor.h" #include "nsCSSStyleSheet.h" @@ -61,7 +62,7 @@ class nsStyleSet public: nsStyleSet(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; void Init(nsPresContext *aPresContext); diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index 7bb62d30e8fc..e63b1e0a40fc 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -11,6 +11,7 @@ #include "nsIContent.h" #include "nsStyleContext.h" #include "nsCSSProps.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TimeStamp.h" #include "nsRefreshDriver.h" #include "nsRuleProcessorData.h" @@ -964,13 +965,13 @@ nsTransitionManager::RulesMatching(XULTreeRuleProcessorData* aData) #endif /* virtual */ size_t -nsTransitionManager::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsTransitionManager::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { return CommonAnimationManager::SizeOfExcludingThis(aMallocSizeOf); } /* virtual */ size_t -nsTransitionManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsTransitionManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index 99e87865e75d..02f748b291fb 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -9,6 +9,7 @@ #define nsTransitionManager_h_ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "AnimationCommon.h" #include "nsCSSPseudoElements.h" @@ -170,9 +171,9 @@ public: #ifdef MOZ_XUL virtual void RulesMatching(XULTreeRuleProcessorData* aData) MOZ_OVERRIDE; #endif - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const MOZ_MUST_OVERRIDE MOZ_OVERRIDE; // nsARefreshObserver diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index e8c973ecb5c0..cc46d281cd8b 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -34,6 +34,7 @@ #include "mozilla/Assertions.h" #include "mozilla/HashFunctions.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" // MOZ_REPLACE_ONLY_MEMALIGN saves us from having to define // replace_{posix_memalign,aligned_alloc,valloc}. It requires defining @@ -1992,7 +1993,7 @@ PrintSortedTraceAndFrameRecords(const Writer& aWriter, } // Note that, unlike most SizeOf* functions, this function does not take a -// |nsMallocSizeOfFun| argument. That's because those arguments are primarily +// |mozilla::MallocSizeOf| argument. That's because those arguments are primarily // to aid DMD track heap blocks... but DMD deliberately doesn't track heap // blocks it allocated for itself! // diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index 7c9155dd27d7..72729b175e9b 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/Attributes.h" @@ -164,7 +165,7 @@ NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(PreferencesMallocSizeOf) static size_t SizeOfObserverEntryExcludingThis(ValueObserverHashKey* aKey, const nsRefPtr& aData, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void*) { size_t n = 0; diff --git a/modules/libpref/src/nsPrefBranch.h b/modules/libpref/src/nsPrefBranch.h index b58173611921..539a12a37cf7 100644 --- a/modules/libpref/src/nsPrefBranch.h +++ b/modules/libpref/src/nsPrefBranch.h @@ -21,6 +21,7 @@ #include "prbit.h" #include "nsTraceRefcnt.h" #include "mozilla/HashFunctions.h" +#include "mozilla/MemoryReporting.h" class nsPrefBranch; @@ -187,7 +188,7 @@ public: static nsresult NotifyObserver(const char *newpref, void *data); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); protected: nsPrefBranch() /* disallow use of this constructer */ diff --git a/modules/libpref/src/prefapi.cpp b/modules/libpref/src/prefapi.cpp index cec84da69aee..59ad7c6d554c 100644 --- a/modules/libpref/src/prefapi.cpp +++ b/modules/libpref/src/prefapi.cpp @@ -26,6 +26,7 @@ #include "plbase64.h" #include "prlog.h" #include "prprf.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/PContent.h" #include "nsQuickSort.h" #include "nsString.h" @@ -807,7 +808,7 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t } size_t -pref_SizeOfPrivateData(nsMallocSizeOfFun aMallocSizeOf) +pref_SizeOfPrivateData(MallocSizeOf aMallocSizeOf) { size_t n = PL_SizeOfArenaPoolExcludingPool(&gPrefNameArena, aMallocSizeOf); for (struct CallbackNode* node = gCallbacks; node; node = node->next) { diff --git a/modules/libpref/src/prefapi_private_data.h b/modules/libpref/src/prefapi_private_data.h index 55f58005c7f5..0a5f9b6f8bc0 100644 --- a/modules/libpref/src/prefapi_private_data.h +++ b/modules/libpref/src/prefapi_private_data.h @@ -5,6 +5,8 @@ /* Data shared between prefapi.c and nsPref.cpp */ +#include "mozilla/MemoryReporting.h" + extern PLDHashTable gHashTable; extern bool gDirty; @@ -39,4 +41,4 @@ void pref_GetPrefFromEntry(PrefHashEntry *aHashEntry, mozilla::dom::PrefSetting* aPref); size_t -pref_SizeOfPrivateData(nsMallocSizeOfFun aMallocSizeOf); +pref_SizeOfPrivateData(mozilla::MallocSizeOf aMallocSizeOf); diff --git a/netwerk/base/src/nsSimpleURI.cpp b/netwerk/base/src/nsSimpleURI.cpp index 92fab862b53c..76bba913334f 100644 --- a/netwerk/base/src/nsSimpleURI.cpp +++ b/netwerk/base/src/nsSimpleURI.cpp @@ -21,6 +21,7 @@ #include "nsError.h" #include "nsIProgrammingLanguage.h" #include "nsIIPCSerializableURI.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/ipc/URIUtils.h" using namespace mozilla::ipc; @@ -635,7 +636,7 @@ nsSimpleURI::SetMutable(bool value) //---------------------------------------------------------------------------- size_t -nsSimpleURI::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsSimpleURI::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + @@ -643,7 +644,7 @@ nsSimpleURI::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -nsSimpleURI::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { +nsSimpleURI::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/netwerk/base/src/nsSimpleURI.h b/netwerk/base/src/nsSimpleURI.h index 1c996332c986..94bffab1d807 100644 --- a/netwerk/base/src/nsSimpleURI.h +++ b/netwerk/base/src/nsSimpleURI.h @@ -6,6 +6,7 @@ #ifndef nsSimpleURI_h__ #define nsSimpleURI_h__ +#include "mozilla/MemoryReporting.h" #include "nsIURL.h" #include "nsAgg.h" #include "nsISerializable.h" @@ -50,8 +51,8 @@ public: // - nsJSURI: mBaseURI // - nsSimpleNestedURI: mInnerURI // - nsBlobURI: mPrincipal - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; protected: // enum used in a few places to specify how .ref attribute should be handled diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 16a001caa2d3..8476ffad6a5a 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -23,6 +23,7 @@ #include "nsAutoPtr.h" #include "nsIProgrammingLanguage.h" #include "nsVoidArray.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/ipc/URIUtils.h" #include @@ -3028,7 +3029,7 @@ nsStandardURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) //---------------------------------------------------------------------------- size_t -nsStandardURL::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +nsStandardURL::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return mSpec.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + mOriginCharset.SizeOfExcludingThisIfUnshared(aMallocSizeOf) + @@ -3041,6 +3042,6 @@ nsStandardURL::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const } size_t -nsStandardURL::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const { +nsStandardURL::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } diff --git a/netwerk/base/src/nsStandardURL.h b/netwerk/base/src/nsStandardURL.h index 17ade39c2909..17c6bfc9e0c7 100644 --- a/netwerk/base/src/nsStandardURL.h +++ b/netwerk/base/src/nsStandardURL.h @@ -23,6 +23,7 @@ #include "nsISizeOf.h" #include "prclist.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsIIPCSerializableURI.h" #ifdef NS_BUILD_REFCNT_LOGGING @@ -58,8 +59,8 @@ public: NS_DECL_NSIIPCSERIALIZABLEURI // nsISizeOf - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; nsStandardURL(bool aSupportsFileURL = false); virtual ~nsStandardURL(); diff --git a/netwerk/cache/nsDiskCacheBinding.cpp b/netwerk/cache/nsDiskCacheBinding.cpp index 2467994c7d71..558905daa393 100644 --- a/netwerk/cache/nsDiskCacheBinding.cpp +++ b/netwerk/cache/nsDiskCacheBinding.cpp @@ -4,6 +4,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "nsCache.h" #include @@ -372,7 +373,7 @@ nsDiskCacheBindery::ActiveBindings() struct AccumulatorArg { size_t mUsage; - nsMallocSizeOfFun mMallocSizeOf; + mozilla::MallocSizeOf mMallocSizeOf; }; PLDHashOperator @@ -408,7 +409,7 @@ AccumulateHeapUsage(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number, * SizeOfExcludingThis: return the amount of heap memory (bytes) being used by the bindery */ size_t -nsDiskCacheBindery::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsDiskCacheBindery::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) { NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized"); if (!initialized) return 0; diff --git a/netwerk/cache/nsDiskCacheBinding.h b/netwerk/cache/nsDiskCacheBinding.h index 7e607c38474c..0290a9487ac6 100644 --- a/netwerk/cache/nsDiskCacheBinding.h +++ b/netwerk/cache/nsDiskCacheBinding.h @@ -8,6 +8,7 @@ #ifndef _nsDiskCacheBinding_h_ #define _nsDiskCacheBinding_h_ +#include "mozilla/MemoryReporting.h" #include "nspr.h" #include "pldhash.h" @@ -105,7 +106,7 @@ public: void RemoveBinding(nsDiskCacheBinding * binding); bool ActiveBindings(); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: nsresult AddBinding(nsDiskCacheBinding * binding); diff --git a/netwerk/cache/nsDiskCacheBlockFile.cpp b/netwerk/cache/nsDiskCacheBlockFile.cpp index 7d2a075339eb..6a1f4182f24a 100644 --- a/netwerk/cache/nsDiskCacheBlockFile.cpp +++ b/netwerk/cache/nsDiskCacheBlockFile.cpp @@ -8,6 +8,7 @@ #include "nsDiskCache.h" #include "nsDiskCacheBlockFile.h" #include "mozilla/FileUtils.h" +#include "mozilla/MemoryReporting.h" #include using namespace mozilla; @@ -397,7 +398,7 @@ nsDiskCacheBlockFile::Write(int32_t offset, const void *buf, int32_t amount) } size_t -nsDiskCacheBlockFile::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsDiskCacheBlockFile::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) { return aMallocSizeOf(mBitMap) + aMallocSizeOf(mFD); } diff --git a/netwerk/cache/nsDiskCacheBlockFile.h b/netwerk/cache/nsDiskCacheBlockFile.h index 5e5caa2e6716..058cc7fcca97 100644 --- a/netwerk/cache/nsDiskCacheBlockFile.h +++ b/netwerk/cache/nsDiskCacheBlockFile.h @@ -7,6 +7,7 @@ #ifndef _nsDiskCacheBlockFile_h_ #define _nsDiskCacheBlockFile_h_ +#include "mozilla/MemoryReporting.h" #include "nsIFile.h" #include "nsDiskCache.h" @@ -45,7 +46,7 @@ public: nsresult ReadBlocks( void * buffer, int32_t startBlock, int32_t numBlocks, int32_t * bytesRead); - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: nsresult FlushBitMap(); diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index 998e01693ee4..a6dcd50164e7 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -49,6 +49,7 @@ #include "nsISimpleEnumerator.h" #include "nsThreadUtils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" static const char DISK_CACHE_DEVICE_ID[] = { "disk" }; @@ -1190,7 +1191,7 @@ nsDiskCacheDevice::SetMaxEntrySize(int32_t maxSizeInKilobytes) } size_t -nsDiskCacheDevice::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsDiskCacheDevice::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t usage = aMallocSizeOf(this); diff --git a/netwerk/cache/nsDiskCacheDevice.h b/netwerk/cache/nsDiskCacheDevice.h index 88f822314ee4..803a623879da 100644 --- a/netwerk/cache/nsDiskCacheDevice.h +++ b/netwerk/cache/nsDiskCacheDevice.h @@ -7,6 +7,7 @@ #ifndef _nsDiskCacheDevice_h_ #define _nsDiskCacheDevice_h_ +#include "mozilla/MemoryReporting.h" #include "nsCacheDevice.h" #include "nsDiskCacheBinding.h" #include "nsDiskCacheBlockFile.h" @@ -55,7 +56,7 @@ public: bool EntryIsTooBig(int64_t entrySize); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); /** * Preference accessors diff --git a/netwerk/cache/nsDiskCacheMap.cpp b/netwerk/cache/nsDiskCacheMap.cpp index 76a9b03ff1de..d294e0eb4876 100644 --- a/netwerk/cache/nsDiskCacheMap.cpp +++ b/netwerk/cache/nsDiskCacheMap.cpp @@ -17,6 +17,7 @@ #include "nsISerializable.h" #include "nsSerializationHelper.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" #include "mozilla/VisualEventTracer.h" #include @@ -1230,7 +1231,7 @@ nsDiskCacheMap::NotifyCapacityChange(uint32_t capacity) } size_t -nsDiskCacheMap::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsDiskCacheMap::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) { size_t usage = aMallocSizeOf(mRecordArray); diff --git a/netwerk/cache/nsDiskCacheMap.h b/netwerk/cache/nsDiskCacheMap.h index 71ae9feb5163..f1c5abe448e2 100644 --- a/netwerk/cache/nsDiskCacheMap.h +++ b/netwerk/cache/nsDiskCacheMap.h @@ -7,6 +7,7 @@ #ifndef _nsDiskCacheMap_h_ #define _nsDiskCacheMap_h_ +#include "mozilla/MemoryReporting.h" #include #include "prtypes.h" @@ -485,7 +486,7 @@ public: int32_t EntryCount() { return mHeader.mEntryCount; } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: diff --git a/netwerk/cache/nsDiskCacheStreams.cpp b/netwerk/cache/nsDiskCacheStreams.cpp index 80c9cd48082f..447cf3b52b28 100644 --- a/netwerk/cache/nsDiskCacheStreams.cpp +++ b/netwerk/cache/nsDiskCacheStreams.cpp @@ -12,6 +12,7 @@ #include "nsCacheService.h" #include "mozilla/FileUtils.h" #include "nsThreadUtils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include @@ -620,7 +621,7 @@ nsDiskCacheStreamIO::DeleteBuffer() } size_t -nsDiskCacheStreamIO::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsDiskCacheStreamIO::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t usage = aMallocSizeOf(this); diff --git a/netwerk/cache/nsDiskCacheStreams.h b/netwerk/cache/nsDiskCacheStreams.h index 2fbe2f0a81df..f69b73384177 100644 --- a/netwerk/cache/nsDiskCacheStreams.h +++ b/netwerk/cache/nsDiskCacheStreams.h @@ -8,6 +8,7 @@ #ifndef _nsDiskCacheStreams_h_ #define _nsDiskCacheStreams_h_ +#include "mozilla/MemoryReporting.h" #include "nsDiskCacheBinding.h" #include "nsCache.h" @@ -40,7 +41,7 @@ public: NS_ASSERTION(mInStreamCount >= 0, "mInStreamCount has gone negative"); } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); // GCC 2.95.2 requires this to be defined, although we never call it. // and OS/2 requires that it not be private diff --git a/netwerk/dns/nsEffectiveTLDService.cpp b/netwerk/dns/nsEffectiveTLDService.cpp index 328283e20c4e..30ed008da975 100644 --- a/netwerk/dns/nsEffectiveTLDService.cpp +++ b/netwerk/dns/nsEffectiveTLDService.cpp @@ -7,6 +7,7 @@ // complete description of the expected file format and parsing rules, see // http://wiki.mozilla.org/Gecko:Effective_TLD_Service +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "nsEffectiveTLDService.h" @@ -121,7 +122,7 @@ nsEffectiveTLDService::~nsEffectiveTLDService() } size_t -nsEffectiveTLDService::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsEffectiveTLDService::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); n += mHash.SizeOfExcludingThis(nullptr, aMallocSizeOf); diff --git a/netwerk/dns/nsEffectiveTLDService.h b/netwerk/dns/nsEffectiveTLDService.h index 731a62cea095..edd38159ac15 100644 --- a/netwerk/dns/nsEffectiveTLDService.h +++ b/netwerk/dns/nsEffectiveTLDService.h @@ -9,6 +9,7 @@ #include "nsString.h" #include "nsCOMPtr.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" class nsIIDNService; class nsIMemoryReporter; @@ -110,7 +111,7 @@ public: nsEffectiveTLDService() { } nsresult Init(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: nsresult GetBaseDomainInternal(nsCString &aHostname, int32_t aAdditionalParts, nsACString &aBaseDomain); diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 95a30df34ce6..5e8b9c2f210e 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -7,6 +7,7 @@ #include "prtypes.h" #include "pldhash.h" #include "nsXPCOMStrings.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/scache/StartupCache.h" #include "nsAutoPtr.h" @@ -382,7 +383,7 @@ StartupCache::SizeOfMapping() } size_t -StartupCache::HeapSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +StartupCache::HeapSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { // This function could measure more members, but they haven't been found by // DMD to be significant. They can be added later if necessary. @@ -392,7 +393,7 @@ StartupCache::HeapSizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) /* static */ size_t StartupCache::SizeOfEntryExcludingThis(const nsACString& key, const nsAutoPtr& data, - nsMallocSizeOfFun mallocSizeOf, void *) + mozilla::MallocSizeOf mallocSizeOf, void *) { return data->SizeOfExcludingThis(mallocSizeOf); } diff --git a/startupcache/StartupCache.h b/startupcache/StartupCache.h index ae51cfc32071..e2f7a03b9996 100644 --- a/startupcache/StartupCache.h +++ b/startupcache/StartupCache.h @@ -16,6 +16,7 @@ #include "nsIOutputStream.h" #include "nsIFile.h" #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" /** * The StartupCache is a persistent cache of simple key-value pairs, @@ -82,7 +83,7 @@ struct CacheEntry { } - size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { return mallocSizeOf(data); } }; @@ -129,7 +130,7 @@ public: // This measures all the heap memory used by the StartupCache, i.e. it // excludes the mapping. - size_t HeapSizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t HeapSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); size_t SizeOfMapping(); @@ -155,7 +156,7 @@ private: static size_t SizeOfEntryExcludingThis(const nsACString& key, const nsAutoPtr& data, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *); nsClassHashtable mTable; diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index ba7963529c2a..f9e640b7b122 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -6,6 +6,7 @@ #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/dom/ContentChild.h" @@ -2221,13 +2222,13 @@ History::FetchPageInfo(VisitData& _place, bool* _exists) } /* static */ size_t -History::SizeOfEntryExcludingThis(KeyClass* aEntry, nsMallocSizeOfFun aMallocSizeOf, void *) +History::SizeOfEntryExcludingThis(KeyClass* aEntry, mozilla::MallocSizeOf aMallocSizeOf, void *) { return aEntry->array.SizeOfExcludingThis(aMallocSizeOf); } size_t -History::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOfThis) +History::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOfThis) { return aMallocSizeOfThis(this) + mObservers.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOfThis); diff --git a/toolkit/components/places/History.h b/toolkit/components/places/History.h index 91197b9b36fa..5b96d1fe6339 100644 --- a/toolkit/components/places/History.h +++ b/toolkit/components/places/History.h @@ -8,6 +8,7 @@ #define mozilla_places_History_h_ #include "mozilla/IHistory.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozIAsyncHistory.h" #include "nsIDownloadHistory.h" @@ -82,7 +83,7 @@ public: * Get the number of bytes of memory this History object is using, * including sizeof(*this)) */ - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); /** * Obtains a pointer to this service. @@ -192,7 +193,7 @@ private: * SizeOfIncludingThis(). */ static size_t SizeOfEntryExcludingThis(KeyClass* aEntry, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void*); nsTHashtable mObservers; diff --git a/toolkit/components/places/tests/cpp/mock_Link.h b/toolkit/components/places/tests/cpp/mock_Link.h index 6ca54a953fd6..d02a4314aa83 100644 --- a/toolkit/components/places/tests/cpp/mock_Link.h +++ b/toolkit/components/places/tests/cpp/mock_Link.h @@ -11,6 +11,7 @@ #ifndef mock_Link_h__ #define mock_Link_h__ +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/Link.h" class mock_Link : public mozilla::dom::Link @@ -41,7 +42,7 @@ public: mDeathGrip = 0; } - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { return 0; // the value shouldn't matter } @@ -108,7 +109,7 @@ Link::GetURI() const } size_t -Link::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { NS_NOTREACHED("Unexpected call to Link::SizeOfExcludingThis"); return 0; diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 89ca6d0f90e8..71a585ff5a66 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -21,6 +21,7 @@ #include "nsCOMArray.h" #include "nsCOMPtr.h" #include "nsXPCOMPrivate.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/ModuleUtils.h" #include "nsIXPConnect.h" #include "mozilla/Services.h" @@ -251,7 +252,7 @@ public: #endif static nsresult GetHistogramEnumId(const char *name, Telemetry::ID *id); static int64_t GetTelemetryMemoryUsed(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); struct Stat { uint32_t hitCount; uint32_t totalTime; @@ -268,7 +269,7 @@ private: template struct impl { static size_t SizeOfEntryExcludingThis(EntryType *, - nsMallocSizeOfFun, + mozilla::MallocSizeOf, void *) { return 0; }; @@ -346,7 +347,7 @@ TelemetryImpl* TelemetryImpl::sTelemetry = NULL; NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(TelemetryMallocSizeOf) size_t -TelemetryImpl::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = 0; n += aMallocSizeOf(this); diff --git a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp index 58f53b9828f2..624905028ac3 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp @@ -16,6 +16,7 @@ #include "nsToolkitCompsCID.h" #include "nsTArray.h" #include "nsThreadUtils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozilla/Telemetry.h" #include "mozilla/FileUtils.h" @@ -314,7 +315,7 @@ nsUrlClassifierPrefixSet::Contains(uint32_t aPrefix, bool* aFound) } size_t -nsUrlClassifierPrefixSet::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsUrlClassifierPrefixSet::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = 0; n += aMallocSizeOf(this); diff --git a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h index f6b0481b5335..380f77d947b9 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h @@ -15,6 +15,7 @@ #include "nsIMemoryReporter.h" #include "nsTArray.h" #include "nsToolkitCompsCID.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozilla/CondVar.h" #include "mozilla/FileUtils.h" @@ -39,7 +40,7 @@ public: // Return the estimated size of the set on disk and in memory, // in bytes - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf); protected: static const uint32_t DELTAS_LIMIT = 100; diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 4ed82709985d..e9b8e0d868b5 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -55,6 +55,7 @@ // traversed. #include "mozilla/CycleCollectedJSRuntime.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/DOMJSClass.h" #include "jsfriendapi.h" @@ -480,7 +481,7 @@ CycleCollectedJSRuntime::~CycleCollectedJSRuntime() } size_t -CycleCollectedJSRuntime::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const +CycleCollectedJSRuntime::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; diff --git a/xpcom/base/CycleCollectedJSRuntime.h b/xpcom/base/CycleCollectedJSRuntime.h index a53a7ce02f0b..f179bd64c7b9 100644 --- a/xpcom/base/CycleCollectedJSRuntime.h +++ b/xpcom/base/CycleCollectedJSRuntime.h @@ -7,6 +7,7 @@ #ifndef mozilla_CycleCollectedJSRuntime_h__ #define mozilla_CycleCollectedJSRuntime_h__ +#include "mozilla/MemoryReporting.h" #include "jsprvtd.h" #include "jsapi.h" @@ -88,7 +89,7 @@ protected: return mJSRuntime; } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; void UnmarkSkippableJSHolders(); virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb) = 0; diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index b2150c0c6b9a..253eff43295e 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -99,6 +99,7 @@ #include "base/process_util.h" /* This must occur *after* base/process_util.h to avoid typedefs conflicts. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Util.h" #include "mozilla/CycleCollectedJSRuntime.h" @@ -385,7 +386,7 @@ public: Block **mNextBlockPtr; }; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; Block *b = Blocks(); while (b) { @@ -582,7 +583,7 @@ public: PtrInfo *mNext, *mBlockEnd, *&mLast; }; - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const { + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { // We don't measure the things pointed to by mEntries[] because those // pointers are non-owning. size_t n = 0; @@ -623,7 +624,7 @@ struct GCGraph ~GCGraph() { } - void SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, size_t *aNodesSize, size_t *aEdgesSize) const { *aNodesSize = mNodes.SizeOfExcludingThis(aMallocSizeOf); *aEdgesSize = mEdges.SizeOfExcludingThis(aMallocSizeOf); @@ -837,7 +838,7 @@ public: return mCount; } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const + size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; @@ -1089,7 +1090,7 @@ public: mGraph.mRootCount = 0; } - void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, + void SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, size_t *aObjectSize, size_t *aGraphNodesSize, size_t *aGraphEdgesSize, @@ -2919,7 +2920,7 @@ nsCycleCollector::Shutdown() } void -nsCycleCollector::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf, +nsCycleCollector::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf, size_t *aObjectSize, size_t *aGraphNodesSize, size_t *aGraphEdgesSize, diff --git a/xpcom/base/nsISizeOf.h b/xpcom/base/nsISizeOf.h index 258ec1827bde..35f5de44c742 100644 --- a/xpcom/base/nsISizeOf.h +++ b/xpcom/base/nsISizeOf.h @@ -7,6 +7,7 @@ #ifndef nsISizeOf_h___ #define nsISizeOf_h___ +#include "mozilla/MemoryReporting.h" #include "nsISupports.h" #define NS_ISIZEOF_IID \ @@ -21,12 +22,12 @@ public: /** * Measures the size of the things pointed to by the object. */ - virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const = 0; + virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0; /** * Like SizeOfExcludingThis, but also includes the size of the object itself. */ - virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const = 0; + virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsISizeOf, NS_ISIZEOF_IID) diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index c7864553c728..72f02e61d188 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -28,12 +28,6 @@ #include "mozilla/NullPtr.h" -/* - * This is for functions that are like malloc_usable_size. Such functions are - * used for measuring the size of data structures. - */ -typedef size_t(*nsMallocSizeOfFun)(const void *p); - /* Core XPCOM declarations. */ /*----------------------------------------------------------------------*/ diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 62e873c3828a..4d853604090a 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -28,6 +28,7 @@ #include "nsQuickSort.h" #include "nsEnumeratorUtils.h" #include "nsThreadUtils.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Services.h" #include "ManifestParser.h" @@ -312,7 +313,7 @@ CategoryNode::Enumerate(nsISimpleEnumerator **_retval) } size_t -CategoryNode::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) +CategoryNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) { // We don't measure the strings pointed to by the entries because the // pointers are non-owning. @@ -499,7 +500,7 @@ nsCategoryManager::GetCategoryManagerSize() static size_t SizeOfCategoryManagerTableEntryExcludingThis(nsDepCharHashKey::KeyType aKey, const nsAutoPtr &aData, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { // We don't measure the string pointed to by aKey because it's a non-owning @@ -508,7 +509,7 @@ SizeOfCategoryManagerTableEntryExcludingThis(nsDepCharHashKey::KeyType aKey, } size_t -nsCategoryManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsCategoryManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); diff --git a/xpcom/components/nsCategoryManager.h b/xpcom/components/nsCategoryManager.h index 6ac9a84bb846..5f3e3efaad80 100644 --- a/xpcom/components/nsCategoryManager.h +++ b/xpcom/components/nsCategoryManager.h @@ -11,6 +11,7 @@ #include "plarena.h" #include "nsClassHashtable.h" #include "nsICategoryManager.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozilla/Attributes.h" @@ -76,7 +77,7 @@ public: ~CategoryNode(); void operator delete(void*) { } - size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: CategoryNode() @@ -122,7 +123,7 @@ public: static void Destroy(); static int64_t GetCategoryManagerSize(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: static nsCategoryManager* gCategoryManager; diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index df16aa4cf373..d5acd371b6dd 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -36,6 +36,7 @@ #include "nsCategoryManager.h" #include "nsCategoryManagerUtils.h" #include "xptiprivate.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/XPTInterfaceInfoManager.h" #include "nsIConsoleService.h" #include "nsIMemoryReporter.h" @@ -1680,7 +1681,7 @@ nsComponentManagerImpl::ContractIDToCID(const char *aContractID, static size_t SizeOfFactoriesEntryExcludingThis(nsIDHashKey::KeyType aKey, nsFactoryEntry* const &aData, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { return aData->SizeOfIncludingThis(aMallocSizeOf); @@ -1689,7 +1690,7 @@ SizeOfFactoriesEntryExcludingThis(nsIDHashKey::KeyType aKey, static size_t SizeOfContractIDsEntryExcludingThis(nsCStringHashKey::KeyType aKey, nsFactoryEntry* const &aData, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aUserArg) { // We don't measure the nsFactoryEntry data because its owned by mFactories @@ -1698,7 +1699,7 @@ SizeOfContractIDsEntryExcludingThis(nsCStringHashKey::KeyType aKey, } size_t -nsComponentManagerImpl::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsComponentManagerImpl::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); n += mLoaderMap.SizeOfExcludingThis(nullptr, aMallocSizeOf); @@ -1802,7 +1803,7 @@ nsFactoryEntry::GetFactory() } size_t -nsFactoryEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +nsFactoryEntry::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index a5c96097d040..be605ac721ec 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -13,6 +13,7 @@ #include "nsIComponentRegistrar.h" #include "nsIServiceManager.h" #include "nsIFile.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Module.h" #include "mozilla/ModuleLoader.h" #include "mozilla/Mutex.h" @@ -311,7 +312,7 @@ public: nsTArray mPendingServices; - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); private: ~nsComponentManagerImpl(); @@ -336,7 +337,7 @@ struct nsFactoryEntry already_AddRefed GetFactory(); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); const mozilla::Module::CIDEntry* mCIDEntry; nsComponentManagerImpl::KnownModule* mModule; diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 4f470829dcb7..babf74523073 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -7,6 +7,7 @@ #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/HashFunctions.h" +#include "mozilla/MemoryReporting.h" #include "nsAtomTable.h" #include "nsStaticAtom.h" @@ -96,7 +97,7 @@ public: // for |#ifdef NS_BUILD_REFCNT_LOGGING| access to reference count nsrefcnt GetRefCount() { return mRefCnt; } - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; }; /** @@ -435,7 +436,7 @@ AtomImpl::IsStaticAtom() } size_t -AtomImpl::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const +AtomImpl::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + nsStringBuffer::FromData(mString)-> @@ -446,7 +447,7 @@ AtomImpl::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const static size_t SizeOfAtomTableEntryExcludingThis(PLDHashEntryHdr *aHdr, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void *aArg) { AtomTableEntry* entry = static_cast(aHdr); @@ -456,14 +457,14 @@ SizeOfAtomTableEntryExcludingThis(PLDHashEntryHdr *aHdr, static size_t SizeOfStaticAtomTableEntryExcludingThis(const nsAString& aKey, nsIAtom* const& aData, - nsMallocSizeOfFun aMallocSizeOf, + MallocSizeOf aMallocSizeOf, void* aArg) { return aKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf); } size_t -NS_SizeOfAtomTablesIncludingThis(nsMallocSizeOfFun aMallocSizeOf) { +NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = 0; if (gAtomTable.ops) { n += PL_DHashTableSizeOfExcludingThis(&gAtomTable, diff --git a/xpcom/ds/nsAtomTable.h b/xpcom/ds/nsAtomTable.h index 30b1f9e55d33..0f9244cffbbe 100644 --- a/xpcom/ds/nsAtomTable.h +++ b/xpcom/ds/nsAtomTable.h @@ -6,11 +6,12 @@ #ifndef nsAtomTable_h__ #define nsAtomTable_h__ +#include "mozilla/MemoryReporting.h" #include #include "nscore.h" void NS_PurgeAtomTable(); -size_t NS_SizeOfAtomTablesIncludingThis(nsMallocSizeOfFun aMallocSizeOf); +size_t NS_SizeOfAtomTablesIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); #endif // nsAtomTable_h__ diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h index 7c2fbb02ee4d..126ff8021619 100644 --- a/xpcom/glue/nsBaseHashtable.h +++ b/xpcom/glue/nsBaseHashtable.h @@ -6,6 +6,7 @@ #ifndef nsBaseHashtable_h__ #define nsBaseHashtable_h__ +#include "mozilla/MemoryReporting.h" #include "nsTHashtable.h" #include "prlock.h" #include "nsDebug.h" @@ -240,7 +241,7 @@ public: typedef size_t (* SizeOfEntryExcludingThisFun)(KeyType aKey, const DataType &aData, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void* userArg); /** @@ -256,7 +257,7 @@ public: * @return the summed size of the entries, the table, and the table's storage */ size_t SizeOfIncludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, void *userArg = nullptr) + mozilla::MallocSizeOf mallocSizeOf, void *userArg = nullptr) { return mallocSizeOf(this) + this->SizeOfExcludingThis(sizeOfEntryExcludingThis, mallocSizeOf, userArg); @@ -275,7 +276,7 @@ public: * @return the summed size of all the entries */ size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, void *userArg = nullptr) const + mozilla::MallocSizeOf mallocSizeOf, void *userArg = nullptr) const { if (!IsInitialized()) { return 0; @@ -323,7 +324,7 @@ protected: }; static size_t s_SizeOfStub(PLDHashEntryHdr *entry, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg); }; @@ -457,7 +458,7 @@ nsBaseHashtable::s_EnumStub template size_t nsBaseHashtable::s_SizeOfStub - (PLDHashEntryHdr *hdr, nsMallocSizeOfFun mallocSizeOf, void *arg) + (PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *arg) { EntryType* ent = static_cast(hdr); s_SizeOfArgs* eargs = static_cast(arg); diff --git a/xpcom/glue/nsCOMArray.cpp b/xpcom/glue/nsCOMArray.cpp index 32941fca30c9..35bf7ee8a80d 100644 --- a/xpcom/glue/nsCOMArray.cpp +++ b/xpcom/glue/nsCOMArray.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include "nsCOMArray.h" #include "nsCOMPtr.h" @@ -264,7 +265,7 @@ nsCOMArray_base::SetCount(int32_t aNewCount) size_t nsCOMArray_base::SizeOfExcludingThis( nsBaseArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, - nsMallocSizeOfFun aMallocSizeOf, void* aData) const + mozilla::MallocSizeOf aMallocSizeOf, void* aData) const { size_t n = mArray.SizeOfExcludingThis(aMallocSizeOf); diff --git a/xpcom/glue/nsCOMArray.h b/xpcom/glue/nsCOMArray.h index 0d9dd05fca02..f1c66788c1ce 100644 --- a/xpcom/glue/nsCOMArray.h +++ b/xpcom/glue/nsCOMArray.h @@ -7,6 +7,7 @@ #define nsCOMArray_h__ #include "mozilla/Attributes.h" +#include "mozilla/MemoryReporting.h" #include "nsCycleCollectionNoteChild.h" #include "nsTArray.h" @@ -161,14 +162,14 @@ public: } typedef size_t (* nsBaseArraySizeOfElementIncludingThisFunc) - (nsISupports* aElement, nsMallocSizeOfFun aMallocSizeOf, void *aData); + (nsISupports* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData); // Measures the size of the array's element storage, and if // |aSizeOfElement| is non-NULL, measures the size of things pointed to by // elements. size_t SizeOfExcludingThis( nsBaseArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, - nsMallocSizeOfFun aMallocSizeOf, void* aData = NULL) const; + mozilla::MallocSizeOf aMallocSizeOf, void* aData = NULL) const; private: @@ -376,11 +377,11 @@ class nsCOMArray : public nsCOMArray_base // "IncludingThis" rather than "ExcludingThis" because it needs to measure // the memory taken by the T itself as well as anything it points to. typedef size_t (* nsCOMArraySizeOfElementIncludingThisFunc) - (T* aElement, nsMallocSizeOfFun aMallocSizeOf, void *aData); + (T* aElement, mozilla::MallocSizeOf aMallocSizeOf, void *aData); size_t SizeOfExcludingThis( nsCOMArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, - nsMallocSizeOfFun aMallocSizeOf, void *aData = NULL) const { + mozilla::MallocSizeOf aMallocSizeOf, void *aData = NULL) const { return nsCOMArray_base::SizeOfExcludingThis( nsBaseArraySizeOfElementIncludingThisFunc(aSizeOfElementIncludingThis), aMallocSizeOf, aData); diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index 3c059eb66b00..f272b02ff7c4 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -9,6 +9,7 @@ #include "nsTArrayForwardDeclare.h" #include "mozilla/Assertions.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/TypeTraits.h" #include "mozilla/Util.h" @@ -829,7 +830,7 @@ public: // @return The amount of memory used by this nsTArray_Impl, excluding // sizeof(*this). - size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { if (this->UsesAutoArrayBuffer() || Hdr() == EmptyHdr()) return 0; return mallocSizeOf(this->Hdr()); @@ -837,7 +838,7 @@ public: // @return The amount of memory used by this nsTArray_Impl, including // sizeof(*this). - size_t SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf) const { + size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf); } diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index 72ffcde6cdc4..53fb8167d2d7 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -10,6 +10,7 @@ #include "pldhash.h" #include "nsDebug.h" #include NEW_H +#include "mozilla/MemoryReporting.h" #include "mozilla/fallible.h" // helper function for nsTHashtable::Clear() @@ -256,7 +257,7 @@ public: * @return summed size of the things pointed to by the entries */ typedef size_t (* SizeOfEntryExcludingThisFun)(EntryType* aEntry, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg); /** @@ -272,7 +273,7 @@ public: * @return the summed size of all the entries */ size_t SizeOfExcludingThis(SizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, void *userArg = NULL) const + mozilla::MallocSizeOf mallocSizeOf, void *userArg = NULL) const { if (!IsInitialized()) { return 0; @@ -355,7 +356,7 @@ protected: }; static size_t s_SizeOfStub(PLDHashEntryHdr *entry, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg); private: @@ -489,7 +490,7 @@ nsTHashtable::s_EnumStub(PLDHashTable *table, template size_t nsTHashtable::s_SizeOfStub(PLDHashEntryHdr *entry, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg) { // dereferences the function-pointer to the user's enumeration function diff --git a/xpcom/glue/nsTObserverArray.h b/xpcom/glue/nsTObserverArray.h index eb862f33ffa3..92dc9d0e13f3 100644 --- a/xpcom/glue/nsTObserverArray.h +++ b/xpcom/glue/nsTObserverArray.h @@ -6,6 +6,7 @@ #ifndef nsTObserverArray_h___ #define nsTObserverArray_h___ +#include "mozilla/MemoryReporting.h" #include "nsTArray.h" #include "nsCycleCollectionNoteChild.h" @@ -243,7 +244,7 @@ class nsAutoTObserverArray : protected nsTObserverArray_base { // Returns the number of bytes on the heap taken up by this object, not // including sizeof(*this). - size_t SizeOfExcludingThis(nsMallocSizeOfFun mallocSizeOf) const { + size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mArray.SizeOfExcludingThis(mallocSizeOf); } diff --git a/xpcom/glue/nsVoidArray.cpp b/xpcom/glue/nsVoidArray.cpp index 60bddbfc7726..02f4e13857cb 100644 --- a/xpcom/glue/nsVoidArray.cpp +++ b/xpcom/glue/nsVoidArray.cpp @@ -3,6 +3,7 @@ * 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/. */ +#include "mozilla/MemoryReporting.h" #include #include "nsVoidArray.h" @@ -697,7 +698,7 @@ struct SizeOfElementIncludingThisData { size_t mSize; nsVoidArraySizeOfElementIncludingThisFunc mSizeOfElementIncludingThis; - nsMallocSizeOfFun mMallocSizeOf; + mozilla::MallocSizeOf mMallocSizeOf; void *mData; // the arg passed by the user }; @@ -712,7 +713,7 @@ SizeOfElementIncludingThisEnumerator(const void *aElement, void *aData) size_t nsVoidArray::SizeOfExcludingThis( nsVoidArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, - nsMallocSizeOfFun aMallocSizeOf, void* aData) const + mozilla::MallocSizeOf aMallocSizeOf, void* aData) const { size_t n = 0; // Measure the element storage. diff --git a/xpcom/glue/nsVoidArray.h b/xpcom/glue/nsVoidArray.h index 78193bc50eb1..310095b71f90 100644 --- a/xpcom/glue/nsVoidArray.h +++ b/xpcom/glue/nsVoidArray.h @@ -9,6 +9,7 @@ #include "nsDebug.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/StandardInteger.h" // Comparator callback function for sorting array values. @@ -21,7 +22,7 @@ typedef bool (* nsVoidArrayEnumFuncConst)(const void* aElement, void *aData); // SizeOfExcludingThis callback function. typedef size_t (* nsVoidArraySizeOfElementIncludingThisFunc)(const void* aElement, - nsMallocSizeOfFun aMallocSizeOf, + mozilla::MallocSizeOf aMallocSizeOf, void *aData); /// A basic zero-based array of void*'s that manages its own memory @@ -111,7 +112,7 @@ public: // pointed to by elements. size_t SizeOfExcludingThis( nsVoidArraySizeOfElementIncludingThisFunc aSizeOfElementIncludingThis, - nsMallocSizeOfFun aMallocSizeOf, void* aData = NULL) const; + mozilla::MallocSizeOf aMallocSizeOf, void* aData = NULL) const; protected: bool GrowArrayBy(int32_t aGrowBy); diff --git a/xpcom/glue/pldhash.cpp b/xpcom/glue/pldhash.cpp index 4357dfaea2d3..9f4010a8b669 100644 --- a/xpcom/glue/pldhash.cpp +++ b/xpcom/glue/pldhash.cpp @@ -15,6 +15,7 @@ #include "nsDebug.h" /* for PR_ASSERT */ #include "nsAlgorithm.h" #include "mozilla/Likely.h" +#include "mozilla/MemoryReporting.h" #ifdef PL_DHASHMETER # if defined MOZILLA_CLIENT && defined DEBUG_XXXbrendan @@ -755,7 +756,7 @@ struct SizeOfEntryExcludingThisArg { size_t total; PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis; - nsMallocSizeOfFun mallocSizeOf; + MallocSizeOf mallocSizeOf; void *arg; // the arg passed by the user }; @@ -771,7 +772,7 @@ SizeOfEntryExcludingThisEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr, size_t PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table, PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, + MallocSizeOf mallocSizeOf, void *arg /* = NULL */) { size_t n = 0; @@ -788,7 +789,7 @@ PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table, size_t PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table, PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, + MallocSizeOf mallocSizeOf, void *arg /* = NULL */) { return mallocSizeOf(table) + diff --git a/xpcom/glue/pldhash.h b/xpcom/glue/pldhash.h index a05d2c3f79f3..c13a62bea503 100644 --- a/xpcom/glue/pldhash.h +++ b/xpcom/glue/pldhash.h @@ -8,6 +8,7 @@ /* * Double hashing, a la Knuth 6. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/Types.h" #include "nscore.h" @@ -549,7 +550,7 @@ PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg); typedef size_t (* PLDHashSizeOfEntryExcludingThisFun)(PLDHashEntryHdr *hdr, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg); /** @@ -561,7 +562,7 @@ typedef size_t NS_COM_GLUE size_t PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table, PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg = NULL); /** @@ -570,7 +571,7 @@ PL_DHashTableSizeOfExcludingThis(const PLDHashTable *table, NS_COM_GLUE size_t PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table, PLDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - nsMallocSizeOfFun mallocSizeOf, + mozilla::MallocSizeOf mallocSizeOf, void *arg = NULL); #ifdef DEBUG diff --git a/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h b/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h index 1fddf395f4f5..4876e03eab33 100644 --- a/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h +++ b/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h @@ -9,6 +9,7 @@ #include "nsIInterfaceInfoManager.h" +#include "mozilla/MemoryReporting.h" #include "mozilla/Mutex.h" #include "mozilla/ReentrantMonitor.h" #include "nsDataHashtable.h" @@ -44,7 +45,7 @@ public: xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid); - size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf); + size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf); static int64_t GetXPTIWorkingSetSize(); diff --git a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp index 771f034d7018..39c5904fc7e7 100644 --- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp +++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp @@ -5,6 +5,7 @@ /* Implementation of xptiInterfaceInfoManager. */ +#include "mozilla/MemoryReporting.h" #include "mozilla/XPTInterfaceInfoManager.h" #include "xptiprivate.h" @@ -30,7 +31,7 @@ static int gCallCount = 0; NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(XPTMallocSizeOf) size_t -XPTInterfaceInfoManager::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) +XPTInterfaceInfoManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); ReentrantMonitorAutoEnter monitor(mWorkingSet.mTableReentrantMonitor); diff --git a/xpcom/string/public/nsStringBuffer.h b/xpcom/string/public/nsStringBuffer.h index be0cc3da002f..dbd92759825d 100644 --- a/xpcom/string/public/nsStringBuffer.h +++ b/xpcom/string/public/nsStringBuffer.h @@ -7,6 +7,8 @@ #ifndef nsStringBuffer_h__ #define nsStringBuffer_h__ +#include "mozilla/MemoryReporting.h" + template struct already_AddRefed; /** @@ -143,12 +145,12 @@ class nsStringBuffer * This measures the size. It should only be used if the StringBuffer is * unshared. This is checked. */ - size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThisMustBeUnshared(mozilla::MallocSizeOf aMallocSizeOf) const; /** * This measures the size only if the StringBuffer is unshared. */ - size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf aMallocSizeOf) const; /** * This measures the size regardless of whether the StringBuffer is @@ -159,7 +161,7 @@ class nsStringBuffer * please explain clearly in a comment why it's safe and won't lead to * double-counting. */ - size_t SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun aMallocSizeOf) const; + size_t SizeOfIncludingThisEvenIfShared(mozilla::MallocSizeOf aMallocSizeOf) const; }; #endif /* !defined(nsStringBuffer_h__ */ diff --git a/xpcom/string/public/nsTSubstring.h b/xpcom/string/public/nsTSubstring.h index 28ca1fa5af9d..972195ec380b 100644 --- a/xpcom/string/public/nsTSubstring.h +++ b/xpcom/string/public/nsTSubstring.h @@ -6,6 +6,8 @@ // IWYU pragma: private, include "nsAString.h" +#include "mozilla/MemoryReporting.h" + #ifndef MOZILLA_INTERNAL_API #error Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead. #endif @@ -626,14 +628,14 @@ class nsTSubstring_CharT mFlags(flags) {} #endif /* DEBUG || FORCE_BUILD_REFCNT_LOGGING */ - size_t SizeOfExcludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfExcludingThisMustBeUnshared(mozilla::MallocSizeOf mallocSizeOf) const; - size_t SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfIncludingThisMustBeUnshared(mozilla::MallocSizeOf mallocSizeOf) const; - size_t SizeOfExcludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfExcludingThisIfUnshared(mozilla::MallocSizeOf mallocSizeOf) const; - size_t SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf mallocSizeOf) const; /** @@ -642,9 +644,9 @@ class nsTSubstring_CharT * you do use them, please explain clearly in a comment why it's safe * and won't lead to double-counting. */ - size_t SizeOfExcludingThisEvenIfShared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfExcludingThisEvenIfShared(mozilla::MallocSizeOf mallocSizeOf) const; - size_t SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun mallocSizeOf) + size_t SizeOfIncludingThisEvenIfShared(mozilla::MallocSizeOf mallocSizeOf) const; protected: diff --git a/xpcom/string/src/nsSubstring.cpp b/xpcom/string/src/nsSubstring.cpp index fe1c22755343..ee6ca120c60d 100644 --- a/xpcom/string/src/nsSubstring.cpp +++ b/xpcom/string/src/nsSubstring.cpp @@ -8,6 +8,8 @@ #define ENABLE_STRING_STATS #endif +#include "mozilla/MemoryReporting.h" + #ifdef ENABLE_STRING_STATS #include #endif @@ -277,7 +279,7 @@ nsStringBuffer::ToString(uint32_t len, nsACString &str, } size_t -nsStringBuffer::SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun aMallocSizeOf) const +nsStringBuffer::SizeOfIncludingThisMustBeUnshared(mozilla::MallocSizeOf aMallocSizeOf) const { NS_ASSERTION(!IsReadonly(), "shared StringBuffer in SizeOfIncludingThisMustBeUnshared"); @@ -285,7 +287,7 @@ nsStringBuffer::SizeOfIncludingThisMustBeUnshared(nsMallocSizeOfFun aMallocSizeO } size_t -nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) const +nsStringBuffer::SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf aMallocSizeOf) const { if (!IsReadonly()) { @@ -295,7 +297,7 @@ nsStringBuffer::SizeOfIncludingThisIfUnshared(nsMallocSizeOfFun aMallocSizeOf) c } size_t -nsStringBuffer::SizeOfIncludingThisEvenIfShared(nsMallocSizeOfFun aMallocSizeOf) const +nsStringBuffer::SizeOfIncludingThisEvenIfShared(mozilla::MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this); } diff --git a/xpcom/string/src/nsTSubstring.cpp b/xpcom/string/src/nsTSubstring.cpp index d9d078d211fa..4acfb87b9a84 100644 --- a/xpcom/string/src/nsTSubstring.cpp +++ b/xpcom/string/src/nsTSubstring.cpp @@ -3,6 +3,7 @@ /* 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/. */ +#include "mozilla/MemoryReporting.h" #include "prdtoa.h" #ifdef XPCOM_STRING_CONSTRUCTOR_OUT_OF_LINE @@ -883,7 +884,7 @@ nsTSubstring_CharT::DoAppendFloat( double aFloat, int digits ) size_t nsTSubstring_CharT::SizeOfExcludingThisMustBeUnshared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { if (mFlags & F_SHARED) { return nsStringBuffer::FromData(mData)-> @@ -906,7 +907,7 @@ nsTSubstring_CharT::SizeOfExcludingThisMustBeUnshared( size_t nsTSubstring_CharT::SizeOfExcludingThisIfUnshared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { // This is identical to SizeOfExcludingThisMustBeUnshared except for the // F_SHARED case. @@ -922,7 +923,7 @@ nsTSubstring_CharT::SizeOfExcludingThisIfUnshared( size_t nsTSubstring_CharT::SizeOfExcludingThisEvenIfShared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { // This is identical to SizeOfExcludingThisMustBeUnshared except for the // F_SHARED case. @@ -938,21 +939,21 @@ nsTSubstring_CharT::SizeOfExcludingThisEvenIfShared( size_t nsTSubstring_CharT::SizeOfIncludingThisMustBeUnshared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + SizeOfExcludingThisMustBeUnshared(mallocSizeOf); } size_t nsTSubstring_CharT::SizeOfIncludingThisIfUnshared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + SizeOfExcludingThisIfUnshared(mallocSizeOf); } size_t nsTSubstring_CharT::SizeOfIncludingThisEvenIfShared( - nsMallocSizeOfFun mallocSizeOf) const + mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + SizeOfExcludingThisEvenIfShared(mallocSizeOf); } From 71f4105f111facc1dd133c8dd24fcd2de049232c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 24 Jun 2013 15:55:52 -0700 Subject: [PATCH 06/45] Bug 886205 (part 1) - Move some function definitions from gc/Barrier-inl.h to gc/Barrier.h. r=terrence. --HG-- extra : rebase_source : d6eeb4f6273c36069a8bbb28033737c2aec40ba0 --- js/src/gc/Barrier-inl.h | 14 -------------- js/src/gc/Barrier.h | 10 ++++++++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/js/src/gc/Barrier-inl.h b/js/src/gc/Barrier-inl.h index 7be0c1dfafcd..93116e645dcb 100644 --- a/js/src/gc/Barrier-inl.h +++ b/js/src/gc/Barrier-inl.h @@ -56,20 +56,6 @@ EncapsulatedValue::~EncapsulatedValue() pre(); } -inline void -EncapsulatedValue::init(const Value &v) -{ - JS_ASSERT(!IsPoisonedValue(v)); - value = v; -} - -inline void -EncapsulatedValue::init(JSRuntime *rt, const Value &v) -{ - JS_ASSERT(!IsPoisonedValue(v)); - value = v; -} - inline EncapsulatedValue & EncapsulatedValue::operator=(const Value &v) { diff --git a/js/src/gc/Barrier.h b/js/src/gc/Barrier.h index 05d0d925c06e..bbf49aad0a1e 100644 --- a/js/src/gc/Barrier.h +++ b/js/src/gc/Barrier.h @@ -384,8 +384,14 @@ class EncapsulatedValue : public ValueOperations } inline ~EncapsulatedValue(); - inline void init(const Value &v); - inline void init(JSRuntime *rt, const Value &v); + void init(const Value &v) { + JS_ASSERT(!IsPoisonedValue(v)); + value = v; + } + void init(JSRuntime *rt, const Value &v) { + JS_ASSERT(!IsPoisonedValue(v)); + value = v; + } inline EncapsulatedValue &operator=(const Value &v); inline EncapsulatedValue &operator=(const EncapsulatedValue &v); From 1727aad1db4414c4c8bf130e077ff158b08e122c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 24 Jun 2013 16:03:02 -0700 Subject: [PATCH 07/45] Bug 886205 (part 2) - Move some function definitions from vm/ObjectImpl-inl.h to vm/ObjectImpl.h. r=terrence. --HG-- extra : rebase_source : c12d632b99542002954f02b7004cbbcfdee7f6c5 --- js/src/builtin/TestingFunctions.cpp | 1 + js/src/vm/Interpreter.h | 31 ---- js/src/vm/ObjectImpl-inl.h | 218 ---------------------------- js/src/vm/ObjectImpl.cpp | 12 ++ js/src/vm/ObjectImpl.h | 209 ++++++++++++++++++++++---- 5 files changed, 191 insertions(+), 280 deletions(-) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index c4b37bc5215b..3f81a1ebf174 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -16,6 +16,7 @@ #include "ion/AsmJS.h" #include "vm/ForkJoin.h" +#include "vm/Interpreter.h" #include "vm/ObjectImpl-inl.h" diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index a16cfe31fd5f..6fa0de001167 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -393,37 +393,6 @@ class TryNoteIter /************************************************************************/ -/* - * To really poison a set of values, using 'magic' or 'undefined' isn't good - * enough since often these will just be ignored by buggy code (see bug 629974) - * in debug builds and crash in release builds. Instead, we use a safe-for-crash - * pointer. - */ -static JS_ALWAYS_INLINE void -Debug_SetValueRangeToCrashOnTouch(Value *beg, Value *end) -{ -#ifdef DEBUG - for (Value *v = beg; v != end; ++v) - v->setObject(*reinterpret_cast(0x42)); -#endif -} - -static JS_ALWAYS_INLINE void -Debug_SetValueRangeToCrashOnTouch(Value *vec, size_t len) -{ -#ifdef DEBUG - Debug_SetValueRangeToCrashOnTouch(vec, vec + len); -#endif -} - -static JS_ALWAYS_INLINE void -Debug_SetValueRangeToCrashOnTouch(HeapValue *vec, size_t len) -{ -#ifdef DEBUG - Debug_SetValueRangeToCrashOnTouch((Value *) vec, len); -#endif -} - bool Throw(JSContext *cx, HandleValue v); diff --git a/js/src/vm/ObjectImpl-inl.h b/js/src/vm/ObjectImpl-inl.h index c5a4b4a864f4..bca18c168a85 100644 --- a/js/src/vm/ObjectImpl-inl.h +++ b/js/src/vm/ObjectImpl-inl.h @@ -16,97 +16,22 @@ #include "gc/Heap.h" #include "gc/Marking.h" #include "js/TemplateLib.h" -#include "vm/Interpreter.h" #include "vm/ObjectImpl.h" #include "gc/Barrier-inl.h" -namespace js { - -static MOZ_ALWAYS_INLINE void -Debug_SetSlotRangeToCrashOnTouch(HeapSlot *vec, uint32_t len) -{ -#ifdef DEBUG - Debug_SetValueRangeToCrashOnTouch((Value *) vec, len); -#endif -} - -static MOZ_ALWAYS_INLINE void -Debug_SetSlotRangeToCrashOnTouch(HeapSlot *begin, HeapSlot *end) -{ -#ifdef DEBUG - Debug_SetValueRangeToCrashOnTouch((Value *) begin, end - begin); -#endif -} - -} // namespace js - inline JSCompartment * js::ObjectImpl::compartment() const { return lastProperty()->base()->compartment(); } -inline js::TaggedProto -js::ObjectImpl::getTaggedProto() const -{ - return TaggedProto(getProto()); -} - -inline js::Shape * -js::ObjectImpl::nativeLookup(JSContext *cx, PropertyId pid) -{ - return nativeLookup(cx, pid.asId()); -} - -inline js::Shape * -js::ObjectImpl::nativeLookup(JSContext *cx, PropertyName *name) -{ - return nativeLookup(cx, NameToId(name)); -} - -inline bool -js::ObjectImpl::nativeContains(JSContext *cx, jsid id) -{ - return nativeLookup(cx, id) != NULL; -} - -inline bool -js::ObjectImpl::nativeContains(JSContext *cx, PropertyName *name) -{ - return nativeLookup(cx, name) != NULL; -} - inline bool js::ObjectImpl::nativeContains(JSContext *cx, Shape *shape) { return nativeLookup(cx, shape->propid()) == shape; } -inline js::Shape * -js::ObjectImpl::nativeLookupPure(PropertyId pid) -{ - return nativeLookupPure(pid.asId()); -} - -inline js::Shape * -js::ObjectImpl::nativeLookupPure(PropertyName *name) -{ - return nativeLookupPure(NameToId(name)); -} - -inline bool -js::ObjectImpl::nativeContainsPure(jsid id) -{ - return nativeLookupPure(id) != NULL; -} - -inline bool -js::ObjectImpl::nativeContainsPure(PropertyName *name) -{ - return nativeContainsPure(NameToId(name)); -} - inline bool js::ObjectImpl::nativeContainsPure(Shape *shape) { @@ -123,88 +48,6 @@ js::ObjectImpl::isExtensible() const return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE); } -inline uint32_t -js::ObjectImpl::getDenseInitializedLength() -{ - MOZ_ASSERT(isNative()); - return getElementsHeader()->initializedLength; -} - -inline uint32_t -js::ObjectImpl::getDenseCapacity() -{ - MOZ_ASSERT(isNative()); - return getElementsHeader()->capacity; -} - -inline js::HeapSlotArray -js::ObjectImpl::getDenseElements() -{ - MOZ_ASSERT(isNative()); - return HeapSlotArray(elements); -} - -inline const js::Value & -js::ObjectImpl::getDenseElement(uint32_t idx) -{ - MOZ_ASSERT(isNative() && idx < getDenseInitializedLength()); - return elements[idx]; -} - -inline bool -js::ObjectImpl::containsDenseElement(uint32_t idx) -{ - MOZ_ASSERT(isNative()); - return idx < getDenseInitializedLength() && !elements[idx].isMagic(JS_ELEMENTS_HOLE); -} - -inline void -js::ObjectImpl::getSlotRangeUnchecked(uint32_t start, uint32_t length, - HeapSlot **fixedStart, HeapSlot **fixedEnd, - HeapSlot **slotsStart, HeapSlot **slotsEnd) -{ - MOZ_ASSERT(start + length >= start); - - uint32_t fixed = numFixedSlots(); - if (start < fixed) { - if (start + length < fixed) { - *fixedStart = &fixedSlots()[start]; - *fixedEnd = &fixedSlots()[start + length]; - *slotsStart = *slotsEnd = NULL; - } else { - uint32_t localCopy = fixed - start; - *fixedStart = &fixedSlots()[start]; - *fixedEnd = &fixedSlots()[start + localCopy]; - *slotsStart = &slots[0]; - *slotsEnd = &slots[length - localCopy]; - } - } else { - *fixedStart = *fixedEnd = NULL; - *slotsStart = &slots[start - fixed]; - *slotsEnd = &slots[start - fixed + length]; - } -} - -inline void -js::ObjectImpl::getSlotRange(uint32_t start, uint32_t length, - HeapSlot **fixedStart, HeapSlot **fixedEnd, - HeapSlot **slotsStart, HeapSlot **slotsEnd) -{ - MOZ_ASSERT(slotInRange(start + length, SENTINEL_ALLOWED)); - getSlotRangeUnchecked(start, length, fixedStart, fixedEnd, slotsStart, slotsEnd); -} - -inline void -js::ObjectImpl::invalidateSlotRange(uint32_t start, uint32_t length) -{ -#ifdef DEBUG - HeapSlot *fixedStart, *fixedEnd, *slotsStart, *slotsEnd; - getSlotRange(start, length, &fixedStart, &fixedEnd, &slotsStart, &slotsEnd); - Debug_SetSlotRangeToCrashOnTouch(fixedStart, fixedEnd); - Debug_SetSlotRangeToCrashOnTouch(slotsStart, slotsEnd); -#endif /* DEBUG */ -} - inline bool js::ObjectImpl::isNative() const { @@ -217,22 +60,6 @@ js::ObjectImpl::isProxy() const return js::IsProxy(const_cast(this->asObjectPtr())); } -inline js::HeapSlot & -js::ObjectImpl::nativeGetSlotRef(uint32_t slot) -{ - MOZ_ASSERT(isNative()); - MOZ_ASSERT(slot < slotSpan()); - return getSlotRef(slot); -} - -inline const js::Value & -js::ObjectImpl::nativeGetSlot(uint32_t slot) const -{ - MOZ_ASSERT(isNative()); - MOZ_ASSERT(slot < slotSpan()); - return getSlot(slot); -} - #ifdef DEBUG inline bool IsObjectValueInCompartment(js::Value v, JSCompartment *comp) @@ -309,18 +136,6 @@ js::ObjectImpl::numDynamicSlots() const return dynamicSlotsCount(numFixedSlots(), slotSpan()); } -inline JSClass * -js::ObjectImpl::getJSClass() const -{ - return Jsvalify(getClass()); -} - -inline const js::ObjectOps * -js::ObjectImpl::getOps() const -{ - return &getClass()->ops; -} - inline bool js::ObjectImpl::isDelegate() const { @@ -333,26 +148,6 @@ js::ObjectImpl::inDictionaryMode() const return lastProperty()->inDictionary(); } -/* static */ inline uint32_t -js::ObjectImpl::dynamicSlotsCount(uint32_t nfixed, uint32_t span) -{ - if (span <= nfixed) - return 0; - span -= nfixed; - if (span <= SLOT_CAPACITY_MIN) - return SLOT_CAPACITY_MIN; - - uint32_t slots = RoundUpPow2(span); - MOZ_ASSERT(slots >= span); - return slots; -} - -inline size_t -js::ObjectImpl::tenuredSizeOfThis() const -{ - return js::gc::Arena::thingSize(tenuredGetAllocKind()); -} - JS_ALWAYS_INLINE JS::Zone * js::ObjectImpl::zone() const { @@ -442,17 +237,4 @@ js::ObjectImpl::setPrivateGCThing(js::gc::Cell *cell) privateWriteBarrierPost(pprivate); } -inline void -js::ObjectImpl::setPrivateUnbarriered(void *data) -{ - void **pprivate = &privateRef(numFixedSlots()); - *pprivate = data; -} - -inline void -js::ObjectImpl::initPrivate(void *data) -{ - privateRef(numFixedSlots()) = data; -} - #endif /* vm_ObjectImpl_inl_h */ diff --git a/js/src/vm/ObjectImpl.cpp b/js/src/vm/ObjectImpl.cpp index b1ce27530b44..f369f1b9c331 100644 --- a/js/src/vm/ObjectImpl.cpp +++ b/js/src/vm/ObjectImpl.cpp @@ -16,6 +16,18 @@ using namespace js; +void +js::ObjectImpl::assertIsNative() const +{ + MOZ_ASSERT(isNative()); +} + +void +js::ObjectImpl::assertSlotIsWithinSpan(uint32_t slot) const +{ + MOZ_ASSERT(slot < slotSpan()); +} + PropDesc::PropDesc() : pd_(UndefinedValue()), value_(UndefinedValue()), diff --git a/js/src/vm/ObjectImpl.h b/js/src/vm/ObjectImpl.h index 980f935bdbab..f1d4d2cae9de 100644 --- a/js/src/vm/ObjectImpl.h +++ b/js/src/vm/ObjectImpl.h @@ -27,6 +27,53 @@ class ObjectImpl; class Nursery; class Shape; +/* + * To really poison a set of values, using 'magic' or 'undefined' isn't good + * enough since often these will just be ignored by buggy code (see bug 629974) + * in debug builds and crash in release builds. Instead, we use a safe-for-crash + * pointer. + */ +static JS_ALWAYS_INLINE void +Debug_SetValueRangeToCrashOnTouch(Value *beg, Value *end) +{ +#ifdef DEBUG + for (Value *v = beg; v != end; ++v) + v->setObject(*reinterpret_cast(0x42)); +#endif +} + +static JS_ALWAYS_INLINE void +Debug_SetValueRangeToCrashOnTouch(Value *vec, size_t len) +{ +#ifdef DEBUG + Debug_SetValueRangeToCrashOnTouch(vec, vec + len); +#endif +} + +static JS_ALWAYS_INLINE void +Debug_SetValueRangeToCrashOnTouch(HeapValue *vec, size_t len) +{ +#ifdef DEBUG + Debug_SetValueRangeToCrashOnTouch((Value *) vec, len); +#endif +} + +static MOZ_ALWAYS_INLINE void +Debug_SetSlotRangeToCrashOnTouch(HeapSlot *vec, uint32_t len) +{ +#ifdef DEBUG + Debug_SetValueRangeToCrashOnTouch((Value *) vec, len); +#endif +} + +static MOZ_ALWAYS_INLINE void +Debug_SetSlotRangeToCrashOnTouch(HeapSlot *begin, HeapSlot *end) +{ +#ifdef DEBUG + Debug_SetValueRangeToCrashOnTouch((Value *) begin, end - begin); +#endif +} + static inline PropertyOp CastAsPropertyOp(JSObject *object) { @@ -1197,11 +1244,27 @@ class ObjectImpl : public gc::Cell static bool preventExtensions(JSContext *cx, Handle obj); - inline HeapSlotArray getDenseElements(); - inline const Value & getDenseElement(uint32_t idx); - inline bool containsDenseElement(uint32_t idx); - inline uint32_t getDenseInitializedLength(); - inline uint32_t getDenseCapacity(); + HeapSlotArray getDenseElements() { + assertIsNative(); + return HeapSlotArray(elements); + } + const Value &getDenseElement(uint32_t idx) { + assertIsNative(); + MOZ_ASSERT(idx < getDenseInitializedLength()); + return elements[idx]; + } + bool containsDenseElement(uint32_t idx) { + assertIsNative(); + return idx < getDenseInitializedLength() && !elements[idx].isMagic(JS_ELEMENTS_HOLE); + } + uint32_t getDenseInitializedLength() { + assertIsNative(); + return getElementsHeader()->initializedLength; + } + uint32_t getDenseCapacity() { + assertIsNative(); + return getElementsHeader()->capacity; + } bool makeElementsSparse(JSContext *cx) { NEW_OBJECT_REPRESENTATION_ONLY(); @@ -1238,19 +1301,54 @@ class ObjectImpl : public gc::Cell * Get internal pointers to the range of values starting at start and * running for length. */ - inline void getSlotRangeUnchecked(uint32_t start, uint32_t length, - HeapSlot **fixedStart, HeapSlot **fixedEnd, - HeapSlot **slotsStart, HeapSlot **slotsEnd); - inline void getSlotRange(uint32_t start, uint32_t length, - HeapSlot **fixedStart, HeapSlot **fixedEnd, - HeapSlot **slotsStart, HeapSlot **slotsEnd); + void getSlotRangeUnchecked(uint32_t start, uint32_t length, + HeapSlot **fixedStart, HeapSlot **fixedEnd, + HeapSlot **slotsStart, HeapSlot **slotsEnd) + { + MOZ_ASSERT(start + length >= start); + + uint32_t fixed = numFixedSlots(); + if (start < fixed) { + if (start + length < fixed) { + *fixedStart = &fixedSlots()[start]; + *fixedEnd = &fixedSlots()[start + length]; + *slotsStart = *slotsEnd = NULL; + } else { + uint32_t localCopy = fixed - start; + *fixedStart = &fixedSlots()[start]; + *fixedEnd = &fixedSlots()[start + localCopy]; + *slotsStart = &slots[0]; + *slotsEnd = &slots[length - localCopy]; + } + } else { + *fixedStart = *fixedEnd = NULL; + *slotsStart = &slots[start - fixed]; + *slotsEnd = &slots[start - fixed + length]; + } + } + + void getSlotRange(uint32_t start, uint32_t length, + HeapSlot **fixedStart, HeapSlot **fixedEnd, + HeapSlot **slotsStart, HeapSlot **slotsEnd) + { + MOZ_ASSERT(slotInRange(start + length, SENTINEL_ALLOWED)); + getSlotRangeUnchecked(start, length, fixedStart, fixedEnd, slotsStart, slotsEnd); + } protected: friend struct GCMarker; friend class Shape; friend class NewObjectCache; - inline void invalidateSlotRange(uint32_t start, uint32_t count); + void invalidateSlotRange(uint32_t start, uint32_t length) { +#ifdef DEBUG + HeapSlot *fixedStart, *fixedEnd, *slotsStart, *slotsEnd; + getSlotRange(start, length, &fixedStart, &fixedEnd, &slotsStart, &slotsEnd); + Debug_SetSlotRangeToCrashOnTouch(fixedStart, fixedEnd); + Debug_SetSlotRangeToCrashOnTouch(slotsStart, slotsEnd); +#endif /* DEBUG */ + } + void initializeSlotRange(uint32_t start, uint32_t count); /* @@ -1310,7 +1408,9 @@ class ObjectImpl : public gc::Cell */ public: - inline js::TaggedProto getTaggedProto() const; + js::TaggedProto getTaggedProto() const { + return TaggedProto(getProto()); + } Shape * lastProperty() const { MOZ_ASSERT(shape_); @@ -1324,6 +1424,7 @@ class ObjectImpl : public gc::Cell inline JSCompartment *compartment() const; inline bool isNative() const; + void assertIsNative() const; types::TypeObject *type() const { MOZ_ASSERT(!hasLazyType()); @@ -1347,16 +1448,25 @@ class ObjectImpl : public gc::Cell bool hasLazyType() const { return type_->lazy(); } inline uint32_t slotSpan() const; + void assertSlotIsWithinSpan(uint32_t slot) const; /* Compute dynamicSlotsCount() for this object. */ inline uint32_t numDynamicSlots() const; Shape *nativeLookup(JSContext *cx, jsid id); - inline Shape *nativeLookup(JSContext *cx, PropertyId pid); - inline Shape *nativeLookup(JSContext *cx, PropertyName *name); + Shape *nativeLookup(JSContext *cx, PropertyId pid) { + return nativeLookup(cx, pid.asId()); + } + Shape *nativeLookup(JSContext *cx, PropertyName *name) { + return nativeLookup(cx, NameToId(name)); + } - inline bool nativeContains(JSContext *cx, jsid id); - inline bool nativeContains(JSContext *cx, PropertyName* name); + bool nativeContains(JSContext *cx, jsid id) { + return nativeLookup(cx, id) != NULL; + } + bool nativeContains(JSContext *cx, PropertyName* name) { + return nativeLookup(cx, name) != NULL; + } inline bool nativeContains(JSContext *cx, Shape* shape); /* @@ -1364,18 +1474,30 @@ class ObjectImpl : public gc::Cell * operation would have been effectful. */ Shape *nativeLookupPure(jsid id); - inline Shape *nativeLookupPure(PropertyId pid); - inline Shape *nativeLookupPure(PropertyName *name); + Shape *nativeLookupPure(PropertyId pid) { + return nativeLookupPure(pid.asId()); + } + Shape *nativeLookupPure(PropertyName *name) { + return nativeLookupPure(NameToId(name)); + } - inline bool nativeContainsPure(jsid id); - inline bool nativeContainsPure(PropertyName* name); - inline bool nativeContainsPure(Shape* shape); + bool nativeContainsPure(jsid id) { + return nativeLookupPure(id) != NULL; + } + bool nativeContainsPure(PropertyName* name) { + return nativeContainsPure(NameToId(name)); + } + bool nativeContainsPure(Shape* shape); - inline JSClass *getJSClass() const; - inline bool hasClass(const Class *c) const { + JSClass *getJSClass() const { + return Jsvalify(getClass()); + } + bool hasClass(const Class *c) const { return getClass() == c; } - inline const ObjectOps *getOps() const; + const ObjectOps *getOps() const { + return &getClass()->ops; + } /* * An object is a delegate if it is on another object's prototype or scope @@ -1425,8 +1547,16 @@ class ObjectImpl : public gc::Cell return *getSlotAddress(slot); } - inline HeapSlot &nativeGetSlotRef(uint32_t slot); - inline const Value &nativeGetSlot(uint32_t slot) const; + HeapSlot &nativeGetSlotRef(uint32_t slot) { + assertIsNative(); + assertSlotIsWithinSpan(slot); + return getSlotRef(slot); + } + const Value &nativeGetSlot(uint32_t slot) const { + assertIsNative(); + assertSlotIsWithinSpan(slot); + return getSlot(slot); + } inline void setSlot(uint32_t slot, const Value &value); inline void setCrossCompartmentSlot(uint32_t slot, const Value &value); @@ -1455,10 +1585,22 @@ class ObjectImpl : public gc::Cell * capacity is not stored explicitly, and the allocated size of the slot * array is kept in sync with this count. */ - static inline uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span); + static uint32_t dynamicSlotsCount(uint32_t nfixed, uint32_t span) { + if (span <= nfixed) + return 0; + span -= nfixed; + if (span <= SLOT_CAPACITY_MIN) + return SLOT_CAPACITY_MIN; + + uint32_t slots = RoundUpPow2(span); + MOZ_ASSERT(slots >= span); + return slots; + } /* Memory usage functions. */ - inline size_t tenuredSizeOfThis() const; + size_t tenuredSizeOfThis() const { + return js::gc::Arena::thingSize(tenuredGetAllocKind()); + } /* Elements accessors. */ @@ -1531,8 +1673,13 @@ class ObjectImpl : public gc::Cell } inline void setPrivate(void *data); inline void setPrivateGCThing(gc::Cell *cell); - inline void setPrivateUnbarriered(void *data); - inline void initPrivate(void *data); + void setPrivateUnbarriered(void *data) { + void **pprivate = &privateRef(numFixedSlots()); + *pprivate = data; + } + void initPrivate(void *data) { + privateRef(numFixedSlots()) = data; + } /* Access private data for an object with a known number of fixed slots. */ inline void *getPrivate(uint32_t nfixed) const { From e74572c8bcace594eb7692b2d56fba678faac26d Mon Sep 17 00:00:00 2001 From: Brian Nicholson Date: Mon, 24 Jun 2013 21:44:07 -0700 Subject: [PATCH 08/45] Bug 849847 - Make about:home scrollable with the analog stick. r=Cwiiis --- mobile/android/base/BrowserApp.java | 4 +- mobile/android/base/Makefile.in | 1 + mobile/android/base/ScrollAnimator.java | 84 +++++++++++++++++++++++ mobile/android/base/widget/AboutHome.java | 15 ++++ 4 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 mobile/android/base/ScrollAnimator.java diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 65727bfda825..b13079a9db64 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -411,9 +411,9 @@ abstract public class BrowserApp extends GeckoApp // put the focus on the layerview and carry on if (mLayerView != null && !mLayerView.hasFocus() && GamepadUtils.isPanningControl(event)) { if (mAboutHome.getUserVisibleHint()) { - mLayerView.requestFocus(); - } else { mAboutHome.requestFocus(); + } else { + mLayerView.requestFocus(); } } return false; diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index b58b8c425faf..bb4957dfbd29 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -148,6 +148,7 @@ FENNEC_JAVA_FILES = \ RemoteTabs.java \ RobocopAPI.java \ ServiceNotificationClient.java \ + ScrollAnimator.java \ SessionParser.java \ SetupScreen.java \ ShapedButton.java \ diff --git a/mobile/android/base/ScrollAnimator.java b/mobile/android/base/ScrollAnimator.java new file mode 100644 index 000000000000..fd70179b43e7 --- /dev/null +++ b/mobile/android/base/ScrollAnimator.java @@ -0,0 +1,84 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- +/* 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/. */ + +package org.mozilla.gecko; + +import java.util.Timer; +import java.util.TimerTask; + +import org.mozilla.gecko.util.GamepadUtils; + +import android.view.InputDevice; +import android.view.MotionEvent; +import android.view.View; + +public class ScrollAnimator implements View.OnGenericMotionListener { + private Timer mScrollTimer; + private int mX; + private int mY; + + // Assuming 60fps, this will make the view scroll once per frame + static final long MS_PER_FRAME = 1000 / 60; + + // Maximum number of pixels that can be scrolled per frame + static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi(); + + private class ScrollRunnable extends TimerTask { + private View mView; + + public ScrollRunnable(View view) { + mView = view; + } + + @Override + public final void run() { + mView.scrollBy(mX, mY); + } + } + + @Override + public boolean onGenericMotion(View view, MotionEvent event) { + if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { + switch (event.getAction()) { + case MotionEvent.ACTION_MOVE: + // Cancel the animation if the joystick is in a neutral position + if (GamepadUtils.isValueInDeadZone(event, MotionEvent.AXIS_X) && + GamepadUtils.isValueInDeadZone(event, MotionEvent.AXIS_Y)) { + if (mScrollTimer != null) { + mScrollTimer.cancel(); + mScrollTimer = null; + } + return true; + } + + // Scroll with a velocity relative to the screen DPI + mX = (int) (event.getAxisValue(MotionEvent.AXIS_X) * MAX_SCROLL); + mY = (int) (event.getAxisValue(MotionEvent.AXIS_Y) * MAX_SCROLL); + + // Start the timer; the view will continue to scroll as long as + // the joystick is not in the deadzone. + if (mScrollTimer == null) { + mScrollTimer = new Timer(); + ScrollRunnable task = new ScrollRunnable(view); + mScrollTimer.scheduleAtFixedRate(task, 0, MS_PER_FRAME); + } + + return true; + } + } + + return false; + } + + /** + * Cancels the running scroll animation if it is in progress. + */ + public void cancel() { + if (mScrollTimer != null) { + mScrollTimer.cancel(); + mScrollTimer = null; + } + } +} diff --git a/mobile/android/base/widget/AboutHome.java b/mobile/android/base/widget/AboutHome.java index 099cf12d6539..78a2b8bdb762 100644 --- a/mobile/android/base/widget/AboutHome.java +++ b/mobile/android/base/widget/AboutHome.java @@ -10,11 +10,13 @@ import java.util.EnumSet; import org.mozilla.gecko.GeckoApplication; import org.mozilla.gecko.LightweightTheme; import org.mozilla.gecko.R; +import org.mozilla.gecko.ScrollAnimator; import org.mozilla.gecko.db.BrowserContract; import android.app.Activity; import android.content.res.Configuration; import android.database.ContentObserver; +import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.ContextMenu.ContextMenuInfo; @@ -43,6 +45,7 @@ public class AboutHome extends Fragment { private LastTabsSection mLastTabsSection; private RemoteTabsSection mRemoteTabsSection; private TopSitesView mTopSitesView; + private ScrollAnimator mScrollAnimator; public interface UriLoadListener { public void onAboutHomeUriLoad(String uriSpec); @@ -103,6 +106,13 @@ public class AboutHome extends Fragment { mAboutHomeView.setLightweightTheme(mLightweightTheme); mLightweightTheme.addListener(mAboutHomeView); + // ScrollAnimator implements the View.OnGenericMotionListener + // interface, which was added in API level 12. + if (Build.VERSION.SDK_INT >= 12) { + mScrollAnimator = new ScrollAnimator(); + mAboutHomeView.setOnGenericMotionListener(mScrollAnimator); + } + return mAboutHomeView; } @@ -137,6 +147,11 @@ public class AboutHome extends Fragment { getActivity().getContentResolver().unregisterContentObserver(mTabsContentObserver); mTopSitesView.onDestroy(); + if (mScrollAnimator != null) { + mScrollAnimator.cancel(); + } + mScrollAnimator = null; + mAboutHomeView = null; mAddonsSection = null; mLastTabsSection = null; From ad935d26206e379824f1cbc773741ebb88852682 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Mon, 24 Jun 2013 22:07:12 -0700 Subject: [PATCH 09/45] Bug 870103 - Disable plugins and HTML5 media in BackgroundPageThumbs's browser. r=markh --- .../thumbnails/content/backgroundPageThumbsContent.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js index d106991604c9..9597e82cb196 100644 --- a/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js +++ b/toolkit/components/thumbnails/content/backgroundPageThumbsContent.js @@ -18,6 +18,9 @@ const backgroundPageThumbsContent = { getInterface(Ci.nsIDOMWindowUtils); dwu.preventFurtherDialogs(); + docShell.allowMedia = false; + docShell.allowPlugins = false; + // Stop about:blank from loading. If it finishes loading after a capture // request is received, it could trigger the capture's load listener. this._webNav.stop(Ci.nsIWebNavigation.STOP_NETWORK); From 5ef67cfb8812772e30d8495d36c10acb81806990 Mon Sep 17 00:00:00 2001 From: Sam Foster Date: Mon, 24 Jun 2013 18:24:09 -0700 Subject: [PATCH 10/45] Bug 828088 - Rework richgrid and richgriditem bindings to use css columns for down-then-across grids. r=fryn --HG-- extra : rebase_source : 797845516ce09fab93cfc0690ee204fa9cc0a157 --- browser/metro/base/content/TopSites.js | 2 +- browser/metro/base/content/bindings/grid.xml | 237 ++++++++++----- browser/metro/base/content/browser.xul | 8 +- .../base/tests/mochitest/browser_tilegrid.xul | 19 +- .../base/tests/mochitest/browser_tiles.js | 82 +++++- browser/metro/base/tests/mochitest/head.js | 18 ++ browser/metro/theme/browser.css | 20 +- browser/metro/theme/defines.inc | 10 +- browser/metro/theme/jar.mn | 1 + browser/metro/theme/platform.css | 142 --------- browser/metro/theme/tiles.css | 274 ++++++++++++++++++ 11 files changed, 576 insertions(+), 237 deletions(-) create mode 100644 browser/metro/theme/tiles.css diff --git a/browser/metro/base/content/TopSites.js b/browser/metro/base/content/TopSites.js index 7e8d8812e2a2..6450738513cc 100644 --- a/browser/metro/base/content/TopSites.js +++ b/browser/metro/base/content/TopSites.js @@ -328,8 +328,8 @@ TopSitesView.prototype = { for (let idx=0; idx < length; idx++) { let isNew = !tileset.children[idx], - item = tileset.children[idx] || document.createElement("richgriditem"), site = sites[idx]; + let item = isNew ? tileset.createItemElement(site.title, site.url) : tileset.children[idx]; this.updateTile(item, site); if (isNew) { diff --git a/browser/metro/base/content/bindings/grid.xml b/browser/metro/base/content/bindings/grid.xml index 95f5c3b1acab..51fc1ebc3ea3 100644 --- a/browser/metro/base/content/bindings/grid.xml +++ b/browser/metro/base/content/bindings/grid.xml @@ -3,7 +3,6 @@ - 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/. --> - - + + + + + null @@ -85,6 +88,8 @@ @@ -96,6 +101,8 @@ + @@ -208,7 +217,7 @@ 0 - - 10 - - + - + this._itemHeightRenderThreshold) { - return gridItemRect; - } + // grab tile/item dimensions + this._tileSizes = this._getTileSizes(); + + let type = this.getAttribute("tiletype") || "default"; + let dims = this._tileSizes && this._tileSizes[type]; + if (!dims) { + throw new Error("Missing tile sizes for '" + type + "' type"); } - return null; + return dims; ]]> @@ -378,13 +387,18 @@ @@ -486,6 +510,7 @@ @@ -511,6 +537,62 @@ } ]]> + + + + + "tiles.css" + + + width/height values + let typeSelectors = { + "richgriditem" : "default", + "richgriditem[customImage]": "thumbnail", + "richgriditem[compact]": "compact" + }; + let rules, sheet; + for (let i=0; (sheet=sheets[i]); i++) { + if (sheet.href && sheet.href.endsWith( this._tileStyleSheetName )) { + rules = sheet.cssRules; + break; + } + } + if (rules) { + // walk the stylesheet rules until we've matched all our selectors + for (let i=0, rule;(rule=rules[i]); i++) { + let type = rule.selectorText && typeSelectors[rule.selectorText]; + if (type) { + let sizes = typeSizes[type] = {}; + typeSelectors[type] = null; + delete typeSelectors[type]; + // we assume px unit for tile dimension values + sizes.width = parseInt(rule.style.getPropertyValue("width")); + sizes.height = parseInt(rule.style.getPropertyValue("height")); + } + if (!Object.keys(typeSelectors).length) + break; + } + } else { + throw new Error("Failed to find stylesheet to parse out richgriditem dimensions\n"); + } + return typeSizes; + ]]> + + @@ -520,13 +602,12 @@ - + @@ -555,7 +636,7 @@ if (this.suppressOnSelect || this._suppressOnSelect) return; - var event = document.createEvent("Events"); + let event = document.createEvent("Events"); event.initEvent("selectionchange", true, true); this.dispatchEvent(event); ]]> @@ -630,22 +711,30 @@ + - - - - - - - + + + + + + - - - - + + + + + + + + + + @@ -663,16 +752,11 @@ onget="return this.hasAttribute('pinned')" onset="if (val) { this.setAttribute('pinned', val) } else this.removeAttribute('pinned');"/> - - - @@ -722,19 +804,21 @@ @@ -772,12 +856,11 @@ + diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul index 947ce0cde831..ef32c04b7996 100644 --- a/browser/metro/base/content/browser.xul +++ b/browser/metro/base/content/browser.xul @@ -9,6 +9,7 @@ + @@ -194,7 +195,7 @@ + - + - + diff --git a/browser/metro/base/tests/mochitest/browser_tilegrid.xul b/browser/metro/base/tests/mochitest/browser_tilegrid.xul index 5859a57275bf..4e3c24db52d3 100644 --- a/browser/metro/base/tests/mochitest/browser_tilegrid.xul +++ b/browser/metro/base/tests/mochitest/browser_tilegrid.xul @@ -6,16 +6,33 @@ + - + + + + + + + + + + + + + + + + + diff --git a/browser/metro/base/tests/mochitest/browser_tiles.js b/browser/metro/base/tests/mochitest/browser_tiles.js index f94acbcf5b15..82031bd114dd 100644 --- a/browser/metro/base/tests/mochitest/browser_tiles.js +++ b/browser/metro/base/tests/mochitest/browser_tiles.js @@ -8,6 +8,7 @@ function test() { info(chromeRoot + "browser_tilegrid.xul"); yield addTab(chromeRoot + "browser_tilegrid.xul"); doc = Browser.selectedTab.browser.contentWindow.document; + info("browser_tilegrid.xul loaded, doc populated, running tests"); }).then(runTests); } @@ -20,7 +21,7 @@ gTests.push({ ok(grid, "#grid1 is found"); is(typeof grid.clearSelection, "function", "#grid1 has the binding applied"); - is(grid.children.length, 1, "#grid1 has a single item"); + is(grid.children.length, 2, "#grid1 has a 2 items"); is(grid.children[0].control, grid, "#grid1 item's control points back at #grid1'"); } }); @@ -28,6 +29,7 @@ gTests.push({ gTests.push({ desc: "item clicks are handled", run: function() { + let grid = doc.querySelector("#grid1"); is(typeof grid.handleItemClick, "function", "grid.handleItemClick is a function"); let handleStub = stubMethod(grid, 'handleItemClick'); @@ -55,16 +57,90 @@ gTests.push({ is(controllerHandleStub.callCount, 1, "controller.handleItemClick was called when we clicked an item"); is(controllerHandleStub.calledWith[0], doc.getElementById(itemId), "controller.handleItemClick was passed the grid item"); grid.controller = origController; + } }); gTests.push({ desc: "arrangeItems", run: function() { + let container = doc.getElementById("alayout"); // implements an arrangeItems method, with optional cols, rows signature - let grid = doc.querySelector("#grid1"); + let grid = doc.querySelector("#grid_layout"); + is(typeof grid.arrangeItems, "function", "arrangeItems is a function on the grid"); - todo(false, "Test outcome of arrangeItems with cols and rows arguments"); + ok(grid.tileHeight, "grid has truthy tileHeight value"); + ok(grid.tileWidth, "grid has truthy tileWidth value"); + + // make the container big enough for 3 rows + container.style.height = 3 * grid.tileHeight + 20 + "px"; + + // add some items + grid.appendItem("test title", "about:blank", true); + grid.appendItem("test title", "about:blank", true); + grid.appendItem("test title", "about:blank", true); + grid.appendItem("test title", "about:blank", true); + grid.appendItem("test title", "about:blank", true); + + grid.arrangeItems(); + // they should all fit nicely in a 3x2 grid + is(grid.rowCount, 3, "rowCount is calculated correctly for a given container height and tileheight"); + is(grid.columnCount, 2, "columnCount is calculated correctly for a given container maxWidth and tilewidth"); + + // squish the available height + // should overflow (clip) a 2x2 grid + + dump("grid tileheight:" +grid.tileHeight+"\n"); + let under3rowsHeight = (3 * grid.tileHeight -20) + "px"; + dump("Squishing grid container to less than 3x tileheight:" +under3rowsHeight + "\n"); + container.style.height = under3rowsHeight; + grid.arrangeItems(); + + is(grid.rowCount, 2, "rowCount is re-calculated correctly for a given container height"); + } +}); + +gTests.push({ + desc: "clearAll", + run: function() { + let grid = doc.getElementById("clearGrid"); + grid.arrangeItems(); + + // grid has rows=2 so we expect at least 2 rows and 2 columns with 3 items + is(typeof grid.clearAll, "function", "clearAll is a function on the grid"); + is(grid.itemCount, 3, "grid has 3 items initially"); + is(grid.rowCount, 2, "grid has 2 rows initially"); + is(grid.columnCount, 2, "grid has 2 cols initially"); + + let arrangeSpy = spyOnMethod(grid, "arrangeItems"); + grid.clearAll(); + + is(grid.itemCount, 0, "grid has 0 itemCount after clearAll"); + is(grid.children.length, 0, "grid has 0 children after clearAll"); + is(grid.rowCount, 0, "grid has 0 rows when empty"); + is(grid.columnCount, 0, "grid has 0 cols when empty"); + + is(arrangeSpy.callCount, 1, "arrangeItems is called once when we clearAll"); + arrangeSpy.restore(); + } +}); + +gTests.push({ + desc: "empty grid", + run: function() { + let grid = doc.getElementById("emptyGrid"); + grid.arrangeItems(); + yield waitForCondition(() => !grid.isArranging); + + // grid has rows=2 but 0 items + ok(grid.isBound, "binding was applied"); + is(grid.itemCount, 0, "empty grid has 0 items"); + is(grid.rowCount, 0, "empty grid has 0 rows"); + is(grid.columnCount, 0, "empty grid has 0 cols"); + + let columnsNode = grid._grid; + let cStyle = doc.defaultView.getComputedStyle(columnsNode); + is(cStyle.getPropertyValue("-moz-column-count"), "auto", "empty grid has -moz-column-count: auto"); } }); diff --git a/browser/metro/base/tests/mochitest/head.js b/browser/metro/base/tests/mochitest/head.js index d9091b883d42..b392b608b69e 100644 --- a/browser/metro/base/tests/mochitest/head.js +++ b/browser/metro/base/tests/mochitest/head.js @@ -756,6 +756,24 @@ function runTests() { }); } +// wrap a method with a spy that records how and how many times it gets called +// the spy is returned; use spy.restore() to put the original back +function spyOnMethod(aObj, aMethod) { + let origFunc = aObj[aMethod]; + let spy = function() { + spy.calledWith = Array.slice(arguments); + spy.callCount++; + return (spy.returnValue = origFunc.apply(aObj, arguments)); + }; + spy.callCount = 0; + spy.restore = function() { + return (aObj[aMethod] = origFunc); + }; + return (aObj[aMethod] = spy); +} + +// replace a method with a stub that records how and how many times it gets called +// the stub is returned; use stub.restore() to put the original back function stubMethod(aObj, aMethod) { let origFunc = aObj[aMethod]; let func = function() { diff --git a/browser/metro/theme/browser.css b/browser/metro/theme/browser.css index 0c2e09a9a059..4408aef20ca4 100644 --- a/browser/metro/theme/browser.css +++ b/browser/metro/theme/browser.css @@ -122,7 +122,7 @@ opacity: 0; transform: scale(0, 0); } - + 100% { opacity: 1; transform: scale(1, 1); @@ -168,7 +168,7 @@ documenttab[closing] > .documenttab-container { font-size: @metro_font_normal@; width: @thumbnail_width@; padding: 4px @metro_spacing_snormal@ 8px; - + background: #000; opacity: 0.95; color: #fff; @@ -223,7 +223,7 @@ documenttab[selected] .documenttab-selection { } .selection-overlay { - pointer-events: none; + pointer-events: none; } .selection-overlay:-moz-focusring { @@ -749,13 +749,15 @@ setting[type="radio"] > vbox { visibility: collapse; } -/*tile content should be on same line in snapped view */ -#snapped-topsites-grid > richgriditem > .richgrid-item-content { - -moz-box-orient: horizontal; +/* startUI sections, grids */ +#start-container .meta-section { + /* allot space for at least a single column */ + min-width: @grid_double_column_width@; } -[viewstate="snapped"] .canSnapTiles .richgrid-item-desc { - -moz-margin-start: 8px; +#start-topsites { + /* allot space for 3 tile columns for the topsites grid */ + min-width: calc(3 * @grid_double_column_width@); } /* if snapped, hide the fullscreen awesome screen, if viewstate is anything @@ -778,9 +780,9 @@ setting[type="radio"] > vbox { #start-container[viewstate="snapped"] .meta-section { margin: 0px; + min-width: @grid_double_column_width@; } - /* Browser Content Areas ----------------------------------------------------- */ /* Hide the browser while the start UI is visible */ diff --git a/browser/metro/theme/defines.inc b/browser/metro/theme/defines.inc index 429cb1bfe8ea..871984be1eea 100644 --- a/browser/metro/theme/defines.inc +++ b/browser/metro/theme/defines.inc @@ -29,8 +29,16 @@ %define thumbnail_width 232px %define thumbnail_height 148px +%define grid_column_width 131px +%define grid_double_column_width 262px +%define grid_row_height 86px +%define grid_double_row_height 172px + +%define compactgrid_column_width 62px +%define compactgrid_row_height 62px + %define tile_border_color #dbdcde -%define tile_width 200px +%define tile_spacing 12px %define scroller_thickness 4px %define scroller_minimum 8px diff --git a/browser/metro/theme/jar.mn b/browser/metro/theme/jar.mn index 83d1a7cc4c3a..f5b879bda924 100644 --- a/browser/metro/theme/jar.mn +++ b/browser/metro/theme/jar.mn @@ -15,6 +15,7 @@ chrome.jar: skin/config.css (config.css) * skin/forms.css (forms.css) * skin/platform.css (platform.css) +* skin/tiles.css (tiles.css) skin/touchcontrols.css (touchcontrols.css) skin/netError.css (netError.css) % override chrome://global/skin/about.css chrome://browser/skin/about.css diff --git a/browser/metro/theme/platform.css b/browser/metro/theme/platform.css index f30f84efc771..bbf9bb6f5079 100644 --- a/browser/metro/theme/platform.css +++ b/browser/metro/theme/platform.css @@ -447,148 +447,6 @@ notification { } -/* Rich Grid ---------------------------------------------------------------- */ - -richgrid { - display: -moz-box; - -moz-box-sizing: border-box; -} - -richgrid .meta-grid { - display: block; -} - -richgriditem { - padding: @metro_spacing_small@; -} - -richgriditem .richgrid-item-content { - border: @metro_border_thin@ solid @tile_border_color@; - box-shadow: 0 0 @metro_spacing_snormal@ rgba(0, 0, 0, 0.1); - -moz-box-sizing: border-box; - padding: 10px 8px 6px 8px; - position: relative; -} -.richgrid-item-content { - background: #fff; -} - -richgriditem[selected] .richgrid-item-content::after { - content: ""; - pointer-events: none; - display: block; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - background-image: url(chrome://browser/skin/images/tile-selected-check-hdpi.png); - background-origin: border-box; - background-position: right 0 top 0; - background-repeat: no-repeat; - /* scale the image whatever the dppx */ - background-size: 35px 35px; - border: @metro_border_xthick@ solid @selected_color@; -} - -richgriditem[crosssliding] { - z-index: 1; -} - -/* ease the return to original position when cross-sliding */ -richgriditem:not([crosssliding]) { - transition: transform ease-out 0.2s; -} - -richgriditem .richgrid-icon-container { - padding-bottom: 2px; -} - -richgriditem .richgrid-icon-box { - padding: 4px; - background: #fff; - opacity: 1.0; -} - - -/* tile pinned-state indication */ -richgriditem[pinned] .richgrid-item-content::before { - pointer-events:none; - content: ""; - display: block; - position: absolute; - width: 35px; - height: 35px; - right: 0; - left: auto; - top: 0; - background-image: url(chrome://browser/skin/images/pinned-hdpi.png); - background-position: center; - background-repeat: no-repeat; - /* scale the image whatever the dppx */ - background-size: 70px 70px; -} - -/* Selected _and_ pinned tiles*/ -richgriditem[selected][pinned] .richgrid-item-content::before { - background-position: right -@metro_border_xthick@ top -@metro_border_xthick@; - width: 70px; - height: 70px; -} - -richgriditem[pinned]:-moz-locale-dir(rtl) .richgrid-item-content::before { - left: 0; - right: auto; -} - -richgriditem[customColor] { - color: #f1f1f1; -} -richgriditem[customImage] { - color: #1a1a1a; -} - - -richgriditem[customColor] .richgrid-icon-box { - opacity: 0.8; - background-color: #fff; -} - -.richgrid-item-content[customImage] { - height: 160px; - width: 250px; - background-size: cover; - background-position: center; - background-repeat: no-repeat; - -moz-box-pack: end; - padding: 0px; -} - -/* hide icon if there is an image background */ -.richgrid-icon-container[customImage] { - visibility: collapse; -} - -.richgrid-item-desc { - width: @tile_width@; - font-size: @metro_font_normal@; - margin-left: 0px; - padding-left: 0px !important; -} - -.richgrid-item-content[customImage] > .richgrid-item-desc { - background: hsla(0,2%,98%,.95); - /*margin-bottom: 0px; - margin-right: 0px;*/ - margin: 0px; -} - -richgriditem image { - width: 24px; - height: 24px; - list-style-image: url("chrome://browser/skin/images/identity-icons-generic.png"); -} - /* Dialogs ----------------------------------------------------------------- */ .modal-block, diff --git a/browser/metro/theme/tiles.css b/browser/metro/theme/tiles.css new file mode 100644 index 000000000000..d42c6c084b3b --- /dev/null +++ b/browser/metro/theme/tiles.css @@ -0,0 +1,274 @@ +/* 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/. */ + +/* Tile grid ------------------------------------------------------------- */ + +%filter substitution +%include defines.inc + +/* + ***************************************************** + The following rules define the key tile dimensions + They are (also) snarfed via the CSSOM as the dimensions used in the #richgrid binding + ***************************************************** + */ +richgriditem { + width: @grid_double_column_width@; + height: @grid_row_height@; +} +richgriditem[customImage] { + width: @grid_double_column_width@; + height: @grid_double_row_height@; +} +richgriditem[compact] { + width: auto; + height: @compactgrid_row_height@; +} + +/* + ***************************************************** + */ + +richgrid { + display: -moz-box; +} + +richgrid > .richgrid-grid { + -moz-column-width: @grid_double_column_width@; /* tile width (2x unit + gutter) */ + min-width: @grid_double_column_width@; /* min 1 column */ + min-height: @grid_double_row_height@; /* 2 rows (or 1 double rows) minimum; multiple of tile_height */ + -moz-column-fill: auto; /* do not attempt to balance content between columns */ + -moz-column-gap: 0; + -moz-column-count: auto; + display: block; + -moz-box-sizing: content-box; + overflow-x: hidden; /* clipping will only kick in if an explicit width is set */ + transition: 100ms transform ease-out; +} + +richgriditem { + display: block; + position: relative; + width: @grid_double_column_width@; + height: @grid_row_height@; + -moz-box-sizing: border-box; + -moz-column-gap: 0; + overflow:hidden; + cursor: default; + transition: 300ms height ease-out, + 150ms opacity ease-out, + 100ms transform ease-out; +} + +.tile-content { + display: block; + position: absolute; + background-color: #fff; + background-origin: padding-box; + /* content positioning within the grid "cell" + gives us the gutters/spacing between tiles */ + top: 2px; right: 6px; bottom: 10px; left: 6px; + border: @metro_border_thin@ solid @tile_border_color@; + box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1); + transition: 150ms transform ease-out; +} + +.tile-start-container { + position: absolute; + top: 0; + bottom: 0; + right: 0; + left: 20px; + background: hsla(0,2%,98%,.95); + padding: 8px; +} + +.tile-icon-box { + display: inline-block; + padding: 4px; + background: #fff; + opacity: 1.0; +} + +.tile-icon-box > image { + width: 24px; + height: 24px; + list-style-image: url("chrome://browser/skin/images/identity-icons-generic.png"); +} + +.tile-desc { + display: block; + position: absolute; + bottom: 0; + right: 0; + left: 20px; /* the colored bar in the default tile is the background color peeking through */ + z-index: 1; + padding: 4px 8px; + color: #333; + margin: 0; + -moz-margin-start: 0; + display: block; + font-size: 20px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +richgriditem.collapsed { + height: 0!important; + overflow: hidden; + opacity: 0; +} + +richgriditem.collapsed > .tile-content { + transform: scaleY(0); + transition: 150ms transform ease-out 150ms; +} + +richgriditem:active { + z-index: 2; +} + +/* thumbnail variation */ +richgriditem[customImage] { + width: @grid_double_column_width@; + height: @grid_double_row_height@; + -moz-box-pack: end; + padding: 0px; + color: #1a1a1a; +} + +richgriditem[customImage] .tile-desc { + background: transparent; + margin: 0px; + left: 0; +} + +richgriditem[customImage] > .tile-content > .tile-desc { + /* ensure thumbnail labels get their color from the parent richgriditem element */ + color: inherit; +} + +/* put the image in place of the icon if there is an image background */ +richgriditem[customImage] > .tile-content > .tile-start-container { + background-size: cover; + background-position: top left; + background-repeat: no-repeat; + position: absolute; + top: 0; + bottom: 32px; /* TODO: should be some em value? */; + right: 0; + left: 0; + background-color: hsla(0,2%,98%,.95); +} +richgriditem[customImage] .tile-icon-box { + visibility: collapse; +} + +/* selected tile indicator */ +richgriditem[selected] > .tile-content::after { + content: ""; + pointer-events: none; + display: block; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1; + background-image: url(chrome://browser/skin/images/tile-selected-check-hdpi.png); + background-origin: border-box; + background-position: right 0 top 0; + background-repeat: no-repeat; + /* scale the image whatever the dppx */ + background-size: 35px 35px; + border: @metro_border_xthick@ solid @selected_color@; +} + +richgriditem[crosssliding] { + z-index: 10; +} + +/* ease the return to original position when cross-sliding */ +richgriditem:not([crosssliding]) { + transition: transform ease-out 0.2s; +} + + +/* tile pinned-state indication */ +richgriditem[pinned] > .tile-content::before { + pointer-events:none; + content: ""; + display: block; + position: absolute; + top: 0; + right: 0; + left: auto; + z-index: 1; + width: 35px; + height: 35px; + background-image: url(chrome://browser/skin/images/pinned-hdpi.png); + background-position: center; + background-repeat: no-repeat; + /* scale the image whatever the dppx */ + background-size: 70px 70px; +} + +/* Selected _and_ pinned tiles*/ +richgriditem[selected][pinned] > .tile-content::before { + background-position: right -@metro_border_xthick@ top -@metro_border_xthick@; + width: 70px; + height: 70px; +} + +richgriditem[pinned]:-moz-locale-dir(rtl) > .tile-content::before { + left: 0; + right: auto; +} + +richgriditem[customColor] { + color: #f1f1f1; +} + +/* Snapped-view variation + We use the compact, single-column grid treatment for <=320px */ + +@media (max-width: 330px) { + + richgrid > .richgrid-grid { + -moz-column-width: auto!important; /* let it flow */ + -moz-column-count: auto!important; /* let it flow */ + height: auto; /* let it flow */ + min-width: 280px; + transition: 100ms transform ease-out; + } + + richgriditem { + width: @grid_double_column_width@; + overflow: hidden; + height: @compactgrid_row_height@; + } + + .tile-desc { + top: 0; + left: 44px; /* label goes to the right of the favicon */ + right: 0; + padding: 8px; + } + + .tile-start-container { + position: absolute; + top: 0; + bottom: 0; + right: 0; + left: 6px; + background: #fff; + padding: 8px; + } + .tile-icon-box { + padding: 2px; + background: #fff; + opacity: 1.0; + } +} From 4c0fbc2e273c425e50985721e77096e342e498a0 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 24 Jun 2013 22:32:10 -0700 Subject: [PATCH 11/45] Bug 858937 patch 1: Add nsLayoutUtils::GetStyleFrame() variant taking nsIContent*, and use it for two existing users of the variant taking nsIFrame*. r=nrc --- layout/base/nsCSSFrameConstructor.cpp | 3 +-- layout/base/nsLayoutUtils.cpp | 11 +++++++++++ layout/base/nsLayoutUtils.h | 8 ++++++++ layout/style/nsComputedDOMStyle.cpp | 5 ++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8120855ab22c..74caedafe50a 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -8907,8 +8907,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) // our content nsIContent* content = fixed->GetContent(); nsStyleContext* styleContext = - nsLayoutUtils::GetStyleFrame(content->GetPrimaryFrame())-> - StyleContext(); + nsLayoutUtils::GetStyleFrame(content)->StyleContext(); FrameConstructionItemList items; AddFrameConstructionItemsInternal(state, content, canvasFrame, content->Tag(), diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 794dec4099be..5013af855501 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -713,6 +713,17 @@ nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame) return aFrame; } +nsIFrame* +nsLayoutUtils::GetStyleFrame(const nsIContent* aContent) +{ + nsIFrame *frame = aContent->GetPrimaryFrame(); + if (!frame) { + return nullptr; + } + + return nsLayoutUtils::GetStyleFrame(frame); +} + nsIFrame* nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) { NS_ASSERTION(nsGkAtoms::placeholderFrame == aFrame->GetType(), diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 8756c8606216..0efdf5d7e0c9 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -145,6 +145,14 @@ public: */ static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame); + /** + * Given a content node, + * return the frame that has the non-psuedoelement style context for + * the content. May return null. + * This is aContent->GetPrimaryFrame() except for tableOuter frames. + */ + static nsIFrame* GetStyleFrame(const nsIContent* aContent); + /** * IsGeneratedContentFor returns true if aFrame is the outermost * frame for generated content of type aPseudoElement for aContent. diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 71add63dd046..eb1dd0f19d11 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -307,10 +307,9 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, } if (!aPseudo && aStyleType == eAll) { - nsIFrame* frame = aElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); if (frame) { - nsStyleContext* result = - nsLayoutUtils::GetStyleFrame(frame)->StyleContext(); + nsStyleContext* result = frame->StyleContext(); // Don't use the style context if it was influenced by // pseudo-elements, since then it's not the primary style // for this element. From 85ffcbb8add8fe6ca216ca7501c804e5c017edc4 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 24 Jun 2013 22:32:10 -0700 Subject: [PATCH 12/45] Bug 858937 patch 2: Make off-main-thread CSS transitions/animations code that should be using nsLayoutUtils::GetStyleFrame do so. r=nrc The fixes to the miniflush code (nsTransitionManager::UpdateThrottledStyle and UpdateAllThrottledStyles) fix the case where we constructed totally incorrect style contexts for outer table frames (which have special style contexts inheriting from the table frame) during the miniflush, leading to inconsistent style data and other bad things, when we should have been touching the style on the table frame instead. The fixes to the other OMTA codepaths lead to layer tests being performed on the same frame that the styles will be applied to, and probably fix real bugs (which would occur when animating opacity or transform on a table). --- layout/style/AnimationCommon.cpp | 8 ++++---- layout/style/nsAnimationManager.cpp | 2 +- layout/style/nsTransitionManager.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 64c05f01b692..1a4ec01126aa 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -261,7 +261,7 @@ CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *a return false; } - nsIFrame* frame = aElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); if (IsGeometricProperty(aProperty)) { if (shouldLog) { nsCString message; @@ -353,8 +353,8 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) // If the nearest scrollable ancestor has overflow:hidden, // we don't care about overflow. - nsIScrollableFrame* scrollable = - nsLayoutUtils::GetNearestScrollableFrame(mElement->GetPrimaryFrame()); + nsIScrollableFrame* scrollable = nsLayoutUtils::GetNearestScrollableFrame( + nsLayoutUtils::GetStyleFrame(mElement)); if (!scrollable) { return true; } @@ -372,7 +372,7 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) bool CommonElementAnimationData::CanThrottleAnimation(TimeStamp aTime) { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 1a9fb163466a..8a9c9f557420 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -356,7 +356,7 @@ ElementAnimations::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index e63b1e0a40fc..cccbe4859779 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -142,7 +142,7 @@ ElementTransitions::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementTransitions::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } @@ -260,7 +260,7 @@ nsTransitionManager::UpdateThrottledStyle(dom::Element* aElement, nsCSSPseudoElements::ePseudo_NotPseudoElement, false), "element not transitioning"); - nsIFrame* primaryFrame = aElement->GetPrimaryFrame(); + nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aElement); if (!primaryFrame) { return nullptr; } @@ -351,7 +351,7 @@ nsTransitionManager::UpdateThrottledStylesForSubtree(nsIContent* aContent, } else { // reparent the element's style nsStyleSet* styleSet = mPresContext->PresShell()->StyleSet(); - nsIFrame* primaryFrame = aContent->GetPrimaryFrame(); + nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aContent); if (!primaryFrame) { return; } @@ -424,7 +424,7 @@ nsTransitionManager::UpdateAllThrottledStyles() nsIFrame* primaryFrame; if (element && - (primaryFrame = element->GetPrimaryFrame())) { + (primaryFrame = nsLayoutUtils::GetStyleFrame(element))) { UpdateThrottledStylesForSubtree(element, primaryFrame->StyleContext()->GetParent(), changeList); } From b6aed040b7f8876884cb1013e0e9eadfe1c68406 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 24 Jun 2013 22:32:11 -0700 Subject: [PATCH 13/45] Bug 886635: HTMLCanvasElement.h (which is included in dom/bindings) should not include nsLayoutUtils.h r=khuey (It still ends up included in dom/bindings, though.) --- content/canvas/src/WebGLContext.h | 1 + content/html/content/public/HTMLCanvasElement.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 3c7054e733bd..250c7631163a 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -27,6 +27,7 @@ #include "nsIJSNativeInitializer.h" #include "nsWrapperCache.h" #include "nsIObserver.h" +#include "nsLayoutUtils.h" #include "GLContextProvider.h" diff --git a/content/html/content/public/HTMLCanvasElement.h b/content/html/content/public/HTMLCanvasElement.h index 0b4d61306187..1e525facf7c6 100644 --- a/content/html/content/public/HTMLCanvasElement.h +++ b/content/html/content/public/HTMLCanvasElement.h @@ -15,7 +15,6 @@ #include "nsNodeInfoManager.h" #include "nsICanvasElementExternal.h" -#include "nsLayoutUtils.h" #include "mozilla/gfx/Rect.h" class nsICanvasRenderingContextInternal; From 994ad89b823d78de9018aa1ef736d5eab9b22437 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Tue, 25 Jun 2013 16:01:38 +1000 Subject: [PATCH 14/45] Bug 886230 - Don't paint SVG text under DrawWindow(..., DRAWWINDOW_DO_NOT_FLUSH) when frames are dirty. r=roc --- .../canvas/src/CanvasRenderingContext2D.cpp | 3 + content/svg/content/test/Makefile.in | 1 + content/svg/content/test/test_text_dirty.html | 55 +++++++++++++++++++ layout/base/nsIPresShell.h | 13 ++++- layout/base/nsPresShell.cpp | 3 + layout/svg/nsSVGTextFrame2.cpp | 12 +++- .../specialpowers/content/specialpowersAPI.js | 25 ++++++--- 7 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 content/svg/content/test/test_text_dirty.html diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 48758c95c6ea..fd7683c45a70 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -3204,6 +3204,9 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x, if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_ASYNC_DECODE_IMAGES) { renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES; } + if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH) { + renderDocFlags |= nsIPresShell::RENDER_DRAWWINDOW_NOT_FLUSHING; + } // gfxContext-over-Azure may modify the DrawTarget's transform, so // save and restore it diff --git a/content/svg/content/test/Makefile.in b/content/svg/content/test/Makefile.in index 205a094d6787..786c3057c86c 100644 --- a/content/svg/content/test/Makefile.in +++ b/content/svg/content/test/Makefile.in @@ -80,6 +80,7 @@ MOCHITEST_FILES = \ switch-helper.svg \ test_text.html \ test_text_2.html \ + test_text_dirty.html \ test_text_scaled.html \ test_text_selection.html \ test_text_update.html \ diff --git a/content/svg/content/test/test_text_dirty.html b/content/svg/content/test/test_text_dirty.html new file mode 100644 index 000000000000..cfa4ab9d734f --- /dev/null +++ b/content/svg/content/test/test_text_dirty.html @@ -0,0 +1,55 @@ + + + + + Test for Bug 886230 + + + + + + +Mozilla Bug 886230 +

+ + x + + +

+ +
+
+
+ + diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 4242846bb956..5ab3aff4801a 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -173,7 +173,8 @@ protected: typedef mozilla::layers::LayerManager LayerManager; enum eRenderFlag { - STATE_IGNORING_VIEWPORT_SCROLLING = 0x1 + STATE_IGNORING_VIEWPORT_SCROLLING = 0x1, + STATE_DRAWWINDOW_NOT_FLUSHING = 0x2 }; typedef uint8_t RenderFlags; // for storing the above flags @@ -983,7 +984,8 @@ public: RENDER_CARET = 0x04, RENDER_USE_WIDGET_LAYERS = 0x08, RENDER_ASYNC_DECODE_IMAGES = 0x10, - RENDER_DOCUMENT_RELATIVE = 0x20 + RENDER_DOCUMENT_RELATIVE = 0x20, + RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40 }; virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, uint32_t aFlags, nscolor aBackgroundColor, @@ -1220,6 +1222,13 @@ public: float GetXResolution() { return mXResolution; } float GetYResolution() { return mYResolution; } + /** + * Returns whether we are in a DrawWindow() call that used the + * DRAWWINDOW_DO_NOT_FLUSH flag. + */ + bool InDrawWindowNotFlushing() const + { return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING; } + /** * Set the isFirstPaint flag. */ diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 60a03c5daaad..2735bb9c68d1 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4450,6 +4450,9 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags, wouldFlushRetainedLayers = !IgnoringViewportScrolling(); mRenderFlags = ChangeFlag(mRenderFlags, true, STATE_IGNORING_VIEWPORT_SCROLLING); } + if (aFlags & RENDER_DRAWWINDOW_NOT_FLUSHING) { + mRenderFlags = ChangeFlag(mRenderFlags, true, STATE_DRAWWINDOW_NOT_FLUSHING); + } if (aFlags & RENDER_DOCUMENT_RELATIVE) { // XXX be smarter about this ... drawWindow might want a rect // that's "pretty close" to what our retained layer tree covers. diff --git a/layout/svg/nsSVGTextFrame2.cpp b/layout/svg/nsSVGTextFrame2.cpp index ca092b302191..0d852ce1bd3b 100644 --- a/layout/svg/nsSVGTextFrame2.cpp +++ b/layout/svg/nsSVGTextFrame2.cpp @@ -3356,12 +3356,22 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext, if (!kid) return NS_OK; + nsPresContext* presContext = PresContext(); + gfxContext *gfx = aContext->ThebesContext(); gfxMatrix initialMatrix = gfx->CurrentMatrix(); AutoCanvasTMForMarker autoCanvasTMFor(this, FOR_PAINTING); if (mState & NS_STATE_SVG_NONDISPLAY_CHILD) { + // If we are in a canvas DrawWindow call that used the + // DRAWWINDOW_DO_NOT_FLUSH flag, then we may still have out + // of date frames. Just don't paint anything if they are + // dirty. + if (presContext->PresShell()->InDrawWindowNotFlushing() && + NS_SUBTREE_DIRTY(this)) { + return NS_OK; + } // Text frames inside , , etc. will never have had // ReflowSVG called on them, so call UpdateGlyphPositioning to do this now. UpdateGlyphPositioning(); @@ -3381,8 +3391,6 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext, gfxMatrix matrixForPaintServers(canvasTM); matrixForPaintServers.Multiply(initialMatrix); - nsPresContext* presContext = PresContext(); - // Check if we need to draw anything. if (aDirtyRect) { NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() || diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 30bf79cf9c48..0ba1e96e7702 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -1112,33 +1112,42 @@ SpecialPowersAPI.prototype = { return this.wrap(Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest)); }, - snapshotWindow: function (win, withCaret, rect, bgcolor) { + snapshotWindowWithOptions: function (win, rect, bgcolor, options) { var el = this.window.get().document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); - if (arguments.length < 3) { + if (rect === undefined) { rect = { top: win.scrollY, left: win.scrollX, width: win.innerWidth, height: win.innerHeight }; } - if (arguments.length < 4) { + if (bgcolor === undefined) { bgcolor = "rgb(255,255,255)"; } + if (options === undefined) { + options = { }; + } el.width = rect.width; el.height = rect.height; var ctx = el.getContext("2d"); var flags = 0; + for (var option in options) { + flags |= ctx[option]; + } + ctx.drawWindow(win, rect.left, rect.top, rect.width, rect.height, bgcolor, - withCaret ? ctx.DRAWWINDOW_DRAW_CARET : 0); + flags); return el; }, + snapshotWindow: function (win, withCaret, rect, bgcolor) { + return this.snapshotWindowWithOptions(win, rect, bgcolor, + { DRAWWINDOW_DRAW_CARET: withCaret }); + }, + snapshotRect: function (win, rect, bgcolor) { - // Splice in our "do not want caret" bit - args = Array.slice(arguments); - args.splice(1, 0, false); - return this.snapshotWindow.apply(this, args); + return this.snapshotWindow(win, false, rect, bgcolor); }, gc: function() { From 3b03878100f8b2590f38c7bfb1bb1b572c89e1fc Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 24 Jun 2013 23:05:31 -0700 Subject: [PATCH 15/45] Bug 886611 part 1: Rename the nsSVGUtils function SetupCairoStrokeGeometry() to SetupCairoStrokeBBoxGeometry() . r=longsonr --- layout/svg/nsSVGPathGeometryFrame.cpp | 2 +- layout/svg/nsSVGUtils.cpp | 7 ++++--- layout/svg/nsSVGUtils.h | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/layout/svg/nsSVGPathGeometryFrame.cpp b/layout/svg/nsSVGPathGeometryFrame.cpp index 5eba955662ba..62f89e66c820 100644 --- a/layout/svg/nsSVGPathGeometryFrame.cpp +++ b/layout/svg/nsSVGPathGeometryFrame.cpp @@ -426,7 +426,7 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace, // though, because if pathExtents is empty, its position will not have // been set. Happily we can use tmpCtx->GetUserStrokeExtent() to find // the center point of the extents even though it gets the extents wrong. - nsSVGUtils::SetupCairoStrokeGeometry(this, tmpCtx); + nsSVGUtils::SetupCairoStrokeBBoxGeometry(this, tmpCtx); pathExtents.MoveTo(tmpCtx->GetUserStrokeExtent().Center()); pathExtents.SizeTo(0, 0); } diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index ea4c0df8a8d7..ad3d023219c4 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -1635,8 +1635,9 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextObjectPaint *aObjectPaint) } void -nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext, - gfxTextObjectPaint *aObjectPaint) +nsSVGUtils::SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame, + gfxContext *aContext, + gfxTextObjectPaint *aObjectPaint) { float width = GetStrokeWidth(aFrame, aObjectPaint); if (width <= 0) @@ -1743,7 +1744,7 @@ void nsSVGUtils::SetupCairoStrokeHitGeometry(nsIFrame* aFrame, gfxContext* aContext, gfxTextObjectPaint *aObjectPaint) { - SetupCairoStrokeGeometry(aFrame, aContext, aObjectPaint); + SetupCairoStrokeBBoxGeometry(aFrame, aContext, aObjectPaint); AutoFallibleTArray dashes; gfxFloat dashOffset; diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index e078fddc305a..a60b3a6dd8bd 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -639,10 +639,11 @@ public: gfxTextObjectPaint *aObjectPaint = nullptr); /* - * Set up a cairo context for measuring a stroked path + * Set up a cairo context for measuring the bounding box of a stroked path. */ - static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext, - gfxTextObjectPaint *aObjectPaint = nullptr); + static void SetupCairoStrokeBBoxGeometry(nsIFrame* aFrame, + gfxContext *aContext, + gfxTextObjectPaint *aObjectPaint = nullptr); /* * Set up a cairo context for hit testing a stroked path From b1ae895bb45c1c149de281c6abd247518f7590ab Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 24 Jun 2013 23:05:32 -0700 Subject: [PATCH 16/45] Bug 886611 part 2: Rename the nsSVGUtils function SetupCairoStrokeHitGeometry() to SetupCairoStrokeGeometry() . r=longsonr --- layout/svg/nsSVGGlyphFrame.cpp | 2 +- layout/svg/nsSVGPathGeometryFrame.cpp | 2 +- layout/svg/nsSVGTextFrame2.cpp | 2 +- layout/svg/nsSVGUtils.cpp | 6 +++--- layout/svg/nsSVGUtils.h | 7 ++++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/layout/svg/nsSVGGlyphFrame.cpp b/layout/svg/nsSVGGlyphFrame.cpp index e25e0ca2cc88..bf93cf86557c 100644 --- a/layout/svg/nsSVGGlyphFrame.cpp +++ b/layout/svg/nsSVGGlyphFrame.cpp @@ -970,7 +970,7 @@ nsSVGGlyphFrame::SetupCairoStroke(gfxContext *aContext, } const nsStyleSVG *style = StyleSVG(); - nsSVGUtils::SetupCairoStrokeHitGeometry(this, aContext, aOuterObjectPaint); + nsSVGUtils::SetupCairoStrokeGeometry(this, aContext, aOuterObjectPaint); float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource, style->mStrokeOpacity, aOuterObjectPaint); diff --git a/layout/svg/nsSVGPathGeometryFrame.cpp b/layout/svg/nsSVGPathGeometryFrame.cpp index 62f89e66c820..f9792ae6bf13 100644 --- a/layout/svg/nsSVGPathGeometryFrame.cpp +++ b/layout/svg/nsSVGPathGeometryFrame.cpp @@ -243,7 +243,7 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint) if (hitTestFlags & SVG_HIT_TEST_FILL) isHit = tmpCtx->PointInFill(userSpacePoint); if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) { - nsSVGUtils::SetupCairoStrokeHitGeometry(this, tmpCtx); + nsSVGUtils::SetupCairoStrokeGeometry(this, tmpCtx); isHit = tmpCtx->PointInStroke(userSpacePoint); } diff --git a/layout/svg/nsSVGTextFrame2.cpp b/layout/svg/nsSVGTextFrame2.cpp index 0d852ce1bd3b..c1ca2702c71b 100644 --- a/layout/svg/nsSVGTextFrame2.cpp +++ b/layout/svg/nsSVGTextFrame2.cpp @@ -5285,7 +5285,7 @@ nsSVGTextFrame2::SetupCairoStroke(gfxContext* aContext, gfxContextMatrixAutoSaveRestore matrixRestore(aContext); aContext->IdentityMatrix(); - nsSVGUtils::SetupCairoStrokeHitGeometry(aFrame, aContext, aOuterObjectPaint); + nsSVGUtils::SetupCairoStrokeGeometry(aFrame, aContext, aOuterObjectPaint); float opacity = nsSVGUtils::GetOpacity(style->mStrokeOpacitySource, style->mStrokeOpacity, aOuterObjectPaint); diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index ad3d023219c4..3e693557b69c 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -1741,8 +1741,8 @@ GetStrokeDashData(nsIFrame* aFrame, } void -nsSVGUtils::SetupCairoStrokeHitGeometry(nsIFrame* aFrame, gfxContext* aContext, - gfxTextObjectPaint *aObjectPaint) +nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext, + gfxTextObjectPaint *aObjectPaint) { SetupCairoStrokeBBoxGeometry(aFrame, aContext, aObjectPaint); @@ -1819,7 +1819,7 @@ nsSVGUtils::SetupCairoStroke(nsIFrame* aFrame, gfxContext* aContext, if (!HasStroke(aFrame, aObjectPaint)) { return false; } - SetupCairoStrokeHitGeometry(aFrame, aContext, aObjectPaint); + SetupCairoStrokeGeometry(aFrame, aContext, aObjectPaint); return SetupCairoStrokePaint(aFrame, aContext, aObjectPaint); } diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index a60b3a6dd8bd..9d8f37e7a6d3 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -646,10 +646,11 @@ public: gfxTextObjectPaint *aObjectPaint = nullptr); /* - * Set up a cairo context for hit testing a stroked path + * Set up a cairo context for a stroked path (including any dashing that + * applies). */ - static void SetupCairoStrokeHitGeometry(nsIFrame* aFrame, gfxContext *aContext, - gfxTextObjectPaint *aObjectPaint = nullptr); + static void SetupCairoStrokeGeometry(nsIFrame* aFrame, gfxContext *aContext, + gfxTextObjectPaint *aObjectPaint = nullptr); /* * Set up a cairo context for stroking, including setting up any stroke-related From 3d0fc664422c864810888d6e3af22c74b9537e1b Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 24 Jun 2013 23:42:05 -0700 Subject: [PATCH 17/45] Back out 2332bb3fe186:10f70b8b04fe (bug 858937) for warnings-as-errors bustage CLOSED TREE --- layout/base/nsCSSFrameConstructor.cpp | 3 ++- layout/base/nsLayoutUtils.cpp | 11 ----------- layout/base/nsLayoutUtils.h | 8 -------- layout/style/AnimationCommon.cpp | 8 ++++---- layout/style/nsAnimationManager.cpp | 2 +- layout/style/nsComputedDOMStyle.cpp | 5 +++-- layout/style/nsTransitionManager.cpp | 8 ++++---- 7 files changed, 14 insertions(+), 31 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 74caedafe50a..8120855ab22c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -8907,7 +8907,8 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) // our content nsIContent* content = fixed->GetContent(); nsStyleContext* styleContext = - nsLayoutUtils::GetStyleFrame(content)->StyleContext(); + nsLayoutUtils::GetStyleFrame(content->GetPrimaryFrame())-> + StyleContext(); FrameConstructionItemList items; AddFrameConstructionItemsInternal(state, content, canvasFrame, content->Tag(), diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5013af855501..794dec4099be 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -713,17 +713,6 @@ nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame) return aFrame; } -nsIFrame* -nsLayoutUtils::GetStyleFrame(const nsIContent* aContent) -{ - nsIFrame *frame = aContent->GetPrimaryFrame(); - if (!frame) { - return nullptr; - } - - return nsLayoutUtils::GetStyleFrame(frame); -} - nsIFrame* nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) { NS_ASSERTION(nsGkAtoms::placeholderFrame == aFrame->GetType(), diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 0efdf5d7e0c9..8756c8606216 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -145,14 +145,6 @@ public: */ static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame); - /** - * Given a content node, - * return the frame that has the non-psuedoelement style context for - * the content. May return null. - * This is aContent->GetPrimaryFrame() except for tableOuter frames. - */ - static nsIFrame* GetStyleFrame(const nsIContent* aContent); - /** * IsGeneratedContentFor returns true if aFrame is the outermost * frame for generated content of type aPseudoElement for aContent. diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 1a4ec01126aa..64c05f01b692 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -261,7 +261,7 @@ CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *a return false; } - nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); + nsIFrame* frame = aElement->GetPrimaryFrame(); if (IsGeometricProperty(aProperty)) { if (shouldLog) { nsCString message; @@ -353,8 +353,8 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) // If the nearest scrollable ancestor has overflow:hidden, // we don't care about overflow. - nsIScrollableFrame* scrollable = nsLayoutUtils::GetNearestScrollableFrame( - nsLayoutUtils::GetStyleFrame(mElement)); + nsIScrollableFrame* scrollable = + nsLayoutUtils::GetNearestScrollableFrame(mElement->GetPrimaryFrame()); if (!scrollable) { return true; } @@ -372,7 +372,7 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) bool CommonElementAnimationData::CanThrottleAnimation(TimeStamp aTime) { - nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); + nsIFrame* frame = mElement->GetPrimaryFrame(); if (!frame) { return false; } diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 8a9c9f557420..1a9fb163466a 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -356,7 +356,7 @@ ElementAnimations::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); + nsIFrame* frame = mElement->GetPrimaryFrame(); if (!frame) { return false; } diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index eb1dd0f19d11..71add63dd046 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -307,9 +307,10 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, } if (!aPseudo && aStyleType == eAll) { - nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); + nsIFrame* frame = aElement->GetPrimaryFrame(); if (frame) { - nsStyleContext* result = frame->StyleContext(); + nsStyleContext* result = + nsLayoutUtils::GetStyleFrame(frame)->StyleContext(); // Don't use the style context if it was influenced by // pseudo-elements, since then it's not the primary style // for this element. diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index cccbe4859779..e63b1e0a40fc 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -142,7 +142,7 @@ ElementTransitions::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementTransitions::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); + nsIFrame* frame = mElement->GetPrimaryFrame(); if (!frame) { return false; } @@ -260,7 +260,7 @@ nsTransitionManager::UpdateThrottledStyle(dom::Element* aElement, nsCSSPseudoElements::ePseudo_NotPseudoElement, false), "element not transitioning"); - nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aElement); + nsIFrame* primaryFrame = aElement->GetPrimaryFrame(); if (!primaryFrame) { return nullptr; } @@ -351,7 +351,7 @@ nsTransitionManager::UpdateThrottledStylesForSubtree(nsIContent* aContent, } else { // reparent the element's style nsStyleSet* styleSet = mPresContext->PresShell()->StyleSet(); - nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aContent); + nsIFrame* primaryFrame = aContent->GetPrimaryFrame(); if (!primaryFrame) { return; } @@ -424,7 +424,7 @@ nsTransitionManager::UpdateAllThrottledStyles() nsIFrame* primaryFrame; if (element && - (primaryFrame = nsLayoutUtils::GetStyleFrame(element))) { + (primaryFrame = element->GetPrimaryFrame())) { UpdateThrottledStylesForSubtree(element, primaryFrame->StyleContext()->GetParent(), changeList); } From cd48b205e00b9f6dd6d7a26b016e3ae3251a4fd3 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 24 Jun 2013 23:44:52 -0700 Subject: [PATCH 18/45] Back out 8e83da248fc9 (bug 886635) for warnings-as-errors bustage CLOSED TREE --- content/canvas/src/WebGLContext.h | 1 - content/html/content/public/HTMLCanvasElement.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 250c7631163a..3c7054e733bd 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -27,7 +27,6 @@ #include "nsIJSNativeInitializer.h" #include "nsWrapperCache.h" #include "nsIObserver.h" -#include "nsLayoutUtils.h" #include "GLContextProvider.h" diff --git a/content/html/content/public/HTMLCanvasElement.h b/content/html/content/public/HTMLCanvasElement.h index 1e525facf7c6..0b4d61306187 100644 --- a/content/html/content/public/HTMLCanvasElement.h +++ b/content/html/content/public/HTMLCanvasElement.h @@ -15,6 +15,7 @@ #include "nsNodeInfoManager.h" #include "nsICanvasElementExternal.h" +#include "nsLayoutUtils.h" #include "mozilla/gfx/Rect.h" class nsICanvasRenderingContextInternal; From d4d4c1d79b08c1e6635eb00c2cf86e233c139330 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 24 Jun 2013 22:32:10 -0700 Subject: [PATCH 19/45] Bug 858937 patch 1: Add nsLayoutUtils::GetStyleFrame() variant taking nsIContent*, and use it for two existing users of the variant taking nsIFrame*. r=nrc --- layout/base/nsCSSFrameConstructor.cpp | 3 +-- layout/base/nsLayoutUtils.cpp | 11 +++++++++++ layout/base/nsLayoutUtils.h | 8 ++++++++ layout/style/nsComputedDOMStyle.cpp | 5 ++--- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8120855ab22c..74caedafe50a 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -8907,8 +8907,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame) // our content nsIContent* content = fixed->GetContent(); nsStyleContext* styleContext = - nsLayoutUtils::GetStyleFrame(content->GetPrimaryFrame())-> - StyleContext(); + nsLayoutUtils::GetStyleFrame(content)->StyleContext(); FrameConstructionItemList items; AddFrameConstructionItemsInternal(state, content, canvasFrame, content->Tag(), diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 794dec4099be..5013af855501 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -713,6 +713,17 @@ nsLayoutUtils::GetStyleFrame(nsIFrame* aFrame) return aFrame; } +nsIFrame* +nsLayoutUtils::GetStyleFrame(const nsIContent* aContent) +{ + nsIFrame *frame = aContent->GetPrimaryFrame(); + if (!frame) { + return nullptr; + } + + return nsLayoutUtils::GetStyleFrame(frame); +} + nsIFrame* nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) { NS_ASSERTION(nsGkAtoms::placeholderFrame == aFrame->GetType(), diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 8756c8606216..0efdf5d7e0c9 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -145,6 +145,14 @@ public: */ static nsIFrame* GetStyleFrame(nsIFrame* aPrimaryFrame); + /** + * Given a content node, + * return the frame that has the non-psuedoelement style context for + * the content. May return null. + * This is aContent->GetPrimaryFrame() except for tableOuter frames. + */ + static nsIFrame* GetStyleFrame(const nsIContent* aContent); + /** * IsGeneratedContentFor returns true if aFrame is the outermost * frame for generated content of type aPseudoElement for aContent. diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 71add63dd046..eb1dd0f19d11 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -307,10 +307,9 @@ nsComputedDOMStyle::GetStyleContextForElementNoFlush(Element* aElement, } if (!aPseudo && aStyleType == eAll) { - nsIFrame* frame = aElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); if (frame) { - nsStyleContext* result = - nsLayoutUtils::GetStyleFrame(frame)->StyleContext(); + nsStyleContext* result = frame->StyleContext(); // Don't use the style context if it was influenced by // pseudo-elements, since then it's not the primary style // for this element. From ea5e7313db6b07ac4849e9817b69bc323f6cb82d Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Mon, 24 Jun 2013 22:32:10 -0700 Subject: [PATCH 20/45] Bug 858937 patch 2: Make off-main-thread CSS transitions/animations code that should be using nsLayoutUtils::GetStyleFrame do so. r=nrc The fixes to the miniflush code (nsTransitionManager::UpdateThrottledStyle and UpdateAllThrottledStyles) fix the case where we constructed totally incorrect style contexts for outer table frames (which have special style contexts inheriting from the table frame) during the miniflush, leading to inconsistent style data and other bad things, when we should have been touching the style on the table frame instead. The fixes to the other OMTA codepaths lead to layer tests being performed on the same frame that the styles will be applied to, and probably fix real bugs (which would occur when animating opacity or transform on a table). --- layout/style/AnimationCommon.cpp | 8 ++++---- layout/style/nsAnimationManager.cpp | 2 +- layout/style/nsTransitionManager.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 64c05f01b692..1a4ec01126aa 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -261,7 +261,7 @@ CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *a return false; } - nsIFrame* frame = aElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(aElement); if (IsGeometricProperty(aProperty)) { if (shouldLog) { nsCString message; @@ -353,8 +353,8 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) // If the nearest scrollable ancestor has overflow:hidden, // we don't care about overflow. - nsIScrollableFrame* scrollable = - nsLayoutUtils::GetNearestScrollableFrame(mElement->GetPrimaryFrame()); + nsIScrollableFrame* scrollable = nsLayoutUtils::GetNearestScrollableFrame( + nsLayoutUtils::GetStyleFrame(mElement)); if (!scrollable) { return true; } @@ -372,7 +372,7 @@ CommonElementAnimationData::CanThrottleTransformChanges(TimeStamp aTime) bool CommonElementAnimationData::CanThrottleAnimation(TimeStamp aTime) { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 1a9fb163466a..8a9c9f557420 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -356,7 +356,7 @@ ElementAnimations::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index e63b1e0a40fc..cccbe4859779 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -142,7 +142,7 @@ ElementTransitions::HasAnimationOfProperty(nsCSSProperty aProperty) const bool ElementTransitions::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const { - nsIFrame* frame = mElement->GetPrimaryFrame(); + nsIFrame* frame = nsLayoutUtils::GetStyleFrame(mElement); if (!frame) { return false; } @@ -260,7 +260,7 @@ nsTransitionManager::UpdateThrottledStyle(dom::Element* aElement, nsCSSPseudoElements::ePseudo_NotPseudoElement, false), "element not transitioning"); - nsIFrame* primaryFrame = aElement->GetPrimaryFrame(); + nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aElement); if (!primaryFrame) { return nullptr; } @@ -351,7 +351,7 @@ nsTransitionManager::UpdateThrottledStylesForSubtree(nsIContent* aContent, } else { // reparent the element's style nsStyleSet* styleSet = mPresContext->PresShell()->StyleSet(); - nsIFrame* primaryFrame = aContent->GetPrimaryFrame(); + nsIFrame* primaryFrame = nsLayoutUtils::GetStyleFrame(aContent); if (!primaryFrame) { return; } @@ -424,7 +424,7 @@ nsTransitionManager::UpdateAllThrottledStyles() nsIFrame* primaryFrame; if (element && - (primaryFrame = element->GetPrimaryFrame())) { + (primaryFrame = nsLayoutUtils::GetStyleFrame(element))) { UpdateThrottledStylesForSubtree(element, primaryFrame->StyleContext()->GetParent(), changeList); } From 4a82c65c1826fb28299d4e933d3a01a40d11fee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez?= Date: Tue, 25 Jun 2013 15:28:28 +0800 Subject: [PATCH 21/45] Bug 886225 - Ci is not defined in SpecialPowersObserverAPI. r=gwagner --- testing/specialpowers/content/SpecialPowersObserverAPI.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/specialpowers/content/SpecialPowersObserverAPI.js b/testing/specialpowers/content/SpecialPowersObserverAPI.js index a10c68bbf72f..61752ab8e659 100644 --- a/testing/specialpowers/content/SpecialPowersObserverAPI.js +++ b/testing/specialpowers/content/SpecialPowersObserverAPI.js @@ -4,6 +4,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); +const Ci = Components.interfaces; + /** * Special Powers Exception - used to throw exceptions nicely **/ From cca4f9757d3a94ddd58eefb7b9895d05e31dfade Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Tue, 25 Jun 2013 09:55:33 +0200 Subject: [PATCH 22/45] Bug 884989: OdinMonkey: Check argument types before enabling ffi fastpath to IM, r=luke --- js/src/ion/AsmJS.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/src/ion/AsmJS.cpp b/js/src/ion/AsmJS.cpp index 9083c447f343..02de435b73d7 100644 --- a/js/src/ion/AsmJS.cpp +++ b/js/src/ion/AsmJS.cpp @@ -5277,17 +5277,18 @@ TryEnablingIon(JSContext *cx, AsmJSModule::ExitDatum *exitDatum, int32_t argc, V const AsmJSModule &module = cx->mainThread().asmJSActivationStackFromOwnerThread()->module(); -#ifdef DEBUG - // The types should correspond, since we just run through invoke, before testing this. - JS_ASSERT(types::TypeScript::ThisTypes(script)->hasType(types::Type::UndefinedType())); + // Normally the types should corresond, since we just ran with those types, + // but there are reports this is asserting. Therefore doing it as a check, instead of DEBUG only. + if (!types::TypeScript::ThisTypes(script)->hasType(types::Type::UndefinedType())) + return true; for(uint32_t i = 0; i < exitDatum->fun->nargs; i++) { types::StackTypeSet *typeset = types::TypeScript::ArgTypes(script, i); types::Type type = types::Type::DoubleType(); if (!argv[i].isDouble()) type = types::Type::PrimitiveType(argv[i].extractNonDoubleType()); - JS_ASSERT(typeset->hasType(type)); + if (!typeset->hasType(type)) + return true; } -#endif // Enable IonScript *ionScript = script->ionScript(); From 6877977bcde0343d54fdcbf15f28bb35612d708e Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Tue, 25 Jun 2013 09:57:17 +0200 Subject: [PATCH 23/45] Bug 886241 - IonMonkey: Enable inlined arguments_get_elem for constant index, r=djvj --- js/src/ion/IonBuilder.cpp | 54 +++++++++++++++++++++++++++------------ js/src/ion/IonBuilder.h | 2 +- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index 527ff6376e0a..231657ad9a2f 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -7038,33 +7038,55 @@ IonBuilder::jsop_arguments_length() bool IonBuilder::jsop_arguments_getelem() { - if (inliningDepth_ != 0) - return abort("NYI inlined get argument element"); + JS_ASSERT(!info().argsObjAliasesFormals()); + // Get the argument id MDefinition *idx = current->pop(); // Type Inference has guaranteed this is an optimized arguments object. MDefinition *args = current->pop(); args->setFoldedUnchecked(); - // To ensure that we are not looking above the number of actual arguments. - MArgumentsLength *length = MArgumentsLength::New(); - current->add(length); - // Ensure idx is an integer. - MInstruction *index = MToInt32::New(idx); - current->add(index); + // When we are not inlining, we can just get the arguments from the stack. + if (inliningDepth_ == 0) { + // To ensure that we are not looking above the number of actual arguments. + MArgumentsLength *length = MArgumentsLength::New(); + current->add(length); - // Bailouts if we read more than the number of actual arguments. - index = addBoundsCheck(index, length); + // Ensure idx is an integer. + MInstruction *index = MToInt32::New(idx); + current->add(index); - // Load the argument from the actual arguments. - MGetArgument *load = MGetArgument::New(index); - current->add(load); - current->push(load); + // Bailouts if we read more than the number of actual arguments. + index = addBoundsCheck(index, length); - types::StackTypeSet *types = types::TypeScript::BytecodeTypes(script(), pc); - return pushTypeBarrier(load, types, true); + // Load the argument from the actual arguments. + MGetArgument *load = MGetArgument::New(index); + current->add(load); + current->push(load); + + types::StackTypeSet *types = types::TypeScript::BytecodeTypes(script(), pc); + return pushTypeBarrier(load, types, true); + } + + // When the id is constant, we can just return the corresponding inlined argument + if (idx->isConstant() && idx->toConstant()->value().isInt32()) { + JS_ASSERT(inliningDepth_ > 0); + + int32_t id = idx->toConstant()->value().toInt32(); + idx->setFoldedUnchecked(); + + if (id < (int32_t)inlineCallInfo_->argc() && id >= 0) + current->push(inlineCallInfo_->getArg(id)); + else + pushConstant(UndefinedValue()); + + return true; + } + + // inlined not constant not supported, yet. + return abort("NYI inlined not constant get argument element"); } bool diff --git a/js/src/ion/IonBuilder.h b/js/src/ion/IonBuilder.h index 10f2e9038ae8..4e131dafbf29 100644 --- a/js/src/ion/IonBuilder.h +++ b/js/src/ion/IonBuilder.h @@ -720,7 +720,7 @@ class CallInfo return args_; } - MDefinition *getArg(uint32_t i) { + MDefinition *getArg(uint32_t i) const { JS_ASSERT(i < argc()); return args_[i]; } From e13a42f40ccf8f9ba91395254b5f1794610ef8c4 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 25 Jun 2013 09:14:03 +0100 Subject: [PATCH 24/45] bug 878674 - pt 1 - load Fennec bundled fonts directly from omnijar without copying them out to the filesystem. r=roc --- gfx/thebes/gfxFT2FontList.cpp | 470 ++++++++++++++++++-------------- gfx/thebes/gfxFT2FontList.h | 39 ++- gfx/thebes/gfxFT2Fonts.cpp | 6 - gfx/thebes/gfxFT2Fonts.h | 2 - gfx/thebes/gfxFont.cpp | 27 ++ gfx/thebes/gfxFont.h | 9 +- gfx/thebes/gfxPangoFonts.cpp | 21 +- modules/libpref/src/init/all.js | 22 +- 8 files changed, 349 insertions(+), 247 deletions(-) diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 9c4bc642f5cc..b2ad898c386a 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -52,6 +52,7 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsISimpleEnumerator.h" +#include "mozilla/Preferences.h" #include "mozilla/scache/StartupCache.h" #include @@ -77,6 +78,8 @@ GetFontInfoLog() #define LOG(args) PR_LOG(GetFontInfoLog(), PR_LOG_DEBUG, args) #define LOG_ENABLED() PR_LOG_TEST(GetFontInfoLog(), PR_LOG_DEBUG) +static cairo_user_data_key_t sFTUserFontDataKey; + static __inline void BuildKeyNameFromFontName(nsAString &aName) { @@ -92,45 +95,89 @@ BuildKeyNameFromFontName(nsAString &aName) // This allows us to read font names, tables, etc if necessary // without permanently instantiating a freetype face and consuming // memory long-term. +// This may fail (resulting in a null FT_Face), e.g. if it fails to +// allocate memory to uncompress a font from omnijar. class AutoFTFace { public: AutoFTFace(FT2FontEntry* aFontEntry) - : mFace(nullptr), mOwnsFace(false) + : mFace(nullptr), mFontDataBuf(nullptr), mOwnsFace(false) { if (aFontEntry->mFTFace) { mFace = aFontEntry->mFTFace; + return; + } + + NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(), + "can't use AutoFTFace for fonts without a filename"); + FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary(); + + // A relative path (no initial "/") means this is a resource in + // omnijar, not an installed font on the device. + // The NS_ASSERTIONs here should never fail, as the resource must have + // been read successfully during font-list initialization or we'd never + // have created the font entry. The only legitimate runtime failure + // here would be memory allocation, in which case mFace remains null. + if (aFontEntry->mFilename[0] != '/') { + nsRefPtr reader = + Omnijar::GetReader(Omnijar::Type::GRE); + nsZipItem *item = reader->GetItem(aFontEntry->mFilename.get()); + NS_ASSERTION(item, "failed to find zip entry"); + + uint32_t bufSize = item->RealSize(); + mFontDataBuf = static_cast(moz_malloc(bufSize)); + if (mFontDataBuf) { + nsZipCursor cursor(item, reader, mFontDataBuf, bufSize); + cursor.Copy(&bufSize); + NS_ASSERTION(bufSize == item->RealSize(), + "error reading bundled font"); + + if (FT_Err_Ok != FT_New_Memory_Face(ft, mFontDataBuf, bufSize, + aFontEntry->mFTFontIndex, + &mFace)) { + NS_WARNING("failed to create freetype face"); + } + } } else { - NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(), - "can't use AutoFTFace for fonts without a filename"); - FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary(); if (FT_Err_Ok != FT_New_Face(ft, aFontEntry->mFilename.get(), aFontEntry->mFTFontIndex, &mFace)) { NS_WARNING("failed to create freetype face"); } - if (FT_Err_Ok != FT_Select_Charmap(mFace, FT_ENCODING_UNICODE)) { - NS_WARNING("failed to select Unicode charmap"); - } - mOwnsFace = true; } + if (FT_Err_Ok != FT_Select_Charmap(mFace, FT_ENCODING_UNICODE)) { + NS_WARNING("failed to select Unicode charmap"); + } + mOwnsFace = true; } ~AutoFTFace() { if (mFace && mOwnsFace) { FT_Done_Face(mFace); + if (mFontDataBuf) { + moz_free(mFontDataBuf); + } } } operator FT_Face() { return mFace; } + // If we 'forget' the FT_Face (used when ownership is handed over to Cairo), + // we do -not- free the mFontDataBuf (if used); that also becomes the + // responsibility of the new owner of the face. FT_Face forget() { NS_ASSERTION(mOwnsFace, "can't forget() when we didn't own the face"); mOwnsFace = false; return mFace; } + const uint8_t* FontData() const { return mFontDataBuf; } + private: - FT_Face mFace; - bool mOwnsFace; + FT_Face mFace; + uint8_t* mFontDataBuf; // Uncompressed data (for fonts stored in a JAR), + // or null for fonts instantiated from a file. + // If non-null, this must survive as long as the + // FT_Face. + bool mOwnsFace; }; /* @@ -146,7 +193,12 @@ private: cairo_scaled_font_t * FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) { - cairo_scaled_font_t *scaledFont = NULL; + cairo_font_face_t *cairoFace = CairoFontFace(); + if (!cairoFace) { + return nullptr; + } + + cairo_scaled_font_t *scaledFont = nullptr; cairo_matrix_t sizeMatrix; cairo_matrix_t identityMatrix; @@ -179,7 +231,7 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF); } - scaledFont = cairo_scaled_font_create(CairoFontFace(), + scaledFont = cairo_scaled_font_create(cairoFace, &sizeMatrix, &identityMatrix, fontOptions); cairo_font_options_destroy(fontOptions); @@ -207,6 +259,9 @@ gfxFont* FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold) { cairo_scaled_font_t *scaledFont = CreateScaledFont(aFontStyle); + if (!scaledFont) { + return nullptr; + } gfxFont *font = new gfxFT2Font(scaledFont, this, aFontStyle, aNeedsBold); cairo_scaled_font_destroy(scaledFont); return font; @@ -263,6 +318,8 @@ public: } } + const uint8_t *FontData() const { return mFontData; } + private: FT_Face mFace; const uint8_t *mFontData; @@ -340,8 +397,6 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, const nsAString& aName, const uint8_t *aFontData) { - static cairo_user_data_key_t key; - FT2FontEntry *fe = new FT2FontEntry(aName); fe->mItalic = FTFaceIsItalic(aFace); fe->mWeight = FTFaceGetWeight(aFace); @@ -355,7 +410,7 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING); fe->mFontFace = cairo_ft_font_face_create_for_ft_face(aFace, flags); FTUserFontData *userFontData = new FTUserFontData(aFace, aFontData); - cairo_font_face_set_user_data(fe->mFontFace, &key, + cairo_font_face_set_user_data(fe->mFontFace, &sFTUserFontDataKey, userFontData, FTFontDestroyFunc); } @@ -388,8 +443,6 @@ gfxFT2Font::GetFontEntry() cairo_font_face_t * FT2FontEntry::CairoFontFace() { - static cairo_user_data_key_t key; - if (!mFontFace) { AutoFTFace face(this); if (!face) { @@ -400,8 +453,8 @@ FT2FontEntry::CairoFontFace() FT_LOAD_DEFAULT : (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING); mFontFace = cairo_ft_font_face_create_for_ft_face(face, flags); - FTUserFontData *userFontData = new FTUserFontData(face, nullptr); - cairo_font_face_set_user_data(mFontFace, &key, + FTUserFontData *userFontData = new FTUserFontData(face, face.FontData()); + cairo_font_face_set_user_data(mFontFace, &sFTUserFontDataKey, userFontData, FTFontDestroyFunc); } return mFontFace; @@ -464,6 +517,24 @@ FT2FontEntry::CopyFontTable(uint32_t aTableTag, return NS_OK; } +hb_blob_t* +FT2FontEntry::GetFontTable(uint32_t aTableTag) +{ + if (mFontFace) { + // if there's a cairo font face, we may be able to return a blob + // that just wraps a range of the attached user font data + FTUserFontData *userFontData = static_cast( + cairo_font_face_get_user_data(mFontFace, &sFTUserFontDataKey)); + if (userFontData && userFontData->FontData()) { + return GetTableFromFontData(userFontData->FontData(), aTableTag); + } + } + + // otherwise, use the default method (which in turn will call our + // implementation of CopyFontTable) + return gfxFontEntry::GetFontTable(aTableTag); +} + void FT2FontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const @@ -617,7 +688,7 @@ public: } virtual void - GetInfoForFile(nsCString& aFileName, nsCString& aFaceList, + GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList, uint32_t *aTimestamp, uint32_t *aFilesize) { if (!mMap.ops) { @@ -629,7 +700,7 @@ public: return; } FNCMapEntry* entry = static_cast(hdr); - if (entry && entry->mTimestamp && entry->mFilesize) { + if (entry && entry->mFilesize) { *aTimestamp = entry->mTimestamp; *aFilesize = entry->mFilesize; aFaceList.Assign(entry->mFaces); @@ -641,7 +712,7 @@ public: } virtual void - CacheFileInfo(nsCString& aFileName, nsCString& aFaceList, + CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList, uint32_t aTimestamp, uint32_t aFilesize) { if (!mMap.ops) { @@ -738,9 +809,9 @@ gfxFT2FontList::gfxFT2FontList() } void -gfxFT2FontList::AppendFacesFromCachedFaceList(nsCString& aFileName, +gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName, bool aStdFile, - nsCString& aFaceList) + const nsCString& aFaceList) { const char *beginning = aFaceList.get(); const char *end = strchr(beginning, ','); @@ -833,7 +904,7 @@ FT2FontEntry::CheckForBrokenFont(gfxFontFamily *aFamily) } void -gfxFT2FontList::AppendFacesFromFontFile(nsCString& aFileName, +gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName, bool aStdFile, FontNameCache *aCache) { @@ -869,44 +940,7 @@ gfxFT2FontList::AppendFacesFromFontFile(nsCString& aFileName, if (FT_Err_Ok != FT_New_Face(ftLibrary, aFileName.get(), i, &face)) { continue; } - if (FT_Err_Ok != FT_Select_Charmap(face, FT_ENCODING_UNICODE)) { - FT_Done_Face(face); - continue; - } - - // build the font entry name and create an FT2FontEntry, - // but do -not- keep a reference to the FT_Face - FT2FontEntry* fe = - CreateNamedFontEntry(face, aFileName.get(), i); - - if (fe) { - NS_ConvertUTF8toUTF16 name(face->family_name); - BuildKeyNameFromFontName(name); - gfxFontFamily *family = mFontFamilies.GetWeak(name); - if (!family) { - family = new FT2FontFamily(name); - mFontFamilies.Put(name, family); - if (mBadUnderlineFamilyNames.Contains(name)) { - family->SetBadUnderlineFamily(); - } - } - fe->mStandardFace = aStdFile; - family->AddFontEntry(fe); - - fe->CheckForBrokenFont(family); - - AppendToFaceList(faceList, name, fe); -#ifdef PR_LOGGING - if (LOG_ENABLED()) { - LOG(("(fontinit) added (%s) to family (%s)" - " with style: %s weight: %d stretch: %d", - NS_ConvertUTF16toUTF8(fe->Name()).get(), - NS_ConvertUTF16toUTF8(family->Name()).get(), - fe->IsItalic() ? "italic" : "normal", - fe->Weight(), fe->Stretch())); - } -#endif - } + AddFaceToList(aFileName, i, aStdFile, face, faceList); FT_Done_Face(face); } FT_Done_Face(dummy); @@ -916,6 +950,160 @@ gfxFT2FontList::AppendFacesFromFontFile(nsCString& aFileName, } } +#define JAR_LAST_MODIFED_TIME "jar-last-modified-time" + +void +gfxFT2FontList::FindFontsInOmnijar(FontNameCache *aCache) +{ + bool jarChanged = false; + + mozilla::scache::StartupCache* cache = + mozilla::scache::StartupCache::GetSingleton(); + char *cachedModifiedTimeBuf; + uint32_t longSize; + int64_t jarModifiedTime; + if (cache && + NS_SUCCEEDED(cache->GetBuffer(JAR_LAST_MODIFED_TIME, + &cachedModifiedTimeBuf, + &longSize)) && + longSize == sizeof(int64_t)) + { + nsCOMPtr jarFile = Omnijar::GetPath(Omnijar::Type::GRE); + jarFile->GetLastModifiedTime(&jarModifiedTime); + if (jarModifiedTime > *(int64_t*)cachedModifiedTimeBuf) { + jarChanged = true; + } + } + + static const char* sJarSearchPaths[] = { + "res/fonts/*.ttf$", + }; + nsRefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); + for (unsigned i = 0; i < ArrayLength(sJarSearchPaths); i++) { + nsZipFind* find; + if (NS_SUCCEEDED(reader->FindInit(sJarSearchPaths[i], &find))) { + const char* path; + uint16_t len; + while (NS_SUCCEEDED(find->FindNext(&path, &len))) { + nsCString entryName(path, len); + AppendFacesFromOmnijarEntry(reader, entryName, aCache, + jarChanged); + } + delete find; + } + } + + if (cache) { + cache->PutBuffer(JAR_LAST_MODIFED_TIME, (char*)&jarModifiedTime, + sizeof(jarModifiedTime)); + } +} + +// Given the freetype face corresponding to an entryName and face index, +// add the face to the available font list and to the faceList string +void +gfxFT2FontList::AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, + bool aStdFile, FT_Face aFace, + nsCString& aFaceList) +{ + if (FT_Err_Ok != FT_Select_Charmap(aFace, FT_ENCODING_UNICODE)) { + // ignore faces that don't support a Unicode charmap + return; + } + + // build the font entry name and create an FT2FontEntry, + // but do -not- keep a reference to the FT_Face + FT2FontEntry* fe = + CreateNamedFontEntry(aFace, aEntryName.get(), aIndex); + + if (fe) { + NS_ConvertUTF8toUTF16 name(aFace->family_name); + BuildKeyNameFromFontName(name); + gfxFontFamily *family = mFontFamilies.GetWeak(name); + if (!family) { + family = new FT2FontFamily(name); + mFontFamilies.Put(name, family); + if (mBadUnderlineFamilyNames.Contains(name)) { + family->SetBadUnderlineFamily(); + } + } + fe->mStandardFace = aStdFile; + family->AddFontEntry(fe); + + fe->CheckForBrokenFont(family); + + AppendToFaceList(aFaceList, name, fe); +#ifdef PR_LOGGING + if (LOG_ENABLED()) { + LOG(("(fontinit) added (%s) to family (%s)" + " with style: %s weight: %d stretch: %d", + NS_ConvertUTF16toUTF8(fe->Name()).get(), + NS_ConvertUTF16toUTF8(family->Name()).get(), + fe->IsItalic() ? "italic" : "normal", + fe->Weight(), fe->Stretch())); + } +#endif + } +} + +void +gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive, + const nsCString& aEntryName, + FontNameCache *aCache, + bool aJarChanged) +{ + nsCString faceList; + if (aCache && !aJarChanged) { + uint32_t filesize, timestamp; + aCache->GetInfoForFile(aEntryName, faceList, ×tamp, &filesize); + if (faceList.Length() > 0) { + AppendFacesFromCachedFaceList(aEntryName, true, faceList); + return; + } + } + + nsZipItem *item = aArchive->GetItem(aEntryName.get()); + NS_ASSERTION(item, "failed to find zip entry"); + + uint32_t bufSize = item->RealSize(); + // We use fallible allocation here; if there's not enough RAM, we'll simply + // ignore the bundled fonts and fall back to the device's installed fonts. + nsAutoPtr buf(static_cast(moz_malloc(bufSize))); + if (!buf) { + return; + } + + nsZipCursor cursor(item, aArchive, buf, bufSize); + uint8_t* data = cursor.Copy(&bufSize); + NS_ASSERTION(data && bufSize == item->RealSize(), + "error reading bundled font"); + if (!data) { + return; + } + + FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary(); + + FT_Face dummy; + if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf, bufSize, 0, &dummy)) { + return; + } + + for (FT_Long i = 0; i < dummy->num_faces; i++) { + FT_Face face; + if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf, bufSize, i, &face)) { + continue; + } + AddFaceToList(aEntryName, i, true, face, faceList); + FT_Done_Face(face); + } + + FT_Done_Face(dummy); + + if (aCache && !faceList.IsEmpty()) { + aCache->CacheFileInfo(aEntryName, faceList, 0, bufSize); + } +} + // Called on each family after all fonts are added to the list; // this will sort faces to give priority to "standard" font files // if aUserArg is non-null (i.e. we're using it as a boolean flag) @@ -937,131 +1125,6 @@ FinalizeFamilyMemberList(nsStringHashKey::KeyType aKey, return PL_DHASH_NEXT; } -#ifdef ANDROID - -#define JAR_READ_BUFFER_SIZE 1024 - -nsresult -CopyFromUriToFile(nsCString aSpec, nsIFile* aLocalFile) -{ - nsCOMPtr uri; - nsCOMPtr inputStream; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aSpec); - NS_ENSURE_SUCCESS(rv, rv); - - rv = NS_OpenURI(getter_AddRefs(inputStream), uri); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr outputStream; - rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), aLocalFile); - NS_ENSURE_SUCCESS(rv, rv); - - char buf[JAR_READ_BUFFER_SIZE]; - while (true) { - uint32_t read; - uint32_t written; - - rv = inputStream->Read(buf, JAR_READ_BUFFER_SIZE, &read); - NS_ENSURE_SUCCESS(rv, rv); - - rv = outputStream->Write(buf, read, &written); - NS_ENSURE_SUCCESS(rv, rv); - - if (written != read) { - return NS_ERROR_FAILURE; - } - - if (read != JAR_READ_BUFFER_SIZE) { - break; - } - } - return NS_OK; -} - -#define JAR_LAST_MODIFED_TIME "jar-last-modified-time" - -void ExtractFontsFromJar(nsIFile* aLocalDir) -{ - bool exists; - bool allFontsExtracted = true; - nsCString jarPath; - int64_t jarModifiedTime; - uint32_t longSize; - char* cachedModifiedTimeBuf; - nsZipFind* find; - - nsRefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); - nsCOMPtr jarFile = Omnijar::GetPath(Omnijar::Type::GRE); - - Omnijar::GetURIString(Omnijar::Type::GRE, jarPath); - jarFile->GetLastModifiedTime(&jarModifiedTime); - - mozilla::scache::StartupCache* cache = mozilla::scache::StartupCache::GetSingleton(); - if (cache && NS_SUCCEEDED(cache->GetBuffer(JAR_LAST_MODIFED_TIME, &cachedModifiedTimeBuf, &longSize)) - && longSize == sizeof(int64_t)) { - if (jarModifiedTime < *((int64_t*) cachedModifiedTimeBuf)) { - return; - } - } - - aLocalDir->Exists(&exists); - if (!exists) { - aLocalDir->Create(nsIFile::DIRECTORY_TYPE, 0700); - } - - static const char* sJarSearchPaths[] = { - "res/fonts/*.ttf$", - }; - - for (size_t i = 0; i < ArrayLength(sJarSearchPaths); i++) { - reader->FindInit(sJarSearchPaths[i], &find); - while (true) { - const char* tmpPath; - uint16_t len; - find->FindNext(&tmpPath, &len); - if (!tmpPath) { - break; - } - - nsCString path(tmpPath, len); - nsCOMPtr localFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); - if (NS_FAILED(localFile->InitWithFile(aLocalDir))) { - allFontsExtracted = false; - continue; - } - - int32_t lastSlash = path.RFindChar('/'); - nsCString fileName; - if (lastSlash == kNotFound) { - fileName = path; - } else { - fileName = Substring(path, lastSlash + 1); - } - if (NS_FAILED(localFile->AppendNative(fileName))) { - allFontsExtracted = false; - continue; - } - int64_t lastModifiedTime; - localFile->Exists(&exists); - localFile->GetLastModifiedTime(&lastModifiedTime); - if (!exists || lastModifiedTime < jarModifiedTime) { - nsCString spec; - spec.Append(jarPath); - spec.Append(path); - if (NS_FAILED(CopyFromUriToFile(spec, localFile))) { - localFile->Remove(true); - allFontsExtracted = false; - } - } - } - } - if (allFontsExtracted && cache) { - cache->PutBuffer(JAR_LAST_MODIFED_TIME, (char*)&jarModifiedTime, sizeof(int64_t)); - } -} - -#endif - void gfxFT2FontList::FindFonts() { @@ -1154,25 +1217,25 @@ gfxFT2FontList::FindFonts() // if we can't find/read the font directory, we are doomed! NS_RUNTIMEABORT("Could not read the system fonts directory"); } +#endif // XP_WIN && ANDROID - // look for fonts shipped with the product - NS_NAMED_LITERAL_STRING(kFontsDirName, "fonts"); - nsCOMPtr localDir; - nsresult rv = NS_GetSpecialDirectory(NS_APP_RES_DIR, - getter_AddRefs(localDir)); - if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(localDir->Append(kFontsDirName))) { - ExtractFontsFromJar(localDir); - nsCString localPath; - rv = localDir->GetNativePath(localPath); - if (NS_SUCCEEDED(rv)) { - FindFontsInDir(localPath, &fnc); - } + // Look for fonts stored in omnijar, unless we're on a low-memory + // device where we don't want to spend the RAM to decompress them. + // (Prefs may disable this, or force-enable it even with low memory.) + bool lowmem; + nsCOMPtr mem = nsMemory::GetGlobalMemoryService(); + if ((NS_SUCCEEDED(mem->IsLowMemoryPlatform(&lowmem)) && !lowmem && + Preferences::GetBool("gfx.bundled_fonts.enabled")) || + Preferences::GetBool("gfx.bundled_fonts.force-enabled")) { + FindFontsInOmnijar(&fnc); } // look for locally-added fonts in a "fonts" subdir of the profile - rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, - getter_AddRefs(localDir)); - if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(localDir->Append(kFontsDirName))) { + nsCOMPtr localDir; + nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, + getter_AddRefs(localDir)); + if (NS_SUCCEEDED(rv) && + NS_SUCCEEDED(localDir->Append(NS_LITERAL_STRING("fonts")))) { nsCString localPath; rv = localDir->GetNativePath(localPath); if (NS_SUCCEEDED(rv)) { @@ -1184,7 +1247,6 @@ gfxFT2FontList::FindFonts() // and marking "simple" families. // Passing non-null userData here says that we want faces to be sorted. mFontFamilies.Enumerate(FinalizeFamilyMemberList, this); -#endif // XP_WIN && ANDROID } #ifdef ANDROID diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index 098ba9658dbc..decf489c2eb8 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -23,16 +23,17 @@ using mozilla::dom::FontListEntry; class FontNameCache; typedef struct FT_FaceRec_* FT_Face; +class nsZipArchive; class FT2FontEntry : public gfxFontEntry { public: FT2FontEntry(const nsAString& aFaceName) : - gfxFontEntry(aFaceName) + gfxFontEntry(aFaceName), + mFTFace(nullptr), + mFontFace(nullptr), + mFTFontIndex(0) { - mFTFace = nullptr; - mFontFace = nullptr; - mFTFontIndex = 0; } ~FT2FontEntry(); @@ -53,22 +54,30 @@ public: CreateFontEntry(const FontListEntry& aFLE); // Create a font entry for a given freetype face; if it is an installed font, - // also record the filename and index + // also record the filename and index. // aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on, // to be freed after the face is destroyed static FT2FontEntry* - CreateFontEntry(FT_Face aFace, const char *aFilename, uint8_t aIndex, + CreateFontEntry(FT_Face aFace, + const char *aFilename, uint8_t aIndex, const nsAString& aName, const uint8_t *aFontData = nullptr); virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold); + // Create (if necessary) and return the cairo_font_face for this font. + // This may fail and return null, so caller must be prepared to handle this. cairo_font_face_t *CairoFontFace(); + + // Create a cairo_scaled_font for this face, with the given style. + // This may fail and return null, so caller must be prepared to handle this. cairo_scaled_font_t *CreateScaledFont(const gfxFontStyle *aStyle); nsresult ReadCMAP(); + virtual hb_blob_t* GetFontTable(uint32_t aTableTag) MOZ_OVERRIDE; + virtual nsresult CopyFontTable(uint32_t aTableTag, FallibleTArray& aBuffer) MOZ_OVERRIDE; @@ -85,7 +94,7 @@ public: cairo_font_face_t *mFontFace; nsCString mFilename; - uint8_t mFTFontIndex; + uint8_t mFTFontIndex; }; class FT2FontFamily : public gfxFontFamily @@ -124,16 +133,26 @@ protected: void AppendFaceFromFontListEntry(const FontListEntry& aFLE, bool isStdFile); - void AppendFacesFromFontFile(nsCString& aFileName, + void AppendFacesFromFontFile(const nsCString& aFileName, bool isStdFile = false, FontNameCache *aCache = nullptr); - void AppendFacesFromCachedFaceList(nsCString& aFileName, + void AppendFacesFromOmnijarEntry(nsZipArchive *aReader, + const nsCString& aEntryName, + FontNameCache *aCache, + bool aJarChanged); + + void AppendFacesFromCachedFaceList(const nsCString& aFileName, bool isStdFile, - nsCString& aFaceList); + const nsCString& aFaceList); + + void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, + bool aStdFile, FT_Face aFace, nsCString& aFaceList); void FindFonts(); + void FindFontsInOmnijar(FontNameCache *aCache); + #ifdef ANDROID void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC); #endif diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index 02209d8615cf..1e36c3066e9d 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -557,12 +557,6 @@ gfxFT2Font::~gfxFT2Font() { } -cairo_font_face_t * -gfxFT2Font::CairoFontFace() -{ - return GetFontEntry()->CairoFontFace(); -} - /** * Look up the font in the gfxFont cache. If we don't find it, create one. * In either case, add a ref, append it to the aFonts array, and return it --- diff --git a/gfx/thebes/gfxFT2Fonts.h b/gfx/thebes/gfxFT2Fonts.h index 014b1f03b353..5831e3e8c388 100644 --- a/gfx/thebes/gfxFT2Fonts.h +++ b/gfx/thebes/gfxFT2Fonts.h @@ -25,8 +25,6 @@ public: // new functions bool aNeedsBold); virtual ~gfxFT2Font (); - cairo_font_face_t *CairoFontFace(); - FT2FontEntry *GetFontEntry(); static already_AddRefed diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 79dada4b97a8..3d3456037588 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -442,6 +442,33 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag, return entry->ShareTableAndGetBlob(*aBuffer, &mFontTableCache); } +static int +DirEntryCmp(const void* aKey, const void* aItem) +{ + int32_t tag = *static_cast(aKey); + const TableDirEntry* entry = static_cast(aItem); + return tag - int32_t(entry->tag); +} + +hb_blob_t* +gfxFontEntry::GetTableFromFontData(const void* aFontData, uint32_t aTableTag) +{ + const SFNTHeader* header = + reinterpret_cast(aFontData); + const TableDirEntry* dir = + reinterpret_cast(header + 1); + dir = static_cast + (bsearch(&aTableTag, dir, uint16_t(header->numTables), + sizeof(TableDirEntry), DirEntryCmp)); + if (dir) { + return hb_blob_create(reinterpret_cast(aFontData) + + dir->offset, dir->length, + HB_MEMORY_MODE_READONLY, nullptr, nullptr); + + } + return nullptr; +} + hb_blob_t * gfxFontEntry::GetFontTable(uint32_t aTag) { diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 631652b03271..e4d2c128a477 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -508,7 +508,14 @@ protected: return NS_ERROR_FAILURE; } -protected: + // Return a blob that wraps a table found within a buffer of font data. + // The blob does NOT own its data; caller guarantees that the buffer + // will remain valid at least as long as the blob. + // Returns null if the specified table is not found. + // This method assumes aFontData is valid 'sfnt' data; before using this, + // caller is responsible to do any sanitization/validation necessary. + hb_blob_t* GetTableFromFontData(const void* aFontData, uint32_t aTableTag); + // Shaper-specific face objects, shared by all instantiations of the same // physical font, regardless of size. // Usually, only one of these will actually be created for any given font diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index e9e272ead2d0..d6e7967e5f9e 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -627,14 +627,6 @@ bool gfxDownloadedFcFontEntry::SetCairoFace(cairo_font_face_t *aFace) return true; } -static int -DirEntryCmp(const void* aKey, const void* aItem) -{ - int32_t tag = *static_cast(aKey); - const TableDirEntry* entry = static_cast(aItem); - return tag - int32_t(entry->tag); -} - hb_blob_t * gfxDownloadedFcFontEntry::GetFontTable(uint32_t aTableTag) { @@ -642,18 +634,7 @@ gfxDownloadedFcFontEntry::GetFontTable(uint32_t aTableTag) // so we can just return a blob that "wraps" the appropriate chunk of it. // The blob should not attempt to free its data, as the entire sfnt data // will be freed when the font entry is deleted. - const SFNTHeader* header = reinterpret_cast(mFontData); - const TableDirEntry* dir = reinterpret_cast(header + 1); - dir = static_cast - (bsearch(&aTableTag, dir, uint16_t(header->numTables), - sizeof(TableDirEntry), DirEntryCmp)); - if (dir) { - return hb_blob_create(reinterpret_cast(mFontData) + - dir->offset, dir->length, - HB_MEMORY_MODE_READONLY, nullptr, nullptr); - - } - return nullptr; + return GetTableFromFontData(mFontData, aTableTag); } /* diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 6cd52fb87027..947e3a79f7b3 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -253,6 +253,11 @@ pref("gfx.color_management.enablev4", false); pref("gfx.downloadable_fonts.enabled", true); pref("gfx.downloadable_fonts.fallback_delay", 3000); +#ifdef ANDROID +pref("gfx.bundled_fonts.enabled", true); +pref("gfx.bundled_fonts.force-enabled", false); +#endif + pref("gfx.filter.nearest.force-enabled", false); // prefs controlling the font (name/cmap) loader that runs shortly after startup @@ -3321,73 +3326,82 @@ pref("font.name-list.sans-serif.he", "Droid Sans Hebrew, Open Sans, Droid Sans") pref("font.name.serif.ja", "Charis SIL Compact"); pref("font.name.sans-serif.ja", "Open Sans"); pref("font.name.monospace.ja", "MotoyaLMaru"); +pref("font.name-list.serif.ja", "Droid Serif"); pref("font.name-list.sans-serif.ja", "Open Sans, Roboto, Droid Sans, MotoyaLMaru, MotoyaLCedar, Droid Sans Japanese"); pref("font.name-list.monospace.ja", "MotoyaLMaru, MotoyaLCedar, Droid Sans Mono"); pref("font.name.serif.ko", "Charis SIL Compact"); pref("font.name.sans-serif.ko", "Open Sans"); pref("font.name.monospace.ko", "Droid Sans Mono"); -pref("font.name-list.serif.ko", "HYSerif"); +pref("font.name-list.serif.ko", "Droid Serif, HYSerif"); pref("font.name-list.sans-serif.ko", "SmartGothic, NanumGothic, DroidSansFallback, Droid Sans Fallback"); pref("font.name.serif.th", "Charis SIL Compact"); pref("font.name.sans-serif.th", "Open Sans"); pref("font.name.monospace.th", "Droid Sans Mono"); +pref("font.name-list.serif.th", "Droid Serif"); pref("font.name-list.sans-serif.th", "Droid Sans Thai, Open Sans, Droid Sans"); pref("font.name.serif.tr", "Charis SIL Compact"); pref("font.name.sans-serif.tr", "Open Sans"); pref("font.name.monospace.tr", "Droid Sans Mono"); +pref("font.name-list.serif.tr", "Droid Serif"); pref("font.name-list.sans-serif.tr", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-baltic", "Charis SIL Compact"); pref("font.name.sans-serif.x-baltic", "Open Sans"); pref("font.name.monospace.x-baltic", "Droid Sans Mono"); +pref("font.name-list.serif.x-baltic", "Droid Serif"); pref("font.name-list.sans-serif.x-baltic", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-central-euro", "Charis SIL Compact"); pref("font.name.sans-serif.x-central-euro", "Open Sans"); pref("font.name.monospace.x-central-euro", "Droid Sans Mono"); +pref("font.name-list.serif.x-central-euro", "Droid Serif"); pref("font.name-list.sans-serif.x-central-euro", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-cyrillic", "Charis SIL Compact"); pref("font.name.sans-serif.x-cyrillic", "Open Sans"); pref("font.name.monospace.x-cyrillic", "Droid Sans Mono"); +pref("font.name-list.serif.x-cyrillic", "Droid Serif"); pref("font.name-list.sans-serif.x-cyrillic", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-unicode", "Charis SIL Compact"); pref("font.name.sans-serif.x-unicode", "Open Sans"); pref("font.name.monospace.x-unicode", "Droid Sans Mono"); +pref("font.name-list.serif.x-unicode", "Droid Serif"); pref("font.name-list.sans-serif.x-unicode", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-user-def", "Charis SIL Compact"); pref("font.name.sans-serif.x-user-def", "Open Sans"); pref("font.name.monospace.x-user-def", "Droid Sans Mono"); +pref("font.name-list.serif.x-user-def", "Droid Serif"); pref("font.name-list.sans-serif.x-user-def", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-western", "Charis SIL Compact"); pref("font.name.sans-serif.x-western", "Open Sans"); pref("font.name.monospace.x-western", "Droid Sans Mono"); +pref("font.name-list.serif.x-western", "Droid Serif"); pref("font.name-list.sans-serif.x-western", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.zh-CN", "Charis SIL Compact"); pref("font.name.sans-serif.zh-CN", "Open Sans"); pref("font.name.monospace.zh-CN", "Droid Sans Mono"); -pref("font.name-list.serif.zh-CN", "Droid Sans Fallback"); +pref("font.name-list.serif.zh-CN", "Droid Serif, Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-CN", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-CN", "Droid Sans Fallback"); pref("font.name.serif.zh-HK", "Charis SIL Compact"); pref("font.name.sans-serif.zh-HK", "Open Sans"); pref("font.name.monospace.zh-HK", "Droid Sans Mono"); -pref("font.name-list.serif.zh-HK", "Droid Sans Fallback"); +pref("font.name-list.serif.zh-HK", "Droid Serif, Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-HK", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-HK", "Droid Sans Fallback"); pref("font.name.serif.zh-TW", "Charis SIL Compact"); pref("font.name.sans-serif.zh-TW", "Open Sans"); pref("font.name.monospace.zh-TW", "Droid Sans Mono"); -pref("font.name-list.serif.zh-TW", "Droid Sans Fallback"); +pref("font.name-list.serif.zh-TW", "Droid Serif, Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-TW", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-TW", "Droid Sans Fallback"); From c3b3a2eb65d124c65ce96ae459eff6b3d30c7867 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Tue, 25 Jun 2013 09:14:37 +0100 Subject: [PATCH 25/45] bug 878674 - pt 2 - clean up obsolete copies of packaged fonts from the Android filesystem. r=blassey --- mobile/android/base/GeckoApp.java | 2 + mobile/android/base/ProfileMigrator.java | 57 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 74c690eb0c29..4f729ca76e6f 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -2142,6 +2142,8 @@ abstract public class GeckoApp public void run() { ProfileMigrator profileMigrator = new ProfileMigrator(app); + profileMigrator.launchDeferredCleanup(); + // Do a migration run on the first start after an upgrade. if (!GeckoApp.sIsUsingCustomProfile && !profileMigrator.hasMigrationRun()) { diff --git a/mobile/android/base/ProfileMigrator.java b/mobile/android/base/ProfileMigrator.java index 1aa905a87070..fe6bd7bebd6e 100644 --- a/mobile/android/base/ProfileMigrator.java +++ b/mobile/android/base/ProfileMigrator.java @@ -29,6 +29,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; +import android.os.Handler; import android.os.RemoteException; import android.text.TextUtils; import android.util.Log; @@ -60,6 +61,10 @@ public class ProfileMigrator { private Runnable mLongOperationStopCallback; private LocalBrowserDB mDB; + // Delay before running one-time "cleanup" tasks that may be needed + // after a version upgrade. + private static final int CLEANUP_DEFERRAL_SECONDS = 15; + // Default number of history entries to migrate in one run. private static final int DEFAULT_HISTORY_MIGRATE_COUNT = 2000; @@ -342,6 +347,15 @@ public class ProfileMigrator { new MoveProfileTask().run(); } + public void launchDeferredCleanup() { + // Do any relevant cleanup shortly after startup to deal with "residue" + // from older versions of Gecko. + // This cleanup is done on the ProfileMigrator background thread, + // CLEANUP_DEFERRAL_SECONDS seconds after startup. + Handler handler = new Handler(); + handler.postDelayed(new DeferredCleanupTask(), CLEANUP_DEFERRAL_SECONDS * 1000); + } + public boolean areBookmarksMigrated() { return getPreferences().getBoolean(PREFS_MIGRATE_BOOKMARKS_DONE, false); } @@ -691,6 +705,49 @@ public class ProfileMigrator { } } + private class DeferredCleanupTask implements Runnable { + // The cleanup-version setting is recorded to avoid repeating the same + // tasks on subsequent startups; CURRENT_CLEANUP_VERSION may be updated + // if we need to do additional cleanup for future Gecko versions. + + private static final String CLEANUP_VERSION = "cleanup-version"; + private static final int CURRENT_CLEANUP_VERSION = 1; + + @Override + public void run() { + long cleanupVersion = getPreferences().getInt(CLEANUP_VERSION, 0); + + if (cleanupVersion < 1) { + // Reduce device storage footprint by removing .ttf files from + // the res/fonts directory: we no longer need to copy our + // bundled fonts out of the APK in order to use them. + // See https://bugzilla.mozilla.org/show_bug.cgi?id=878674. + File dir = new File("res/fonts"); + if (dir.exists() && dir.isDirectory()) { + for (File file : dir.listFiles()) { + if (file.isFile() && file.getName().endsWith(".ttf")) { + Log.i(LOGTAG, "deleting " + file.toString()); + file.delete(); + } + } + if (!dir.delete()) { + Log.w(LOGTAG, "unable to delete res/fonts directory (not empty?)"); + } else { + Log.i(LOGTAG, "res/fonts directory deleted"); + } + } + } + + // Additional cleanup needed for future versions would go here + + if (cleanupVersion != CURRENT_CLEANUP_VERSION) { + SharedPreferences.Editor editor = getPreferences().edit(); + editor.putInt(CLEANUP_VERSION, CURRENT_CLEANUP_VERSION); + editor.apply(); + } + } + } + private class PlacesRunnable implements Runnable { private File mProfileDir; private Map mRerootMap; From 53b32255586d337be0720fcb8c693d4af2a6dbc4 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 09:46:34 +0100 Subject: [PATCH 26/45] Backed out changeset 02f3a517a7c7 (bug 886225) for breaking mochitest on a CLOSED TREE --- testing/specialpowers/content/SpecialPowersObserverAPI.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/testing/specialpowers/content/SpecialPowersObserverAPI.js b/testing/specialpowers/content/SpecialPowersObserverAPI.js index 61752ab8e659..a10c68bbf72f 100644 --- a/testing/specialpowers/content/SpecialPowersObserverAPI.js +++ b/testing/specialpowers/content/SpecialPowersObserverAPI.js @@ -4,8 +4,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); -const Ci = Components.interfaces; - /** * Special Powers Exception - used to throw exceptions nicely **/ From ab2aeb90c35ecd3df52992564431423970b1fcf3 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Tue, 25 Jun 2013 20:58:46 +1200 Subject: [PATCH 27/45] Bug 878142; be more precise about removing the animation manager from the refresh driver. r=dbaron --- layout/style/AnimationCommon.cpp | 22 ----------------- layout/style/AnimationCommon.h | 4 ++-- layout/style/nsAnimationManager.cpp | 36 ++++++++++++++++++++++++++++ layout/style/nsAnimationManager.h | 20 +++++++++++++++- layout/style/nsTransitionManager.cpp | 25 ++++++++++++++++--- layout/style/nsTransitionManager.h | 7 +++++- 6 files changed, 85 insertions(+), 29 deletions(-) diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 1a4ec01126aa..9cd3cd3dc70f 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -59,28 +59,6 @@ CommonAnimationManager::Disconnect() mPresContext = nullptr; } -void -CommonAnimationManager::AddElementData(CommonElementAnimationData* aData) -{ - if (PR_CLIST_IS_EMPTY(&mElementData)) { - // We need to observe the refresh driver. - nsRefreshDriver *rd = mPresContext->RefreshDriver(); - rd->AddRefreshObserver(this, Flush_Style); - } - - PR_INSERT_BEFORE(aData, &mElementData); -} - -void -CommonAnimationManager::ElementDataRemoved() -{ - // If we have no transitions or animations left, remove ourselves from - // the refresh driver. - if (PR_CLIST_IS_EMPTY(&mElementData)) { - mPresContext->RefreshDriver()->RemoveRefreshObserver(this, Flush_Style); - } -} - void CommonAnimationManager::RemoveAllElementData() { diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index a247ddd09ccb..09f18a2f2364 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -65,8 +65,8 @@ public: protected: friend struct CommonElementAnimationData; // for ElementDataRemoved - void AddElementData(CommonElementAnimationData* aData); - void ElementDataRemoved(); + virtual void AddElementData(CommonElementAnimationData* aData) = 0; + virtual void ElementDataRemoved() = 0; void RemoveAllElementData(); PRCList mElementData; diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 8a9c9f557420..af7d55a3de86 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -473,6 +473,7 @@ nsAnimationManager::EnsureStyleRuleFor(ElementAnimations* aET) aET->EnsureStyleRuleFor(mPresContext->RefreshDriver()->MostRecentRefresh(), mPendingEvents, false); + CheckNeedsRefresh(); } /* virtual */ void @@ -636,6 +637,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, ea->mNeedsRefreshes = true; ea->EnsureStyleRuleFor(refreshTime, mPendingEvents, false); + CheckNeedsRefresh(); // We don't actually dispatch the mPendingEvents now. We'll either // dispatch them the next time we get a refresh driver notification // or the next time somebody calls @@ -1004,6 +1006,39 @@ nsAnimationManager::WillRefresh(mozilla::TimeStamp aTime) FlushAnimations(Can_Throttle); } +void +nsAnimationManager::AddElementData(CommonElementAnimationData* aData) +{ + if (!mObservingRefreshDriver) { + NS_ASSERTION(static_cast(aData)->mNeedsRefreshes, + "Added data which doesn't need refreshing?"); + // We need to observe the refresh driver. + mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style); + mObservingRefreshDriver = true; + } + + PR_INSERT_BEFORE(aData, &mElementData); +} + +void +nsAnimationManager::CheckNeedsRefresh() +{ + for (PRCList *l = PR_LIST_HEAD(&mElementData); l != &mElementData; + l = PR_NEXT_LINK(l)) { + if (static_cast(l)->mNeedsRefreshes) { + if (!mObservingRefreshDriver) { + mPresContext->RefreshDriver()->AddRefreshObserver(this, Flush_Style); + mObservingRefreshDriver = true; + } + return; + } + } + if (mObservingRefreshDriver) { + mObservingRefreshDriver = false; + mPresContext->RefreshDriver()->RemoveRefreshObserver(this, Flush_Style); + } +} + void nsAnimationManager::FlushAnimations(FlushFlags aFlags) { @@ -1022,6 +1057,7 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags) nsRefPtr oldStyleRule = ea->mStyleRule; ea->EnsureStyleRuleFor(now, mPendingEvents, canThrottleTick); + CheckNeedsRefresh(); if (oldStyleRule != ea->mStyleRule) { ea->PostRestyleForAnimation(mPresContext); } else { diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 9239792f6da9..f9b6be5fd4ee 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -145,6 +145,8 @@ struct ElementAnimations MOZ_FINAL // run (because it is not currently active and has no fill behavior), but // only does so if aAnimation is non-null; with a null aAnimation it is an // error to give aCurrentTime < aStartTime, and fill-forwards is assumed. + // After calling GetPositionInIteration with non-null aAnimation and aEa, be + // sure to call CheckNeedsRefresh on the animation manager afterwards. static double GetPositionInIteration(TimeDuration aElapsedDuration, TimeDuration aIterationDuration, double aIterationCount, @@ -187,12 +189,14 @@ struct ElementAnimations MOZ_FINAL InfallibleTArray mAnimations; }; -class nsAnimationManager : public mozilla::css::CommonAnimationManager +class nsAnimationManager MOZ_FINAL + : public mozilla::css::CommonAnimationManager { public: nsAnimationManager(nsPresContext *aPresContext) : mozilla::css::CommonAnimationManager(aPresContext) , mKeyframesListIsDirty(true) + , mObservingRefreshDriver(false) { mKeyframesRules.Init(16); // FIXME: make infallible! } @@ -280,6 +284,18 @@ public: nsCSSPseudoElements::Type aPseudoType, bool aCreateIfNeeded); +protected: + virtual void ElementDataRemoved() MOZ_OVERRIDE + { + CheckNeedsRefresh(); + } + virtual void AddElementData(mozilla::css::CommonElementAnimationData* aData) MOZ_OVERRIDE; + + /** + * Check to see if we should stop or start observing the refresh driver + */ + void CheckNeedsRefresh(); + private: void BuildAnimations(nsStyleContext* aStyleContext, InfallibleTArray& aAnimations); @@ -300,6 +316,8 @@ private: nsDataHashtable mKeyframesRules; EventArray mPendingEvents; + + bool mObservingRefreshDriver; }; #endif /* !defined(nsAnimationManager_h_) */ diff --git a/layout/style/nsTransitionManager.cpp b/layout/style/nsTransitionManager.cpp index cccbe4859779..8272535ab981 100644 --- a/layout/style/nsTransitionManager.cpp +++ b/layout/style/nsTransitionManager.cpp @@ -436,6 +436,28 @@ nsTransitionManager::UpdateAllThrottledStyles() FlushOverflowChangedTracker(); } +void +nsTransitionManager::ElementDataRemoved() +{ + // If we have no transitions or animations left, remove ourselves from + // the refresh driver. + if (PR_CLIST_IS_EMPTY(&mElementData)) { + mPresContext->RefreshDriver()->RemoveRefreshObserver(this, Flush_Style); + } +} + +void +nsTransitionManager::AddElementData(CommonElementAnimationData* aData) +{ + if (PR_CLIST_IS_EMPTY(&mElementData)) { + // We need to observe the refresh driver. + nsRefreshDriver *rd = mPresContext->RefreshDriver(); + rd->AddRefreshObserver(this, Flush_Style); + } + + PR_INSERT_BEFORE(aData, &mElementData); +} + already_AddRefed nsTransitionManager::StyleContextChanged(dom::Element *aElement, nsStyleContext *aOldStyleContext, @@ -1120,9 +1142,6 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags) } } - // We might have removed transitions above. - ElementDataRemoved(); - if (didThrottle) { mPresContext->Document()->SetNeedStyleFlush(); } diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index 02f748b291fb..352c94353ea3 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -100,7 +100,8 @@ struct ElementTransitions MOZ_FINAL -class nsTransitionManager : public mozilla::css::CommonAnimationManager +class nsTransitionManager MOZ_FINAL + : public mozilla::css::CommonAnimationManager { public: nsTransitionManager(nsPresContext *aPresContext) @@ -202,6 +203,10 @@ public: // other than primary frames. void UpdateAllThrottledStyles(); +protected: + virtual void ElementDataRemoved() MOZ_OVERRIDE; + virtual void AddElementData(mozilla::css::CommonElementAnimationData* aData) MOZ_OVERRIDE; + private: void ConsiderStartingTransition(nsCSSProperty aProperty, const nsTransition& aTransition, From 364d9b30d966bd5586a4fdacf71627907647aea0 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 22 Jun 2013 00:29:00 +0200 Subject: [PATCH 28/45] Bug 857334 - Fix crash in mozilla::a11y::XULTextFieldAccessible::FrameSelection Bug 857334 - Fix crash in mozilla::a11y::XULTextFieldAccessible::FrameSelection, r=tbsaunde --- accessible/src/xul/XULFormControlAccessible.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/accessible/src/xul/XULFormControlAccessible.cpp b/accessible/src/xul/XULFormControlAccessible.cpp index 7964499c87b2..9a660b1723c0 100644 --- a/accessible/src/xul/XULFormControlAccessible.cpp +++ b/accessible/src/xul/XULFormControlAccessible.cpp @@ -830,6 +830,10 @@ already_AddRefed XULTextFieldAccessible::FrameSelection() { nsCOMPtr inputContent(GetInputField()); + NS_ASSERTION(inputContent, "No input content"); + if (!inputContent) + return nullptr; + nsIFrame* frame = inputContent->GetPrimaryFrame(); return frame ? frame->GetFrameSelection() : nullptr; } From c1374919d00dab0dae8357dd1c555305c3d59cf0 Mon Sep 17 00:00:00 2001 From: Emanuel Hoogeveen Date: Mon, 24 Jun 2013 21:32:05 -0700 Subject: [PATCH 29/45] Bug 886128 - Fix various clang warnings and some potential bugs in nonstandard configurations. r=nnethercote,terrence. --HG-- extra : rebase_source : 0d833ecc9879f5d9fd0a28f9b4eca7793d01aa40 --- js/src/builtin/Profilers.cpp | 4 ++++ js/src/frontend/NameFunctions.h | 2 +- js/src/frontend/ParseNode.h | 3 +-- js/src/frontend/Parser.h | 3 ++- js/src/gc/Nursery-inl.h | 2 +- js/src/gc/Nursery.cpp | 6 +++++- js/src/gc/StoreBuffer.cpp | 12 +++++++++--- js/src/gc/StoreBuffer.h | 4 +++- js/src/ion/AsmJS.h | 2 +- js/src/ion/BaselineJIT.h | 2 +- js/src/ion/IonCompartment.h | 2 +- js/src/jsapi-tests/testVersion.cpp | 4 ++++ js/src/jsatom.cpp | 6 ++++-- js/src/jsgc.h | 13 ++++++------- js/src/jsprvtd.h | 4 ++-- js/src/jsscript.h | 5 ++--- js/src/vm/ForkJoin.h | 4 ++-- js/src/vm/String.cpp | 6 ++++-- mfbt/CheckedInt.h | 2 +- 19 files changed, 54 insertions(+), 32 deletions(-) diff --git a/js/src/builtin/Profilers.cpp b/js/src/builtin/Profilers.cpp index 5c061657337e..2c2cfc9e33d8 100644 --- a/js/src/builtin/Profilers.cpp +++ b/js/src/builtin/Profilers.cpp @@ -21,6 +21,10 @@ #include "jscntxtinlines.h" +#ifdef JSGC_GENERATIONAL +#include "vm/Shape-inl.h" +#endif + using namespace js; using mozilla::ArrayLength; diff --git a/js/src/frontend/NameFunctions.h b/js/src/frontend/NameFunctions.h index 1100c51728ee..bfefd4cf27c9 100644 --- a/js/src/frontend/NameFunctions.h +++ b/js/src/frontend/NameFunctions.h @@ -12,7 +12,7 @@ struct JSContext; namespace js { namespace frontend { -struct ParseNode; +class ParseNode; bool NameFunctions(JSContext *cx, ParseNode *pn); diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h index 8ff5cb34f666..eff7fb061779 100644 --- a/js/src/frontend/ParseNode.h +++ b/js/src/frontend/ParseNode.h @@ -416,9 +416,8 @@ class ConditionalExpression; class PropertyAccess; class ModuleBox; -struct ParseNode +class ParseNode { - private: uint32_t pn_type : 16, /* PNK_* type */ pn_op : 8, /* see JSOp enum and jsopcode.tbl */ pn_arity : 5, /* see ParseNodeArity enum */ diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index f0a7fb8b7d7f..3a8e92174251 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -258,8 +258,9 @@ enum VarContext { HoistVars, DontHoistVars }; enum FunctionType { Getter, Setter, Normal }; template -struct Parser : private AutoGCRooter, public StrictModeGetter +class Parser : private AutoGCRooter, public StrictModeGetter { + public: JSContext *const context; /* FIXME Bug 551291: use AutoGCRooter::context? */ TokenStream tokenStream; LifoAlloc::Mark tempPoolMark; diff --git a/js/src/gc/Nursery-inl.h b/js/src/gc/Nursery-inl.h index bb1c8dca3892..474422a0ca35 100644 --- a/js/src/gc/Nursery-inl.h +++ b/js/src/gc/Nursery-inl.h @@ -22,7 +22,7 @@ namespace gc { */ class RelocationOverlay { - friend struct MinorCollectionTracer; + friend class MinorCollectionTracer; /* The low bit is set so this should never equal a normal pointer. */ const static uintptr_t Relocated = uintptr_t(0xbad0bad1); diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index fc0da80302c8..60972193aa3a 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -48,7 +48,7 @@ js::Nursery::init() // were marked as uncommitted, but it's a little complicated to avoid // clobbering pre-existing unrelated mappings. while (IsPoisonedPtr(heap) || IsPoisonedPtr((void*)(uintptr_t(heap) + NurserySize))) - heap = MapAlignedPages(NurserySize, Alignment); + heap = MapAlignedPages(runtime(), NurserySize, Alignment); #endif if (!heap) return false; @@ -58,7 +58,9 @@ js::Nursery::init() rt->gcNurseryEnd_ = chunk(LastNurseryChunk).end(); numActiveChunks_ = 1; setCurrentChunk(0); +#ifdef DEBUG JS_POISON(heap, FreshNursery, NurserySize); +#endif for (int i = 0; i < NumNurseryChunks; ++i) chunk(i).runtime = rt; @@ -108,7 +110,9 @@ js::Nursery::allocate(size_t size) void *thing = (void *)position(); position_ = position() + size; +#ifdef DEBUG JS_POISON(thing, AllocatedThing, size); +#endif return thing; } diff --git a/js/src/gc/StoreBuffer.cpp b/js/src/gc/StoreBuffer.cpp index 67f78c2e9f50..385b599f77fd 100644 --- a/js/src/gc/StoreBuffer.cpp +++ b/js/src/gc/StoreBuffer.cpp @@ -6,11 +6,13 @@ #ifdef JSGC_GENERATIONAL -#include "jsgc.h" +#include "gc/StoreBuffer.h" + +#include "mozilla/Assertions.h" + +#include "vm/ForkJoin.h" #include "gc/Barrier-inl.h" -#include "gc/StoreBuffer.h" -#include "vm/ForkJoin.h" #include "vm/ObjectImpl-inl.h" using namespace js; @@ -64,8 +66,12 @@ StoreBuffer::WholeCellEdges::mark(JSTracer *trc) MarkChildren(trc, static_cast(tenured)); return; } +#ifdef JS_ION JS_ASSERT(kind == JSTRACE_IONCODE); static_cast(tenured)->trace(trc); +#else + MOZ_NOT_REACHED("Only objects can be in the wholeCellBuffer if IonMonkey is disabled."); +#endif } /*** MonoTypeBuffer ***/ diff --git a/js/src/gc/StoreBuffer.h b/js/src/gc/StoreBuffer.h index ba561eb9c9f8..4ef7defadeb9 100644 --- a/js/src/gc/StoreBuffer.h +++ b/js/src/gc/StoreBuffer.h @@ -13,10 +13,12 @@ # error "Generational GC requires exact rooting." #endif -#include "jsgc.h" #include "jsalloc.h" +#include "jsgc.h" #include "jsobj.h" +#include "gc/Nursery.h" + namespace js { namespace gc { diff --git a/js/src/ion/AsmJS.h b/js/src/ion/AsmJS.h index cdd0f5aaa321..c65cd7cd270f 100644 --- a/js/src/ion/AsmJS.h +++ b/js/src/ion/AsmJS.h @@ -17,7 +17,7 @@ namespace js { class ScriptSource; class SPSProfiler; class AsmJSModule; -namespace frontend { struct TokenStream; struct ParseNode; } +namespace frontend { class TokenStream; class ParseNode; } namespace ion { class MIRGenerator; class LIRGraph; } // Called after parsing a function 'fn' which contains the "use asm" directive. diff --git a/js/src/ion/BaselineJIT.h b/js/src/ion/BaselineJIT.h index c0d326fb265c..d83ee1ca69c9 100644 --- a/js/src/ion/BaselineJIT.h +++ b/js/src/ion/BaselineJIT.h @@ -24,7 +24,7 @@ namespace js { namespace ion { class StackValue; -struct ICEntry; +class ICEntry; class ICStub; class PCMappingSlotInfo diff --git a/js/src/ion/IonCompartment.h b/js/src/ion/IonCompartment.h index a8e72e054b2f..7eca88d55fe6 100644 --- a/js/src/ion/IonCompartment.h +++ b/js/src/ion/IonCompartment.h @@ -66,7 +66,7 @@ typedef Vector OffThreadCompilationVector; // Optimized stubs are allocated per-compartment and are always purged when // JIT-code is discarded. Fallback stubs are allocated per BaselineScript and // are only destroyed when the BaselineScript is destroyed. -struct ICStubSpace +class ICStubSpace { protected: LifoAlloc allocator_; diff --git a/js/src/jsapi-tests/testVersion.cpp b/js/src/jsapi-tests/testVersion.cpp index f2f972968a8a..6673e2c35e61 100644 --- a/js/src/jsapi-tests/testVersion.cpp +++ b/js/src/jsapi-tests/testVersion.cpp @@ -8,6 +8,10 @@ #include "jscntxtinlines.h" +#ifdef JSGC_GENERATIONAL +#include "vm/Shape-inl.h" +#endif + using namespace js; struct VersionFixture; diff --git a/js/src/jsatom.cpp b/js/src/jsatom.cpp index 86feca001b4d..182d5606ba69 100644 --- a/js/src/jsatom.cpp +++ b/js/src/jsatom.cpp @@ -7,7 +7,7 @@ /* * JS atom table. */ -#include "jsatom.h" +#include "jsatominlines.h" #include "mozilla/RangedPtr.h" #include "mozilla/Util.h" @@ -22,9 +22,11 @@ #include "gc/Marking.h" #include "vm/Xdr.h" -#include "jsatominlines.h" #include "jscompartmentinlines.h" +#ifdef JSGC_GENERATIONAL +#include "vm/Shape-inl.h" +#endif #include "vm/String-inl.h" using namespace js; diff --git a/js/src/jsgc.h b/js/src/jsgc.h index b0e13895db6b..d6aac7e7a7bd 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -25,11 +25,11 @@ #include "js/HashTable.h" #include "js/Vector.h" -struct JSAtom; +class JSAtom; struct JSCompartment; -struct JSFunction; -struct JSFlatString; -struct JSLinearString; +class JSFunction; +class JSFlatString; +class JSLinearString; namespace js { @@ -258,9 +258,8 @@ struct ArenaList { void insert(ArenaHeader *arena); }; -struct ArenaLists +class ArenaLists { - private: /* * For each arena kind its free list is represented as the first span with * free things. Initially all the spans are initialized as empty. After we @@ -684,7 +683,7 @@ class GCHelperThread { bool backgroundAllocation; - friend struct js::gc::ArenaLists; + friend class js::gc::ArenaLists; void replenishAndFreeLater(void *ptr); diff --git a/js/src/jsprvtd.h b/js/src/jsprvtd.h index abf84067a3cf..4e7dfffbdafd 100644 --- a/js/src/jsprvtd.h +++ b/js/src/jsprvtd.h @@ -148,10 +148,10 @@ struct Token; struct TokenPos; class TokenStream; class ParseMapPool; -struct ParseNode; +class ParseNode; template -struct Parser; +class Parser; } /* namespace frontend */ diff --git a/js/src/jsscript.h b/js/src/jsscript.h index a0c95014c2e7..e15c61319946 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -279,10 +279,9 @@ typedef HashMap, SystemAllocPolicy> DebugScriptMap; -struct ScriptSource +class ScriptSource { friend class SourceCompressorThread; - private: union { // Before setSourceCopy or setSource are successfully called, this union // has a NULL pointer. When the script source is ready, @@ -1328,7 +1327,7 @@ class SourceCompressorThread struct SourceCompressionToken { - friend struct ScriptSource; + friend class ScriptSource; friend class SourceCompressorThread; private: JSContext *cx; diff --git a/js/src/vm/ForkJoin.h b/js/src/vm/ForkJoin.h index 8ade8c85d88f..4340234d71b2 100644 --- a/js/src/vm/ForkJoin.h +++ b/js/src/vm/ForkJoin.h @@ -200,7 +200,7 @@ namespace js { -struct ForkJoinSlice; +class ForkJoinSlice; bool ForkJoin(JSContext *cx, CallArgs &args); @@ -290,7 +290,7 @@ struct ParallelBailoutRecord { struct ForkJoinShared; -struct ForkJoinSlice : ThreadSafeContext +class ForkJoinSlice : public ThreadSafeContext { public: // Which slice should you process? Ranges from 0 to |numSlices|. diff --git a/js/src/vm/String.cpp b/js/src/vm/String.cpp index d2b8d8633637..d5a77b630ef4 100644 --- a/js/src/vm/String.cpp +++ b/js/src/vm/String.cpp @@ -4,7 +4,7 @@ * 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/. */ -#include "vm/String.h" +#include "vm/String-inl.h" #include "mozilla/MemoryReporting.h" #include "mozilla/PodOperations.h" @@ -14,7 +14,9 @@ #include "jscompartmentinlines.h" -#include "String-inl.h" +#ifdef JSGC_GENERATIONAL +#include "vm/Shape-inl.h" +#endif using namespace js; diff --git a/mfbt/CheckedInt.h b/mfbt/CheckedInt.h index e0c0ebe74963..a6f68b56a50f 100644 --- a/mfbt/CheckedInt.h +++ b/mfbt/CheckedInt.h @@ -604,7 +604,7 @@ class CheckedInt "This type is not supported by CheckedInt"); } - friend class detail::NegateImpl; + friend struct detail::NegateImpl; public: /** From b068dae3e895ac57c808250c99f2406b005ac093 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 11:25:30 +0100 Subject: [PATCH 30/45] Backed out changeset 30bf232b44f7 (bug 878674) --- mobile/android/base/GeckoApp.java | 2 - mobile/android/base/ProfileMigrator.java | 57 ------------------------ 2 files changed, 59 deletions(-) diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 4f729ca76e6f..74c690eb0c29 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -2142,8 +2142,6 @@ abstract public class GeckoApp public void run() { ProfileMigrator profileMigrator = new ProfileMigrator(app); - profileMigrator.launchDeferredCleanup(); - // Do a migration run on the first start after an upgrade. if (!GeckoApp.sIsUsingCustomProfile && !profileMigrator.hasMigrationRun()) { diff --git a/mobile/android/base/ProfileMigrator.java b/mobile/android/base/ProfileMigrator.java index fe6bd7bebd6e..1aa905a87070 100644 --- a/mobile/android/base/ProfileMigrator.java +++ b/mobile/android/base/ProfileMigrator.java @@ -29,7 +29,6 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; -import android.os.Handler; import android.os.RemoteException; import android.text.TextUtils; import android.util.Log; @@ -61,10 +60,6 @@ public class ProfileMigrator { private Runnable mLongOperationStopCallback; private LocalBrowserDB mDB; - // Delay before running one-time "cleanup" tasks that may be needed - // after a version upgrade. - private static final int CLEANUP_DEFERRAL_SECONDS = 15; - // Default number of history entries to migrate in one run. private static final int DEFAULT_HISTORY_MIGRATE_COUNT = 2000; @@ -347,15 +342,6 @@ public class ProfileMigrator { new MoveProfileTask().run(); } - public void launchDeferredCleanup() { - // Do any relevant cleanup shortly after startup to deal with "residue" - // from older versions of Gecko. - // This cleanup is done on the ProfileMigrator background thread, - // CLEANUP_DEFERRAL_SECONDS seconds after startup. - Handler handler = new Handler(); - handler.postDelayed(new DeferredCleanupTask(), CLEANUP_DEFERRAL_SECONDS * 1000); - } - public boolean areBookmarksMigrated() { return getPreferences().getBoolean(PREFS_MIGRATE_BOOKMARKS_DONE, false); } @@ -705,49 +691,6 @@ public class ProfileMigrator { } } - private class DeferredCleanupTask implements Runnable { - // The cleanup-version setting is recorded to avoid repeating the same - // tasks on subsequent startups; CURRENT_CLEANUP_VERSION may be updated - // if we need to do additional cleanup for future Gecko versions. - - private static final String CLEANUP_VERSION = "cleanup-version"; - private static final int CURRENT_CLEANUP_VERSION = 1; - - @Override - public void run() { - long cleanupVersion = getPreferences().getInt(CLEANUP_VERSION, 0); - - if (cleanupVersion < 1) { - // Reduce device storage footprint by removing .ttf files from - // the res/fonts directory: we no longer need to copy our - // bundled fonts out of the APK in order to use them. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=878674. - File dir = new File("res/fonts"); - if (dir.exists() && dir.isDirectory()) { - for (File file : dir.listFiles()) { - if (file.isFile() && file.getName().endsWith(".ttf")) { - Log.i(LOGTAG, "deleting " + file.toString()); - file.delete(); - } - } - if (!dir.delete()) { - Log.w(LOGTAG, "unable to delete res/fonts directory (not empty?)"); - } else { - Log.i(LOGTAG, "res/fonts directory deleted"); - } - } - } - - // Additional cleanup needed for future versions would go here - - if (cleanupVersion != CURRENT_CLEANUP_VERSION) { - SharedPreferences.Editor editor = getPreferences().edit(); - editor.putInt(CLEANUP_VERSION, CURRENT_CLEANUP_VERSION); - editor.apply(); - } - } - } - private class PlacesRunnable implements Runnable { private File mProfileDir; private Map mRerootMap; From 3b7e3a0a845cea3b6c409a4782dd46e256731638 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 11:26:00 +0100 Subject: [PATCH 31/45] Backed out changeset 8284007baae4 (bug 878674) for Android startup java exceptions --- gfx/thebes/gfxFT2FontList.cpp | 470 ++++++++++++++------------------ gfx/thebes/gfxFT2FontList.h | 39 +-- gfx/thebes/gfxFT2Fonts.cpp | 6 + gfx/thebes/gfxFT2Fonts.h | 2 + gfx/thebes/gfxFont.cpp | 27 -- gfx/thebes/gfxFont.h | 9 +- gfx/thebes/gfxPangoFonts.cpp | 21 +- modules/libpref/src/init/all.js | 22 +- 8 files changed, 247 insertions(+), 349 deletions(-) diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index b2ad898c386a..9c4bc642f5cc 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -52,7 +52,6 @@ #include "nsAppDirectoryServiceDefs.h" #include "nsISimpleEnumerator.h" -#include "mozilla/Preferences.h" #include "mozilla/scache/StartupCache.h" #include @@ -78,8 +77,6 @@ GetFontInfoLog() #define LOG(args) PR_LOG(GetFontInfoLog(), PR_LOG_DEBUG, args) #define LOG_ENABLED() PR_LOG_TEST(GetFontInfoLog(), PR_LOG_DEBUG) -static cairo_user_data_key_t sFTUserFontDataKey; - static __inline void BuildKeyNameFromFontName(nsAString &aName) { @@ -95,89 +92,45 @@ BuildKeyNameFromFontName(nsAString &aName) // This allows us to read font names, tables, etc if necessary // without permanently instantiating a freetype face and consuming // memory long-term. -// This may fail (resulting in a null FT_Face), e.g. if it fails to -// allocate memory to uncompress a font from omnijar. class AutoFTFace { public: AutoFTFace(FT2FontEntry* aFontEntry) - : mFace(nullptr), mFontDataBuf(nullptr), mOwnsFace(false) + : mFace(nullptr), mOwnsFace(false) { if (aFontEntry->mFTFace) { mFace = aFontEntry->mFTFace; - return; - } - - NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(), - "can't use AutoFTFace for fonts without a filename"); - FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary(); - - // A relative path (no initial "/") means this is a resource in - // omnijar, not an installed font on the device. - // The NS_ASSERTIONs here should never fail, as the resource must have - // been read successfully during font-list initialization or we'd never - // have created the font entry. The only legitimate runtime failure - // here would be memory allocation, in which case mFace remains null. - if (aFontEntry->mFilename[0] != '/') { - nsRefPtr reader = - Omnijar::GetReader(Omnijar::Type::GRE); - nsZipItem *item = reader->GetItem(aFontEntry->mFilename.get()); - NS_ASSERTION(item, "failed to find zip entry"); - - uint32_t bufSize = item->RealSize(); - mFontDataBuf = static_cast(moz_malloc(bufSize)); - if (mFontDataBuf) { - nsZipCursor cursor(item, reader, mFontDataBuf, bufSize); - cursor.Copy(&bufSize); - NS_ASSERTION(bufSize == item->RealSize(), - "error reading bundled font"); - - if (FT_Err_Ok != FT_New_Memory_Face(ft, mFontDataBuf, bufSize, - aFontEntry->mFTFontIndex, - &mFace)) { - NS_WARNING("failed to create freetype face"); - } - } } else { + NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(), + "can't use AutoFTFace for fonts without a filename"); + FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary(); if (FT_Err_Ok != FT_New_Face(ft, aFontEntry->mFilename.get(), aFontEntry->mFTFontIndex, &mFace)) { NS_WARNING("failed to create freetype face"); } + if (FT_Err_Ok != FT_Select_Charmap(mFace, FT_ENCODING_UNICODE)) { + NS_WARNING("failed to select Unicode charmap"); + } + mOwnsFace = true; } - if (FT_Err_Ok != FT_Select_Charmap(mFace, FT_ENCODING_UNICODE)) { - NS_WARNING("failed to select Unicode charmap"); - } - mOwnsFace = true; } ~AutoFTFace() { if (mFace && mOwnsFace) { FT_Done_Face(mFace); - if (mFontDataBuf) { - moz_free(mFontDataBuf); - } } } operator FT_Face() { return mFace; } - // If we 'forget' the FT_Face (used when ownership is handed over to Cairo), - // we do -not- free the mFontDataBuf (if used); that also becomes the - // responsibility of the new owner of the face. FT_Face forget() { NS_ASSERTION(mOwnsFace, "can't forget() when we didn't own the face"); mOwnsFace = false; return mFace; } - const uint8_t* FontData() const { return mFontDataBuf; } - private: - FT_Face mFace; - uint8_t* mFontDataBuf; // Uncompressed data (for fonts stored in a JAR), - // or null for fonts instantiated from a file. - // If non-null, this must survive as long as the - // FT_Face. - bool mOwnsFace; + FT_Face mFace; + bool mOwnsFace; }; /* @@ -193,12 +146,7 @@ private: cairo_scaled_font_t * FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) { - cairo_font_face_t *cairoFace = CairoFontFace(); - if (!cairoFace) { - return nullptr; - } - - cairo_scaled_font_t *scaledFont = nullptr; + cairo_scaled_font_t *scaledFont = NULL; cairo_matrix_t sizeMatrix; cairo_matrix_t identityMatrix; @@ -231,7 +179,7 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) cairo_font_options_set_hint_metrics(fontOptions, CAIRO_HINT_METRICS_OFF); } - scaledFont = cairo_scaled_font_create(cairoFace, + scaledFont = cairo_scaled_font_create(CairoFontFace(), &sizeMatrix, &identityMatrix, fontOptions); cairo_font_options_destroy(fontOptions); @@ -259,9 +207,6 @@ gfxFont* FT2FontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold) { cairo_scaled_font_t *scaledFont = CreateScaledFont(aFontStyle); - if (!scaledFont) { - return nullptr; - } gfxFont *font = new gfxFT2Font(scaledFont, this, aFontStyle, aNeedsBold); cairo_scaled_font_destroy(scaledFont); return font; @@ -318,8 +263,6 @@ public: } } - const uint8_t *FontData() const { return mFontData; } - private: FT_Face mFace; const uint8_t *mFontData; @@ -397,6 +340,8 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, const nsAString& aName, const uint8_t *aFontData) { + static cairo_user_data_key_t key; + FT2FontEntry *fe = new FT2FontEntry(aName); fe->mItalic = FTFaceIsItalic(aFace); fe->mWeight = FTFaceGetWeight(aFace); @@ -410,7 +355,7 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace, (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING); fe->mFontFace = cairo_ft_font_face_create_for_ft_face(aFace, flags); FTUserFontData *userFontData = new FTUserFontData(aFace, aFontData); - cairo_font_face_set_user_data(fe->mFontFace, &sFTUserFontDataKey, + cairo_font_face_set_user_data(fe->mFontFace, &key, userFontData, FTFontDestroyFunc); } @@ -443,6 +388,8 @@ gfxFT2Font::GetFontEntry() cairo_font_face_t * FT2FontEntry::CairoFontFace() { + static cairo_user_data_key_t key; + if (!mFontFace) { AutoFTFace face(this); if (!face) { @@ -453,8 +400,8 @@ FT2FontEntry::CairoFontFace() FT_LOAD_DEFAULT : (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING); mFontFace = cairo_ft_font_face_create_for_ft_face(face, flags); - FTUserFontData *userFontData = new FTUserFontData(face, face.FontData()); - cairo_font_face_set_user_data(mFontFace, &sFTUserFontDataKey, + FTUserFontData *userFontData = new FTUserFontData(face, nullptr); + cairo_font_face_set_user_data(mFontFace, &key, userFontData, FTFontDestroyFunc); } return mFontFace; @@ -517,24 +464,6 @@ FT2FontEntry::CopyFontTable(uint32_t aTableTag, return NS_OK; } -hb_blob_t* -FT2FontEntry::GetFontTable(uint32_t aTableTag) -{ - if (mFontFace) { - // if there's a cairo font face, we may be able to return a blob - // that just wraps a range of the attached user font data - FTUserFontData *userFontData = static_cast( - cairo_font_face_get_user_data(mFontFace, &sFTUserFontDataKey)); - if (userFontData && userFontData->FontData()) { - return GetTableFromFontData(userFontData->FontData(), aTableTag); - } - } - - // otherwise, use the default method (which in turn will call our - // implementation of CopyFontTable) - return gfxFontEntry::GetFontTable(aTableTag); -} - void FT2FontEntry::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const @@ -688,7 +617,7 @@ public: } virtual void - GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList, + GetInfoForFile(nsCString& aFileName, nsCString& aFaceList, uint32_t *aTimestamp, uint32_t *aFilesize) { if (!mMap.ops) { @@ -700,7 +629,7 @@ public: return; } FNCMapEntry* entry = static_cast(hdr); - if (entry && entry->mFilesize) { + if (entry && entry->mTimestamp && entry->mFilesize) { *aTimestamp = entry->mTimestamp; *aFilesize = entry->mFilesize; aFaceList.Assign(entry->mFaces); @@ -712,7 +641,7 @@ public: } virtual void - CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList, + CacheFileInfo(nsCString& aFileName, nsCString& aFaceList, uint32_t aTimestamp, uint32_t aFilesize) { if (!mMap.ops) { @@ -809,9 +738,9 @@ gfxFT2FontList::gfxFT2FontList() } void -gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName, +gfxFT2FontList::AppendFacesFromCachedFaceList(nsCString& aFileName, bool aStdFile, - const nsCString& aFaceList) + nsCString& aFaceList) { const char *beginning = aFaceList.get(); const char *end = strchr(beginning, ','); @@ -904,7 +833,7 @@ FT2FontEntry::CheckForBrokenFont(gfxFontFamily *aFamily) } void -gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName, +gfxFT2FontList::AppendFacesFromFontFile(nsCString& aFileName, bool aStdFile, FontNameCache *aCache) { @@ -940,7 +869,44 @@ gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName, if (FT_Err_Ok != FT_New_Face(ftLibrary, aFileName.get(), i, &face)) { continue; } - AddFaceToList(aFileName, i, aStdFile, face, faceList); + if (FT_Err_Ok != FT_Select_Charmap(face, FT_ENCODING_UNICODE)) { + FT_Done_Face(face); + continue; + } + + // build the font entry name and create an FT2FontEntry, + // but do -not- keep a reference to the FT_Face + FT2FontEntry* fe = + CreateNamedFontEntry(face, aFileName.get(), i); + + if (fe) { + NS_ConvertUTF8toUTF16 name(face->family_name); + BuildKeyNameFromFontName(name); + gfxFontFamily *family = mFontFamilies.GetWeak(name); + if (!family) { + family = new FT2FontFamily(name); + mFontFamilies.Put(name, family); + if (mBadUnderlineFamilyNames.Contains(name)) { + family->SetBadUnderlineFamily(); + } + } + fe->mStandardFace = aStdFile; + family->AddFontEntry(fe); + + fe->CheckForBrokenFont(family); + + AppendToFaceList(faceList, name, fe); +#ifdef PR_LOGGING + if (LOG_ENABLED()) { + LOG(("(fontinit) added (%s) to family (%s)" + " with style: %s weight: %d stretch: %d", + NS_ConvertUTF16toUTF8(fe->Name()).get(), + NS_ConvertUTF16toUTF8(family->Name()).get(), + fe->IsItalic() ? "italic" : "normal", + fe->Weight(), fe->Stretch())); + } +#endif + } FT_Done_Face(face); } FT_Done_Face(dummy); @@ -950,160 +916,6 @@ gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName, } } -#define JAR_LAST_MODIFED_TIME "jar-last-modified-time" - -void -gfxFT2FontList::FindFontsInOmnijar(FontNameCache *aCache) -{ - bool jarChanged = false; - - mozilla::scache::StartupCache* cache = - mozilla::scache::StartupCache::GetSingleton(); - char *cachedModifiedTimeBuf; - uint32_t longSize; - int64_t jarModifiedTime; - if (cache && - NS_SUCCEEDED(cache->GetBuffer(JAR_LAST_MODIFED_TIME, - &cachedModifiedTimeBuf, - &longSize)) && - longSize == sizeof(int64_t)) - { - nsCOMPtr jarFile = Omnijar::GetPath(Omnijar::Type::GRE); - jarFile->GetLastModifiedTime(&jarModifiedTime); - if (jarModifiedTime > *(int64_t*)cachedModifiedTimeBuf) { - jarChanged = true; - } - } - - static const char* sJarSearchPaths[] = { - "res/fonts/*.ttf$", - }; - nsRefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); - for (unsigned i = 0; i < ArrayLength(sJarSearchPaths); i++) { - nsZipFind* find; - if (NS_SUCCEEDED(reader->FindInit(sJarSearchPaths[i], &find))) { - const char* path; - uint16_t len; - while (NS_SUCCEEDED(find->FindNext(&path, &len))) { - nsCString entryName(path, len); - AppendFacesFromOmnijarEntry(reader, entryName, aCache, - jarChanged); - } - delete find; - } - } - - if (cache) { - cache->PutBuffer(JAR_LAST_MODIFED_TIME, (char*)&jarModifiedTime, - sizeof(jarModifiedTime)); - } -} - -// Given the freetype face corresponding to an entryName and face index, -// add the face to the available font list and to the faceList string -void -gfxFT2FontList::AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, - bool aStdFile, FT_Face aFace, - nsCString& aFaceList) -{ - if (FT_Err_Ok != FT_Select_Charmap(aFace, FT_ENCODING_UNICODE)) { - // ignore faces that don't support a Unicode charmap - return; - } - - // build the font entry name and create an FT2FontEntry, - // but do -not- keep a reference to the FT_Face - FT2FontEntry* fe = - CreateNamedFontEntry(aFace, aEntryName.get(), aIndex); - - if (fe) { - NS_ConvertUTF8toUTF16 name(aFace->family_name); - BuildKeyNameFromFontName(name); - gfxFontFamily *family = mFontFamilies.GetWeak(name); - if (!family) { - family = new FT2FontFamily(name); - mFontFamilies.Put(name, family); - if (mBadUnderlineFamilyNames.Contains(name)) { - family->SetBadUnderlineFamily(); - } - } - fe->mStandardFace = aStdFile; - family->AddFontEntry(fe); - - fe->CheckForBrokenFont(family); - - AppendToFaceList(aFaceList, name, fe); -#ifdef PR_LOGGING - if (LOG_ENABLED()) { - LOG(("(fontinit) added (%s) to family (%s)" - " with style: %s weight: %d stretch: %d", - NS_ConvertUTF16toUTF8(fe->Name()).get(), - NS_ConvertUTF16toUTF8(family->Name()).get(), - fe->IsItalic() ? "italic" : "normal", - fe->Weight(), fe->Stretch())); - } -#endif - } -} - -void -gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive, - const nsCString& aEntryName, - FontNameCache *aCache, - bool aJarChanged) -{ - nsCString faceList; - if (aCache && !aJarChanged) { - uint32_t filesize, timestamp; - aCache->GetInfoForFile(aEntryName, faceList, ×tamp, &filesize); - if (faceList.Length() > 0) { - AppendFacesFromCachedFaceList(aEntryName, true, faceList); - return; - } - } - - nsZipItem *item = aArchive->GetItem(aEntryName.get()); - NS_ASSERTION(item, "failed to find zip entry"); - - uint32_t bufSize = item->RealSize(); - // We use fallible allocation here; if there's not enough RAM, we'll simply - // ignore the bundled fonts and fall back to the device's installed fonts. - nsAutoPtr buf(static_cast(moz_malloc(bufSize))); - if (!buf) { - return; - } - - nsZipCursor cursor(item, aArchive, buf, bufSize); - uint8_t* data = cursor.Copy(&bufSize); - NS_ASSERTION(data && bufSize == item->RealSize(), - "error reading bundled font"); - if (!data) { - return; - } - - FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary(); - - FT_Face dummy; - if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf, bufSize, 0, &dummy)) { - return; - } - - for (FT_Long i = 0; i < dummy->num_faces; i++) { - FT_Face face; - if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf, bufSize, i, &face)) { - continue; - } - AddFaceToList(aEntryName, i, true, face, faceList); - FT_Done_Face(face); - } - - FT_Done_Face(dummy); - - if (aCache && !faceList.IsEmpty()) { - aCache->CacheFileInfo(aEntryName, faceList, 0, bufSize); - } -} - // Called on each family after all fonts are added to the list; // this will sort faces to give priority to "standard" font files // if aUserArg is non-null (i.e. we're using it as a boolean flag) @@ -1125,6 +937,131 @@ FinalizeFamilyMemberList(nsStringHashKey::KeyType aKey, return PL_DHASH_NEXT; } +#ifdef ANDROID + +#define JAR_READ_BUFFER_SIZE 1024 + +nsresult +CopyFromUriToFile(nsCString aSpec, nsIFile* aLocalFile) +{ + nsCOMPtr uri; + nsCOMPtr inputStream; + nsresult rv = NS_NewURI(getter_AddRefs(uri), aSpec); + NS_ENSURE_SUCCESS(rv, rv); + + rv = NS_OpenURI(getter_AddRefs(inputStream), uri); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr outputStream; + rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), aLocalFile); + NS_ENSURE_SUCCESS(rv, rv); + + char buf[JAR_READ_BUFFER_SIZE]; + while (true) { + uint32_t read; + uint32_t written; + + rv = inputStream->Read(buf, JAR_READ_BUFFER_SIZE, &read); + NS_ENSURE_SUCCESS(rv, rv); + + rv = outputStream->Write(buf, read, &written); + NS_ENSURE_SUCCESS(rv, rv); + + if (written != read) { + return NS_ERROR_FAILURE; + } + + if (read != JAR_READ_BUFFER_SIZE) { + break; + } + } + return NS_OK; +} + +#define JAR_LAST_MODIFED_TIME "jar-last-modified-time" + +void ExtractFontsFromJar(nsIFile* aLocalDir) +{ + bool exists; + bool allFontsExtracted = true; + nsCString jarPath; + int64_t jarModifiedTime; + uint32_t longSize; + char* cachedModifiedTimeBuf; + nsZipFind* find; + + nsRefPtr reader = Omnijar::GetReader(Omnijar::Type::GRE); + nsCOMPtr jarFile = Omnijar::GetPath(Omnijar::Type::GRE); + + Omnijar::GetURIString(Omnijar::Type::GRE, jarPath); + jarFile->GetLastModifiedTime(&jarModifiedTime); + + mozilla::scache::StartupCache* cache = mozilla::scache::StartupCache::GetSingleton(); + if (cache && NS_SUCCEEDED(cache->GetBuffer(JAR_LAST_MODIFED_TIME, &cachedModifiedTimeBuf, &longSize)) + && longSize == sizeof(int64_t)) { + if (jarModifiedTime < *((int64_t*) cachedModifiedTimeBuf)) { + return; + } + } + + aLocalDir->Exists(&exists); + if (!exists) { + aLocalDir->Create(nsIFile::DIRECTORY_TYPE, 0700); + } + + static const char* sJarSearchPaths[] = { + "res/fonts/*.ttf$", + }; + + for (size_t i = 0; i < ArrayLength(sJarSearchPaths); i++) { + reader->FindInit(sJarSearchPaths[i], &find); + while (true) { + const char* tmpPath; + uint16_t len; + find->FindNext(&tmpPath, &len); + if (!tmpPath) { + break; + } + + nsCString path(tmpPath, len); + nsCOMPtr localFile (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID)); + if (NS_FAILED(localFile->InitWithFile(aLocalDir))) { + allFontsExtracted = false; + continue; + } + + int32_t lastSlash = path.RFindChar('/'); + nsCString fileName; + if (lastSlash == kNotFound) { + fileName = path; + } else { + fileName = Substring(path, lastSlash + 1); + } + if (NS_FAILED(localFile->AppendNative(fileName))) { + allFontsExtracted = false; + continue; + } + int64_t lastModifiedTime; + localFile->Exists(&exists); + localFile->GetLastModifiedTime(&lastModifiedTime); + if (!exists || lastModifiedTime < jarModifiedTime) { + nsCString spec; + spec.Append(jarPath); + spec.Append(path); + if (NS_FAILED(CopyFromUriToFile(spec, localFile))) { + localFile->Remove(true); + allFontsExtracted = false; + } + } + } + } + if (allFontsExtracted && cache) { + cache->PutBuffer(JAR_LAST_MODIFED_TIME, (char*)&jarModifiedTime, sizeof(int64_t)); + } +} + +#endif + void gfxFT2FontList::FindFonts() { @@ -1217,25 +1154,25 @@ gfxFT2FontList::FindFonts() // if we can't find/read the font directory, we are doomed! NS_RUNTIMEABORT("Could not read the system fonts directory"); } -#endif // XP_WIN && ANDROID - // Look for fonts stored in omnijar, unless we're on a low-memory - // device where we don't want to spend the RAM to decompress them. - // (Prefs may disable this, or force-enable it even with low memory.) - bool lowmem; - nsCOMPtr mem = nsMemory::GetGlobalMemoryService(); - if ((NS_SUCCEEDED(mem->IsLowMemoryPlatform(&lowmem)) && !lowmem && - Preferences::GetBool("gfx.bundled_fonts.enabled")) || - Preferences::GetBool("gfx.bundled_fonts.force-enabled")) { - FindFontsInOmnijar(&fnc); + // look for fonts shipped with the product + NS_NAMED_LITERAL_STRING(kFontsDirName, "fonts"); + nsCOMPtr localDir; + nsresult rv = NS_GetSpecialDirectory(NS_APP_RES_DIR, + getter_AddRefs(localDir)); + if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(localDir->Append(kFontsDirName))) { + ExtractFontsFromJar(localDir); + nsCString localPath; + rv = localDir->GetNativePath(localPath); + if (NS_SUCCEEDED(rv)) { + FindFontsInDir(localPath, &fnc); + } } // look for locally-added fonts in a "fonts" subdir of the profile - nsCOMPtr localDir; - nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, - getter_AddRefs(localDir)); - if (NS_SUCCEEDED(rv) && - NS_SUCCEEDED(localDir->Append(NS_LITERAL_STRING("fonts")))) { + rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_LOCAL_50_DIR, + getter_AddRefs(localDir)); + if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(localDir->Append(kFontsDirName))) { nsCString localPath; rv = localDir->GetNativePath(localPath); if (NS_SUCCEEDED(rv)) { @@ -1247,6 +1184,7 @@ gfxFT2FontList::FindFonts() // and marking "simple" families. // Passing non-null userData here says that we want faces to be sorted. mFontFamilies.Enumerate(FinalizeFamilyMemberList, this); +#endif // XP_WIN && ANDROID } #ifdef ANDROID diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index decf489c2eb8..098ba9658dbc 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -23,17 +23,16 @@ using mozilla::dom::FontListEntry; class FontNameCache; typedef struct FT_FaceRec_* FT_Face; -class nsZipArchive; class FT2FontEntry : public gfxFontEntry { public: FT2FontEntry(const nsAString& aFaceName) : - gfxFontEntry(aFaceName), - mFTFace(nullptr), - mFontFace(nullptr), - mFTFontIndex(0) + gfxFontEntry(aFaceName) { + mFTFace = nullptr; + mFontFace = nullptr; + mFTFontIndex = 0; } ~FT2FontEntry(); @@ -54,30 +53,22 @@ public: CreateFontEntry(const FontListEntry& aFLE); // Create a font entry for a given freetype face; if it is an installed font, - // also record the filename and index. + // also record the filename and index // aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on, // to be freed after the face is destroyed static FT2FontEntry* - CreateFontEntry(FT_Face aFace, - const char *aFilename, uint8_t aIndex, + CreateFontEntry(FT_Face aFace, const char *aFilename, uint8_t aIndex, const nsAString& aName, const uint8_t *aFontData = nullptr); virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold); - // Create (if necessary) and return the cairo_font_face for this font. - // This may fail and return null, so caller must be prepared to handle this. cairo_font_face_t *CairoFontFace(); - - // Create a cairo_scaled_font for this face, with the given style. - // This may fail and return null, so caller must be prepared to handle this. cairo_scaled_font_t *CreateScaledFont(const gfxFontStyle *aStyle); nsresult ReadCMAP(); - virtual hb_blob_t* GetFontTable(uint32_t aTableTag) MOZ_OVERRIDE; - virtual nsresult CopyFontTable(uint32_t aTableTag, FallibleTArray& aBuffer) MOZ_OVERRIDE; @@ -94,7 +85,7 @@ public: cairo_font_face_t *mFontFace; nsCString mFilename; - uint8_t mFTFontIndex; + uint8_t mFTFontIndex; }; class FT2FontFamily : public gfxFontFamily @@ -133,26 +124,16 @@ protected: void AppendFaceFromFontListEntry(const FontListEntry& aFLE, bool isStdFile); - void AppendFacesFromFontFile(const nsCString& aFileName, + void AppendFacesFromFontFile(nsCString& aFileName, bool isStdFile = false, FontNameCache *aCache = nullptr); - void AppendFacesFromOmnijarEntry(nsZipArchive *aReader, - const nsCString& aEntryName, - FontNameCache *aCache, - bool aJarChanged); - - void AppendFacesFromCachedFaceList(const nsCString& aFileName, + void AppendFacesFromCachedFaceList(nsCString& aFileName, bool isStdFile, - const nsCString& aFaceList); - - void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, - bool aStdFile, FT_Face aFace, nsCString& aFaceList); + nsCString& aFaceList); void FindFonts(); - void FindFontsInOmnijar(FontNameCache *aCache); - #ifdef ANDROID void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC); #endif diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index 1e36c3066e9d..02209d8615cf 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -557,6 +557,12 @@ gfxFT2Font::~gfxFT2Font() { } +cairo_font_face_t * +gfxFT2Font::CairoFontFace() +{ + return GetFontEntry()->CairoFontFace(); +} + /** * Look up the font in the gfxFont cache. If we don't find it, create one. * In either case, add a ref, append it to the aFonts array, and return it --- diff --git a/gfx/thebes/gfxFT2Fonts.h b/gfx/thebes/gfxFT2Fonts.h index 5831e3e8c388..014b1f03b353 100644 --- a/gfx/thebes/gfxFT2Fonts.h +++ b/gfx/thebes/gfxFT2Fonts.h @@ -25,6 +25,8 @@ public: // new functions bool aNeedsBold); virtual ~gfxFT2Font (); + cairo_font_face_t *CairoFontFace(); + FT2FontEntry *GetFontEntry(); static already_AddRefed diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 3d3456037588..79dada4b97a8 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -442,33 +442,6 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag, return entry->ShareTableAndGetBlob(*aBuffer, &mFontTableCache); } -static int -DirEntryCmp(const void* aKey, const void* aItem) -{ - int32_t tag = *static_cast(aKey); - const TableDirEntry* entry = static_cast(aItem); - return tag - int32_t(entry->tag); -} - -hb_blob_t* -gfxFontEntry::GetTableFromFontData(const void* aFontData, uint32_t aTableTag) -{ - const SFNTHeader* header = - reinterpret_cast(aFontData); - const TableDirEntry* dir = - reinterpret_cast(header + 1); - dir = static_cast - (bsearch(&aTableTag, dir, uint16_t(header->numTables), - sizeof(TableDirEntry), DirEntryCmp)); - if (dir) { - return hb_blob_create(reinterpret_cast(aFontData) + - dir->offset, dir->length, - HB_MEMORY_MODE_READONLY, nullptr, nullptr); - - } - return nullptr; -} - hb_blob_t * gfxFontEntry::GetFontTable(uint32_t aTag) { diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index e4d2c128a477..631652b03271 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -508,14 +508,7 @@ protected: return NS_ERROR_FAILURE; } - // Return a blob that wraps a table found within a buffer of font data. - // The blob does NOT own its data; caller guarantees that the buffer - // will remain valid at least as long as the blob. - // Returns null if the specified table is not found. - // This method assumes aFontData is valid 'sfnt' data; before using this, - // caller is responsible to do any sanitization/validation necessary. - hb_blob_t* GetTableFromFontData(const void* aFontData, uint32_t aTableTag); - +protected: // Shaper-specific face objects, shared by all instantiations of the same // physical font, regardless of size. // Usually, only one of these will actually be created for any given font diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index d6e7967e5f9e..e9e272ead2d0 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -627,6 +627,14 @@ bool gfxDownloadedFcFontEntry::SetCairoFace(cairo_font_face_t *aFace) return true; } +static int +DirEntryCmp(const void* aKey, const void* aItem) +{ + int32_t tag = *static_cast(aKey); + const TableDirEntry* entry = static_cast(aItem); + return tag - int32_t(entry->tag); +} + hb_blob_t * gfxDownloadedFcFontEntry::GetFontTable(uint32_t aTableTag) { @@ -634,7 +642,18 @@ gfxDownloadedFcFontEntry::GetFontTable(uint32_t aTableTag) // so we can just return a blob that "wraps" the appropriate chunk of it. // The blob should not attempt to free its data, as the entire sfnt data // will be freed when the font entry is deleted. - return GetTableFromFontData(mFontData, aTableTag); + const SFNTHeader* header = reinterpret_cast(mFontData); + const TableDirEntry* dir = reinterpret_cast(header + 1); + dir = static_cast + (bsearch(&aTableTag, dir, uint16_t(header->numTables), + sizeof(TableDirEntry), DirEntryCmp)); + if (dir) { + return hb_blob_create(reinterpret_cast(mFontData) + + dir->offset, dir->length, + HB_MEMORY_MODE_READONLY, nullptr, nullptr); + + } + return nullptr; } /* diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 947e3a79f7b3..6cd52fb87027 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -253,11 +253,6 @@ pref("gfx.color_management.enablev4", false); pref("gfx.downloadable_fonts.enabled", true); pref("gfx.downloadable_fonts.fallback_delay", 3000); -#ifdef ANDROID -pref("gfx.bundled_fonts.enabled", true); -pref("gfx.bundled_fonts.force-enabled", false); -#endif - pref("gfx.filter.nearest.force-enabled", false); // prefs controlling the font (name/cmap) loader that runs shortly after startup @@ -3326,82 +3321,73 @@ pref("font.name-list.sans-serif.he", "Droid Sans Hebrew, Open Sans, Droid Sans") pref("font.name.serif.ja", "Charis SIL Compact"); pref("font.name.sans-serif.ja", "Open Sans"); pref("font.name.monospace.ja", "MotoyaLMaru"); -pref("font.name-list.serif.ja", "Droid Serif"); pref("font.name-list.sans-serif.ja", "Open Sans, Roboto, Droid Sans, MotoyaLMaru, MotoyaLCedar, Droid Sans Japanese"); pref("font.name-list.monospace.ja", "MotoyaLMaru, MotoyaLCedar, Droid Sans Mono"); pref("font.name.serif.ko", "Charis SIL Compact"); pref("font.name.sans-serif.ko", "Open Sans"); pref("font.name.monospace.ko", "Droid Sans Mono"); -pref("font.name-list.serif.ko", "Droid Serif, HYSerif"); +pref("font.name-list.serif.ko", "HYSerif"); pref("font.name-list.sans-serif.ko", "SmartGothic, NanumGothic, DroidSansFallback, Droid Sans Fallback"); pref("font.name.serif.th", "Charis SIL Compact"); pref("font.name.sans-serif.th", "Open Sans"); pref("font.name.monospace.th", "Droid Sans Mono"); -pref("font.name-list.serif.th", "Droid Serif"); pref("font.name-list.sans-serif.th", "Droid Sans Thai, Open Sans, Droid Sans"); pref("font.name.serif.tr", "Charis SIL Compact"); pref("font.name.sans-serif.tr", "Open Sans"); pref("font.name.monospace.tr", "Droid Sans Mono"); -pref("font.name-list.serif.tr", "Droid Serif"); pref("font.name-list.sans-serif.tr", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-baltic", "Charis SIL Compact"); pref("font.name.sans-serif.x-baltic", "Open Sans"); pref("font.name.monospace.x-baltic", "Droid Sans Mono"); -pref("font.name-list.serif.x-baltic", "Droid Serif"); pref("font.name-list.sans-serif.x-baltic", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-central-euro", "Charis SIL Compact"); pref("font.name.sans-serif.x-central-euro", "Open Sans"); pref("font.name.monospace.x-central-euro", "Droid Sans Mono"); -pref("font.name-list.serif.x-central-euro", "Droid Serif"); pref("font.name-list.sans-serif.x-central-euro", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-cyrillic", "Charis SIL Compact"); pref("font.name.sans-serif.x-cyrillic", "Open Sans"); pref("font.name.monospace.x-cyrillic", "Droid Sans Mono"); -pref("font.name-list.serif.x-cyrillic", "Droid Serif"); pref("font.name-list.sans-serif.x-cyrillic", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-unicode", "Charis SIL Compact"); pref("font.name.sans-serif.x-unicode", "Open Sans"); pref("font.name.monospace.x-unicode", "Droid Sans Mono"); -pref("font.name-list.serif.x-unicode", "Droid Serif"); pref("font.name-list.sans-serif.x-unicode", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-user-def", "Charis SIL Compact"); pref("font.name.sans-serif.x-user-def", "Open Sans"); pref("font.name.monospace.x-user-def", "Droid Sans Mono"); -pref("font.name-list.serif.x-user-def", "Droid Serif"); pref("font.name-list.sans-serif.x-user-def", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.x-western", "Charis SIL Compact"); pref("font.name.sans-serif.x-western", "Open Sans"); pref("font.name.monospace.x-western", "Droid Sans Mono"); -pref("font.name-list.serif.x-western", "Droid Serif"); pref("font.name-list.sans-serif.x-western", "Open Sans, Roboto, Droid Sans"); pref("font.name.serif.zh-CN", "Charis SIL Compact"); pref("font.name.sans-serif.zh-CN", "Open Sans"); pref("font.name.monospace.zh-CN", "Droid Sans Mono"); -pref("font.name-list.serif.zh-CN", "Droid Serif, Droid Sans Fallback"); +pref("font.name-list.serif.zh-CN", "Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-CN", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-CN", "Droid Sans Fallback"); pref("font.name.serif.zh-HK", "Charis SIL Compact"); pref("font.name.sans-serif.zh-HK", "Open Sans"); pref("font.name.monospace.zh-HK", "Droid Sans Mono"); -pref("font.name-list.serif.zh-HK", "Droid Serif, Droid Sans Fallback"); +pref("font.name-list.serif.zh-HK", "Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-HK", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-HK", "Droid Sans Fallback"); pref("font.name.serif.zh-TW", "Charis SIL Compact"); pref("font.name.sans-serif.zh-TW", "Open Sans"); pref("font.name.monospace.zh-TW", "Droid Sans Mono"); -pref("font.name-list.serif.zh-TW", "Droid Serif, Droid Sans Fallback"); +pref("font.name-list.serif.zh-TW", "Droid Sans Fallback"); pref("font.name-list.sans-serif.zh-TW", "Roboto, Droid Sans, Droid Sans Fallback"); pref("font.name-list.monospace.zh-TW", "Droid Sans Fallback"); From dec629599d53567aa965c65d54b81518d69e7d4e Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Tue, 25 Jun 2013 20:29:14 +0900 Subject: [PATCH 32/45] Bug 874669 - Remove legacy event type constants. r=smaug CLOBBER --- dom/interfaces/events/nsIDOMEvent.idl | 32 ------------------------- dom/interfaces/events/nsIDOMNSEvent.idl | 32 ------------------------- dom/webidl/Event.webidl | 32 ------------------------- 3 files changed, 96 deletions(-) diff --git a/dom/interfaces/events/nsIDOMEvent.idl b/dom/interfaces/events/nsIDOMEvent.idl index 17025c80221e..5ecfcf6ba5ec 100644 --- a/dom/interfaces/events/nsIDOMEvent.idl +++ b/dom/interfaces/events/nsIDOMEvent.idl @@ -180,38 +180,6 @@ interface nsIDOMEvent : nsISupports */ void stopImmediatePropagation(); - const long MOUSEDOWN = 0x00000001; - const long MOUSEUP = 0x00000002; - const long MOUSEOVER = 0x00000004; - const long MOUSEOUT = 0x00000008; - const long MOUSEMOVE = 0x00000010; - const long MOUSEDRAG = 0x00000020; - const long CLICK = 0x00000040; - const long DBLCLICK = 0x00000080; - const long KEYDOWN = 0x00000100; - const long KEYUP = 0x00000200; - const long KEYPRESS = 0x00000400; - const long DRAGDROP = 0x00000800; - const long FOCUS = 0x00001000; - const long BLUR = 0x00002000; - const long SELECT = 0x00004000; - const long CHANGE = 0x00008000; - const long RESET = 0x00010000; - const long SUBMIT = 0x00020000; - const long SCROLL = 0x00040000; - const long LOAD = 0x00080000; - const long UNLOAD = 0x00100000; - const long XFER_DONE = 0x00200000; - const long ABORT = 0x00400000; - const long ERROR = 0x00800000; - const long LOCATE = 0x01000000; - const long MOVE = 0x02000000; - const long RESIZE = 0x04000000; - const long FORWARD = 0x08000000; - const long HELP = 0x10000000; - const long BACK = 0x20000000; - const long TEXT = 0x40000000; - const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; diff --git a/dom/interfaces/events/nsIDOMNSEvent.idl b/dom/interfaces/events/nsIDOMNSEvent.idl index afce8db1ec58..822a4835aba7 100644 --- a/dom/interfaces/events/nsIDOMNSEvent.idl +++ b/dom/interfaces/events/nsIDOMNSEvent.idl @@ -14,38 +14,6 @@ [scriptable, uuid(2580b4a2-6d85-4ca6-9be2-98f3406ad296)] interface nsIDOMNSEvent : nsISupports { - const long MOUSEDOWN = 0x00000001; - const long MOUSEUP = 0x00000002; - const long MOUSEOVER = 0x00000004; - const long MOUSEOUT = 0x00000008; - const long MOUSEMOVE = 0x00000010; - const long MOUSEDRAG = 0x00000020; - const long CLICK = 0x00000040; - const long DBLCLICK = 0x00000080; - const long KEYDOWN = 0x00000100; - const long KEYUP = 0x00000200; - const long KEYPRESS = 0x00000400; - const long DRAGDROP = 0x00000800; - const long FOCUS = 0x00001000; - const long BLUR = 0x00002000; - const long SELECT = 0x00004000; - const long CHANGE = 0x00008000; - const long RESET = 0x00010000; - const long SUBMIT = 0x00020000; - const long SCROLL = 0x00040000; - const long LOAD = 0x00080000; - const long UNLOAD = 0x00100000; - const long XFER_DONE = 0x00200000; - const long ABORT = 0x00400000; - const long ERROR = 0x00800000; - const long LOCATE = 0x01000000; - const long MOVE = 0x02000000; - const long RESIZE = 0x04000000; - const long FORWARD = 0x08000000; - const long HELP = 0x10000000; - const long BACK = 0x20000000; - const long TEXT = 0x40000000; - const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; diff --git a/dom/webidl/Event.webidl b/dom/webidl/Event.webidl index b96bc3fa61b5..aa3e8e72014b 100644 --- a/dom/webidl/Event.webidl +++ b/dom/webidl/Event.webidl @@ -39,38 +39,6 @@ interface Event { // Mozilla specific legacy stuff. partial interface Event { - const long MOUSEDOWN = 0x00000001; - const long MOUSEUP = 0x00000002; - const long MOUSEOVER = 0x00000004; - const long MOUSEOUT = 0x00000008; - const long MOUSEMOVE = 0x00000010; - const long MOUSEDRAG = 0x00000020; - const long CLICK = 0x00000040; - const long DBLCLICK = 0x00000080; - const long KEYDOWN = 0x00000100; - const long KEYUP = 0x00000200; - const long KEYPRESS = 0x00000400; - const long DRAGDROP = 0x00000800; - const long FOCUS = 0x00001000; - const long BLUR = 0x00002000; - const long SELECT = 0x00004000; - const long CHANGE = 0x00008000; - const long RESET = 0x00010000; - const long SUBMIT = 0x00020000; - const long SCROLL = 0x00040000; - const long LOAD = 0x00080000; - const long UNLOAD = 0x00100000; - const long XFER_DONE = 0x00200000; - const long ABORT = 0x00400000; - const long ERROR = 0x00800000; - const long LOCATE = 0x01000000; - const long MOVE = 0x02000000; - const long RESIZE = 0x04000000; - const long FORWARD = 0x08000000; - const long HELP = 0x10000000; - const long BACK = 0x20000000; - const long TEXT = 0x40000000; - const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; From 6d813019971519f5f6ae41e682da60a09ecaf1b3 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 25 Jun 2013 14:15:08 +0200 Subject: [PATCH 33/45] Bug 885660 - Fix Ion bailouts to overwrite arguments on the stack at the end of the bailout. r=djvj --- js/src/ion/BaselineBailouts.cpp | 32 ++++++++++++++++++++++---- js/src/jit-test/tests/ion/bug885660.js | 23 ++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 js/src/jit-test/tests/ion/bug885660.js diff --git a/js/src/ion/BaselineBailouts.cpp b/js/src/ion/BaselineBailouts.cpp index 763364845eb3..013f8b8dda3e 100644 --- a/js/src/ion/BaselineBailouts.cpp +++ b/js/src/ion/BaselineBailouts.cpp @@ -445,7 +445,8 @@ static bool InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC, HandleFunction fun, HandleScript script, IonScript *ionScript, SnapshotIterator &iter, bool invalidate, BaselineStackBuilder &builder, - MutableHandleFunction nextCallee, jsbytecode **callPC) + AutoValueVector &startFrameFormals, MutableHandleFunction nextCallee, + jsbytecode **callPC) { uint32_t exprStackSlots = iter.slots() - (script->nfixed + CountArgSlots(script, fun)); @@ -592,12 +593,27 @@ InitFromBailout(JSContext *cx, HandleScript caller, jsbytecode *callerPC, IonSpew(IonSpew_BaselineBailouts, " frame slots %u, nargs %u, nfixed %u", iter.slots(), fun->nargs, script->nfixed); + if (!callerPC) { + // This is the first frame. Store the formals in a Vector until we + // are done. Due to UCE and phi elimination, we could store an + // UndefinedValue() here for formals we think are unused, but + // locals may still reference the original argument slot + // (MParameter/LArgument) and expect the original Value. + JS_ASSERT(startFrameFormals.empty()); + if (!startFrameFormals.resize(fun->nargs)) + return false; + } + for (uint32_t i = 0; i < fun->nargs; i++) { Value arg = iter.read(); IonSpew(IonSpew_BaselineBailouts, " arg %d = %016llx", (int) i, *((uint64_t *) &arg)); - size_t argOffset = builder.framePushed() + IonJSFrameLayout::offsetOfActualArg(i); - *builder.valuePointerAtStackOffset(argOffset) = arg; + if (callerPC) { + size_t argOffset = builder.framePushed() + IonJSFrameLayout::offsetOfActualArg(i); + *builder.valuePointerAtStackOffset(argOffset) = arg; + } else { + startFrameFormals[i] = arg; + } } } @@ -1091,12 +1107,14 @@ ion::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIt jsbytecode *callerPC = NULL; RootedFunction fun(cx, callee); RootedScript scr(cx, iter.script()); + AutoValueVector startFrameFormals(cx); while (true) { IonSpew(IonSpew_BaselineBailouts, " FrameNo %d", frameNo); jsbytecode *callPC = NULL; RootedFunction nextCallee(cx, NULL); if (!InitFromBailout(cx, caller, callerPC, fun, scr, iter.ionScript(), - snapIter, invalidate, builder, &nextCallee, &callPC)) + snapIter, invalidate, builder, startFrameFormals, + &nextCallee, &callPC)) { return BAILOUT_RETURN_FATAL_ERROR; } @@ -1119,6 +1137,12 @@ ion::BailoutIonToBaseline(JSContext *cx, JitActivation *activation, IonBailoutIt IonSpew(IonSpew_BaselineBailouts, " Done restoring frames"); BailoutKind bailoutKind = snapIter.bailoutKind(); + if (!startFrameFormals.empty()) { + // Set the first frame's formals, see the comment in InitFromBailout. + Value *argv = builder.startFrame()->argv() + 1; // +1 to skip |this|. + mozilla::PodCopy(argv, startFrameFormals.begin(), startFrameFormals.length()); + } + // Take the reconstructed baseline stack so it doesn't get freed when builder destructs. BaselineBailoutInfo *info = builder.takeBuffer(); info->numFrames = frameNo + 1; diff --git a/js/src/jit-test/tests/ion/bug885660.js b/js/src/jit-test/tests/ion/bug885660.js new file mode 100644 index 000000000000..f7fed17dc182 --- /dev/null +++ b/js/src/jit-test/tests/ion/bug885660.js @@ -0,0 +1,23 @@ +function ff(parsedTypeName, defaultContext) { + var context = null; + + if (context === null) + context = defaultContext; + + if (parsedTypeName.genericArguments !== null) { + for (var i = 0; i < 0; i++) {} + } + + var foo = parsedTypeName.type; + assertEq(typeof context, "object"); + return foo; +} +function test() { + var parsedTypeName = {genericArguments: null}; + for (var i=0; i<140; i++) { + if (i > 100) + parsedTypeName.x = {}; + ff(parsedTypeName, {}); + } +} +test(); From 702726731f49f0f658538e3e548794974930cdcf Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 13:45:09 +0100 Subject: [PATCH 34/45] Backed out changeset d7c237784ce9 (bug 886230) for B2G mochitest-9 failures in test_bug582181-1.html --- .../canvas/src/CanvasRenderingContext2D.cpp | 3 - content/svg/content/test/Makefile.in | 1 - content/svg/content/test/test_text_dirty.html | 55 ------------------- layout/base/nsIPresShell.h | 13 +---- layout/base/nsPresShell.cpp | 3 - layout/svg/nsSVGTextFrame2.cpp | 12 +--- .../specialpowers/content/specialpowersAPI.js | 25 +++------ 7 files changed, 12 insertions(+), 100 deletions(-) delete mode 100644 content/svg/content/test/test_text_dirty.html diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index fd7683c45a70..48758c95c6ea 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -3204,9 +3204,6 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x, if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_ASYNC_DECODE_IMAGES) { renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES; } - if (flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH) { - renderDocFlags |= nsIPresShell::RENDER_DRAWWINDOW_NOT_FLUSHING; - } // gfxContext-over-Azure may modify the DrawTarget's transform, so // save and restore it diff --git a/content/svg/content/test/Makefile.in b/content/svg/content/test/Makefile.in index 786c3057c86c..205a094d6787 100644 --- a/content/svg/content/test/Makefile.in +++ b/content/svg/content/test/Makefile.in @@ -80,7 +80,6 @@ MOCHITEST_FILES = \ switch-helper.svg \ test_text.html \ test_text_2.html \ - test_text_dirty.html \ test_text_scaled.html \ test_text_selection.html \ test_text_update.html \ diff --git a/content/svg/content/test/test_text_dirty.html b/content/svg/content/test/test_text_dirty.html deleted file mode 100644 index cfa4ab9d734f..000000000000 --- a/content/svg/content/test/test_text_dirty.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Test for Bug 886230 - - - - - - -Mozilla Bug 886230 -

- - x - - -

- -
-
-
- - diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 5ab3aff4801a..4242846bb956 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -173,8 +173,7 @@ protected: typedef mozilla::layers::LayerManager LayerManager; enum eRenderFlag { - STATE_IGNORING_VIEWPORT_SCROLLING = 0x1, - STATE_DRAWWINDOW_NOT_FLUSHING = 0x2 + STATE_IGNORING_VIEWPORT_SCROLLING = 0x1 }; typedef uint8_t RenderFlags; // for storing the above flags @@ -984,8 +983,7 @@ public: RENDER_CARET = 0x04, RENDER_USE_WIDGET_LAYERS = 0x08, RENDER_ASYNC_DECODE_IMAGES = 0x10, - RENDER_DOCUMENT_RELATIVE = 0x20, - RENDER_DRAWWINDOW_NOT_FLUSHING = 0x40 + RENDER_DOCUMENT_RELATIVE = 0x20 }; virtual NS_HIDDEN_(nsresult) RenderDocument(const nsRect& aRect, uint32_t aFlags, nscolor aBackgroundColor, @@ -1222,13 +1220,6 @@ public: float GetXResolution() { return mXResolution; } float GetYResolution() { return mYResolution; } - /** - * Returns whether we are in a DrawWindow() call that used the - * DRAWWINDOW_DO_NOT_FLUSH flag. - */ - bool InDrawWindowNotFlushing() const - { return mRenderFlags & STATE_DRAWWINDOW_NOT_FLUSHING; } - /** * Set the isFirstPaint flag. */ diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 2735bb9c68d1..60a03c5daaad 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4450,9 +4450,6 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags, wouldFlushRetainedLayers = !IgnoringViewportScrolling(); mRenderFlags = ChangeFlag(mRenderFlags, true, STATE_IGNORING_VIEWPORT_SCROLLING); } - if (aFlags & RENDER_DRAWWINDOW_NOT_FLUSHING) { - mRenderFlags = ChangeFlag(mRenderFlags, true, STATE_DRAWWINDOW_NOT_FLUSHING); - } if (aFlags & RENDER_DOCUMENT_RELATIVE) { // XXX be smarter about this ... drawWindow might want a rect // that's "pretty close" to what our retained layer tree covers. diff --git a/layout/svg/nsSVGTextFrame2.cpp b/layout/svg/nsSVGTextFrame2.cpp index c1ca2702c71b..d003e4c58eed 100644 --- a/layout/svg/nsSVGTextFrame2.cpp +++ b/layout/svg/nsSVGTextFrame2.cpp @@ -3356,22 +3356,12 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext, if (!kid) return NS_OK; - nsPresContext* presContext = PresContext(); - gfxContext *gfx = aContext->ThebesContext(); gfxMatrix initialMatrix = gfx->CurrentMatrix(); AutoCanvasTMForMarker autoCanvasTMFor(this, FOR_PAINTING); if (mState & NS_STATE_SVG_NONDISPLAY_CHILD) { - // If we are in a canvas DrawWindow call that used the - // DRAWWINDOW_DO_NOT_FLUSH flag, then we may still have out - // of date frames. Just don't paint anything if they are - // dirty. - if (presContext->PresShell()->InDrawWindowNotFlushing() && - NS_SUBTREE_DIRTY(this)) { - return NS_OK; - } // Text frames inside , , etc. will never have had // ReflowSVG called on them, so call UpdateGlyphPositioning to do this now. UpdateGlyphPositioning(); @@ -3391,6 +3381,8 @@ nsSVGTextFrame2::PaintSVG(nsRenderingContext* aContext, gfxMatrix matrixForPaintServers(canvasTM); matrixForPaintServers.Multiply(initialMatrix); + nsPresContext* presContext = PresContext(); + // Check if we need to draw anything. if (aDirtyRect) { NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() || diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 0ba1e96e7702..30bf79cf9c48 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -1112,42 +1112,33 @@ SpecialPowersAPI.prototype = { return this.wrap(Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest)); }, - snapshotWindowWithOptions: function (win, rect, bgcolor, options) { + snapshotWindow: function (win, withCaret, rect, bgcolor) { var el = this.window.get().document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); - if (rect === undefined) { + if (arguments.length < 3) { rect = { top: win.scrollY, left: win.scrollX, width: win.innerWidth, height: win.innerHeight }; } - if (bgcolor === undefined) { + if (arguments.length < 4) { bgcolor = "rgb(255,255,255)"; } - if (options === undefined) { - options = { }; - } el.width = rect.width; el.height = rect.height; var ctx = el.getContext("2d"); var flags = 0; - for (var option in options) { - flags |= ctx[option]; - } - ctx.drawWindow(win, rect.left, rect.top, rect.width, rect.height, bgcolor, - flags); + withCaret ? ctx.DRAWWINDOW_DRAW_CARET : 0); return el; }, - snapshotWindow: function (win, withCaret, rect, bgcolor) { - return this.snapshotWindowWithOptions(win, rect, bgcolor, - { DRAWWINDOW_DRAW_CARET: withCaret }); - }, - snapshotRect: function (win, rect, bgcolor) { - return this.snapshotWindow(win, false, rect, bgcolor); + // Splice in our "do not want caret" bit + args = Array.slice(arguments); + args.splice(1, 0, false); + return this.snapshotWindow.apply(this, args); }, gc: function() { From a16b574c00c7f0a3c8152950406ae20b0970c7e0 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 14:18:52 +0100 Subject: [PATCH 35/45] Backed out changeset 1d5db5f16a32 (bug 874669) for failures in test_bug716822.html --- dom/interfaces/events/nsIDOMEvent.idl | 32 +++++++++++++++++++++++++ dom/interfaces/events/nsIDOMNSEvent.idl | 32 +++++++++++++++++++++++++ dom/webidl/Event.webidl | 32 +++++++++++++++++++++++++ 3 files changed, 96 insertions(+) diff --git a/dom/interfaces/events/nsIDOMEvent.idl b/dom/interfaces/events/nsIDOMEvent.idl index 5ecfcf6ba5ec..17025c80221e 100644 --- a/dom/interfaces/events/nsIDOMEvent.idl +++ b/dom/interfaces/events/nsIDOMEvent.idl @@ -180,6 +180,38 @@ interface nsIDOMEvent : nsISupports */ void stopImmediatePropagation(); + const long MOUSEDOWN = 0x00000001; + const long MOUSEUP = 0x00000002; + const long MOUSEOVER = 0x00000004; + const long MOUSEOUT = 0x00000008; + const long MOUSEMOVE = 0x00000010; + const long MOUSEDRAG = 0x00000020; + const long CLICK = 0x00000040; + const long DBLCLICK = 0x00000080; + const long KEYDOWN = 0x00000100; + const long KEYUP = 0x00000200; + const long KEYPRESS = 0x00000400; + const long DRAGDROP = 0x00000800; + const long FOCUS = 0x00001000; + const long BLUR = 0x00002000; + const long SELECT = 0x00004000; + const long CHANGE = 0x00008000; + const long RESET = 0x00010000; + const long SUBMIT = 0x00020000; + const long SCROLL = 0x00040000; + const long LOAD = 0x00080000; + const long UNLOAD = 0x00100000; + const long XFER_DONE = 0x00200000; + const long ABORT = 0x00400000; + const long ERROR = 0x00800000; + const long LOCATE = 0x01000000; + const long MOVE = 0x02000000; + const long RESIZE = 0x04000000; + const long FORWARD = 0x08000000; + const long HELP = 0x10000000; + const long BACK = 0x20000000; + const long TEXT = 0x40000000; + const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; diff --git a/dom/interfaces/events/nsIDOMNSEvent.idl b/dom/interfaces/events/nsIDOMNSEvent.idl index 822a4835aba7..afce8db1ec58 100644 --- a/dom/interfaces/events/nsIDOMNSEvent.idl +++ b/dom/interfaces/events/nsIDOMNSEvent.idl @@ -14,6 +14,38 @@ [scriptable, uuid(2580b4a2-6d85-4ca6-9be2-98f3406ad296)] interface nsIDOMNSEvent : nsISupports { + const long MOUSEDOWN = 0x00000001; + const long MOUSEUP = 0x00000002; + const long MOUSEOVER = 0x00000004; + const long MOUSEOUT = 0x00000008; + const long MOUSEMOVE = 0x00000010; + const long MOUSEDRAG = 0x00000020; + const long CLICK = 0x00000040; + const long DBLCLICK = 0x00000080; + const long KEYDOWN = 0x00000100; + const long KEYUP = 0x00000200; + const long KEYPRESS = 0x00000400; + const long DRAGDROP = 0x00000800; + const long FOCUS = 0x00001000; + const long BLUR = 0x00002000; + const long SELECT = 0x00004000; + const long CHANGE = 0x00008000; + const long RESET = 0x00010000; + const long SUBMIT = 0x00020000; + const long SCROLL = 0x00040000; + const long LOAD = 0x00080000; + const long UNLOAD = 0x00100000; + const long XFER_DONE = 0x00200000; + const long ABORT = 0x00400000; + const long ERROR = 0x00800000; + const long LOCATE = 0x01000000; + const long MOVE = 0x02000000; + const long RESIZE = 0x04000000; + const long FORWARD = 0x08000000; + const long HELP = 0x10000000; + const long BACK = 0x20000000; + const long TEXT = 0x40000000; + const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; diff --git a/dom/webidl/Event.webidl b/dom/webidl/Event.webidl index aa3e8e72014b..b96bc3fa61b5 100644 --- a/dom/webidl/Event.webidl +++ b/dom/webidl/Event.webidl @@ -39,6 +39,38 @@ interface Event { // Mozilla specific legacy stuff. partial interface Event { + const long MOUSEDOWN = 0x00000001; + const long MOUSEUP = 0x00000002; + const long MOUSEOVER = 0x00000004; + const long MOUSEOUT = 0x00000008; + const long MOUSEMOVE = 0x00000010; + const long MOUSEDRAG = 0x00000020; + const long CLICK = 0x00000040; + const long DBLCLICK = 0x00000080; + const long KEYDOWN = 0x00000100; + const long KEYUP = 0x00000200; + const long KEYPRESS = 0x00000400; + const long DRAGDROP = 0x00000800; + const long FOCUS = 0x00001000; + const long BLUR = 0x00002000; + const long SELECT = 0x00004000; + const long CHANGE = 0x00008000; + const long RESET = 0x00010000; + const long SUBMIT = 0x00020000; + const long SCROLL = 0x00040000; + const long LOAD = 0x00080000; + const long UNLOAD = 0x00100000; + const long XFER_DONE = 0x00200000; + const long ABORT = 0x00400000; + const long ERROR = 0x00800000; + const long LOCATE = 0x01000000; + const long MOVE = 0x02000000; + const long RESIZE = 0x04000000; + const long FORWARD = 0x08000000; + const long HELP = 0x10000000; + const long BACK = 0x20000000; + const long TEXT = 0x40000000; + const long ALT_MASK = 0x00000001; const long CONTROL_MASK = 0x00000002; const long SHIFT_MASK = 0x00000004; From 252288cc3134e9d2e3457cc37c234a2af7886665 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 14:41:34 +0100 Subject: [PATCH 36/45] Bug 845162 - Disable test_playback.html and test_seek.html on Android for too many intermittent failures --- testing/mochitest/android.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/mochitest/android.json b/testing/mochitest/android.json index f4d068d104ca..b359527faa0a 100644 --- a/testing/mochitest/android.json +++ b/testing/mochitest/android.json @@ -116,6 +116,8 @@ "content/media/test/test_framebuffer.html": "", "content/media/test/test_media_selection.html": "", "content/media/test/test_playback.html": "", + "content/media/test/test_playback_rate.html": "bug 845162", + "content/media/test/test_seek.html": "bug 845162", "content/media/test/test_seekLies.html": "TIMED_OUT", "content/media/test/test_seekable2.html": "", "content/media/test/test_wave_data_s16.html": "TIMED_OUT", From 1808439874f3015dff5f25b086cd6058fd59fbd7 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Tue, 25 Jun 2013 14:51:33 +0100 Subject: [PATCH 37/45] Backed out changeset 7f9cf2a04252 (bug 828088) for near-permaorange metro test runs --- browser/metro/base/content/TopSites.js | 2 +- browser/metro/base/content/bindings/grid.xml | 237 ++---- browser/metro/base/content/browser.xul | 8 +- .../base/tests/mochitest/browser_tilegrid.xul | 155 ++-- .../base/tests/mochitest/browser_tiles.js | 774 ++++++++---------- browser/metro/base/tests/mochitest/head.js | 18 - browser/metro/theme/browser.css | 20 +- browser/metro/theme/defines.inc | 10 +- browser/metro/theme/jar.mn | 1 - browser/metro/theme/platform.css | 142 ++++ browser/metro/theme/tiles.css | 274 ------- 11 files changed, 651 insertions(+), 990 deletions(-) delete mode 100644 browser/metro/theme/tiles.css diff --git a/browser/metro/base/content/TopSites.js b/browser/metro/base/content/TopSites.js index 6450738513cc..7e8d8812e2a2 100644 --- a/browser/metro/base/content/TopSites.js +++ b/browser/metro/base/content/TopSites.js @@ -328,8 +328,8 @@ TopSitesView.prototype = { for (let idx=0; idx < length; idx++) { let isNew = !tileset.children[idx], + item = tileset.children[idx] || document.createElement("richgriditem"), site = sites[idx]; - let item = isNew ? tileset.createItemElement(site.title, site.url) : tileset.children[idx]; this.updateTile(item, site); if (isNew) { diff --git a/browser/metro/base/content/bindings/grid.xml b/browser/metro/base/content/bindings/grid.xml index 51fc1ebc3ea3..95f5c3b1acab 100644 --- a/browser/metro/base/content/bindings/grid.xml +++ b/browser/metro/base/content/bindings/grid.xml @@ -3,6 +3,7 @@ - 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/. --> + - + - - - - null @@ -88,8 +85,6 @@ @@ -101,8 +96,6 @@ - @@ -217,7 +208,7 @@ 0 - + + 10 + + - + this._itemHeightRenderThreshold) { + return gridItemRect; + } } - return dims; + return null; ]]> @@ -387,18 +378,13 @@ @@ -510,7 +486,6 @@ @@ -537,62 +511,6 @@ } ]]> - - - - - "tiles.css" - - - width/height values - let typeSelectors = { - "richgriditem" : "default", - "richgriditem[customImage]": "thumbnail", - "richgriditem[compact]": "compact" - }; - let rules, sheet; - for (let i=0; (sheet=sheets[i]); i++) { - if (sheet.href && sheet.href.endsWith( this._tileStyleSheetName )) { - rules = sheet.cssRules; - break; - } - } - if (rules) { - // walk the stylesheet rules until we've matched all our selectors - for (let i=0, rule;(rule=rules[i]); i++) { - let type = rule.selectorText && typeSelectors[rule.selectorText]; - if (type) { - let sizes = typeSizes[type] = {}; - typeSelectors[type] = null; - delete typeSelectors[type]; - // we assume px unit for tile dimension values - sizes.width = parseInt(rule.style.getPropertyValue("width")); - sizes.height = parseInt(rule.style.getPropertyValue("height")); - } - if (!Object.keys(typeSelectors).length) - break; - } - } else { - throw new Error("Failed to find stylesheet to parse out richgriditem dimensions\n"); - } - return typeSizes; - ]]> - - @@ -602,12 +520,13 @@ - + @@ -636,7 +555,7 @@ if (this.suppressOnSelect || this._suppressOnSelect) return; - let event = document.createEvent("Events"); + var event = document.createEvent("Events"); event.initEvent("selectionchange", true, true); this.dispatchEvent(event); ]]> @@ -711,30 +630,22 @@ - - - - - - - + + + + + + + - - - - - - - - - - + + + + @@ -752,11 +663,16 @@ onget="return this.hasAttribute('pinned')" onset="if (val) { this.setAttribute('pinned', val) } else this.removeAttribute('pinned');"/> + + + @@ -804,21 +722,19 @@ @@ -856,11 +772,12 @@ - diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul index ef32c04b7996..947ce0cde831 100644 --- a/browser/metro/base/content/browser.xul +++ b/browser/metro/base/content/browser.xul @@ -9,7 +9,6 @@ - @@ -195,7 +194,7 @@
- - + - +
diff --git a/browser/metro/base/tests/mochitest/browser_tilegrid.xul b/browser/metro/base/tests/mochitest/browser_tilegrid.xul index 4e3c24db52d3..3f3fe0ccf28e 100644 --- a/browser/metro/base/tests/mochitest/browser_tilegrid.xul +++ b/browser/metro/base/tests/mochitest/browser_tilegrid.xul @@ -1,86 +1,69 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/browser/metro/base/tests/mochitest/browser_tiles.js b/browser/metro/base/tests/mochitest/browser_tiles.js index 82031bd114dd..103bf1f85584 100644 --- a/browser/metro/base/tests/mochitest/browser_tiles.js +++ b/browser/metro/base/tests/mochitest/browser_tiles.js @@ -1,425 +1,349 @@ -let doc; - -function test() { - waitForExplicitFinish(); - Task.spawn(function(){ - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - - info(chromeRoot + "browser_tilegrid.xul"); - yield addTab(chromeRoot + "browser_tilegrid.xul"); - doc = Browser.selectedTab.browser.contentWindow.document; - info("browser_tilegrid.xul loaded, doc populated, running tests"); - }).then(runTests); -} - -gTests.push({ - desc: "richgrid binding is applied", - run: function() { - ok(doc, "doc got defined"); - - let grid = doc.querySelector("#grid1"); - ok(grid, "#grid1 is found"); - is(typeof grid.clearSelection, "function", "#grid1 has the binding applied"); - - is(grid.children.length, 2, "#grid1 has a 2 items"); - is(grid.children[0].control, grid, "#grid1 item's control points back at #grid1'"); - } -}); - -gTests.push({ - desc: "item clicks are handled", - run: function() { - - let grid = doc.querySelector("#grid1"); - is(typeof grid.handleItemClick, "function", "grid.handleItemClick is a function"); - let handleStub = stubMethod(grid, 'handleItemClick'); - let itemId = "grid1_item1"; // grid.children[0].getAttribute("id"); - - // send click to item and wait for next tick; - EventUtils.sendMouseEvent({type: 'click'}, itemId, doc.defaultView); - yield waitForMs(0); - - is(handleStub.callCount, 1, "handleItemClick was called when we clicked an item"); - handleStub.restore(); - - // if the grid has a controller, it should be called too - let gridController = { - handleItemClick: function() {} - }; - let controllerHandleStub = stubMethod(gridController, "handleItemClick"); - let origController = grid.controller; - grid.controller = gridController; - - // send click to item and wait for next tick; - EventUtils.sendMouseEvent({type: 'click'}, itemId, doc.defaultView); - yield waitForMs(0); - - is(controllerHandleStub.callCount, 1, "controller.handleItemClick was called when we clicked an item"); - is(controllerHandleStub.calledWith[0], doc.getElementById(itemId), "controller.handleItemClick was passed the grid item"); - grid.controller = origController; - - } -}); - -gTests.push({ - desc: "arrangeItems", - run: function() { - let container = doc.getElementById("alayout"); - // implements an arrangeItems method, with optional cols, rows signature - let grid = doc.querySelector("#grid_layout"); - - is(typeof grid.arrangeItems, "function", "arrangeItems is a function on the grid"); - ok(grid.tileHeight, "grid has truthy tileHeight value"); - ok(grid.tileWidth, "grid has truthy tileWidth value"); - - // make the container big enough for 3 rows - container.style.height = 3 * grid.tileHeight + 20 + "px"; - - // add some items - grid.appendItem("test title", "about:blank", true); - grid.appendItem("test title", "about:blank", true); - grid.appendItem("test title", "about:blank", true); - grid.appendItem("test title", "about:blank", true); - grid.appendItem("test title", "about:blank", true); - - grid.arrangeItems(); - // they should all fit nicely in a 3x2 grid - is(grid.rowCount, 3, "rowCount is calculated correctly for a given container height and tileheight"); - is(grid.columnCount, 2, "columnCount is calculated correctly for a given container maxWidth and tilewidth"); - - // squish the available height - // should overflow (clip) a 2x2 grid - - dump("grid tileheight:" +grid.tileHeight+"\n"); - let under3rowsHeight = (3 * grid.tileHeight -20) + "px"; - dump("Squishing grid container to less than 3x tileheight:" +under3rowsHeight + "\n"); - container.style.height = under3rowsHeight; - grid.arrangeItems(); - - is(grid.rowCount, 2, "rowCount is re-calculated correctly for a given container height"); - } -}); - -gTests.push({ - desc: "clearAll", - run: function() { - let grid = doc.getElementById("clearGrid"); - grid.arrangeItems(); - - // grid has rows=2 so we expect at least 2 rows and 2 columns with 3 items - is(typeof grid.clearAll, "function", "clearAll is a function on the grid"); - is(grid.itemCount, 3, "grid has 3 items initially"); - is(grid.rowCount, 2, "grid has 2 rows initially"); - is(grid.columnCount, 2, "grid has 2 cols initially"); - - let arrangeSpy = spyOnMethod(grid, "arrangeItems"); - grid.clearAll(); - - is(grid.itemCount, 0, "grid has 0 itemCount after clearAll"); - is(grid.children.length, 0, "grid has 0 children after clearAll"); - is(grid.rowCount, 0, "grid has 0 rows when empty"); - is(grid.columnCount, 0, "grid has 0 cols when empty"); - - is(arrangeSpy.callCount, 1, "arrangeItems is called once when we clearAll"); - arrangeSpy.restore(); - } -}); - -gTests.push({ - desc: "empty grid", - run: function() { - let grid = doc.getElementById("emptyGrid"); - grid.arrangeItems(); - yield waitForCondition(() => !grid.isArranging); - - // grid has rows=2 but 0 items - ok(grid.isBound, "binding was applied"); - is(grid.itemCount, 0, "empty grid has 0 items"); - is(grid.rowCount, 0, "empty grid has 0 rows"); - is(grid.columnCount, 0, "empty grid has 0 cols"); - - let columnsNode = grid._grid; - let cStyle = doc.defaultView.getComputedStyle(columnsNode); - is(cStyle.getPropertyValue("-moz-column-count"), "auto", "empty grid has -moz-column-count: auto"); - } -}); - -gTests.push({ - desc: "appendItem", - run: function() { - // implements an appendItem with signature title, uri, returns item element - // appendItem triggers arrangeItems - let grid = doc.querySelector("#emptygrid"); - - is(grid.itemCount, 0, "0 itemCount when empty"); - is(grid.children.length, 0, "0 children when empty"); - is(typeof grid.appendItem, "function", "appendItem is a function on the grid"); - - let arrangeStub = stubMethod(grid, "arrangeItems"); - let newItem = grid.appendItem("test title", "about:blank"); - - ok(newItem && grid.children[0]==newItem, "appendItem gives back the item"); - is(grid.itemCount, 1, "itemCount is incremented when we appendItem"); - is(newItem.getAttribute("label"), "test title", "title ends up on label attribute"); - is(newItem.getAttribute("value"), "about:blank", "url ends up on value attribute"); - - is(arrangeStub.callCount, 1, "arrangeItems is called when we appendItem"); - arrangeStub.restore(); - } -}); - -gTests.push({ - desc: "getItemAtIndex", - run: function() { - // implements a getItemAtIndex method - let grid = doc.querySelector("#grid2"); - is(typeof grid.getItemAtIndex, "function", "getItemAtIndex is a function on the grid"); - is(grid.getItemAtIndex(0).getAttribute("id"), "grid2_item1", "getItemAtIndex retrieves the first item"); - is(grid.getItemAtIndex(1).getAttribute("id"), "grid2_item2", "getItemAtIndex item at index 2"); - ok(!grid.getItemAtIndex(5), "getItemAtIndex out-of-bounds index returns falsy"); - } -}); - -gTests.push({ - desc: "removeItemAt", - run: function() { - // implements a removeItemAt method, with 'index' signature - // removeItemAt triggers arrangeItems - let grid = doc.querySelector("#grid2"); - - is(grid.itemCount, 2, "2 items initially"); - is(typeof grid.removeItemAt, "function", "removeItemAt is a function on the grid"); - - let arrangeStub = stubMethod(grid, "arrangeItems"); - let removedItem = grid.removeItemAt(0); - - ok(removedItem, "removeItemAt gives back an item"); - is(removedItem.getAttribute("id"), "grid2_item1", "removeItemAt gives back the correct item"); - is(grid.children[0].getAttribute("id"), "grid2_item2", "2nd item becomes the first item"); - is(grid.itemCount, 1, "itemCount is decremented when we removeItemAt"); - - is(arrangeStub.callCount, 1, "arrangeItems is called when we removeItemAt"); - arrangeStub.restore(); - } -}); - -gTests.push({ - desc: "insertItemAt", - run: function() { - // implements an insertItemAt method, with index, title, uri.spec signature - // insertItemAt triggers arrangeItems - let grid = doc.querySelector("#grid3"); - - is(grid.itemCount, 2, "2 items initially"); - is(typeof grid.insertItemAt, "function", "insertItemAt is a function on the grid"); - - let arrangeStub = stubMethod(grid, "arrangeItems"); - let insertedItem = grid.insertItemAt(1, "inserted item", "http://example.com/inserted"); - - ok(insertedItem, "insertItemAt gives back an item"); - is(grid.children[1], insertedItem, "item is inserted at the correct index"); - is(insertedItem.getAttribute("label"), "inserted item", "insertItemAt creates item with the correct label"); - is(insertedItem.getAttribute("value"), "http://example.com/inserted", "insertItemAt creates item with the correct url value"); - is(grid.children[2].getAttribute("id"), "grid3_item2", "following item ends up at the correct index"); - is(grid.itemCount, 3, "itemCount is incremented when we insertItemAt"); - - is(arrangeStub.callCount, 1, "arrangeItems is called when we insertItemAt"); - arrangeStub.restore(); - } -}); - -gTests.push({ - desc: "getIndexOfItem", - run: function() { - // implements a getIndexOfItem method, with item (element) signature - // insertItemAt triggers arrangeItems - let grid = doc.querySelector("#grid4"); - - is(grid.itemCount, 2, "2 items initially"); - is(typeof grid.getIndexOfItem, "function", "getIndexOfItem is a function on the grid"); - - let item = doc.getElementById("grid4_item2"); - let badItem = doc.createElement("richgriditem"); - - is(grid.getIndexOfItem(item), 1, "getIndexOfItem returns the correct value for an item"); - is(grid.getIndexOfItem(badItem), -1, "getIndexOfItem returns -1 for items it doesn't contain"); - } -}); - -gTests.push({ - desc: "getItemsByUrl", - run: function() { - let grid = doc.querySelector("#grid5"); - - is(grid.itemCount, 4, "4 items total"); - is(typeof grid.getItemsByUrl, "function", "getItemsByUrl is a function on the grid"); - - ['about:blank', 'http://bugzilla.mozilla.org/'].forEach(function(testUrl) { - let items = grid.getItemsByUrl(testUrl); - is(items.length, 2, "2 matching items in the test grid"); - is(items.item(0).url, testUrl, "Matched item has correct url property"); - is(items.item(1).url, testUrl, "Matched item has correct url property"); - }); - - let badUrl = 'http://gopher.well.com:70/'; - let items = grid.getItemsByUrl(badUrl); - is(items.length, 0, "0 items matched url: "+badUrl); - - } -}); - -gTests.push({ - desc: "removeItem", - run: function() { - let grid = doc.querySelector("#grid5"); - - is(grid.itemCount, 4, "4 items total"); - is(typeof grid.removeItem, "function", "removeItem is a function on the grid"); - - let arrangeStub = stubMethod(grid, "arrangeItems"); - let removedFirst = grid.removeItem( grid.children[0] ); - - is(arrangeStub.callCount, 1, "arrangeItems is called when we removeItem"); - - let removed2nd = grid.removeItem( grid.children[0], true); - is(removed2nd.getAttribute("label"), "2nd item", "the next item was returned"); - is(grid.itemCount, 2, "2 items remain"); - - // callCount should still be at 1 - is(arrangeStub.callCount, 1, "arrangeItems is not called when we pass the truthy skipArrange param"); - - let otherItem = grid.ownerDocument.querySelector("#grid6_item1"); - let removedFail = grid.removeItem(otherItem); - ok(!removedFail, "Falsy value returned when non-child item passed"); - is(grid.itemCount, 2, "2 items remain"); - - // callCount should still be at 1 - is(arrangeStub.callCount, 1, "arrangeItems is not called when nothing is matched"); - - arrangeStub.restore(); - } -}); - -gTests.push({ - desc: "selections (single)", - run: function() { - // when seltype is single, - // maintains a selectedItem property - // maintains a selectedIndex property - // clearSelection, selectItem, toggleItemSelection methods are implemented - // 'select' events are implemented - let grid = doc.querySelector("#grid-select1"); - - is(typeof grid.clearSelection, "function", "clearSelection is a function on the grid"); - is(typeof grid.selectedItems, "object", "selectedItems is a property on the grid"); - is(typeof grid.toggleItemSelection, "function", "toggleItemSelection is function on the grid"); - is(typeof grid.selectItem, "function", "selectItem is a function on the grid"); - - is(grid.itemCount, 2, "2 items initially"); - is(grid.selectedItems.length, 0, "nothing selected initially"); - - grid.toggleItemSelection(grid.children[1]); - ok(grid.children[1].selected, "toggleItemSelection sets truthy selected prop on previously-unselected item"); - is(grid.selectedIndex, 1, "selectedIndex is correct"); - - grid.toggleItemSelection(grid.children[1]); - ok(!grid.children[1].selected, "toggleItemSelection sets falsy selected prop on previously-selected item"); - is(grid.selectedIndex, -1, "selectedIndex reports correctly with nothing selected"); - - // item selection - grid.selectItem(grid.children[1]); - ok(grid.children[1].selected, "Item selected property is truthy after grid.selectItem"); - ok(grid.children[1].getAttribute("selected"), "Item selected attribute is truthy after grid.selectItem"); - ok(grid.selectedItems.length, "There are selectedItems after grid.selectItem"); - - // clearSelection - grid.selectItem(grid.children[0]); - grid.selectItem(grid.children[1]); - grid.clearSelection(); - is(grid.selectedItems.length, 0, "Nothing selected when we clearSelection"); - is(grid.selectedIndex, -1, "selectedIndex resets after clearSelection"); - - // select events - // in seltype=single mode, select is like the default action for the tile - // (think , not not ) - let handler = { - handleEvent: function(aEvent) {} - }; - let handlerStub = stubMethod(handler, "handleEvent"); - doc.defaultView.addEventListener("selectionchange", handler, false); - info("selectionchange listener added"); - - info("calling toggleItemSelection, currently it is:" + grid.children[0].selected); - // Note: A richgrid in seltype=single mode fires "select" events from selectItem - grid.toggleItemSelection(grid.children[0]); - info("/calling toggleItemSelection, now it is:" + grid.children[0].selected); - yield waitForMs(0); - - is(handlerStub.callCount, 1, "selectionchange event handler was called when we selected an item"); - is(handlerStub.calledWith[0].type, "selectionchange", "handler got a selectionchange event"); - is(handlerStub.calledWith[0].target, grid, "select event had the originating grid as the target"); - handlerStub.restore(); - doc.defaultView.removeEventListener("selectionchange", handler, false); - } -}); - - // implements a getItemAtIndex method (or grid.children[idx] ?) - +let doc; + +function test() { + waitForExplicitFinish(); + Task.spawn(function(){ + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + info(chromeRoot + "browser_tilegrid.xul"); + yield addTab(chromeRoot + "browser_tilegrid.xul"); + doc = Browser.selectedTab.browser.contentWindow.document; + }).then(runTests); +} + +gTests.push({ + desc: "richgrid binding is applied", + run: function() { + ok(doc, "doc got defined"); + + let grid = doc.querySelector("#grid1"); + ok(grid, "#grid1 is found"); + is(typeof grid.clearSelection, "function", "#grid1 has the binding applied"); + + is(grid.children.length, 1, "#grid1 has a single item"); + is(grid.children[0].control, grid, "#grid1 item's control points back at #grid1'"); + } +}); + +gTests.push({ + desc: "item clicks are handled", + run: function() { + let grid = doc.querySelector("#grid1"); + is(typeof grid.handleItemClick, "function", "grid.handleItemClick is a function"); + let handleStub = stubMethod(grid, 'handleItemClick'); + let itemId = "grid1_item1"; // grid.children[0].getAttribute("id"); + + // send click to item and wait for next tick; + EventUtils.sendMouseEvent({type: 'click'}, itemId, doc.defaultView); + yield waitForMs(0); + + is(handleStub.callCount, 1, "handleItemClick was called when we clicked an item"); + handleStub.restore(); + + // if the grid has a controller, it should be called too + let gridController = { + handleItemClick: function() {} + }; + let controllerHandleStub = stubMethod(gridController, "handleItemClick"); + let origController = grid.controller; + grid.controller = gridController; + + // send click to item and wait for next tick; + EventUtils.sendMouseEvent({type: 'click'}, itemId, doc.defaultView); + yield waitForMs(0); + + is(controllerHandleStub.callCount, 1, "controller.handleItemClick was called when we clicked an item"); + is(controllerHandleStub.calledWith[0], doc.getElementById(itemId), "controller.handleItemClick was passed the grid item"); + grid.controller = origController; + } +}); + +gTests.push({ + desc: "arrangeItems", + run: function() { + // implements an arrangeItems method, with optional cols, rows signature + let grid = doc.querySelector("#grid1"); + is(typeof grid.arrangeItems, "function", "arrangeItems is a function on the grid"); + todo(false, "Test outcome of arrangeItems with cols and rows arguments"); + } +}); + +gTests.push({ + desc: "appendItem", + run: function() { + // implements an appendItem with signature title, uri, returns item element + // appendItem triggers arrangeItems + let grid = doc.querySelector("#emptygrid"); + + is(grid.itemCount, 0, "0 itemCount when empty"); + is(grid.children.length, 0, "0 children when empty"); + is(typeof grid.appendItem, "function", "appendItem is a function on the grid"); + + let arrangeStub = stubMethod(grid, "arrangeItems"); + let newItem = grid.appendItem("test title", "about:blank"); + + ok(newItem && grid.children[0]==newItem, "appendItem gives back the item"); + is(grid.itemCount, 1, "itemCount is incremented when we appendItem"); + is(newItem.getAttribute("label"), "test title", "title ends up on label attribute"); + is(newItem.getAttribute("value"), "about:blank", "url ends up on value attribute"); + + is(arrangeStub.callCount, 1, "arrangeItems is called when we appendItem"); + arrangeStub.restore(); + } +}); + +gTests.push({ + desc: "getItemAtIndex", + run: function() { + // implements a getItemAtIndex method + let grid = doc.querySelector("#grid2"); + is(typeof grid.getItemAtIndex, "function", "getItemAtIndex is a function on the grid"); + is(grid.getItemAtIndex(0).getAttribute("id"), "grid2_item1", "getItemAtIndex retrieves the first item"); + is(grid.getItemAtIndex(1).getAttribute("id"), "grid2_item2", "getItemAtIndex item at index 2"); + ok(!grid.getItemAtIndex(5), "getItemAtIndex out-of-bounds index returns falsy"); + } +}); + +gTests.push({ + desc: "removeItemAt", + run: function() { + // implements a removeItemAt method, with 'index' signature + // removeItemAt triggers arrangeItems + let grid = doc.querySelector("#grid2"); + + is(grid.itemCount, 2, "2 items initially"); + is(typeof grid.removeItemAt, "function", "removeItemAt is a function on the grid"); + + let arrangeStub = stubMethod(grid, "arrangeItems"); + let removedItem = grid.removeItemAt(0); + + ok(removedItem, "removeItemAt gives back an item"); + is(removedItem.getAttribute("id"), "grid2_item1", "removeItemAt gives back the correct item"); + is(grid.children[0].getAttribute("id"), "grid2_item2", "2nd item becomes the first item"); + is(grid.itemCount, 1, "itemCount is decremented when we removeItemAt"); + + is(arrangeStub.callCount, 1, "arrangeItems is called when we removeItemAt"); + arrangeStub.restore(); + } +}); + +gTests.push({ + desc: "insertItemAt", + run: function() { + // implements an insertItemAt method, with index, title, uri.spec signature + // insertItemAt triggers arrangeItems + let grid = doc.querySelector("#grid3"); + + is(grid.itemCount, 2, "2 items initially"); + is(typeof grid.insertItemAt, "function", "insertItemAt is a function on the grid"); + + let arrangeStub = stubMethod(grid, "arrangeItems"); + let insertedItem = grid.insertItemAt(1, "inserted item", "http://example.com/inserted"); + + ok(insertedItem, "insertItemAt gives back an item"); + is(grid.children[1], insertedItem, "item is inserted at the correct index"); + is(insertedItem.getAttribute("label"), "inserted item", "insertItemAt creates item with the correct label"); + is(insertedItem.getAttribute("value"), "http://example.com/inserted", "insertItemAt creates item with the correct url value"); + is(grid.children[2].getAttribute("id"), "grid3_item2", "following item ends up at the correct index"); + is(grid.itemCount, 3, "itemCount is incremented when we insertItemAt"); + + is(arrangeStub.callCount, 1, "arrangeItems is called when we insertItemAt"); + arrangeStub.restore(); + } +}); + +gTests.push({ + desc: "getIndexOfItem", + run: function() { + // implements a getIndexOfItem method, with item (element) signature + // insertItemAt triggers arrangeItems + let grid = doc.querySelector("#grid4"); + + is(grid.itemCount, 2, "2 items initially"); + is(typeof grid.getIndexOfItem, "function", "getIndexOfItem is a function on the grid"); + + let item = doc.getElementById("grid4_item2"); + let badItem = doc.createElement("richgriditem"); + + is(grid.getIndexOfItem(item), 1, "getIndexOfItem returns the correct value for an item"); + is(grid.getIndexOfItem(badItem), -1, "getIndexOfItem returns -1 for items it doesn't contain"); + } +}); + +gTests.push({ + desc: "getItemsByUrl", + run: function() { + let grid = doc.querySelector("#grid5"); + + is(grid.itemCount, 4, "4 items total"); + is(typeof grid.getItemsByUrl, "function", "getItemsByUrl is a function on the grid"); + + ['about:blank', 'http://bugzilla.mozilla.org/'].forEach(function(testUrl) { + let items = grid.getItemsByUrl(testUrl); + is(items.length, 2, "2 matching items in the test grid"); + is(items.item(0).url, testUrl, "Matched item has correct url property"); + is(items.item(1).url, testUrl, "Matched item has correct url property"); + }); + + let badUrl = 'http://gopher.well.com:70/'; + let items = grid.getItemsByUrl(badUrl); + is(items.length, 0, "0 items matched url: "+badUrl); + + } +}); + +gTests.push({ + desc: "removeItem", + run: function() { + let grid = doc.querySelector("#grid5"); + + is(grid.itemCount, 4, "4 items total"); + is(typeof grid.removeItem, "function", "removeItem is a function on the grid"); + + let arrangeStub = stubMethod(grid, "arrangeItems"); + let removedFirst = grid.removeItem( grid.children[0] ); + + is(arrangeStub.callCount, 1, "arrangeItems is called when we removeItem"); + + let removed2nd = grid.removeItem( grid.children[0], true); + is(removed2nd.getAttribute("label"), "2nd item", "the next item was returned"); + is(grid.itemCount, 2, "2 items remain"); + + // callCount should still be at 1 + is(arrangeStub.callCount, 1, "arrangeItems is not called when we pass the truthy skipArrange param"); + + let otherItem = grid.ownerDocument.querySelector("#grid6_item1"); + let removedFail = grid.removeItem(otherItem); + ok(!removedFail, "Falsy value returned when non-child item passed"); + is(grid.itemCount, 2, "2 items remain"); + + // callCount should still be at 1 + is(arrangeStub.callCount, 1, "arrangeItems is not called when nothing is matched"); + + arrangeStub.restore(); + } +}); + +gTests.push({ + desc: "selections (single)", + run: function() { + // when seltype is single, + // maintains a selectedItem property + // maintains a selectedIndex property + // clearSelection, selectItem, toggleItemSelection methods are implemented + // 'select' events are implemented + let grid = doc.querySelector("#grid-select1"); + + is(typeof grid.clearSelection, "function", "clearSelection is a function on the grid"); + is(typeof grid.selectedItems, "object", "selectedItems is a property on the grid"); + is(typeof grid.toggleItemSelection, "function", "toggleItemSelection is function on the grid"); + is(typeof grid.selectItem, "function", "selectItem is a function on the grid"); + + is(grid.itemCount, 2, "2 items initially"); + is(grid.selectedItems.length, 0, "nothing selected initially"); + + grid.toggleItemSelection(grid.children[1]); + ok(grid.children[1].selected, "toggleItemSelection sets truthy selected prop on previously-unselected item"); + is(grid.selectedIndex, 1, "selectedIndex is correct"); + + grid.toggleItemSelection(grid.children[1]); + ok(!grid.children[1].selected, "toggleItemSelection sets falsy selected prop on previously-selected item"); + is(grid.selectedIndex, -1, "selectedIndex reports correctly with nothing selected"); + + // item selection + grid.selectItem(grid.children[1]); + ok(grid.children[1].selected, "Item selected property is truthy after grid.selectItem"); + ok(grid.children[1].getAttribute("selected"), "Item selected attribute is truthy after grid.selectItem"); + ok(grid.selectedItems.length, "There are selectedItems after grid.selectItem"); + + // clearSelection + grid.selectItem(grid.children[0]); + grid.selectItem(grid.children[1]); + grid.clearSelection(); + is(grid.selectedItems.length, 0, "Nothing selected when we clearSelection"); + is(grid.selectedIndex, -1, "selectedIndex resets after clearSelection"); + + // select events + // in seltype=single mode, select is like the default action for the tile + // (think , not not ) + let handler = { + handleEvent: function(aEvent) {} + }; + let handlerStub = stubMethod(handler, "handleEvent"); + doc.defaultView.addEventListener("selectionchange", handler, false); + info("selectionchange listener added"); + + info("calling toggleItemSelection, currently it is:" + grid.children[0].selected); + // Note: A richgrid in seltype=single mode fires "select" events from selectItem + grid.toggleItemSelection(grid.children[0]); + info("/calling toggleItemSelection, now it is:" + grid.children[0].selected); + yield waitForMs(0); + + is(handlerStub.callCount, 1, "selectionchange event handler was called when we selected an item"); + is(handlerStub.calledWith[0].type, "selectionchange", "handler got a selectionchange event"); + is(handlerStub.calledWith[0].target, grid, "select event had the originating grid as the target"); + handlerStub.restore(); + doc.defaultView.removeEventListener("selectionchange", handler, false); + } +}); + + // implements a getItemAtIndex method (or grid.children[idx] ?) + diff --git a/browser/metro/base/tests/mochitest/head.js b/browser/metro/base/tests/mochitest/head.js index b392b608b69e..d9091b883d42 100644 --- a/browser/metro/base/tests/mochitest/head.js +++ b/browser/metro/base/tests/mochitest/head.js @@ -756,24 +756,6 @@ function runTests() { }); } -// wrap a method with a spy that records how and how many times it gets called -// the spy is returned; use spy.restore() to put the original back -function spyOnMethod(aObj, aMethod) { - let origFunc = aObj[aMethod]; - let spy = function() { - spy.calledWith = Array.slice(arguments); - spy.callCount++; - return (spy.returnValue = origFunc.apply(aObj, arguments)); - }; - spy.callCount = 0; - spy.restore = function() { - return (aObj[aMethod] = origFunc); - }; - return (aObj[aMethod] = spy); -} - -// replace a method with a stub that records how and how many times it gets called -// the stub is returned; use stub.restore() to put the original back function stubMethod(aObj, aMethod) { let origFunc = aObj[aMethod]; let func = function() { diff --git a/browser/metro/theme/browser.css b/browser/metro/theme/browser.css index 4408aef20ca4..0c2e09a9a059 100644 --- a/browser/metro/theme/browser.css +++ b/browser/metro/theme/browser.css @@ -122,7 +122,7 @@ opacity: 0; transform: scale(0, 0); } - + 100% { opacity: 1; transform: scale(1, 1); @@ -168,7 +168,7 @@ documenttab[closing] > .documenttab-container { font-size: @metro_font_normal@; width: @thumbnail_width@; padding: 4px @metro_spacing_snormal@ 8px; - + background: #000; opacity: 0.95; color: #fff; @@ -223,7 +223,7 @@ documenttab[selected] .documenttab-selection { } .selection-overlay { - pointer-events: none; + pointer-events: none; } .selection-overlay:-moz-focusring { @@ -749,15 +749,13 @@ setting[type="radio"] > vbox { visibility: collapse; } -/* startUI sections, grids */ -#start-container .meta-section { - /* allot space for at least a single column */ - min-width: @grid_double_column_width@; +/*tile content should be on same line in snapped view */ +#snapped-topsites-grid > richgriditem > .richgrid-item-content { + -moz-box-orient: horizontal; } -#start-topsites { - /* allot space for 3 tile columns for the topsites grid */ - min-width: calc(3 * @grid_double_column_width@); +[viewstate="snapped"] .canSnapTiles .richgrid-item-desc { + -moz-margin-start: 8px; } /* if snapped, hide the fullscreen awesome screen, if viewstate is anything @@ -780,9 +778,9 @@ setting[type="radio"] > vbox { #start-container[viewstate="snapped"] .meta-section { margin: 0px; - min-width: @grid_double_column_width@; } + /* Browser Content Areas ----------------------------------------------------- */ /* Hide the browser while the start UI is visible */ diff --git a/browser/metro/theme/defines.inc b/browser/metro/theme/defines.inc index 871984be1eea..429cb1bfe8ea 100644 --- a/browser/metro/theme/defines.inc +++ b/browser/metro/theme/defines.inc @@ -29,16 +29,8 @@ %define thumbnail_width 232px %define thumbnail_height 148px -%define grid_column_width 131px -%define grid_double_column_width 262px -%define grid_row_height 86px -%define grid_double_row_height 172px - -%define compactgrid_column_width 62px -%define compactgrid_row_height 62px - %define tile_border_color #dbdcde -%define tile_spacing 12px +%define tile_width 200px %define scroller_thickness 4px %define scroller_minimum 8px diff --git a/browser/metro/theme/jar.mn b/browser/metro/theme/jar.mn index f5b879bda924..83d1a7cc4c3a 100644 --- a/browser/metro/theme/jar.mn +++ b/browser/metro/theme/jar.mn @@ -15,7 +15,6 @@ chrome.jar: skin/config.css (config.css) * skin/forms.css (forms.css) * skin/platform.css (platform.css) -* skin/tiles.css (tiles.css) skin/touchcontrols.css (touchcontrols.css) skin/netError.css (netError.css) % override chrome://global/skin/about.css chrome://browser/skin/about.css diff --git a/browser/metro/theme/platform.css b/browser/metro/theme/platform.css index bbf9bb6f5079..f30f84efc771 100644 --- a/browser/metro/theme/platform.css +++ b/browser/metro/theme/platform.css @@ -447,6 +447,148 @@ notification { } +/* Rich Grid ---------------------------------------------------------------- */ + +richgrid { + display: -moz-box; + -moz-box-sizing: border-box; +} + +richgrid .meta-grid { + display: block; +} + +richgriditem { + padding: @metro_spacing_small@; +} + +richgriditem .richgrid-item-content { + border: @metro_border_thin@ solid @tile_border_color@; + box-shadow: 0 0 @metro_spacing_snormal@ rgba(0, 0, 0, 0.1); + -moz-box-sizing: border-box; + padding: 10px 8px 6px 8px; + position: relative; +} +.richgrid-item-content { + background: #fff; +} + +richgriditem[selected] .richgrid-item-content::after { + content: ""; + pointer-events: none; + display: block; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-image: url(chrome://browser/skin/images/tile-selected-check-hdpi.png); + background-origin: border-box; + background-position: right 0 top 0; + background-repeat: no-repeat; + /* scale the image whatever the dppx */ + background-size: 35px 35px; + border: @metro_border_xthick@ solid @selected_color@; +} + +richgriditem[crosssliding] { + z-index: 1; +} + +/* ease the return to original position when cross-sliding */ +richgriditem:not([crosssliding]) { + transition: transform ease-out 0.2s; +} + +richgriditem .richgrid-icon-container { + padding-bottom: 2px; +} + +richgriditem .richgrid-icon-box { + padding: 4px; + background: #fff; + opacity: 1.0; +} + + +/* tile pinned-state indication */ +richgriditem[pinned] .richgrid-item-content::before { + pointer-events:none; + content: ""; + display: block; + position: absolute; + width: 35px; + height: 35px; + right: 0; + left: auto; + top: 0; + background-image: url(chrome://browser/skin/images/pinned-hdpi.png); + background-position: center; + background-repeat: no-repeat; + /* scale the image whatever the dppx */ + background-size: 70px 70px; +} + +/* Selected _and_ pinned tiles*/ +richgriditem[selected][pinned] .richgrid-item-content::before { + background-position: right -@metro_border_xthick@ top -@metro_border_xthick@; + width: 70px; + height: 70px; +} + +richgriditem[pinned]:-moz-locale-dir(rtl) .richgrid-item-content::before { + left: 0; + right: auto; +} + +richgriditem[customColor] { + color: #f1f1f1; +} +richgriditem[customImage] { + color: #1a1a1a; +} + + +richgriditem[customColor] .richgrid-icon-box { + opacity: 0.8; + background-color: #fff; +} + +.richgrid-item-content[customImage] { + height: 160px; + width: 250px; + background-size: cover; + background-position: center; + background-repeat: no-repeat; + -moz-box-pack: end; + padding: 0px; +} + +/* hide icon if there is an image background */ +.richgrid-icon-container[customImage] { + visibility: collapse; +} + +.richgrid-item-desc { + width: @tile_width@; + font-size: @metro_font_normal@; + margin-left: 0px; + padding-left: 0px !important; +} + +.richgrid-item-content[customImage] > .richgrid-item-desc { + background: hsla(0,2%,98%,.95); + /*margin-bottom: 0px; + margin-right: 0px;*/ + margin: 0px; +} + +richgriditem image { + width: 24px; + height: 24px; + list-style-image: url("chrome://browser/skin/images/identity-icons-generic.png"); +} + /* Dialogs ----------------------------------------------------------------- */ .modal-block, diff --git a/browser/metro/theme/tiles.css b/browser/metro/theme/tiles.css deleted file mode 100644 index d42c6c084b3b..000000000000 --- a/browser/metro/theme/tiles.css +++ /dev/null @@ -1,274 +0,0 @@ -/* 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/. */ - -/* Tile grid ------------------------------------------------------------- */ - -%filter substitution -%include defines.inc - -/* - ***************************************************** - The following rules define the key tile dimensions - They are (also) snarfed via the CSSOM as the dimensions used in the #richgrid binding - ***************************************************** - */ -richgriditem { - width: @grid_double_column_width@; - height: @grid_row_height@; -} -richgriditem[customImage] { - width: @grid_double_column_width@; - height: @grid_double_row_height@; -} -richgriditem[compact] { - width: auto; - height: @compactgrid_row_height@; -} - -/* - ***************************************************** - */ - -richgrid { - display: -moz-box; -} - -richgrid > .richgrid-grid { - -moz-column-width: @grid_double_column_width@; /* tile width (2x unit + gutter) */ - min-width: @grid_double_column_width@; /* min 1 column */ - min-height: @grid_double_row_height@; /* 2 rows (or 1 double rows) minimum; multiple of tile_height */ - -moz-column-fill: auto; /* do not attempt to balance content between columns */ - -moz-column-gap: 0; - -moz-column-count: auto; - display: block; - -moz-box-sizing: content-box; - overflow-x: hidden; /* clipping will only kick in if an explicit width is set */ - transition: 100ms transform ease-out; -} - -richgriditem { - display: block; - position: relative; - width: @grid_double_column_width@; - height: @grid_row_height@; - -moz-box-sizing: border-box; - -moz-column-gap: 0; - overflow:hidden; - cursor: default; - transition: 300ms height ease-out, - 150ms opacity ease-out, - 100ms transform ease-out; -} - -.tile-content { - display: block; - position: absolute; - background-color: #fff; - background-origin: padding-box; - /* content positioning within the grid "cell" - gives us the gutters/spacing between tiles */ - top: 2px; right: 6px; bottom: 10px; left: 6px; - border: @metro_border_thin@ solid @tile_border_color@; - box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1); - transition: 150ms transform ease-out; -} - -.tile-start-container { - position: absolute; - top: 0; - bottom: 0; - right: 0; - left: 20px; - background: hsla(0,2%,98%,.95); - padding: 8px; -} - -.tile-icon-box { - display: inline-block; - padding: 4px; - background: #fff; - opacity: 1.0; -} - -.tile-icon-box > image { - width: 24px; - height: 24px; - list-style-image: url("chrome://browser/skin/images/identity-icons-generic.png"); -} - -.tile-desc { - display: block; - position: absolute; - bottom: 0; - right: 0; - left: 20px; /* the colored bar in the default tile is the background color peeking through */ - z-index: 1; - padding: 4px 8px; - color: #333; - margin: 0; - -moz-margin-start: 0; - display: block; - font-size: 20px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; -} - -richgriditem.collapsed { - height: 0!important; - overflow: hidden; - opacity: 0; -} - -richgriditem.collapsed > .tile-content { - transform: scaleY(0); - transition: 150ms transform ease-out 150ms; -} - -richgriditem:active { - z-index: 2; -} - -/* thumbnail variation */ -richgriditem[customImage] { - width: @grid_double_column_width@; - height: @grid_double_row_height@; - -moz-box-pack: end; - padding: 0px; - color: #1a1a1a; -} - -richgriditem[customImage] .tile-desc { - background: transparent; - margin: 0px; - left: 0; -} - -richgriditem[customImage] > .tile-content > .tile-desc { - /* ensure thumbnail labels get their color from the parent richgriditem element */ - color: inherit; -} - -/* put the image in place of the icon if there is an image background */ -richgriditem[customImage] > .tile-content > .tile-start-container { - background-size: cover; - background-position: top left; - background-repeat: no-repeat; - position: absolute; - top: 0; - bottom: 32px; /* TODO: should be some em value? */; - right: 0; - left: 0; - background-color: hsla(0,2%,98%,.95); -} -richgriditem[customImage] .tile-icon-box { - visibility: collapse; -} - -/* selected tile indicator */ -richgriditem[selected] > .tile-content::after { - content: ""; - pointer-events: none; - display: block; - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1; - background-image: url(chrome://browser/skin/images/tile-selected-check-hdpi.png); - background-origin: border-box; - background-position: right 0 top 0; - background-repeat: no-repeat; - /* scale the image whatever the dppx */ - background-size: 35px 35px; - border: @metro_border_xthick@ solid @selected_color@; -} - -richgriditem[crosssliding] { - z-index: 10; -} - -/* ease the return to original position when cross-sliding */ -richgriditem:not([crosssliding]) { - transition: transform ease-out 0.2s; -} - - -/* tile pinned-state indication */ -richgriditem[pinned] > .tile-content::before { - pointer-events:none; - content: ""; - display: block; - position: absolute; - top: 0; - right: 0; - left: auto; - z-index: 1; - width: 35px; - height: 35px; - background-image: url(chrome://browser/skin/images/pinned-hdpi.png); - background-position: center; - background-repeat: no-repeat; - /* scale the image whatever the dppx */ - background-size: 70px 70px; -} - -/* Selected _and_ pinned tiles*/ -richgriditem[selected][pinned] > .tile-content::before { - background-position: right -@metro_border_xthick@ top -@metro_border_xthick@; - width: 70px; - height: 70px; -} - -richgriditem[pinned]:-moz-locale-dir(rtl) > .tile-content::before { - left: 0; - right: auto; -} - -richgriditem[customColor] { - color: #f1f1f1; -} - -/* Snapped-view variation - We use the compact, single-column grid treatment for <=320px */ - -@media (max-width: 330px) { - - richgrid > .richgrid-grid { - -moz-column-width: auto!important; /* let it flow */ - -moz-column-count: auto!important; /* let it flow */ - height: auto; /* let it flow */ - min-width: 280px; - transition: 100ms transform ease-out; - } - - richgriditem { - width: @grid_double_column_width@; - overflow: hidden; - height: @compactgrid_row_height@; - } - - .tile-desc { - top: 0; - left: 44px; /* label goes to the right of the favicon */ - right: 0; - padding: 8px; - } - - .tile-start-container { - position: absolute; - top: 0; - bottom: 0; - right: 0; - left: 6px; - background: #fff; - padding: 8px; - } - .tile-icon-box { - padding: 2px; - background: #fff; - opacity: 1.0; - } -} From b58fb25691308df4ba9ae94b57528b3e8a148014 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 25 Jun 2013 15:56:08 +0200 Subject: [PATCH 38/45] Bug 883126 - Improve performance of EXIDX unwinding in Breakpad. r=ted --- .../src/common/arm_ex_to_module.cc | 59 +++++-------- .../src/common/arm_ex_to_module.h | 7 +- .../google-breakpad/src/common/module.h | 82 +++++++++++++++++-- 3 files changed, 101 insertions(+), 47 deletions(-) diff --git a/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.cc b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.cc index 27bc51be27ff..f8535b7416cc 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.cc +++ b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.cc @@ -71,6 +71,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using google_breakpad::ustr__pc; using google_breakpad::ustr__lr; using google_breakpad::ustr__sp; +using google_breakpad::ustr__ZDra; +using google_breakpad::ustr__ZDcfa; using google_breakpad::Module; using google_breakpad::ToUniqueString; using google_breakpad::UniqueString; @@ -79,7 +81,8 @@ namespace arm_ex_to_module { // Translate command from extab_data to command for Module. int ARMExToModule::TranslateCmd(const struct extab_data* edata, - Module::StackFrameEntry* entry, string& vsp) { + Module::StackFrameEntry* entry, + Module::Expr& vsp) { int ret = 0; switch (edata->cmd) { case ARM_EXIDX_CMD_FINISH: @@ -88,44 +91,29 @@ int ARMExToModule::TranslateCmd(const struct extab_data* edata, == entry->initial_rules.end()) { if (entry->initial_rules.find(ustr__lr()) == entry->initial_rules.end()) { - entry->initial_rules[ustr__pc()] = Module::Expr("lr"); + entry->initial_rules[ustr__pc()] = Module::Expr(ustr__lr(), + 0, false); // "lr" } else { entry->initial_rules[ustr__pc()] = entry->initial_rules[ustr__lr()]; } } break; case ARM_EXIDX_CMD_SUB_FROM_VSP: - { - char c[16]; - sprintf(c, " %d -", edata->data); - vsp += c; - } + vsp = vsp.add_delta(- static_cast(edata->data)); break; case ARM_EXIDX_CMD_ADD_TO_VSP: - { - char c[16]; - sprintf(c, " %d +", edata->data); - vsp += c; - } + vsp = vsp.add_delta(static_cast(edata->data)); break; case ARM_EXIDX_CMD_REG_POP: for (unsigned int i = 0; i < 16; i++) { if (edata->data & (1 << i)) { - entry->initial_rules[ToUniqueString(regnames[i])] - = Module::Expr(vsp + " ^"); - vsp += " 4 +"; + entry->initial_rules[ToUniqueString(regnames[i])] = vsp.deref(); + vsp = vsp.add_delta(4); } } /* Set cfa in case the SP got popped. */ if (edata->data & (1 << 13)) { - Module::Expr& vsp_expr = entry->initial_rules[ustr__sp()]; - // It must be a postfix expression (we don't generate anything - // else here), so return -1 to fail out if it isn't. - if (!vsp_expr.isExprPostfix()) { - ret = -1; - break; - }; - vsp = vsp_expr.getExprPostfix(); + vsp = entry->initial_rules[ustr__sp()]; } break; case ARM_EXIDX_CMD_REG_TO_SP: { @@ -133,16 +121,12 @@ int ARMExToModule::TranslateCmd(const struct extab_data* edata, const char* const regname = regnames[edata->data]; const UniqueString* regname_us = ToUniqueString(regname); if (entry->initial_rules.find(regname_us) == entry->initial_rules.end()) { - entry->initial_rules[ustr__sp()] = Module::Expr(regname); + entry->initial_rules[ustr__sp()] = Module::Expr(regname_us, + 0, false); // "regname" } else { entry->initial_rules[ustr__sp()] = entry->initial_rules[regname_us]; } - Module::Expr& vsp_expr = entry->initial_rules[ustr__sp()]; - if (!vsp_expr.isExprPostfix()) { - ret = -1; - break; - }; - vsp = vsp_expr.getExprPostfix(); + vsp = entry->initial_rules[ustr__sp()]; break; } case ARM_EXIDX_CMD_VFP_POP: @@ -150,23 +134,23 @@ int ARMExToModule::TranslateCmd(const struct extab_data* edata, pointer. */ for (unsigned int i = ARM_EXBUF_START(edata->data); i <= ARM_EXBUF_END(edata->data); i++) { - vsp += " 8 +"; + vsp = vsp.add_delta(8); } if (!(edata->data & ARM_EXIDX_VFP_FSTMD)) { - vsp += " 4 +"; + vsp = vsp.add_delta(4); } break; case ARM_EXIDX_CMD_WREG_POP: for (unsigned int i = ARM_EXBUF_START(edata->data); i <= ARM_EXBUF_END(edata->data); i++) { - vsp += " 8 +"; + vsp = vsp.add_delta(8); } break; case ARM_EXIDX_CMD_WCGR_POP: // Pop wCGR registers under mask {wCGR3,2,1,0}, hence "i < 4" for (unsigned int i = 0; i < 4; i++) { if (edata->data & (1 << i)) { - vsp += " 4 +"; + vsp = vsp.add_delta(4); } } break; @@ -182,8 +166,9 @@ void ARMExToModule::AddStackFrame(uintptr_t addr, size_t size) { stack_frame_entry_ = new Module::StackFrameEntry; stack_frame_entry_->address = addr; stack_frame_entry_->size = size; - stack_frame_entry_->initial_rules[ToUniqueString(kCFA)] = Module::Expr("sp"); - vsp_ = "sp"; + Module::Expr sp_expr = Module::Expr(ustr__sp(), 0, false); // "sp" + stack_frame_entry_->initial_rules[ustr__ZDcfa()] = sp_expr; // ".cfa" + vsp_ = sp_expr; } int ARMExToModule::ImproveStackFrame(const struct extab_data* edata) { @@ -196,7 +181,7 @@ void ARMExToModule::DeleteStackFrame() { void ARMExToModule::SubmitStackFrame() { // return address always winds up in pc - stack_frame_entry_->initial_rules[ToUniqueString(kRA)] + stack_frame_entry_->initial_rules[ustr__ZDra()] // ".ra" = stack_frame_entry_->initial_rules[ustr__pc()]; // the final value of vsp is the new value of sp stack_frame_entry_->initial_rules[ustr__sp()] = vsp_; diff --git a/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.h b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.h index d35c693226e6..73c936c02a1d 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.h +++ b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.h @@ -94,9 +94,6 @@ enum extab_cmd_flags { ARM_EXIDX_VFP_FSTMD = 1 << 17, // distinguishes FSTMxxD from FSTMxxX }; -const string kRA = ".ra"; -const string kCFA = ".cfa"; - static const char* const regnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", @@ -118,10 +115,10 @@ class ARMExToModule { private: Module* module_; Module::StackFrameEntry* stack_frame_entry_; - string vsp_; + Module::Expr vsp_; int TranslateCmd(const struct extab_data* edata, Module::StackFrameEntry* entry, - string& vsp); + Module::Expr& vsp); }; } // namespace arm_ex_to_module diff --git a/toolkit/crashreporter/google-breakpad/src/common/module.h b/toolkit/crashreporter/google-breakpad/src/common/module.h index ef894f83397c..7f90388903bd 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/module.h +++ b/toolkit/crashreporter/google-breakpad/src/common/module.h @@ -44,6 +44,10 @@ #include #include +#include +#include +#include + #include "common/symbol_data.h" #include "common/using_std_string.h" #include "common/unique_string.h" @@ -166,12 +170,27 @@ class Module { how_ = kExprInvalid; } bool isExprInvalid() const { return how_ == kExprInvalid; } - bool isExprPostfix() const { return how_ == kExprPostfix; } - // Return the postfix expression string. This is only - // meaningful on Exprs for which isExprPostfix returns true. - // In all other cases it returns an empty string. - string getExprPostfix() const { return postfix_; } + // Return the postfix expression string, either directly, + // if this is a postfix expression, or by synthesising it + // for a simple expression. + string getExprPostfix() const { + switch (how_) { + case kExprPostfix: + return postfix_; + case kExprSimple: + case kExprSimpleMem: { + char buf[40]; + sprintf(buf, " %ld %c%s", labs(offset_), offset_ < 0 ? '-' : '+', + how_ == kExprSimple ? "" : " ^"); + return string(FromUniqueString(ident_)) + string(buf); + } + case kExprInvalid: + default: + assert(0 && "getExprPostfix: invalid Module::Expr type"); + return "Expr::genExprPostfix: kExprInvalid"; + } + } bool operator==(const Expr& other) const { return how_ == other.how_ && @@ -180,6 +199,59 @@ class Module { postfix_ == other.postfix_; } + // Returns an Expr which evaluates to |this| + |delta| + Expr add_delta(long delta) { + if (delta == 0) { + return *this; + } + // If it's a simple form expression of the form "identifier + offset", + // simply add |delta| on to |offset|. In the other two possible + // cases: + // *(identifier + offset) + // completely arbitrary postfix expression string + // the only option is to "downgrade" it to a postfix expression and add + // "+/- delta" at the end of the string, since the result can't be + // represented in the simple form. + switch (how_) { + case kExprSimpleMem: + case kExprPostfix: { + char buf[40]; + sprintf(buf, " %ld %c", labs(delta), delta < 0 ? '-' : '+'); + return Expr(getExprPostfix() + string(buf)); + } + case kExprSimple: + return Expr(ident_, offset_ + delta, false); + case kExprInvalid: + default: + assert(0 && "add_delta: invalid Module::Expr type"); + // Invalid inputs produce an invalid result + return Expr(); + } + } + + // Returns an Expr which evaluates to *|this| + Expr deref() { + // In the simplest case, a kExprSimple can be changed into a + // kExprSimpleMem. In all other cases it has to be dumped as a + // postfix string, and " ^" added at the end. + switch (how_) { + case kExprSimple: { + Expr t = *this; + t.how_ = kExprSimpleMem; + return t; + } + case kExprSimpleMem: + case kExprPostfix: { + return Expr(getExprPostfix() + " ^"); + } + case kExprInvalid: + default: + assert(0 && "deref: invalid Module::Expr type"); + // Invalid inputs produce an invalid result + return Expr(); + } + } + // The identifier that gives the starting value for simple expressions. const UniqueString* ident_; // The offset to add for simple expressions. From 4e98d6daaae764f208b1f8f203455f33360b4e2a Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Tue, 25 Jun 2013 10:04:31 -0400 Subject: [PATCH 39/45] bug 886300 fix intermittent orange in blocklist test, r=markh --- .../base/content/test/social/browser_addons.js | 9 ++++++++- .../content/test/social/browser_blocklist.js | 17 +++++++---------- browser/base/content/test/social/head.js | 4 +++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/browser/base/content/test/social/browser_addons.js b/browser/base/content/test/social/browser_addons.js index 0de78b4fa4d3..8f2965e4b168 100644 --- a/browser/base/content/test/social/browser_addons.js +++ b/browser/base/content/test/social/browser_addons.js @@ -48,6 +48,14 @@ function test() { function installListener(next, aManifest) { let expectEvent = "onInstalling"; let prefname = getManifestPrefname(aManifest); + // wait for the actual removal to call next + SocialService.registerProviderListener(function providerListener(topic, data) { + if (topic == "provider-removed") { + SocialService.unregisterProviderListener(providerListener); + executeSoon(next); + } + }); + return { onInstalling: function(addon) { is(expectEvent, "onInstalling", "install started"); @@ -73,7 +81,6 @@ function installListener(next, aManifest) { is(addon.manifest.origin, aManifest.origin, "provider uninstalled"); ok(!Services.prefs.prefHasUserValue(prefname), "manifest is not in user-prefs"); AddonManager.removeAddonListener(this); - next(); } }; } diff --git a/browser/base/content/test/social/browser_blocklist.js b/browser/base/content/test/social/browser_blocklist.js index 4ba51f701a95..d16effc484a7 100644 --- a/browser/base/content/test/social/browser_blocklist.js +++ b/browser/base/content/test/social/browser_blocklist.js @@ -55,17 +55,18 @@ var tests = { setAndUpdateBlocklist(blocklistURL, function() { try { SocialService.addProvider(manifest, function(provider) { - if (provider) { + try { SocialService.removeProvider(provider.origin, function() { ok(true, "added and removed provider"); finish(true); }); - } else { + } catch(e) { + ok(false, "SocialService.removeProvider threw exception: " + e); finish(false); } }); } catch(e) { - dump(e+" - "+e.stack+"\n"); + ok(false, "SocialService.addProvider threw exception: " + e); finish(false); } }); @@ -80,15 +81,11 @@ var tests = { setAndUpdateBlocklist(blocklistURL, function() { try { SocialService.addProvider(manifest_bad, function(provider) { - if (provider) { - SocialService.removeProvider(provider.origin, function() { - finish(false); - }); - } else { - finish(true); - } + ok(false, "SocialService.addProvider should throw blocklist exception"); + finish(false); }); } catch(e) { + ok(true, "SocialService.addProvider should throw blocklist exception"); finish(true); } }); diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js index 0089a06bc371..357bd9fcd8cf 100644 --- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -149,6 +149,7 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) { function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) { let testIter = Iterator(tests); let providersAtStart = Social.providers.length; + info("runSocialTests: start test run with " + providersAtStart + " providers"); if (cbPreTest === undefined) { cbPreTest = function(cb) {cb()}; @@ -164,6 +165,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) { } catch (err if err instanceof StopIteration) { // out of items: (cbFinish || defaultFinishChecks)(); + info("runSocialTests: finish test run with " + Social.providers.length + " providers"); return; } // We run on a timeout as the frameworker also makes use of timeouts, so @@ -174,7 +176,7 @@ function runSocialTests(tests, cbPreTest, cbPostTest, cbFinish) { cbPostTest(runNextTest); } cbPreTest(function() { - is(providersAtStart, Social.providers.length, "no new providers left enabled"); + is(providersAtStart, Social.providers.length, "pre-test: no new providers left enabled"); info("sub-test " + name + " starting"); try { func.call(tests, cleanupAndRunNextTest); From a498fdb818581d2d5f98cd10c5b297d7c4a4b511 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Tue, 25 Jun 2013 16:58:52 +0200 Subject: [PATCH 40/45] Bug 886266 - Fix issues with enabling/disabling non-active activations, r=jandem --- js/src/vm/Stack.cpp | 14 ++++++++++++++ js/src/vm/Stack.h | 4 +--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/js/src/vm/Stack.cpp b/js/src/vm/Stack.cpp index c1c5dbc3f56b..d664227f8902 100644 --- a/js/src/vm/Stack.cpp +++ b/js/src/vm/Stack.cpp @@ -1302,6 +1302,20 @@ js::CheckLocalUnaliased(MaybeCheckAliasing checkAliasing, JSScript *script, } #endif +void +Activation::setActive(bool active) +{ + // Only allowed to deactivate/activate if activation is top. + // (Not tested and will probably fail in other situations.) + JS_ASSERT(cx()->mainThread().activation_ == this); + JS_ASSERT(active != active_); + active_ = active; + + // Restore ionTop + if (!active && isJit()) + cx()->mainThread().ionTop = asJit()->prevIonTop(); +} + ion::JitActivation::JitActivation(JSContext *cx, bool firstFrameIsConstructing, bool active) : Activation(cx, Jit, active), prevIonTop_(cx->mainThread().ionTop), diff --git a/js/src/vm/Stack.h b/js/src/vm/Stack.h index abd97d21c4eb..698ebebe1302 100644 --- a/js/src/vm/Stack.h +++ b/js/src/vm/Stack.h @@ -1179,9 +1179,7 @@ class Activation bool isActive() const { return active_; } - void setActive(bool active = true) { - active_ = active; - } + void setActive(bool active = true); bool isInterpreter() const { return kind_ == Interpreter; From 1b2c65a70ebbe6a7e5e96219e5c3ce72274bd3ea Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Tue, 25 Jun 2013 08:00:03 -0700 Subject: [PATCH 41/45] Bug 885596: cast true and false to uint32_t when comparing them against uint32_t values, to silence MSVC build warning. r=dougt --- embedding/browser/webBrowser/nsWebBrowser.cpp | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp index 85a6bbe82184..8a88de84f4c6 100644 --- a/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -701,49 +701,63 @@ NS_IMETHODIMP nsWebBrowser::SetProperty(uint32_t aId, uint32_t aValue) case nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowPlugins(!!aValue); } break; case nsIWebBrowserSetup::SETUP_ALLOW_JAVASCRIPT: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowJavascript(!!aValue); } break; case nsIWebBrowserSetup::SETUP_ALLOW_META_REDIRECTS: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowMetaRedirects(!!aValue); } break; case nsIWebBrowserSetup::SETUP_ALLOW_SUBFRAMES: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowSubframes(!!aValue); } break; case nsIWebBrowserSetup::SETUP_ALLOW_IMAGES: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowImages(!!aValue); } break; case nsIWebBrowserSetup::SETUP_ALLOW_DNS_PREFETCH: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); mDocShell->SetAllowDNSPrefetch(!!aValue); } break; case nsIWebBrowserSetup::SETUP_USE_GLOBAL_HISTORY: { NS_ENSURE_STATE(mDocShell); - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); rv = EnableGlobalHistory(!!aValue); mShouldEnableHistory = aValue; } @@ -755,7 +769,9 @@ NS_IMETHODIMP nsWebBrowser::SetProperty(uint32_t aId, uint32_t aValue) break; case nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER: { - NS_ENSURE_TRUE((aValue == true || aValue == false), NS_ERROR_INVALID_ARG); + NS_ENSURE_TRUE((aValue == static_cast(true) || + aValue == static_cast(false)), + NS_ERROR_INVALID_ARG); SetItemType(aValue ? static_cast(typeChromeWrapper) : static_cast(typeContentWrapper)); } From 9492393f9269eec165f1d91786f7885f15d3dbcb Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 25 Jun 2013 08:42:39 -0700 Subject: [PATCH 42/45] Bug 883657, part 1 - Run mozJSComponentLoader::UnloadModules() before the shutdown CC. r=bsmedberg --- xpcom/build/nsXPComInit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index a4e378540b13..41c5ec0d31d2 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -648,8 +648,6 @@ ShutdownXPCOM(nsIServiceManager* servMgr) // Release the directory service NS_IF_RELEASE(nsDirectoryService::gService); - nsCycleCollector_shutdown(); - if (moduleLoaders) { bool more; nsCOMPtr el; @@ -675,6 +673,8 @@ ShutdownXPCOM(nsIServiceManager* servMgr) moduleLoaders = nullptr; } + nsCycleCollector_shutdown(); + PROFILER_MARKER("Shutdown xpcom"); // If we are doing any shutdown checks, poison writes. if (gShutdownChecks != SCM_NOTHING) { From ddcec6be65fda60062cffc043ac55410e7997922 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 25 Jun 2013 08:42:40 -0700 Subject: [PATCH 43/45] Bug 883657, part 2 - Don't force a GC in mozJSComponentLoader::UnloadModules. r=bholley --- js/xpconnect/loader/mozJSComponentLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 70875cf060fd..75c4d4565ec7 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -1144,8 +1144,7 @@ mozJSComponentLoader::UnloadModules() mModules.Enumerate(ClearModules, NULL); - // Destroying our context will force a GC. - JS_DestroyContext(mContext); + JS_DestroyContextNoGC(mContext); mContext = nullptr; mRuntimeService = nullptr; From dc3478faeae731a9b2fe0a478c7b6c81cd602e76 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Tue, 25 Jun 2013 11:57:30 -0400 Subject: [PATCH 44/45] Bug 886423 - Turn on the click-to-play UI by default in Firefox desktop. As a side effect, remove the plugin permission from about:permissions because we're using per-plugin permission not per-site and about:permissions doesn't know about that. (page info knows about it) r=keeler --- browser/app/profile/firefox.js | 2 +- .../preferences/aboutPermissions.js | 26 +++---------------- .../preferences/aboutPermissions.xul | 21 --------------- .../preferences/tests/browser_permissions.js | 3 +-- .../extensions/test/xpcshell/test_plugins.js | 2 +- 5 files changed, 6 insertions(+), 48 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index d40ae7a2bee4..6d8ddf2cacaa 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -632,7 +632,7 @@ pref("plugins.hide_infobar_for_outdated_plugin", false); pref("plugins.update.url", "https://www.mozilla.org/%LOCALE%/plugincheck/"); pref("plugins.update.notifyUser", false); -pref("plugins.click_to_play", false); +pref("plugins.click_to_play", true); // display door hanger if flash not installed pref("plugins.notifyMissingFlash", true); diff --git a/browser/components/preferences/aboutPermissions.js b/browser/components/preferences/aboutPermissions.js index d45178319094..86fc3224fdd4 100644 --- a/browser/components/preferences/aboutPermissions.js +++ b/browser/components/preferences/aboutPermissions.js @@ -321,17 +321,6 @@ let PermissionDefaults = { Services.prefs.setBoolPref("dom.disable_open_during_load", value); }, - get plugins() { - if (Services.prefs.getBoolPref("plugins.click_to_play")) { - return this.UNKNOWN; - } - return this.ALLOW; - }, - set plugins(aValue) { - let value = (aValue != this.ALLOW); - Services.prefs.setBoolPref("plugins.click_to_play", value); - }, - get fullscreen() { if (!Services.prefs.getBoolPref("full-screen-api.enabled")) { return this.DENY; @@ -380,7 +369,7 @@ let AboutPermissions = { * * Potential future additions: "sts/use", "sts/subd" */ - _supportedPermissions: ["password", "cookie", "geo", "indexedDB", "popup", "plugins", "fullscreen"], + _supportedPermissions: ["password", "cookie", "geo", "indexedDB", "popup", "fullscreen"], /** * Permissions that don't have a global "Allow" option. @@ -390,7 +379,7 @@ let AboutPermissions = { /** * Permissions that don't have a global "Deny" option. */ - _noGlobalDeny: ["plugins"], + _noGlobalDeny: [], _stringBundle: Services.strings. createBundle("chrome://browser/locale/preferences/aboutPermissions.properties"), @@ -412,7 +401,6 @@ let AboutPermissions = { Services.prefs.addObserver("geo.enabled", this, false); Services.prefs.addObserver("dom.indexedDB.enabled", this, false); Services.prefs.addObserver("dom.disable_open_during_load", this, false); - Services.prefs.addObserver("plugins.click_to_play", this, false); Services.prefs.addObserver("full-screen-api.enabled", this, false); Services.obs.addObserver(this, "perm-changed", false); @@ -434,7 +422,6 @@ let AboutPermissions = { Services.prefs.removeObserver("geo.enabled", this, false); Services.prefs.removeObserver("dom.indexedDB.enabled", this, false); Services.prefs.removeObserver("dom.disable_open_during_load", this, false); - Services.prefs.removeObserver("plugins.click_to_play", this, false); Services.prefs.removeObserver("full-screen-api.enabled", this, false); Services.obs.removeObserver(this, "perm-changed"); @@ -758,18 +745,11 @@ let AboutPermissions = { if (!this._selectedSite) { // If there is no selected site, we are updating the default permissions interface. permissionValue = PermissionDefaults[aType]; - if (aType == "plugins") - document.getElementById("plugins-pref-item").hidden = false; - else if (aType == "cookie") + if (aType == "cookie") // cookie-9 corresponds to ALLOW_FIRST_PARTY_ONLY, which is reserved // for site-specific preferences only. document.getElementById("cookie-9").hidden = true; } else { - if (aType == "plugins") { - document.getElementById("plugins-pref-item").hidden = - !Services.prefs.getBoolPref("plugins.click_to_play"); - return; - } if (aType == "cookie") document.getElementById("cookie-9").hidden = false; let result = {}; diff --git a/browser/components/preferences/aboutPermissions.xul b/browser/components/preferences/aboutPermissions.xul index e7ced9684cec..95f3e9dfc44f 100644 --- a/browser/components/preferences/aboutPermissions.xul +++ b/browser/components/preferences/aboutPermissions.xul @@ -191,27 +191,6 @@
- - - - - - - diff --git a/browser/components/preferences/tests/browser_permissions.js b/browser/components/preferences/tests/browser_permissions.js index ad978eb77c0f..11a23ef6468d 100644 --- a/browser/components/preferences/tests/browser_permissions.js +++ b/browser/components/preferences/tests/browser_permissions.js @@ -26,7 +26,6 @@ const TEST_PERMS = { "geo": PERM_UNKNOWN, "indexedDB": PERM_UNKNOWN, "popup": PERM_DENY, - "plugins" : PERM_ALLOW, "fullscreen" : PERM_UNKNOWN, }; @@ -37,7 +36,7 @@ const NO_GLOBAL_ALLOW = [ ]; // number of managed permissions in the interface -const TEST_PERMS_COUNT = 7; +const TEST_PERMS_COUNT = 6; function test() { waitForExplicitFinish(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js index 30072242c4e3..0a131b4f5e92 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js @@ -91,7 +91,7 @@ function run_test_1() { do_check_true(p.isCompatible); do_check_true(p.providesUpdatesSecurely); do_check_eq(p.blocklistState, 0); - do_check_eq(p.permissions, AddonManager.PERM_CAN_DISABLE); + do_check_eq(p.permissions, AddonManager.PERM_CAN_DISABLE | AddonManager.PERM_CAN_ASK_TO_ACTIVATE); do_check_eq(p.pendingOperations, 0); do_check_true(p.size > 0); do_check_eq(p.size, getFileSize(testPlugin)); From 67599314dd60eed87f6ef80f2d8d91f69acd1bbd Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Tue, 25 Jun 2013 11:57:36 -0400 Subject: [PATCH 45/45] Bug 886403 - Spelling errors from bug 880735, r=spelling --- browser/locales/en-US/chrome/browser/browser.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index 827b663e92eb..374987e70b44 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -113,7 +113,7 @@ crashedpluginsMessage.submitButton.accesskey=S crashedpluginsMessage.learnMore=Learn Moreā€¦ ## Plugin doorhanger strings -# LOCALIZATION NOTE (pluginActivateNw.message): Used for newly-installed +# LOCALIZATION NOTE (pluginActivateNew.message): Used for newly-installed # plugins which are not known to be unsafe. %1$S is the plugin name and %2$S # is the site domain. pluginActivateNew.message=Allow %2$S to run "%1$S"? @@ -160,7 +160,7 @@ pluginContinue.accesskey=C # in-page UI PluginClickToActivate=Activate %S. -PluginVulnerableUpdatable=Thus plugin is vulnerable and should be updated. +PluginVulnerableUpdatable=This plugin is vulnerable and should be updated. PluginVulnerableNoUpdate=This plugin has security vulnerabilities. # Sanitize