Index: third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h |
diff --git a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h |
index 0cc8cf31997441ee3289b0ae76d1314c6df377de..a54f911f81676020ef9acbc3461864f9dd74f6bb 100644 |
--- a/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h |
+++ b/third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h |
@@ -182,6 +182,7 @@ public: |
kSubsequence, |
kEndSubsequence, |
+ kHasBeenMoved, |
kUninitializedType, |
kTypeLast = kUninitializedType |
}; |
@@ -224,11 +225,17 @@ public: |
const Type type; |
}; |
- Id getId() const { return Id(*m_client, m_type); } |
+ Id getId() const { return Id(client(), getType()); } |
virtual void replay(GraphicsContext&) const { } |
- const DisplayItemClient& client() const { ASSERT(m_client); return *m_client; } |
+ const DisplayItemClient& client() const |
+ { |
+ DCHECK(!hasBeenMoved()); |
+ DCHECK(m_client); |
+ return *m_client; |
+ } |
+ |
Type getType() const { return m_type; } |
// Size of this object in memory, used to move it with memcpy. |
@@ -312,11 +319,10 @@ public: |
} |
#endif |
- // True if the client is non-null. Because m_client is const, this should |
- // never be false except when we explicitly create a tombstone/"dead display |
- // item" as part of moving an item from one list to another (see: |
- // DisplayItemList::appendByMoving). |
- bool hasValidClient() const { return m_client; } |
+ // True if the item is a placeholder at the place of the original item that |
+ // has been moved by DisplayItemList::appendByMoving(). |
+ bool hasBeenMoved() const { return m_type == kHasBeenMoved; } |
+ size_t movedToIndex() const { DCHECK(hasBeenMoved()); return m_movedToIndex; } |
virtual bool drawsContent() const { return false; } |
@@ -332,19 +338,21 @@ public: |
#endif |
private: |
- // The default DisplayItem constructor is only used by |
- // ContiguousContainer::appendByMoving where an invalid DisplaItem is |
+ // The DisplayItem(size_t) constructor is only used by |
+ // ContiguousContainer::appendByMoving() where a placeholder DisplayItem is |
// constructed at the source location. |
template <typename T, unsigned alignment> friend class ContiguousContainer; |
- |
- DisplayItem() |
- : m_client(nullptr) |
- , m_type(kUninitializedType) |
+ DisplayItem(size_t movedToIndex) |
+ : m_movedToIndex(movedToIndex) |
+ , m_type(kHasBeenMoved) |
, m_derivedSize(sizeof(*this)) |
, m_skippedCache(false) |
{ } |
- const DisplayItemClient* m_client; |
+ union { |
pdr.
2016/09/08 01:36:23
This approach of using a union is very efficient b
Xianzhu
2016/09/08 03:01:42
Done.
|
+ const DisplayItemClient* m_client; // For m_type != HasBeenMoved. |
+ size_t m_movedToIndex; // For m_type == HasBeenMoved. |
+ }; |
static_assert(kTypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits"); |
const Type m_type : 16; |
const unsigned m_derivedSize : 8; // size of the actual derived class |