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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutObject.h

Issue 2782343002: Store local border box property cache outside ObjectPaintProperties (Closed)
Patch Set: Rebase Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * Copyright (C) 2009 Google Inc. All rights reserved. 8 * Copyright (C) 2009 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 class HitTestLocation; 58 class HitTestLocation;
59 class HitTestRequest; 59 class HitTestRequest;
60 class HitTestResult; 60 class HitTestResult;
61 class InlineBox; 61 class InlineBox;
62 class LayoutBoxModelObject; 62 class LayoutBoxModelObject;
63 class LayoutBlock; 63 class LayoutBlock;
64 class LayoutFlowThread; 64 class LayoutFlowThread;
65 class LayoutGeometryMap; 65 class LayoutGeometryMap;
66 class LayoutMultiColumnSpannerPlaceholder; 66 class LayoutMultiColumnSpannerPlaceholder;
67 class LayoutView; 67 class LayoutView;
68 class PropertyTreeState;
68 class ObjectPaintProperties; 69 class ObjectPaintProperties;
69 class PaintInvalidationState; 70 class PaintInvalidationState;
70 class PaintLayer; 71 class PaintLayer;
71 class PseudoStyleRequest; 72 class PseudoStyleRequest;
72 73
73 struct PaintInfo; 74 struct PaintInfo;
74 struct PaintInvalidatorContext; 75 struct PaintInvalidatorContext;
75 76
76 enum VisualRectFlags { DefaultVisualRectFlags = 0, EdgeInclusive = 1 }; 77 enum VisualRectFlags { DefaultVisualRectFlags = 0, EdgeInclusive = 1 };
77 78
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 395
395 // For SlimmingPaintInvalidation/SPv2 only. 396 // For SlimmingPaintInvalidation/SPv2 only.
396 // The ObjectPaintProperties structure holds references to the property tree 397 // The ObjectPaintProperties structure holds references to the property tree
397 // nodes that are created by the layout object. The property nodes should only 398 // nodes that are created by the layout object. The property nodes should only
398 // be updated during InPrePaint phase of the document lifecycle. 399 // be updated during InPrePaint phase of the document lifecycle.
399 const ObjectPaintProperties* paintProperties() const { 400 const ObjectPaintProperties* paintProperties() const {
400 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()); 401 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
401 return m_rarePaintData ? m_rarePaintData->paintProperties() : nullptr; 402 return m_rarePaintData ? m_rarePaintData->paintProperties() : nullptr;
402 } 403 }
403 404
405 // The complete set of property nodes that should be used as a starting point
406 // to paint this LayoutObject. See: m_localBorderBoxProperties comment.
407 const PropertyTreeState* localBorderBoxProperties() const {
408 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
409 if (m_rarePaintData)
410 return m_rarePaintData->localBorderBoxProperties();
411 return nullptr;
412 }
413
414 // The complete set of property nodes that should be used as a starting point
415 // to paint contents of this LayoutObject. See: m_contentsProperties comment.
416 const PropertyTreeState* contentsProperties() const {
417 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
418 if (m_rarePaintData)
419 return m_rarePaintData->contentsProperties();
420 return nullptr;
421 }
422
404 private: 423 private:
405 // This is for paint-related data that is not needed on all LayoutObjects. 424 // This is for paint-related data that is not needed on all LayoutObjects.
406 // TODO(pdr): Store LayoutBoxModelObject's m_paintLayer in this structure. 425 // TODO(pdr): Store LayoutBoxModelObject's m_paintLayer in this structure.
407 // TODO(pdr): Store ObjectPaintProperties::LocalBorderBoxProperties here.
408 class CORE_EXPORT RarePaintData { 426 class CORE_EXPORT RarePaintData {
409 WTF_MAKE_NONCOPYABLE(RarePaintData); 427 WTF_MAKE_NONCOPYABLE(RarePaintData);
410 USING_FAST_MALLOC(RarePaintData); 428 USING_FAST_MALLOC(RarePaintData);
411 429
412 public: 430 public:
413 RarePaintData(); 431 RarePaintData();
414 ~RarePaintData(); 432 ~RarePaintData();
415 433
416 ObjectPaintProperties* paintProperties() const { 434 ObjectPaintProperties* paintProperties() const {
417 return m_paintProperties.get(); 435 return m_paintProperties.get();
418 } 436 }
419 ObjectPaintProperties& ensurePaintProperties(); 437 ObjectPaintProperties& ensurePaintProperties();
420 438
439 PropertyTreeState* localBorderBoxProperties() const {
440 return m_localBorderBoxProperties.get();
441 }
442
443 void clearLocalBorderBoxProperties();
444 void setLocalBorderBoxProperties(PropertyTreeState&);
445 const PropertyTreeState* contentsProperties() const;
446
421 private: 447 private:
422 // Holds references to the paint property nodes created by this object. 448 // Holds references to the paint property nodes created by this object.
423 std::unique_ptr<ObjectPaintProperties> m_paintProperties; 449 std::unique_ptr<ObjectPaintProperties> m_paintProperties;
450
451 // This is a complete set of property nodes that should be used as a
452 // starting point to paint a LayoutObject. This data is cached because some
453 // properties inherit from the containing block chain instead of the
454 // painting parent and cannot be derived in O(1) during the paint walk.
455 //
456 // For example: <div style='opacity: 0.3;'/>
457 // The div's local border box properties would have an opacity 0.3 effect
458 // node. Even though the div has no transform, its local border box
459 // properties would have a transform node that points to the div's
460 // ancestor transform space.
461 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties;
462
463 // This is the complete set of property nodes that can be used to paint the
464 // contents of this object. It is similar to m_localBorderBoxProperties but
465 // includes properties (e.g., overflow clip, scroll translation) that apply
466 // to contents. This cached value is derived from m_localBorderBoxProperties
467 // and m_paintProperties and should be invalidated when these change.
468 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties;
424 }; 469 };
425 470
426 RarePaintData& ensureRarePaintData(); 471 RarePaintData& ensureRarePaintData();
427 RarePaintData* rarePaintData() { return m_rarePaintData.get(); } 472 RarePaintData* rarePaintData() { return m_rarePaintData.get(); }
428 473
429 ////////////////////////////////////////// 474 //////////////////////////////////////////
430 // Helper functions. Dangerous to use! 475 // Helper functions. Dangerous to use!
431 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 476 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
432 void setNextSibling(LayoutObject* next) { m_next = next; } 477 void setNextSibling(LayoutObject* next) { m_next = next; }
433 void setParent(LayoutObject* parent) { 478 void setParent(LayoutObject* parent) {
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 } 1839 }
1795 #endif 1840 #endif
1796 1841
1797 protected: 1842 protected:
1798 friend class PaintPropertyTreeBuilder; 1843 friend class PaintPropertyTreeBuilder;
1799 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, 1844 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest,
1800 canStartAnimationOnCompositorTransformSPv2); 1845 canStartAnimationOnCompositorTransformSPv2);
1801 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, 1846 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest,
1802 canStartAnimationOnCompositorEffectSPv2); 1847 canStartAnimationOnCompositorEffectSPv2);
1803 1848
1804 // The following two functions can be called from PaintPropertyTreeBuilder 1849 // The following non-const functions for ObjectPaintProperties should only
1805 // only. 1850 // be called from PaintPropertyTreeBuilder.
1806 ObjectPaintProperties& ensurePaintProperties() { 1851 ObjectPaintProperties& ensurePaintProperties() {
1807 return m_layoutObject.ensureRarePaintData().ensurePaintProperties(); 1852 return m_layoutObject.ensureRarePaintData().ensurePaintProperties();
1808 } 1853 }
1809 ObjectPaintProperties* paintProperties() { 1854 ObjectPaintProperties* paintProperties() {
1810 if (auto* paintData = m_layoutObject.rarePaintData()) 1855 if (auto* paintData = m_layoutObject.rarePaintData())
1811 return paintData->paintProperties(); 1856 return paintData->paintProperties();
1812 return nullptr; 1857 return nullptr;
1813 } 1858 }
1814 1859
1860 // The following non-const functions for local border box properties should
1861 // only be called from PaintPropertyTreeBuilder.
1862 void clearLocalBorderBoxProperties() {
1863 if (auto* paintData = m_layoutObject.rarePaintData())
1864 paintData->clearLocalBorderBoxProperties();
1865 }
1866 void setLocalBorderBoxProperties(PropertyTreeState& localBorderBox) {
1867 return m_layoutObject.ensureRarePaintData().setLocalBorderBoxProperties(
1868 localBorderBox);
1869 }
1870
1815 friend class LayoutObject; 1871 friend class LayoutObject;
1816 MutableForPainting(const LayoutObject& layoutObject) 1872 MutableForPainting(const LayoutObject& layoutObject)
1817 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {} 1873 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {}
1818 1874
1819 LayoutObject& m_layoutObject; 1875 LayoutObject& m_layoutObject;
1820 }; 1876 };
1821 MutableForPainting getMutableForPainting() const { 1877 MutableForPainting getMutableForPainting() const {
1822 return MutableForPainting(*this); 1878 return MutableForPainting(*this);
1823 } 1879 }
1824 1880
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
2802 CORE_EXPORT void showLineTree(const blink::LayoutObject*); 2858 CORE_EXPORT void showLineTree(const blink::LayoutObject*);
2803 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); 2859 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1);
2804 // We don't make object2 an optional parameter so that showLayoutTree 2860 // We don't make object2 an optional parameter so that showLayoutTree
2805 // can be called from gdb easily. 2861 // can be called from gdb easily.
2806 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, 2862 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1,
2807 const blink::LayoutObject* object2); 2863 const blink::LayoutObject* object2);
2808 2864
2809 #endif 2865 #endif
2810 2866
2811 #endif // LayoutObject_h 2867 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698