| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DisplayItem_h | 5 #ifndef DisplayItem_h |
| 6 #define DisplayItem_h | 6 #define DisplayItem_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/graphics/ListContainer.h" |
| 9 #include "platform/graphics/paint/DisplayItemClient.h" | 10 #include "platform/graphics/paint/DisplayItemClient.h" |
| 10 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
| 11 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
| 12 | 13 |
| 13 #ifndef NDEBUG | 14 #ifndef NDEBUG |
| 14 #include "wtf/text/StringBuilder.h" | 15 #include "wtf/text/StringBuilder.h" |
| 15 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 class GraphicsContext; | 22 class GraphicsContext; |
| 22 class WebDisplayItemList; | 23 class WebDisplayItemList; |
| 23 | 24 |
| 24 class PLATFORM_EXPORT DisplayItem { | 25 class PLATFORM_EXPORT DisplayItem { |
| 25 public: | 26 public: |
| 26 enum { | 27 enum { |
| 27 // Must be kept in sync with core/layout/PaintPhase.h. | 28 // Must be kept in sync with core/paint/PaintPhase.h. |
| 28 PaintPhaseMax = 12, | 29 PaintPhaseMax = 12, |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 // A display item type uniquely identifies a display item of a client. | 32 // A display item type uniquely identifies a display item of a client. |
| 32 // Some display item types can be categorized using the following directives
: | 33 // Some display item types can be categorized using the following directives
: |
| 33 // - In enum Type: | 34 // - In enum Type: |
| 34 // - enum value <Category>First; | 35 // - enum value <Category>First; |
| 35 // - enum values of the category, first of which should equal <Category>Fi
rst; | 36 // - enum values of the category, first of which should equal <Category>Fi
rst; |
| 36 // (for ease of maintenance, the values should be in alphabetic order) | 37 // (for ease of maintenance, the values should be in alphabetic order) |
| 37 // - enum value <Category>Last which should be equal to the last of the en
um values of the category | 38 // - enum value <Category>Last which should be equal to the last of the en
um values of the category |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 171 |
| 171 EndSubtreeFirst, | 172 EndSubtreeFirst, |
| 172 EndSubtreePaintPhaseFirst = EndSubtreeFirst, | 173 EndSubtreePaintPhaseFirst = EndSubtreeFirst, |
| 173 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, | 174 EndSubtreePaintPhaseLast = EndSubtreePaintPhaseFirst + PaintPhaseMax, |
| 174 EndSubtreeLast = EndSubtreePaintPhaseLast, | 175 EndSubtreeLast = EndSubtreePaintPhaseLast, |
| 175 | 176 |
| 176 UninitializedType, | 177 UninitializedType, |
| 177 TypeLast = UninitializedType | 178 TypeLast = UninitializedType |
| 178 }; | 179 }; |
| 179 | 180 |
| 181 DisplayItem(const DisplayItemClientWrapper& client, Type type) |
| 182 : m_client(client.displayItemClient()) |
| 183 , m_scopeContainer(nullptr) |
| 184 , m_scopeId(0) |
| 185 , m_type(type) |
| 186 , m_skippedCache(false) |
| 187 , m_ignoredFromList(false) |
| 188 #ifndef NDEBUG |
| 189 , m_clientDebugString(client.debugName()) |
| 190 #endif |
| 191 { } |
| 192 |
| 180 struct Id { | 193 struct Id { |
| 181 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC
ontainer(nullptr) | 194 Id(DisplayItemClient c, Type t) : client(c), type(t), scopeId(0), scopeC
ontainer(nullptr) |
| 182 { | 195 { |
| 183 ASSERT(c); | 196 ASSERT(c); |
| 184 } | 197 } |
| 185 | 198 |
| 186 bool operator==(const Id& other) const | 199 bool operator==(const Id& other) const |
| 187 { | 200 { |
| 188 return client == other.client | 201 return client == other.client |
| 189 && type == other.type | 202 && type == other.type |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 310 |
| 298 virtual bool isBegin() const { return false; } | 311 virtual bool isBegin() const { return false; } |
| 299 virtual bool isEnd() const { return false; } | 312 virtual bool isEnd() const { return false; } |
| 300 | 313 |
| 301 #if ENABLE(ASSERT) | 314 #if ENABLE(ASSERT) |
| 302 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } | 315 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } |
| 303 #endif | 316 #endif |
| 304 | 317 |
| 305 virtual bool drawsContent() const { return false; } | 318 virtual bool drawsContent() const { return false; } |
| 306 | 319 |
| 320 bool ignoreFromDisplayList() const { return m_ignoredFromList; } |
| 321 void setIgnoredFromDisplayList() { m_ignoredFromList = true; } |
| 322 |
| 307 #ifndef NDEBUG | 323 #ifndef NDEBUG |
| 308 static WTF::String typeAsDebugString(DisplayItem::Type); | 324 static WTF::String typeAsDebugString(DisplayItem::Type); |
| 309 const WTF::String& clientDebugString() const { return m_clientDebugString; } | 325 const WTF::String& clientDebugString() const { return m_clientDebugString; } |
| 310 WTF::String asDebugString() const; | 326 WTF::String asDebugString() const; |
| 311 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; | 327 virtual void dumpPropertiesAsDebugString(WTF::StringBuilder&) const; |
| 312 #endif | 328 #endif |
| 313 | 329 |
| 314 protected: | 330 private: |
| 315 DisplayItem(const DisplayItemClientWrapper& client, Type type) | 331 // The default DisplayItem constructor is only used by ListContainer::append
ByMoving |
| 316 : m_client(client.displayItemClient()) | 332 // where an inavlid DisplaItem is constructed at the source location. |
| 333 friend DisplayItem* ListContainer<DisplayItem>::appendByMoving<DisplayItem>(
DisplayItem*); |
| 334 DisplayItem() |
| 335 : m_client(nullptr) |
| 317 , m_scopeContainer(nullptr) | 336 , m_scopeContainer(nullptr) |
| 318 , m_scopeId(0) | 337 , m_scopeId(0) |
| 319 , m_type(type) | 338 , m_type(UninitializedType) |
| 320 , m_skippedCache(false) | 339 , m_skippedCache(false) |
| 340 , m_ignoredFromList(true) |
| 321 #ifndef NDEBUG | 341 #ifndef NDEBUG |
| 322 , m_clientDebugString(client.debugName()) | 342 , m_clientDebugString("invalid") |
| 323 #endif | 343 #endif |
| 324 { } | 344 { } |
| 325 | 345 |
| 326 private: | |
| 327 const DisplayItemClient m_client; | 346 const DisplayItemClient m_client; |
| 328 DisplayItemClient m_scopeContainer; | 347 DisplayItemClient m_scopeContainer; |
| 329 int m_scopeId; | 348 int m_scopeId; |
| 330 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); | 349 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); |
| 331 const Type m_type : 16; | 350 const Type m_type : 16; |
| 332 unsigned m_skippedCache : 1; | 351 unsigned m_skippedCache : 1; |
| 352 unsigned m_ignoredFromList : 1; |
| 333 | 353 |
| 334 #ifndef NDEBUG | 354 #ifndef NDEBUG |
| 335 WTF::String m_clientDebugString; | 355 WTF::String m_clientDebugString; |
| 336 #endif | 356 #endif |
| 337 }; | 357 }; |
| 338 | 358 |
| 339 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { | 359 class PLATFORM_EXPORT PairedBeginDisplayItem : public DisplayItem { |
| 340 protected: | 360 protected: |
| 341 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) :
DisplayItem(client, type) { } | 361 PairedBeginDisplayItem(const DisplayItemClientWrapper& client, Type type) :
DisplayItem(client, type) { } |
| 342 | 362 |
| 343 private: | 363 private: |
| 344 virtual bool isBegin() const override final { return true; } | 364 virtual bool isBegin() const override final { return true; } |
| 345 }; | 365 }; |
| 346 | 366 |
| 347 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { | 367 class PLATFORM_EXPORT PairedEndDisplayItem : public DisplayItem { |
| 348 protected: | 368 protected: |
| 349 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di
splayItem(client, type) { } | 369 PairedEndDisplayItem(const DisplayItemClientWrapper& client, Type type) : Di
splayItem(client, type) { } |
| 350 | 370 |
| 351 #if ENABLE(ASSERT) | 371 #if ENABLE(ASSERT) |
| 352 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override
= 0; | 372 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const override
= 0; |
| 353 #endif | 373 #endif |
| 354 | 374 |
| 355 private: | 375 private: |
| 356 virtual bool isEnd() const override final { return true; } | 376 virtual bool isEnd() const override final { return true; } |
| 357 }; | 377 }; |
| 358 | 378 |
| 359 } // namespace blink | 379 } // namespace blink |
| 360 | 380 |
| 361 #endif // DisplayItem_h | 381 #endif // DisplayItem_h |
| OLD | NEW |