Browse Source

import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1143130 - Initialize nsIFrame::ContentOffsets members, and some additional cleanup. r=roc (334109d125)
- Bug 1185436 - Mark DumpFrameTree() and DumpFrameTreeLimited() const. r=roc (f444841ce7)
- Bug 1163328 - Tests for mozilla::Tuple. r=froydnj (9bdf4a67eb)
- Bug 1184385 - Add a Tie() utility function for tuples (the equivalent of std::tie()) to MFBT. r=froydnj (a683a079e7)
- Bug 1186315 - Fix TestTuple error and add it into testing list. r=nfroyd (8ea986d022)
- Bug 1185706 - support Tie() for mozilla::Pair. r=froydnj (2a74853496)
- Bug 1186126 - Note incompatibility with NSPR printf-like functions. r=nfroyd (eb3aa88cd3)
- Bug 1188895 - Replace U+0A00 with U+0200 in MacroForEach.h. r=Ms2ger (e63d0be26f)
- Bug 1182370 - _BitScan* does not modify *pIndex if input is zero. - r=waldo (3c1280da48)
- Bug 1193600 - Add Clamp and IsPowerOfTwo to MFBT. - r=waldo (7e5e321a74)
- Bug 1139036 - Bind all symbols from libmozglue.dylib when it is loaded. r=ted (c948da5c6d)
- bug 1198226 - Add HOST_{CFLAGS,CXXFLAGS,DEFINES} support to mozbuild frontend+recursive make backend. r=mshal (c5558cbf4c)
- bug 1198226 - Move HOST_{C,CXX}FLAGS to moz.build HOST_{CFLAGS,CXXFLAGS,DEFINES}. r=mshal (031909f24a)
- bug 1198226 - Add HOST_{C,CXX}FLAGS recursive make varible blacklist. r=mshal (c808385c2f)
- Bug 1204134 (attempt 2) - Fix and disallow warnings in config/moz.build. r=glandium. (e1a21ccade)
- code style (374f57dbea)
- Bug 1184284 - Remove txToRemove warning from nsSHistory::RemoveDuplicate. r=smaug (14f02229d5)
- Bug 1203379 - Fix indentation of gfxWordCacheTest.cpp. r=jrmuizel. (c04b07ce17)
- Bug 1203427 (part 1) - Add nsExpirationTracker::mName. r=froydnj. (974b39f117)
- Bug 1203427 (part 2) - Remove an argument to nsTimeout::InitTimer. r=mccr8. (f6f196c26c)
- Bug 1203809 - pass textperf obj into gfxFontGroup constructor. r=m_kato (1ea2f5cfd2)
- Bug 1203427 (part 3) - Change order of InitCommon() arguments. r=froydnj. (07e6c9b5ca)
- Bug 1203427 (part 4) - Remove trailing whitespace from nsITimer.idl. r=froydnj. (df4473f30a)
- Bug 1186112 - Get rid of the #define'd constants in BMPFileHeaders.h. r=tn (c18103f391)
master
roytam1 2 months ago
parent
commit
646c78a9d0
  1. 3
      build/unix/stdc++compat/Makefile.in
  2. 3
      build/unix/stdc++compat/moz.build
  3. 2
      config/Makefile.in
  4. 3
      config/config.mk
  5. 6
      config/moz.build
  6. 4
      config/pathsub.c
  7. 4
      config/pathsub.h
  8. 6
      configure.in
  9. 5
      docshell/shistory/src/nsSHEntry.cpp
  10. 6
      docshell/shistory/src/nsSHEntry.h
  11. 6
      docshell/shistory/src/nsSHEntryShared.cpp
  12. 2
      docshell/shistory/src/nsSHEntryShared.h
  13. 6
      docshell/shistory/src/nsSHTransaction.cpp
  14. 6
      docshell/shistory/src/nsSHTransaction.h
  15. 14
      docshell/shistory/src/nsSHistory.cpp
  16. 6
      docshell/shistory/src/nsSHistory.h
  17. 3
      dom/base/nsDocument.cpp
  18. 15
      dom/base/nsGlobalWindow.cpp
  19. 6
      dom/base/nsGlobalWindow.h
  20. 2
      dom/canvas/CanvasImageCache.cpp
  21. 10
      dom/canvas/CanvasRenderingContext2D.cpp
  22. 2
      gfx/layers/client/TiledContentClient.cpp
  23. 3
      gfx/src/nsFontMetrics.cpp
  24. 2
      gfx/tests/gtest/gfxFontSelectionTest.cpp
  25. 2
      gfx/tests/gtest/gfxTextRunPerfTest.cpp
  26. 184
      gfx/tests/gtest/gfxWordCacheTest.cpp
  27. 5
      gfx/thebes/gfxAndroidPlatform.cpp
  28. 5
      gfx/thebes/gfxAndroidPlatform.h
  29. 2
      gfx/thebes/gfxBlur.cpp
  30. 3
      gfx/thebes/gfxFont.cpp
  31. 2
      gfx/thebes/gfxFontconfigFonts.cpp
  32. 3
      gfx/thebes/gfxGradientCache.cpp
  33. 11
      gfx/thebes/gfxPlatform.h
  34. 7
      gfx/thebes/gfxPlatformGtk.cpp
  35. 8
      gfx/thebes/gfxPlatformGtk.h
  36. 3
      gfx/thebes/gfxPlatformMac.cpp
  37. 1
      gfx/thebes/gfxPlatformMac.h
  38. 1
      gfx/thebes/gfxQtPlatform.cpp
  39. 8
      gfx/thebes/gfxQtPlatform.h
  40. 7
      gfx/thebes/gfxTextRun.cpp
  41. 6
      gfx/thebes/gfxTextRun.h
  42. 3
      gfx/thebes/gfxWindowsPlatform.cpp
  43. 8
      gfx/thebes/gfxWindowsPlatform.h
  44. 140
      image/BMPFileHeaders.h
  45. 3
      image/SurfaceCache.cpp
  46. 209
      image/decoders/nsBMPDecoder.cpp
  47. 4
      image/decoders/nsBMPDecoder.h
  48. 2
      image/decoders/nsICODecoder.cpp
  49. 17
      image/encoders/bmp/nsBMPEncoder.cpp
  50. 11
      image/encoders/ico/nsICOEncoder.cpp
  51. 3
      image/imgLoader.cpp
  52. 4
      js/src/configure.in
  53. 4
      layout/base/ActiveLayerTracker.cpp
  54. 20
      layout/generic/nsFrame.cpp
  55. 4
      layout/generic/nsGfxScrollFrame.cpp
  56. 20
      layout/generic/nsIFrame.h
  57. 4
      layout/generic/nsTextFrame.cpp
  58. 3
      layout/style/RuleProcessorCache.h
  59. 6
      mfbt/IntegerPrintfMacros.h
  60. 2
      mfbt/MacroForEach.h
  61. 44
      mfbt/MathAlgorithms.h
  62. 147
      mfbt/Tuple.h
  63. 87
      mfbt/tests/TestMathAlgorithms.cpp
  64. 290
      mfbt/tests/TestTuple.cpp
  65. 2
      mfbt/tests/moz.build
  66. 23
      modules/libmar/tool/Makefile.in
  67. 10
      modules/libmar/tool/moz.build
  68. 10
      mozglue/build/moz.build
  69. 16
      mozglue/linker/Makefile.in
  70. 9
      mozglue/linker/moz.build
  71. 30
      other-licenses/bsdiff/Makefile.in
  72. 1
      other-licenses/bsdiff/moz.build
  73. 10
      python/mozbuild/mozbuild/backend/recursivemake.py
  74. 23
      python/mozbuild/mozbuild/frontend/context.py
  75. 11
      python/mozbuild/mozbuild/frontend/data.py
  76. 7
      python/mozbuild/mozbuild/frontend/emitter.py
  77. 14
      python/mozbuild/mozbuild/test/backend/data/host-defines/moz.build
  78. 2
      python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build
  79. 21
      python/mozbuild/mozbuild/test/backend/test_recursivemake.py
  80. 14
      python/mozbuild/mozbuild/test/frontend/data/host-defines/moz.build
  81. 2
      python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build
  82. 23
      python/mozbuild/mozbuild/test/frontend/test_emitter.py
  83. 1
      testing/cppunittest.ini
  84. 4
      xpcom/ds/nsExpirationTracker.h
  85. 2
      xpcom/tests/gtest/TestExpirationTracker.cpp
  86. 20
      xpcom/threads/nsITimer.idl
  87. 8
      xpcom/threads/nsTimerImpl.cpp
  88. 2
      xpcom/threads/nsTimerImpl.h

3
build/unix/stdc++compat/Makefile.in

@ -5,6 +5,3 @@
ENABLE_CLANG_PLUGIN :=
include $(topsrcdir)/config/rules.mk
CXXFLAGS += -DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_TARGET_VERSION)
HOST_CXXFLAGS += -DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_HOST_VERSION)

3
build/unix/stdc++compat/moz.build

@ -19,3 +19,6 @@ FORCE_STATIC_LIB = True
NO_PGO = True
DISABLE_STL_WRAPPING = True
DEFINES['MOZ_LIBSTDCXX_VERSION'] = CONFIG['MOZ_LIBSTDCXX_TARGET_VERSION']
HOST_DEFINES['MOZ_LIBSTDCXX_VERSION'] = CONFIG['MOZ_LIBSTDCXX_HOST_VERSION']

2
config/Makefile.in

@ -41,8 +41,6 @@ endif
include $(topsrcdir)/config/rules.mk
HOST_CFLAGS += -DUNICODE -D_UNICODE
ifndef JS_STANDALONE
ifndef MOZ_PROFILE_USE
# Generate a new buildid every time we "export" in config... that's only

3
config/config.mk

@ -447,6 +447,9 @@ ifndef CROSS_COMPILE
HOST_CFLAGS += $(RTL_FLAGS)
endif
HOST_CFLAGS += $(HOST_DEFINES) $(MOZBUILD_HOST_CFLAGS)
HOST_CXXFLAGS += $(HOST_DEFINES) $(MOZBUILD_HOST_CXXFLAGS)
#
# Name of the binary code directories
#

6
config/moz.build

@ -46,5 +46,7 @@ PYTHON_UNIT_TESTS += [
if CONFIG['GNU_CC'] and CONFIG['MOZ_OPTIMIZE']:
CFLAGS += ['-O3']
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
HOST_DEFINES = {
'UNICODE': True,
'_UNICODE': True,
}

4
config/pathsub.c

@ -34,7 +34,7 @@
char *program;
void
fail(char *format, ...)
fail(const char *format, ...)
{
int error;
va_list ap;
@ -143,7 +143,7 @@ xbasename(char *path)
}
void
xchdir(char *dir)
xchdir(const char *dir)
{
if (chdir(dir) < 0)
fail("cannot change directory to %s", dir);

4
config/pathsub.h

@ -25,13 +25,13 @@
extern char *program;
extern void fail(char *format, ...);
extern void fail(const char *format, ...);
extern char *getcomponent(char *path, char *name);
extern char *ino2name(ino_t ino);
extern void *xmalloc(size_t size);
extern char *xstrdup(char *s);
extern char *xbasename(char *path);
extern void xchdir(char *dir);
extern void xchdir(const char *dir);
/* Relate absolute pathnames from and to returning the result in outpath. */
extern int relatepaths(char *from, char *to, char *outpath);

6
configure.in

@ -1819,7 +1819,7 @@ case "$host" in
HOST_CFLAGS="$HOST_CFLAGS -mwindows"
fi
HOST_CFLAGS="$HOST_CFLAGS -DXP_WIN32 -DXP_WIN -DWIN32 -D_WIN32 -DNO_X11 -D_CRT_SECURE_NO_WARNINGS"
HOST_NSPR_MDCPUCFG='\"md/_winnt.cfg\"'
HOST_NSPR_MDCPUCFG='"md/_winnt.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O2}"
HOST_BIN_SUFFIX=.exe
case "$host" in
@ -1845,13 +1845,13 @@ case "$host" in
*-darwin*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX -DXP_MACOSX -DNO_X11"
HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
HOST_NSPR_MDCPUCFG='"md/_darwin.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
;;
*-linux*|*-kfreebsd*-gnu|*-gnu*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
HOST_NSPR_MDCPUCFG='"md/_linux.cfg"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
;;

5
docshell/shistory/src/nsSHEntry.cpp

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- 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/. */
@ -83,7 +84,7 @@ nsSHEntry::SetScrollPosition(int32_t aX, int32_t aY)
}
NS_IMETHODIMP
nsSHEntry::GetScrollPosition(int32_t *aX, int32_t *aY)
nsSHEntry::GetScrollPosition(int32_t* aX, int32_t* aY)
{
*aX = mScrollPositionX;
*aY = mScrollPositionY;

6
docshell/shistory/src/nsSHEntry.h

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */

6
docshell/shistory/src/nsSHEntryShared.cpp

@ -1,3 +1,5 @@
/* -*- 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/. */
@ -25,7 +27,7 @@ namespace {
uint64_t gSHEntrySharedID = 0;
} // anonymous namespace
} // namespace
#define CONTENT_VIEWER_TIMEOUT_SECONDS "browser.sessionhistory.contentViewerTimeout"
// Default this to time out unused content viewers after 30 minutes
@ -36,7 +38,7 @@ class HistoryTracker final : public HistoryTrackerBase
{
public:
explicit HistoryTracker(uint32_t aTimeout)
: HistoryTrackerBase(1000 * aTimeout / 2)
: HistoryTrackerBase(1000 * aTimeout / 2, "HistoryTracker")
{
}

2
docshell/shistory/src/nsSHEntryShared.h

@ -1,3 +1,5 @@
/* -*- 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/. */

6
docshell/shistory/src/nsSHTransaction.cpp

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */

6
docshell/shistory/src/nsSHTransaction.h

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */

14
docshell/shistory/src/nsSHistory.cpp

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */
@ -227,7 +227,7 @@ EvictContentViewerForTransaction(nsISHTransaction* aTrans)
}
}
} // anonymous namespace
} // namespace
nsSHistory::nsSHistory()
: mIndex(-1)
@ -1046,7 +1046,7 @@ public:
int32_t mDistance;
};
} // anonymous namespace
} // namespace
// static
void
@ -1315,7 +1315,9 @@ nsSHistory::RemoveDuplicate(int32_t aIndex, bool aKeepNext)
nsCOMPtr<nsISHTransaction> txToRemove, txToKeep, txNext, txPrev;
GetTransactionAtIndex(aIndex, getter_AddRefs(txToRemove));
GetTransactionAtIndex(compareIndex, getter_AddRefs(txToKeep));
NS_ENSURE_TRUE(txToRemove, false);
if (!txToRemove) {
return false;
}
NS_ENSURE_TRUE(txToKeep, false);
txToRemove->GetNext(getter_AddRefs(txNext));
txToRemove->GetPrev(getter_AddRefs(txPrev));

6
docshell/shistory/src/nsSHistory.h

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */

3
dom/base/nsDocument.cpp

@ -1413,7 +1413,8 @@ nsDOMStyleSheetSetList::EnsureFresh()
// ==================================================================
nsIDocument::SelectorCache::SelectorCache()
: nsExpirationTracker<SelectorCacheKey, 4>(1000) { }
: nsExpirationTracker<SelectorCacheKey, 4>(1000, "nsIDocument::SelectorCache")
{ }
// CacheList takes ownership of aSelectorList.
void nsIDocument::SelectorCache::CacheList(const nsAString& aSelector,

15
dom/base/nsGlobalWindow.cpp

@ -544,6 +544,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsTimeout, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsTimeout, Release)
nsresult
nsTimeout::InitTimer(uint32_t aDelay)
{
return mTimer->InitWithFuncCallback(nsGlobalWindow::TimerCallback, this,
aDelay, nsITimer::TYPE_ONE_SHOT);
}
// Return true if this timeout has a refcount of 1. This is used to check
// that dummy_timeout doesn't leak from nsGlobalWindow::RunTimeout.
bool
@ -12224,7 +12231,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
nsRefPtr<nsTimeout> copy = timeout;
rv = timeout->InitTimer(TimerCallback, realInterval);
rv = timeout->InitTimer(realInterval);
if (NS_FAILED(rv)) {
return rv;
}
@ -12473,7 +12480,7 @@ nsGlobalWindow::RescheduleTimeout(nsTimeout* aTimeout, const TimeStamp& now,
// Reschedule the OS timer. Don't bother returning any error codes if
// this fails since the callers of this method don't care about them.
nsresult rv = aTimeout->InitTimer(TimerCallback, delay.ToMilliseconds());
nsresult rv = aTimeout->InitTimer(delay.ToMilliseconds());
if (NS_FAILED(rv)) {
NS_ERROR("Error initializing timer for DOM timeout!");
@ -12770,7 +12777,7 @@ nsresult nsGlobalWindow::ResetTimersForNonBackgroundWindow()
timeout->mFiringDepth = firingDepth;
timeout->Release();
nsresult rv = timeout->InitTimer(TimerCallback, delay.ToMilliseconds());
nsresult rv = timeout->InitTimer(delay.ToMilliseconds());
if (NS_FAILED(rv)) {
NS_WARNING("Error resetting non background timer for DOM timeout!");
@ -13212,7 +13219,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
t->mTimer = do_CreateInstance("@mozilla.org/timer;1");
NS_ENSURE_TRUE(t->mTimer, NS_ERROR_OUT_OF_MEMORY);
rv = t->InitTimer(TimerCallback, delay);
rv = t->InitTimer(delay);
if (NS_FAILED(rv)) {
t->mTimer = nullptr;
return rv;

6
dom/base/nsGlobalWindow.h

@ -159,11 +159,7 @@ public:
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsTimeout)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsTimeout)
nsresult InitTimer(nsTimerCallbackFunc aFunc, uint32_t aDelay)
{
return mTimer->InitWithFuncCallback(aFunc, this, aDelay,
nsITimer::TYPE_ONE_SHOT);
}
nsresult InitTimer(uint32_t aDelay);
bool HasRefCntOne();

2
dom/canvas/CanvasImageCache.cpp

@ -216,7 +216,7 @@ public:
};
ImageCache::ImageCache()
: nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS)
: nsExpirationTracker<ImageCacheEntryData,4>(GENERATION_MS, "ImageCache")
, mTotal(0)
{
if (!sPrefsInitialized) {

10
dom/canvas/CanvasRenderingContext2D.cpp

@ -4006,16 +4006,16 @@ gfxFontGroup *CanvasRenderingContext2D::GetCurrentFontStyle()
if (err.Failed() || !fontUpdated) {
gfxFontStyle style;
style.size = kDefaultFontSize;
gfxTextPerfMetrics* tp = nullptr;
if (presShell && !presShell->IsDestroying()) {
tp = presShell->GetPresContext()->GetTextPerfMetrics();
}
CurrentState().fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(FontFamilyList(eFamily_sans_serif),
&style,
&style, tp,
nullptr);
if (CurrentState().fontGroup) {
CurrentState().font = kDefaultFontStyle;
if (presShell && !presShell->IsDestroying()) {
CurrentState().fontGroup->SetTextPerfMetrics(
presShell->GetPresContext()->GetTextPerfMetrics());
}
} else {
NS_ERROR("Default canvas font is invalid");
}

2
gfx/layers/client/TiledContentClient.cpp

@ -442,7 +442,7 @@ gfxShmSharedReadLock::GetReadCount() {
class TileExpiry final : public nsExpirationTracker<TileClient, 3>
{
public:
TileExpiry() : nsExpirationTracker<TileClient, 3>(1000) {}
TileExpiry() : nsExpirationTracker<TileClient, 3>(1000, "TileExpiry") {}
static void AddTile(TileClient* aTile)
{

3
gfx/src/nsFontMetrics.cpp

@ -151,8 +151,7 @@ nsFontMetrics::Init(const nsFont& aFont,
aFont.AddFontFeaturesToStyle(&style);
mFontGroup = gfxPlatform::GetPlatform()->
CreateFontGroup(aFont.fontlist, &style, aUserFontSet);
mFontGroup->SetTextPerfMetrics(aTextPerf);
CreateFontGroup(aFont.fontlist, &style, aTextPerf, aUserFontSet);
return NS_OK;
}

2
gfx/tests/gtest/gfxFontSelectionTest.cpp

@ -249,7 +249,7 @@ static bool
RunTest (TestEntry *test, gfxContext *ctx) {
nsRefPtr<gfxFontGroup> fontGroup;
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle, nullptr);
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->utf8FamilyString), &test->fontStyle, nullptr, nullptr);
nsAutoPtr<gfxTextRun> textRun;
gfxTextRunFactory::Parameters params = {

2
gfx/tests/gtest/gfxTextRunPerfTest.cpp

@ -63,7 +63,7 @@ RunTest (TestEntry *test, gfxContext *ctx) {
false, false,
NS_LITERAL_STRING(""));
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16, nullptr);
fontGroup = gfxPlatform::GetPlatform()->CreateFontGroup(NS_ConvertUTF8toUTF16(test->mFamilies), &style_western_normal_16, nullptr, nullptr);
}
nsAutoPtr<gfxTextRun> textRun;

184
gfx/tests/gtest/gfxWordCacheTest.cpp

@ -1,5 +1,6 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- 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/. */
@ -33,105 +34,110 @@ static FrameTextRunCache *gTextRuns = nullptr;
*/
class FrameTextRunCache final : public nsExpirationTracker<gfxTextRun,3> {
public:
enum { TIMEOUT_SECONDS = 10 };
FrameTextRunCache()
: nsExpirationTracker<gfxTextRun,3>(TIMEOUT_SECONDS*1000) {}
~FrameTextRunCache() {
AgeAllGenerations();
}
void RemoveFromCache(gfxTextRun* aTextRun) {
if (aTextRun->GetExpirationState()->IsTracked()) {
RemoveObject(aTextRun);
}
}
// This gets called when the timeout has expired on a gfxTextRun
virtual void NotifyExpired(gfxTextRun* aTextRun) {
RemoveFromCache(aTextRun);
delete aTextRun;
}
enum { TIMEOUT_SECONDS = 10 };
FrameTextRunCache()
: nsExpirationTracker<gfxTextRun,3>(TIMEOUT_SECONDS * 1000,
"FrameTextRunCache")
{}
~FrameTextRunCache() {
AgeAllGenerations();
}
void RemoveFromCache(gfxTextRun* aTextRun) {
if (aTextRun->GetExpirationState()->IsTracked()) {
RemoveObject(aTextRun);
}
}
// This gets called when the timeout has expired on a gfxTextRun
virtual void NotifyExpired(gfxTextRun* aTextRun) {
RemoveFromCache(aTextRun);
delete aTextRun;
}
};
static gfxTextRun *
MakeTextRun(const char16_t *aText, uint32_t aLength,
gfxFontGroup *aFontGroup, const gfxFontGroup::Parameters* aParams,
uint32_t aFlags)
MakeTextRun(const char16_t *aText, uint32_t aLength, gfxFontGroup *aFontGroup,
const gfxFontGroup::Parameters* aParams, uint32_t aFlags)
{
nsAutoPtr<gfxTextRun> textRun;
if (aLength == 0) {
abort();
//textRun = aFontGroup->MakeEmptyTextRun(aParams, aFlags);
} else if (aLength == 1 && aText[0] == ' ') {
abort();
//textRun = aFontGroup->MakeSpaceTextRun(aParams, aFlags);
} else {
textRun = aFontGroup->MakeTextRun(aText, aLength, aParams, aFlags);
}
if (!textRun)
return nullptr;
nsresult rv = gTextRuns->AddObject(textRun);
if (NS_FAILED(rv)) {
gTextRuns->RemoveFromCache(textRun);
return nullptr;
}
return textRun.forget();
nsAutoPtr<gfxTextRun> textRun;
if (aLength == 0) {
abort();
//textRun = aFontGroup->MakeEmptyTextRun(aParams, aFlags);
} else if (aLength == 1 && aText[0] == ' ') {
abort();
//textRun = aFontGroup->MakeSpaceTextRun(aParams, aFlags);
} else {
textRun = aFontGroup->MakeTextRun(aText, aLength, aParams, aFlags);
}
if (!textRun) {
return nullptr;
}
nsresult rv = gTextRuns->AddObject(textRun);
if (NS_FAILED(rv)) {
gTextRuns->RemoveFromCache(textRun);
return nullptr;
}
return textRun.forget();
}
static already_AddRefed<gfxContext>
MakeContext ()
{
const int size = 200;
const int size = 200;
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(size, size),
SurfaceFormat::B8G8R8X8);
nsRefPtr<gfxContext> ctx = new gfxContext(drawTarget);
RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
CreateOffscreenContentDrawTarget(IntSize(size, size),
SurfaceFormat::B8G8R8X8);
nsRefPtr<gfxContext> ctx = new gfxContext(drawTarget);
return ctx.forget();
return ctx.forget();
}
TEST(Gfx, WordCache) {
gTextRuns = new FrameTextRunCache();
nsRefPtr<gfxContext> ctx = MakeContext();
{
gfxFontStyle style (mozilla::gfx::FontStyle::NORMAL,
139,
10.0,
0,
NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
0.0,
false, false,
NS_LITERAL_STRING(""));
nsRefPtr<gfxFontGroup> fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style, nullptr);
gfxTextRunFactory::Parameters params = {
ctx, nullptr, nullptr, nullptr, 0, 60
};
uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;
// First load an Arabic word into the cache
const char cString[] = "\xd8\xaa\xd9\x85";
nsDependentCString cStr(cString);
NS_ConvertUTF8toUTF16 str(cStr);
gfxTextRun *tr = MakeTextRun(str.get(), str.Length(), fontGroup, &params, flags);
tr->GetAdvanceWidth(0, str.Length(), nullptr);
// Now try to trigger an assertion with a word cache bug. The first
// word is in the cache so it gets added to the new textrun directly.
// The second word is not in the cache
const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
nsDependentCString cStr2(cString2);
NS_ConvertUTF8toUTF16 str2(cStr2);
gfxTextRun *tr2 = MakeTextRun(str2.get(), str2.Length(), fontGroup, &params, flags);
tr2->GetAdvanceWidth(0, str2.Length(), nullptr);
}
delete gTextRuns;
gTextRuns = nullptr;
gTextRuns = new FrameTextRunCache();
nsRefPtr<gfxContext> ctx = MakeContext();
{
gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL,
139,
10.0,
0,
NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
0.0,
false, false,
NS_LITERAL_STRING(""));
nsRefPtr<gfxFontGroup> fontGroup =
gfxPlatform::GetPlatform()->CreateFontGroup(
NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style,
nullptr, nullptr);
gfxTextRunFactory::Parameters params = {
ctx, nullptr, nullptr, nullptr, 0, 60
};
uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;
// First load an Arabic word into the cache
const char cString[] = "\xd8\xaa\xd9\x85";
nsDependentCString cStr(cString);
NS_ConvertUTF8toUTF16 str(cStr);
gfxTextRun *tr =
MakeTextRun(str.get(), str.Length(), fontGroup, &params, flags);
tr->GetAdvanceWidth(0, str.Length(), nullptr);
// Now try to trigger an assertion with a word cache bug. The first
// word is in the cache so it gets added to the new textrun directly.
// The second word is not in the cache.
const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
nsDependentCString cStr2(cString2);
NS_ConvertUTF8toUTF16 str2(cStr2);
gfxTextRun *tr2 =
MakeTextRun(str2.get(), str2.Length(), fontGroup, &params, flags);
tr2->GetAdvanceWidth(0, str2.Length(), nullptr);
}
delete gTextRuns;
gTextRuns = nullptr;
}

5
gfx/thebes/gfxAndroidPlatform.cpp

@ -300,10 +300,11 @@ gfxAndroidPlatform::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlag
gfxFontGroup *
gfxAndroidPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
FT_Library

5
gfx/thebes/gfxAndroidPlatform.h

@ -69,10 +69,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
nsAString& aFamilyName);
virtual gfxFontGroup*
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet);
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
virtual bool FontHintingEnabled() override;
virtual bool RequiresLinearZoom() override;

2
gfx/thebes/gfxBlur.cpp

@ -249,7 +249,7 @@ class BlurCache final : public nsExpirationTracker<BlurCacheData,4>
{
public:
BlurCache()
: nsExpirationTracker<BlurCacheData, 4>(GENERATION_MS)
: nsExpirationTracker<BlurCacheData, 4>(GENERATION_MS, "BlurCache")
{
}

3
gfx/thebes/gfxFont.cpp

@ -165,7 +165,8 @@ gfxFontCache::Shutdown()
}
gfxFontCache::gfxFontCache()
: nsExpirationTracker<gfxFont,3>(FONT_TIMEOUT_SECONDS * 1000)
: nsExpirationTracker<gfxFont,3>(FONT_TIMEOUT_SECONDS * 1000,
"gfxFontCache")
{
nsCOMPtr<nsIObserverService> obs = GetObserverService();
if (obs) {

2
gfx/thebes/gfxFontconfigFonts.cpp

@ -1256,7 +1256,7 @@ PrepareSortPattern(FcPattern *aPattern, double aFallbackSize,
gfxPangoFontGroup::gfxPangoFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet)
: gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet),
: gfxFontGroup(aFontFamilyList, aStyle, nullptr, aUserFontSet),
mPangoLanguage(GuessPangoLanguage(aStyle->language))
{
// This language is passed to the font for shaping.

3
gfx/thebes/gfxGradientCache.cpp

@ -122,7 +122,8 @@ class GradientCache final : public nsExpirationTracker<GradientCacheData,4>
{
public:
GradientCache()
: nsExpirationTracker<GradientCacheData, 4>(MAX_GENERATION_MS)
: nsExpirationTracker<GradientCacheData,4>(MAX_GENERATION_MS,
"GradientCache")
{
srand(time(nullptr));
mTimerPeriod = rand() % MAX_GENERATION_MS + 1;

11
gfx/thebes/gfxPlatform.h

@ -37,6 +37,7 @@ class nsIURI;
class nsIAtom;
class nsIObserver;
class SRGBOverrideObserver;
class gfxTextPerfMetrics;
namespace mozilla {
namespace gl {
@ -367,11 +368,11 @@ public:
/**
* Create the appropriate platform font group
*/
virtual gfxFontGroup
*CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet) = 0;
virtual gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) = 0;
/**
* Look up a local platform font using the full font face name.

7
gfx/thebes/gfxPlatformGtk.cpp

@ -240,11 +240,12 @@ gfxPlatformGtk::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFa
gfxFontGroup *
gfxPlatformGtk::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet)
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
if (sUseFcFontList) {
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
return new gfxPangoFontGroup(aFontFamilyList, aStyle, aUserFontSet);

8
gfx/thebes/gfxPlatformGtk.h

@ -51,9 +51,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
nsAString& aFamilyName) override;
virtual gfxFontGroup* CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet) override;
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to

3
gfx/thebes/gfxPlatformMac.cpp

@ -138,9 +138,10 @@ gfxPlatformMac::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFa
gfxFontGroup *
gfxPlatformMac::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
// these will move to gfxPlatform once all platforms support the fontlist

1
gfx/thebes/gfxPlatformMac.h

@ -37,6 +37,7 @@ public:
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,

1
gfx/thebes/gfxQtPlatform.cpp

@ -122,6 +122,7 @@ gfxQtPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFam
gfxFontGroup *
gfxQtPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet)
{
return new gfxPangoFontGroup(aFontFamilyList, aStyle, aUserFontSet);

8
gfx/thebes/gfxQtPlatform.h

@ -41,9 +41,11 @@ public:
virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) override;
virtual gfxFontGroup *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet* aUserFontSet) override;
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to

7
gfx/thebes/gfxTextRun.cpp

@ -1528,13 +1528,14 @@ gfxTextRun::Dump(FILE* aOutput) {
gfxFontGroup::gfxFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
: mFamilyList(aFontFamilyList)
, mStyle(*aStyle)
, mUnderlineOffset(UNDERLINE_OFFSET_NOT_SET)
, mHyphenWidth(-1)
, mUserFontSet(aUserFontSet)
, mTextPerf(nullptr)
, mTextPerf(aTextPerf)
, mPageLang(gfxPlatform::GetFontPrefLangFor(aStyle->language))
, mSkipDrawing(false)
, mSkipUpdateUserFonts(false)
@ -1966,8 +1967,8 @@ gfxFontGroup::GetFirstMathFont()
gfxFontGroup *
gfxFontGroup::Copy(const gfxFontStyle *aStyle)
{
gfxFontGroup *fg = new gfxFontGroup(mFamilyList, aStyle, mUserFontSet);
fg->SetTextPerfMetrics(mTextPerf);
gfxFontGroup *fg =
new gfxFontGroup(mFamilyList, aStyle, mTextPerf, mUserFontSet);
return fg;
}

6
gfx/thebes/gfxTextRun.h

@ -732,8 +732,9 @@ public:
static void Shutdown(); // platform must call this to release the languageAtomService
gfxFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet = nullptr);
const gfxFontStyle* aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet* aUserFontSet = nullptr);
virtual ~gfxFontGroup();
@ -856,7 +857,6 @@ public:
// used when logging text performance
gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
void SetTextPerfMetrics(gfxTextPerfMetrics *aTextPerf) { mTextPerf = aTextPerf; }
// This will call UpdateUserFonts() if the user font set is changed.
void SetUserFontSet(gfxUserFontSet *aUserFontSet);

3
gfx/thebes/gfxWindowsPlatform.cpp

@ -1034,9 +1034,10 @@ gfxWindowsPlatform::GetStandardFamilyName(const nsAString& aFontName, nsAString&
gfxFontGroup *
gfxWindowsPlatform::CreateFontGroup(const FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet)
{
return new gfxFontGroup(aFontFamilyList, aStyle, aUserFontSet);
return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf, aUserFontSet);
}
gfxFontEntry*

8
gfx/thebes/gfxWindowsPlatform.h

@ -182,9 +182,11 @@ public:
nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
gfxFontGroup *CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxUserFontSet *aUserFontSet);
gfxFontGroup*
CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
const gfxFontStyle *aStyle,
gfxTextPerfMetrics* aTextPerf,
gfxUserFontSet *aUserFontSet) override;
/**
* Look up a local platform font using the full font face name (needed to support @font-face src local() )

140
image/BMPFileHeaders.h

@ -5,42 +5,53 @@
#ifndef mozilla_image_BMPFileHeaders_h
#define mozilla_image_BMPFileHeaders_h
#include <stddef.h>
#include <stdint.h>
namespace mozilla {
namespace image {
struct BMPFILEHEADER {
char signature[2]; // String "BM"
uint32_t filesize;
int32_t reserved; // Zero
uint32_t dataoffset; // Offset to raster data
uint32_t bihsize;
};
// The length of the bitmap file header as defined in the BMP spec.
#define BFH_LENGTH 14
// Internally we store the bitmap file header with an additional 4 bytes which
// is used to store the bitmap information header size.
#define BFH_INTERNAL_LENGTH 18
#define OS2_INTERNAL_BIH_LENGTH 8
#define WIN_V3_INTERNAL_BIH_LENGTH 36
#define WIN_V5_INTERNAL_BIH_LENGTH 120
#define OS2_BIH_LENGTH 12 // This is the real BIH size (as contained in the
// bihsize field of BMPFILEHEADER)
#define WIN_V3_BIH_LENGTH 40 // This is the real BIH size (as contained in the
// bihsize field of BMPFILEHEADER)
#define WIN_V5_BIH_LENGTH 124 // This is the real BIH size (as contained in the
// bihsize field of BMPFILEHEADER)
#define OS2_HEADER_LENGTH (BFH_INTERNAL_LENGTH + OS2_INTERNAL_BIH_LENGTH)
#define WIN_V3_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V3_INTERNAL_BIH_LENGTH)
#define WIN_V5_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V5_INTERNAL_BIH_LENGTH)
#ifndef LCS_sRGB
#define LCS_sRGB 0x73524742
#endif
namespace image {
// This is the real BIH size (as contained in the bihsize field of
// BMPFILEHEADER).
struct BIH_LENGTH {
enum {
OS2 = 12,
WIN_V3 = 40,
WIN_V5 = 124
};
};
struct BIH_INTERNAL_LENGTH {
enum {
OS2 = 8,
WIN_V3 = 36,
WIN_V5 = 120
};
};
struct BMPFILEHEADER {
char signature[2]; // String "BM"
uint32_t filesize;
int32_t reserved; // Zero
uint32_t dataoffset; // Offset to raster data
uint32_t bihsize;
// The length of the bitmap file header as defined in the BMP spec.
static const size_t LENGTH = 14;
// Internally we store the bitmap file header with an additional 4 bytes which
// is used to store the bitmap information header size.
static const size_t INTERNAL_LENGTH = 18;
};
struct BMP_HEADER_LENGTH {
enum {
OS2 = BMPFILEHEADER::INTERNAL_LENGTH + BIH_INTERNAL_LENGTH::OS2,
WIN_V3 = BMPFILEHEADER::INTERNAL_LENGTH + BIH_INTERNAL_LENGTH::WIN_V3,
WIN_V5 = BMPFILEHEADER::INTERNAL_LENGTH + BIH_INTERNAL_LENGTH::WIN_V5
};
};
struct xyz {
int32_t x, y, z;
@ -78,6 +89,8 @@ struct BITMAPV5HEADER {
uint32_t profile_offset; // Offset to profile data in bytes
uint32_t profile_size; // Size of profile data in bytes
uint32_t reserved; // =0
static const uint32_t COLOR_SPACE_LCS_SRGB = 0x73524742;
};
struct colorTable {
@ -96,38 +109,34 @@ struct bitFields {
uint8_t greenRightShift;
uint8_t blueLeftShift;
uint8_t blueRightShift;
// Length of the bitfields structure in the BMP file.
static const size_t LENGTH = 12;
};
} // namespace image
} // namespace mozilla
struct BMPINFOHEADER {
// BMPINFOHEADER.compression definitions.
enum {
RGB = 0,
RLE8 = 1,
RLE4 = 2,
BITFIELDS = 3,
// ALPHABITFIELDS means no compression and specifies alpha bits. Valid only
// for 32bpp and 16bpp.
ALPHABITFIELDS = 4
};
};
#define BITFIELD_LENGTH 12 // Length of the bitfields structure in the bmp file
#define USE_RGB
// BMPINFOHEADER.compression defines
#ifndef BI_RGB
#define BI_RGB 0
#endif
#ifndef BI_RLE8
#define BI_RLE8 1
#endif
#ifndef BI_RLE4
#define BI_RLE4 2
#endif
#ifndef BI_BITFIELDS
#define BI_BITFIELDS 3
#endif
// BI_ALPHABITFIELDS means no compression and specifies alpha bits
// valid only for 32bpp and 16bpp
#ifndef BI_ALPHABITFIELDS
#define BI_ALPHABITFIELDS 4
#endif
// RLE Escape codes
#define RLE_ESCAPE 0
#define RLE_ESCAPE_EOL 0
#define RLE_ESCAPE_EOF 1
#define RLE_ESCAPE_DELTA 2
// RLE escape codes.
struct RLE {
enum {
ESCAPE = 0,
ESCAPE_EOL = 0,
ESCAPE_EOF = 1,
ESCAPE_DELTA = 2
};
};
/// enums for mState
enum ERLEState {
@ -141,4 +150,7 @@ enum ERLEState {
///< be read as padding
};
} // namespace image
} // namespace mozilla
#endif // mozilla_image_BMPFileHeaders_h

3
image/SurfaceCache.cpp

@ -935,7 +935,8 @@ private:
struct SurfaceTracker : public nsExpirationTracker<CachedSurface, 2>
{
explicit SurfaceTracker(uint32_t aSurfaceCacheExpirationTimeMS)
: nsExpirationTracker<CachedSurface, 2>(aSurfaceCacheExpirationTimeMS)
: nsExpirationTracker<CachedSurface, 2>(aSurfaceCacheExpirationTimeMS,
"SurfaceTracker")
{ }
protected:

209
image/decoders/nsBMPDecoder.cpp

@ -39,7 +39,7 @@ GetBMPLog()
nsBMPDecoder::nsBMPDecoder(RasterImage* aImage)
: Decoder(aImage)
, mPos(0)
, mLOH(WIN_V3_HEADER_LENGTH)
, mLOH(BMP_HEADER_LENGTH::WIN_V3)
, mNumColors(0)
, mColors(nullptr)
, mRow(nullptr)
@ -101,13 +101,14 @@ nsBMPDecoder::GetImageData()
int32_t
nsBMPDecoder::GetCompressedImageSize() const
{
// For everything except BI_RGB the header field must be defined
if (mBIH.compression != BI_RGB) {
// For everything except BMPINFOHEADER::RGB the header field must be defined
if (mBIH.compression != BMPINFOHEADER::RGB) {
return mBIH.image_size;
}
// mBIH.image_size isn't always filled for BI_RGB so calculate it manually
// The pixel array size is calculated based on extra 4 byte boundary padding
// mBIH.image_size isn't always filled for BMPINFOHEADER::RGB so calculate it
// manually. The pixel array size is calculated based on extra 4 byte
// boundary padding.
uint32_t rowSize = (mBIH.bpp * mBIH.width + 7) / 8; // + 7 to round up
// Pad to DWORD Boundary
@ -206,39 +207,39 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
return;
}
// This code assumes that mRawBuf == WIN_V3_INTERNAL_BIH_LENGTH
// and that sizeof(mRawBuf) >= BFH_INTERNAL_LENGTH
MOZ_ASSERT(sizeof(mRawBuf) == WIN_V3_INTERNAL_BIH_LENGTH);
MOZ_ASSERT(sizeof(mRawBuf) >= BFH_INTERNAL_LENGTH);
MOZ_ASSERT(OS2_INTERNAL_BIH_LENGTH < WIN_V3_INTERNAL_BIH_LENGTH);
// This code assumes that mRawBuf == BIH_INTERNAL_LENGTH::WIN_V3
// and that sizeof(mRawBuf) >= BMPFILEHEADER::INTERNAL_LENGTH
MOZ_ASSERT(sizeof(mRawBuf) == BIH_INTERNAL_LENGTH::WIN_V3);
MOZ_ASSERT(sizeof(mRawBuf) >= BMPFILEHEADER::INTERNAL_LENGTH);
MOZ_ASSERT(BIH_INTERNAL_LENGTH::OS2 < BIH_INTERNAL_LENGTH::WIN_V3);
// This code also assumes it's working with a byte array
MOZ_ASSERT(sizeof(mRawBuf[0]) == 1);
if (mPos < BFH_INTERNAL_LENGTH) { /* In BITMAPFILEHEADER */
// BFH_INTERNAL_LENGTH < sizeof(mRawBuf)
// mPos < BFH_INTERNAL_LENGTH
// BFH_INTERNAL_LENGTH - mPos < sizeof(mRawBuf)
// so toCopy <= BFH_INTERNAL_LENGTH
if (mPos < BMPFILEHEADER::INTERNAL_LENGTH) { /* In BITMAPFILEHEADER */
// BMPFILEHEADER::INTERNAL_LENGTH < sizeof(mRawBuf)
// mPos < BMPFILEHEADER::INTERNAL_LENGTH
// BMPFILEHEADER::INTERNAL_LENGTH - mPos < sizeof(mRawBuf)
// so toCopy <= BMPFILEHEADER::INTERNAL_LENGTH
// so toCopy < sizeof(mRawBuf)
// so toCopy > 0 && toCopy <= BFH_INTERNAL_LENGTH
uint32_t toCopy = BFH_INTERNAL_LENGTH - mPos;
// so toCopy > 0 && toCopy <= BMPFILEHEADER::INTERNAL_LENGTH
uint32_t toCopy = BMPFILEHEADER::INTERNAL_LENGTH - mPos;
if (toCopy > aCount) {
toCopy = aCount;
}
// mRawBuf is a byte array of size WIN_V3_INTERNAL_BIH_LENGTH
// mRawBuf is a byte array of size BIH_INTERNAL_LENGTH::WIN_V3
// (verified above)
// mPos is < BFH_INTERNAL_LENGTH
// BFH_INTERNAL_LENGTH < WIN_V3_INTERNAL_BIH_LENGTH
// mPos is < BMPFILEHEADER::INTERNAL_LENGTH
// BMPFILEHEADER::INTERNAL_LENGTH < BIH_INTERNAL_LENGTH::WIN_V3
// so mPos < sizeof(mRawBuf)
//
// Therefore this assert should hold