blob: 73ac77bf1c2b7b46f204e2f38f784d7679c2a3fb (
plain)
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
|
// Copyright 2016 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 DepthOrderedLayoutObjectList_h
#define DepthOrderedLayoutObjectList_h
#include "wtf/Allocator.h"
#include "wtf/HashSet.h"
#include "wtf/Vector.h"
namespace blink {
class LayoutObject;
class DepthOrderedLayoutObjectList {
public:
DepthOrderedLayoutObjectList()
{
}
void add(LayoutObject&);
void remove(LayoutObject&);
void clear();
int size() const { return m_objects.size(); }
bool isEmpty() const { return m_objects.isEmpty(); }
struct LayoutObjectWithDepth {
LayoutObjectWithDepth(LayoutObject* inObject)
: object(inObject)
, depth(determineDepth(inObject))
{
}
LayoutObjectWithDepth()
: object(nullptr)
, depth(0)
{
}
LayoutObject* object;
unsigned depth;
LayoutObject& operator*() const { return *object; }
LayoutObject* operator->() const { return object; }
bool operator<(const DepthOrderedLayoutObjectList::LayoutObjectWithDepth& other) const
{
return depth > other.depth;
}
private:
static unsigned determineDepth(LayoutObject*);
};
const HashSet<LayoutObject*>& unordered() const { return m_objects; }
const Vector<LayoutObjectWithDepth>& ordered();
private:
// LayoutObjects sorted by depth (deepest first). This structure is only
// populated at the beginning of enumerations. See ordered().
Vector<LayoutObjectWithDepth> m_orderedObjects;
// Outside of layout, LayoutObjects can be added and removed as needed such
// as when style was changed or destroyed. They're kept in this hashset to
// keep those operations fast.
HashSet<LayoutObject*> m_objects;
};
} // namespace blink
#endif // DepthOrderedLayoutObjectList_h
|