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

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: 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 struct CORE_EXPORT RarePaintData { 426 struct 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 432
415 ObjectPaintProperties* paintProperties() const { 433 ObjectPaintProperties* paintProperties() const {
416 return m_paintProperties.get(); 434 return m_paintProperties.get();
417 } 435 }
418 ObjectPaintProperties& ensurePaintProperties(); 436 ObjectPaintProperties& ensurePaintProperties();
419 437
438 PropertyTreeState* localBorderBoxProperties() const {
439 return m_localBorderBoxProperties.get();
440 }
441
442 void clearLocalBorderBoxProperties();
443 void setLocalBorderBoxProperties(PropertyTreeState&);
444 const PropertyTreeState* contentsProperties() const;
445
420 private: 446 private:
421 // Holds references to the paint property nodes created by this object. 447 // Holds references to the paint property nodes created by this object.
422 std::unique_ptr<ObjectPaintProperties> m_paintProperties; 448 std::unique_ptr<ObjectPaintProperties> m_paintProperties;
449
450 // This is a complete set of property nodes that should be used as a
451 // starting point to paint a LayoutObject. This data is cached because some
452 // properties inherit from the containing block chain instead of the
453 // painting parent and cannot be derived in O(1) during the paint walk.
454 //
455 // For example: <div style='opacity: 0.3;'/>
456 // The div's local border box properties would have an opacity 0.3 effect
457 // node. Even though the div has no transform, its local border box
458 // properties would have a transform node that points to the div's
459 // ancestor transform space.
460 std::unique_ptr<PropertyTreeState> m_localBorderBoxProperties;
461
462 // This is the complete set of property nodes that can be used to paint the
463 // contents of this object. It is similar to m_localBorderBoxProperties but
464 // includes properties (e.g., overflow clip, scroll translation) that apply
465 // to contents. This cached value is derived from m_localBorderBoxProperties
466 // and m_paintProperties and should be invalidated when these change.
467 mutable std::unique_ptr<PropertyTreeState> m_contentsProperties;
423 }; 468 };
424 469
425 RarePaintData& ensureRarePaintData(); 470 RarePaintData& ensureRarePaintData();
426 RarePaintData* rarePaintData() { return m_rarePaintData.get(); } 471 RarePaintData* rarePaintData() { return m_rarePaintData.get(); }
427 472
428 ////////////////////////////////////////// 473 //////////////////////////////////////////
429 // Helper functions. Dangerous to use! 474 // Helper functions. Dangerous to use!
430 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 475 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
431 void setNextSibling(LayoutObject* next) { m_next = next; } 476 void setNextSibling(LayoutObject* next) { m_next = next; }
432 void setParent(LayoutObject* parent) { 477 void setParent(LayoutObject* parent) {
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 } 1838 }
1794 #endif 1839 #endif
1795 1840
1796 protected: 1841 protected:
1797 friend class PaintPropertyTreeBuilder; 1842 friend class PaintPropertyTreeBuilder;
1798 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, 1843 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest,
1799 canStartAnimationOnCompositorTransformSPv2); 1844 canStartAnimationOnCompositorTransformSPv2);
1800 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest, 1845 FRIEND_TEST_ALL_PREFIXES(AnimationCompositorAnimationsTest,
1801 canStartAnimationOnCompositorEffectSPv2); 1846 canStartAnimationOnCompositorEffectSPv2);
1802 1847
1803 // The following two functions can be called from PaintPropertyTreeBuilder 1848 // The following non-const functions for ObjectPaintProperties should only
1804 // only. 1849 // be called from PaintPropertyTreeBuilder.
1805 ObjectPaintProperties& ensurePaintProperties() { 1850 ObjectPaintProperties& ensurePaintProperties() {
1806 return m_layoutObject.ensureRarePaintData().ensurePaintProperties(); 1851 return m_layoutObject.ensureRarePaintData().ensurePaintProperties();
1807 } 1852 }
1808 ObjectPaintProperties* paintProperties() { 1853 ObjectPaintProperties* paintProperties() {
1809 if (auto* paintData = m_layoutObject.rarePaintData()) 1854 if (auto* paintData = m_layoutObject.rarePaintData())
1810 return paintData->paintProperties(); 1855 return paintData->paintProperties();
1811 return nullptr; 1856 return nullptr;
1812 } 1857 }
1813 1858
1859 // The following non-const functions for local border box properties should
1860 // only be called from PaintPropertyTreeBuilder.
1861 void clearLocalBorderBoxProperties() {
1862 if (auto* paintData = m_layoutObject.rarePaintData())
1863 paintData->clearLocalBorderBoxProperties();
1864 }
1865 void setLocalBorderBoxProperties(PropertyTreeState& localBorderBox) {
1866 return m_layoutObject.ensureRarePaintData().setLocalBorderBoxProperties(
1867 localBorderBox);
1868 }
1869
1814 friend class LayoutObject; 1870 friend class LayoutObject;
1815 MutableForPainting(const LayoutObject& layoutObject) 1871 MutableForPainting(const LayoutObject& layoutObject)
1816 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {} 1872 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {}
1817 1873
1818 LayoutObject& m_layoutObject; 1874 LayoutObject& m_layoutObject;
1819 }; 1875 };
1820 MutableForPainting getMutableForPainting() const { 1876 MutableForPainting getMutableForPainting() const {
1821 return MutableForPainting(*this); 1877 return MutableForPainting(*this);
1822 } 1878 }
1823 1879
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 CORE_EXPORT void showLineTree(const blink::LayoutObject*); 2857 CORE_EXPORT void showLineTree(const blink::LayoutObject*);
2802 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); 2858 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1);
2803 // We don't make object2 an optional parameter so that showLayoutTree 2859 // We don't make object2 an optional parameter so that showLayoutTree
2804 // can be called from gdb easily. 2860 // can be called from gdb easily.
2805 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, 2861 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1,
2806 const blink::LayoutObject* object2); 2862 const blink::LayoutObject* object2);
2807 2863
2808 #endif 2864 #endif
2809 2865
2810 #endif // LayoutObject_h 2866 #endif // LayoutObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698