Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItem.h

Issue 2894093002: Don't access DisplayItemClient::VisualRect() for cached display items. (Closed)
Patch Set: - Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "platform/wtf/Allocator.h" 11 #include "platform/wtf/Allocator.h"
12 #include "platform/wtf/Assertions.h" 12 #include "platform/wtf/Assertions.h"
13 #include "platform/wtf/Noncopyable.h" 13 #include "platform/wtf/Noncopyable.h"
14 14
15 #ifndef NDEBUG 15 #ifndef NDEBUG
16 #include "platform/wtf/text/StringBuilder.h" 16 #include "platform/wtf/text/StringBuilder.h"
17 #include "platform/wtf/text/WTFString.h" 17 #include "platform/wtf/text/WTFString.h"
18 #endif 18 #endif
19 19
20 namespace blink { 20 namespace blink {
21 21
22 class GraphicsContext; 22 class GraphicsContext;
23 class IntRect; 23 class LayoutSize;
pdr. 2017/05/19 17:11:36 Curious: why a LayoutSize instead of an IntSize or
Xianzhu 2017/05/19 18:06:33 This is for the "const LayoutSize& visual_rect_off
24 class WebDisplayItemList; 24 class WebDisplayItemList;
25 25
26 class PLATFORM_EXPORT DisplayItem { 26 class PLATFORM_EXPORT DisplayItem {
27 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 27 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
28 28
29 public: 29 public:
30 enum { 30 enum {
31 // Must be kept in sync with core/paint/PaintPhase.h. 31 // Must be kept in sync with core/paint/PaintPhase.h.
32 kPaintPhaseMax = 11, 32 kPaintPhaseMax = 11,
33 }; 33 };
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // border type. 192 // border type.
193 enum TableCollapsedBorderSides { 193 enum TableCollapsedBorderSides {
194 kTableCollapsedBorderTop = 1 << 0, 194 kTableCollapsedBorderTop = 1 << 0,
195 kTableCollapsedBorderRight = 1 << 1, 195 kTableCollapsedBorderRight = 1 << 1,
196 kTableCollapsedBorderBottom = 1 << 2, 196 kTableCollapsedBorderBottom = 1 << 2,
197 kTableCollapsedBorderLeft = 1 << 3, 197 kTableCollapsedBorderLeft = 1 << 3,
198 }; 198 };
199 199
200 DisplayItem(const DisplayItemClient& client, Type type, size_t derived_size) 200 DisplayItem(const DisplayItemClient& client, Type type, size_t derived_size)
201 : client_(&client), 201 : client_(&client),
202 visual_rect_(client.VisualRect()),
202 type_(type), 203 type_(type),
203 derived_size_(derived_size), 204 derived_size_(derived_size),
204 skipped_cache_(false) 205 skipped_cache_(false)
205 #ifndef NDEBUG 206 #ifndef NDEBUG
206 , 207 ,
207 client_debug_string_(client.DebugName()) 208 client_debug_string_(client.DebugName())
208 #endif 209 #endif
209 { 210 {
210 // derivedSize must fit in m_derivedSize. 211 // derivedSize must fit in m_derivedSize.
211 // If it doesn't, enlarge m_derivedSize and fix this assert. 212 // If it doesn't, enlarge m_derivedSize and fix this assert.
(...skipping 14 matching lines...) Expand all
226 }; 227 };
227 228
228 Id GetId() const { return Id(*client_, type_); } 229 Id GetId() const { return Id(*client_, type_); }
229 230
230 virtual void Replay(GraphicsContext&) const {} 231 virtual void Replay(GraphicsContext&) const {}
231 232
232 const DisplayItemClient& Client() const { 233 const DisplayItemClient& Client() const {
233 DCHECK(client_); 234 DCHECK(client_);
234 return *client_; 235 return *client_;
235 } 236 }
237
238 const LayoutRect& VisualRect() const { return visual_rect_; }
pdr. 2017/05/19 17:11:36 Can you add a comment here about what space this r
Xianzhu 2017/05/19 18:06:33 Done.
239
236 Type GetType() const { return type_; } 240 Type GetType() const { return type_; }
237 241
238 // Size of this object in memory, used to move it with memcpy. 242 // Size of this object in memory, used to move it with memcpy.
239 // This is not sizeof(*this), because it needs to account for the size of 243 // This is not sizeof(*this), because it needs to account for the size of
240 // the derived class (i.e. runtime type). Derived classes are expected to 244 // the derived class (i.e. runtime type). Derived classes are expected to
241 // supply this to the DisplayItem constructor. 245 // supply this to the DisplayItem constructor.
242 size_t DerivedSize() const { return derived_size_; } 246 size_t DerivedSize() const { return derived_size_; }
243 247
244 // For PaintController only. Painters should use DisplayItemCacheSkipper 248 // For PaintController only. Painters should use DisplayItemCacheSkipper
245 // instead. 249 // instead.
246 void SetSkippedCache() { skipped_cache_ = true; } 250 void SetSkippedCache() { skipped_cache_ = true; }
247 bool SkippedCache() const { return skipped_cache_; } 251 bool SkippedCache() const { return skipped_cache_; }
248 252
249 // TODO(wkorman): Only DrawingDisplayItem needs the visual rect argument. 253 virtual void AppendToWebDisplayItemList(const LayoutSize&,
250 // Consider refactoring class hierarchy to make this more explicit.
251 virtual void AppendToWebDisplayItemList(const IntRect&,
252 WebDisplayItemList*) const {} 254 WebDisplayItemList*) const {}
253 255
254 // See comments of enum Type for usage of the following macros. 256 // See comments of enum Type for usage of the following macros.
255 #define DEFINE_CATEGORY_METHODS(Category) \ 257 #define DEFINE_CATEGORY_METHODS(Category) \
256 static bool Is##Category##Type(Type type) { \ 258 static bool Is##Category##Type(Type type) { \
257 return type >= k##Category##First && type <= k##Category##Last; \ 259 return type >= k##Category##First && type <= k##Category##Last; \
258 } \ 260 } \
259 bool Is##Category() const { return Is##Category##Type(GetType()); } 261 bool Is##Category() const { return Is##Category##Type(GetType()); }
260 262
261 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \ 263 #define DEFINE_CONVERSION_METHODS(Category1, category1, Category2, category2) \
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 WTF::String AsDebugString() const; 346 WTF::String AsDebugString() const;
345 virtual void DumpPropertiesAsDebugString(WTF::StringBuilder&) const; 347 virtual void DumpPropertiesAsDebugString(WTF::StringBuilder&) const;
346 #endif 348 #endif
347 349
348 private: 350 private:
349 // The default DisplayItem constructor is only used by 351 // The default DisplayItem constructor is only used by
350 // ContiguousContainer::appendByMoving where an invalid DisplaItem is 352 // ContiguousContainer::appendByMoving where an invalid DisplaItem is
351 // constructed at the source location. 353 // constructed at the source location.
352 template <typename T, unsigned alignment> 354 template <typename T, unsigned alignment>
353 friend class ContiguousContainer; 355 friend class ContiguousContainer;
356 friend class DisplayItemList;
354 357
355 DisplayItem() 358 DisplayItem()
356 : client_(nullptr), 359 : client_(nullptr),
357 type_(kUninitializedType), 360 type_(kUninitializedType),
358 derived_size_(sizeof(*this)), 361 derived_size_(sizeof(*this)),
359 skipped_cache_(false) {} 362 skipped_cache_(false) {}
360 363
361 const DisplayItemClient* client_; 364 const DisplayItemClient* client_;
365 LayoutRect visual_rect_;
366
362 static_assert(kTypeLast < (1 << 16), 367 static_assert(kTypeLast < (1 << 16),
363 "DisplayItem::Type should fit in 16 bits"); 368 "DisplayItem::Type should fit in 16 bits");
364 const Type type_ : 16; 369 const Type type_ : 16;
365 const unsigned derived_size_ : 8; // size of the actual derived class 370 const unsigned derived_size_ : 8; // size of the actual derived class
366 unsigned skipped_cache_ : 1; 371 unsigned skipped_cache_ : 1;
367 372
368 #ifndef NDEBUG 373 #ifndef NDEBUG
369 WTF::String client_debug_string_; 374 WTF::String client_debug_string_;
370 #endif 375 #endif
371 }; 376 };
(...skipping 28 matching lines...) Expand all
400 bool IsEndAndPairedWith(DisplayItem::Type other_type) const override = 0; 405 bool IsEndAndPairedWith(DisplayItem::Type other_type) const override = 0;
401 #endif 406 #endif
402 407
403 private: 408 private:
404 bool IsEnd() const final { return true; } 409 bool IsEnd() const final { return true; }
405 }; 410 };
406 411
407 } // namespace blink 412 } // namespace blink
408 413
409 #endif // DisplayItem_h 414 #endif // DisplayItem_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698