1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef LayoutAnalyzer_h
#define LayoutAnalyzer_h
#include "platform/LayoutUnit.h"
#include "wtf/Allocator.h"
#include "wtf/Noncopyable.h"
#include <memory>
namespace blink {
class LayoutBlock;
class LayoutObject;
class TracedValue;
// Observes the performance of layout and reports statistics via a TracedValue.
// Usage:
// LayoutAnalyzer::Scope analyzer(*this);
class LayoutAnalyzer {
USING_FAST_MALLOC(LayoutAnalyzer);
WTF_MAKE_NONCOPYABLE(LayoutAnalyzer);
public:
enum Counter {
LayoutBlockWidthChanged,
LayoutBlockHeightChanged,
LayoutBlockSizeChanged,
LayoutBlockSizeDidNotChange,
LayoutObjectsThatSpecifyColumns,
LayoutAnalyzerStackMaximumDepth,
LayoutObjectsThatAreFloating,
LayoutObjectsThatHaveALayer,
LayoutInlineObjectsThatAlwaysCreateLineBoxes,
LayoutObjectsThatHadNeverHadLayout,
LayoutObjectsThatAreOutOfFlowPositioned,
LayoutObjectsThatNeedPositionedMovementLayout,
PerformLayoutRootLayoutObjects,
LayoutObjectsThatNeedLayoutForThemselves,
LayoutObjectsThatNeedSimplifiedLayout,
LayoutObjectsThatAreTableCells,
LayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath,
CharactersInLayoutObjectsThatAreTextAndCanNotUseTheSimpleFontCodePath,
LayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath,
CharactersInLayoutObjectsThatAreTextAndCanUseTheSimpleFontCodePath,
TotalLayoutObjectsThatWereLaidOut,
};
static const size_t NumCounters = 21;
class Scope {
STACK_ALLOCATED();
public:
explicit Scope(const LayoutObject&);
~Scope();
private:
const LayoutObject& m_layoutObject;
LayoutAnalyzer* m_analyzer;
};
class BlockScope {
STACK_ALLOCATED();
public:
explicit BlockScope(const LayoutBlock&);
~BlockScope();
private:
const LayoutBlock& m_block;
LayoutUnit m_width;
LayoutUnit m_height;
};
LayoutAnalyzer() {}
void reset();
void push(const LayoutObject&);
void pop(const LayoutObject&);
void increment(Counter counter, unsigned delta = 1) {
m_counters[counter] += delta;
}
std::unique_ptr<TracedValue> toTracedValue();
private:
const char* nameForCounter(Counter) const;
double m_startMs;
unsigned m_depth;
unsigned m_counters[NumCounters];
};
} // namespace blink
#endif // LayoutAnalyzer_h
|