Bug 1206915 - Handle nested PaintFrame() calls correctly during paint dumping. r=mattwoodrow,BenWa

--HG--
extra : source : fab68f61b2f73bbd9b1e9a0c8f542ced62da60b0
This commit is contained in:
Botond Ballo 2015-09-21 19:05:44 -04:00
Родитель 9836d10039
Коммит 0883bb5acc
1 изменённых файлов: 30 добавлений и 4 удалений

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/gfx/PathHelpers.h"
@ -2881,7 +2882,20 @@ nsLayoutUtils::CombineBreakType(uint8_t aOrigBreakType,
#include <stdio.h>
static bool gDumpEventList = false;
int gPaintCount = 0;
// nsLayoutUtils::PaintFrame() can call itself recursively, so rather than
// maintaining a single paint count, we need a stack.
StaticAutoPtr<nsTArray<int>> gPaintCountStack;
struct AutoNestedPaintCount {
AutoNestedPaintCount() {
gPaintCountStack->AppendElement(0);
}
~AutoNestedPaintCount() {
gPaintCountStack->RemoveElementAt(gPaintCountStack->Length() - 1);
}
};
#endif
nsIFrame*
@ -3086,6 +3100,17 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
PROFILER_LABEL("nsLayoutUtils", "PaintFrame",
js::ProfileEntry::Category::GRAPHICS);
#ifdef MOZ_DUMP_PAINTING
if (!gPaintCountStack) {
gPaintCountStack = new nsTArray<int>();
ClearOnShutdown(&gPaintCountStack);
gPaintCountStack->AppendElement(0);
}
++gPaintCountStack->LastElement();
AutoNestedPaintCount nestedPaintCount;
#endif
if (aFlags & PAINT_WIDGET_LAYERS) {
nsView* view = aFrame->GetView();
if (!(view && view->GetWidget() && GetDisplayRootFrame(aFrame) == aFrame)) {
@ -3277,8 +3302,10 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
// Include the process ID in the dump file name, to make sure that in an
// e10s setup different processes don't clobber each other's dump files.
string.AppendInt(getpid());
string.AppendLiteral("-");
string.AppendInt(gPaintCount);
for (int paintCount : *gPaintCountStack) {
string.AppendLiteral("-");
string.AppendInt(paintCount);
}
string.AppendLiteral(".html");
gfxUtils::sDumpPaintFile = fopen(string.BeginReading(), "w");
} else {
@ -3366,7 +3393,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
fclose(gfxUtils::sDumpPaintFile);
}
gfxUtils::sDumpPaintFile = savedDumpFile;
gPaintCount++;
#endif
std::stringstream lsStream;