| 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/ContiguousContainer.h" | 9 #include "platform/graphics/ContiguousContainer.h" |
| 10 #include "platform/graphics/paint/DisplayItemClient.h" | 10 #include "platform/graphics/paint/DisplayItemClient.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps
ed border type. | 189 // Bits or'ed onto TableCollapsedBorderBase to generate a real table collaps
ed border type. |
| 190 enum TableCollapsedBorderSides { | 190 enum TableCollapsedBorderSides { |
| 191 TableCollapsedBorderTop = 1 << 0, | 191 TableCollapsedBorderTop = 1 << 0, |
| 192 TableCollapsedBorderRight = 1 << 1, | 192 TableCollapsedBorderRight = 1 << 1, |
| 193 TableCollapsedBorderBottom = 1 << 2, | 193 TableCollapsedBorderBottom = 1 << 2, |
| 194 TableCollapsedBorderLeft = 1 << 3, | 194 TableCollapsedBorderLeft = 1 << 3, |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 DisplayItem(const DisplayItemClient& client, Type type, size_t derivedSize) | 197 DisplayItem(const DisplayItemClient& client, Type type, size_t derivedSize) |
| 198 : m_client(&client) | 198 : m_client(&client) |
| 199 , m_scope(0) | |
| 200 , m_type(type) | 199 , m_type(type) |
| 201 , m_derivedSize(derivedSize) | 200 , m_derivedSize(derivedSize) |
| 202 , m_skippedCache(false) | 201 , m_skippedCache(false) |
| 203 #ifndef NDEBUG | 202 #ifndef NDEBUG |
| 204 , m_clientDebugString(client.debugName()) | 203 , m_clientDebugString(client.debugName()) |
| 205 #endif | 204 #endif |
| 206 { | 205 { |
| 207 // derivedSize must fit in m_derivedSize. | 206 // derivedSize must fit in m_derivedSize. |
| 208 // If it doesn't, enlarge m_derivedSize and fix this assert. | 207 // If it doesn't, enlarge m_derivedSize and fix this assert. |
| 209 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); | 208 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize < (1 << 8)); |
| 210 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); | 209 ASSERT_WITH_SECURITY_IMPLICATION(derivedSize >= sizeof(*this)); |
| 211 } | 210 } |
| 212 | 211 |
| 213 virtual ~DisplayItem() { } | 212 virtual ~DisplayItem() { } |
| 214 | 213 |
| 215 // Ids are for matching new DisplayItems with existing DisplayItems. | 214 // Ids are for matching new DisplayItems with existing DisplayItems. |
| 216 struct Id { | 215 struct Id { |
| 217 STACK_ALLOCATED(); | 216 STACK_ALLOCATED(); |
| 218 Id(const DisplayItemClient& client, const Type type, const unsigned scop
e) | 217 Id(const DisplayItemClient& client, const Type type) |
| 219 : client(client) | 218 : client(client) |
| 220 , type(type) | 219 , type(type) { } |
| 221 , scope(scope) { } | |
| 222 | 220 |
| 223 bool matches(const DisplayItem& item) const | 221 bool matches(const DisplayItem& item) const |
| 224 { | 222 { |
| 225 // We should always convert to non-cached types before matching. | 223 // We should always convert to non-cached types before matching. |
| 226 ASSERT(!isCachedType(item.m_type)); | 224 ASSERT(!isCachedType(item.m_type)); |
| 227 ASSERT(!isCachedType(type)); | 225 ASSERT(!isCachedType(type)); |
| 228 return &client == item.m_client | 226 return &client == item.m_client && type == item.m_type; |
| 229 && type == item.m_type | |
| 230 && scope == item.m_scope; | |
| 231 } | 227 } |
| 232 | 228 |
| 233 const DisplayItemClient& client; | 229 const DisplayItemClient& client; |
| 234 const Type type; | 230 const Type type; |
| 235 const unsigned scope; | |
| 236 }; | 231 }; |
| 237 | 232 |
| 238 // Convert cached type to non-cached type (e.g., Type::CachedSVGImage -> Typ
e::SVGImage). | 233 // Convert cached type to non-cached type (e.g., Type::CachedSVGImage -> Typ
e::SVGImage). |
| 239 static Type nonCachedType(Type type) | 234 static Type nonCachedType(Type type) |
| 240 { | 235 { |
| 241 if (isCachedDrawingType(type)) | 236 if (isCachedDrawingType(type)) |
| 242 return cachedDrawingTypeToDrawingType(type); | 237 return cachedDrawingTypeToDrawingType(type); |
| 243 if (type == CachedSubsequence) | 238 if (type == CachedSubsequence) |
| 244 return Subsequence; | 239 return Subsequence; |
| 245 return type; | 240 return type; |
| 246 } | 241 } |
| 247 | 242 |
| 248 // Return the Id with cached type converted to non-cached type. | 243 // Return the Id with cached type converted to non-cached type. |
| 249 Id nonCachedId() const | 244 Id nonCachedId() const |
| 250 { | 245 { |
| 251 return Id(*m_client, nonCachedType(m_type), m_scope); | 246 return Id(*m_client, nonCachedType(m_type)); |
| 252 } | 247 } |
| 253 | 248 |
| 254 virtual void replay(GraphicsContext&) const { } | 249 virtual void replay(GraphicsContext&) const { } |
| 255 | 250 |
| 256 const DisplayItemClient& client() const { ASSERT(m_client); return *m_client
; } | 251 const DisplayItemClient& client() const { ASSERT(m_client); return *m_client
; } |
| 257 Type getType() const { return m_type; } | 252 Type getType() const { return m_type; } |
| 258 | 253 |
| 259 void setScope(unsigned scope) { m_scope = scope; } | |
| 260 unsigned scope() { return m_scope; } | |
| 261 | |
| 262 // Size of this object in memory, used to move it with memcpy. | 254 // Size of this object in memory, used to move it with memcpy. |
| 263 // This is not sizeof(*this), because it needs to account for the size of | 255 // This is not sizeof(*this), because it needs to account for the size of |
| 264 // the derived class (i.e. runtime type). Derived classes are expected to | 256 // the derived class (i.e. runtime type). Derived classes are expected to |
| 265 // supply this to the DisplayItem constructor. | 257 // supply this to the DisplayItem constructor. |
| 266 size_t derivedSize() const { return m_derivedSize; } | 258 size_t derivedSize() const { return m_derivedSize; } |
| 267 | 259 |
| 268 // For PaintController only. Painters should use DisplayItemCacheSkipper ins
tead. | 260 // For PaintController only. Painters should use DisplayItemCacheSkipper ins
tead. |
| 269 void setSkippedCache() { m_skippedCache = true; } | 261 void setSkippedCache() { m_skippedCache = true; } |
| 270 bool skippedCache() const { return m_skippedCache; } | 262 bool skippedCache() const { return m_skippedCache; } |
| 271 | 263 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type)
; } | 321 bool isCacheable() const { return !skippedCache() && isCacheableType(m_type)
; } |
| 330 | 322 |
| 331 virtual bool isBegin() const { return false; } | 323 virtual bool isBegin() const { return false; } |
| 332 virtual bool isEnd() const { return false; } | 324 virtual bool isEnd() const { return false; } |
| 333 | 325 |
| 334 #if DCHECK_IS_ON() | 326 #if DCHECK_IS_ON() |
| 335 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } | 327 virtual bool isEndAndPairedWith(DisplayItem::Type otherType) const { return
false; } |
| 336 virtual bool equals(const DisplayItem& other) const | 328 virtual bool equals(const DisplayItem& other) const |
| 337 { | 329 { |
| 338 return m_client == other.m_client | 330 return m_client == other.m_client |
| 339 && m_scope == other.m_scope | |
| 340 && m_type == other.m_type | 331 && m_type == other.m_type |
| 341 && m_derivedSize == other.m_derivedSize | 332 && m_derivedSize == other.m_derivedSize |
| 342 && m_skippedCache == other.m_skippedCache; | 333 && m_skippedCache == other.m_skippedCache; |
| 343 } | 334 } |
| 344 #endif | 335 #endif |
| 345 | 336 |
| 346 // True if the client is non-null. Because m_client is const, this should | 337 // True if the client is non-null. Because m_client is const, this should |
| 347 // never be false except when we explicitly create a tombstone/"dead display | 338 // never be false except when we explicitly create a tombstone/"dead display |
| 348 // item" as part of moving an item from one list to another (see: | 339 // item" as part of moving an item from one list to another (see: |
| 349 // DisplayItemList::appendByMoving). | 340 // DisplayItemList::appendByMoving). |
| (...skipping 13 matching lines...) Expand all Loading... |
| 363 #endif | 354 #endif |
| 364 | 355 |
| 365 private: | 356 private: |
| 366 // The default DisplayItem constructor is only used by | 357 // The default DisplayItem constructor is only used by |
| 367 // ContiguousContainer::appendByMoving where an invalid DisplaItem is | 358 // ContiguousContainer::appendByMoving where an invalid DisplaItem is |
| 368 // constructed at the source location. | 359 // constructed at the source location. |
| 369 template <typename T, unsigned alignment> friend class ContiguousContainer; | 360 template <typename T, unsigned alignment> friend class ContiguousContainer; |
| 370 | 361 |
| 371 DisplayItem() | 362 DisplayItem() |
| 372 : m_client(nullptr) | 363 : m_client(nullptr) |
| 373 , m_scope(0) | |
| 374 , m_type(UninitializedType) | 364 , m_type(UninitializedType) |
| 375 , m_derivedSize(sizeof(*this)) | 365 , m_derivedSize(sizeof(*this)) |
| 376 , m_skippedCache(false) | 366 , m_skippedCache(false) |
| 377 { } | 367 { } |
| 378 | 368 |
| 379 const DisplayItemClient* m_client; | 369 const DisplayItemClient* m_client; |
| 380 unsigned m_scope; | |
| 381 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); | 370 static_assert(TypeLast < (1 << 16), "DisplayItem::Type should fit in 16 bits
"); |
| 382 const Type m_type : 16; | 371 const Type m_type : 16; |
| 383 const unsigned m_derivedSize : 8; // size of the actual derived class | 372 const unsigned m_derivedSize : 8; // size of the actual derived class |
| 384 unsigned m_skippedCache : 1; | 373 unsigned m_skippedCache : 1; |
| 385 | 374 |
| 386 #ifndef NDEBUG | 375 #ifndef NDEBUG |
| 387 WTF::String m_clientDebugString; | 376 WTF::String m_clientDebugString; |
| 388 #endif | 377 #endif |
| 389 }; | 378 }; |
| 390 | 379 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 404 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; | 393 bool isEndAndPairedWith(DisplayItem::Type otherType) const override = 0; |
| 405 #endif | 394 #endif |
| 406 | 395 |
| 407 private: | 396 private: |
| 408 bool isEnd() const final { return true; } | 397 bool isEnd() const final { return true; } |
| 409 }; | 398 }; |
| 410 | 399 |
| 411 } // namespace blink | 400 } // namespace blink |
| 412 | 401 |
| 413 #endif // DisplayItem_h | 402 #endif // DisplayItem_h |
| OLD | NEW |