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

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

Issue 2521613003: Add flag for tracking descendant paint property updates (Closed)
Patch Set: Address Xianzhu's comments Created 4 years 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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 } 1700 }
1701 void clearPreviousVisualRects() { 1701 void clearPreviousVisualRects() {
1702 m_layoutObject.clearPreviousVisualRects(); 1702 m_layoutObject.clearPreviousVisualRects();
1703 } 1703 }
1704 void setNeedsPaintPropertyUpdate() { 1704 void setNeedsPaintPropertyUpdate() {
1705 m_layoutObject.setNeedsPaintPropertyUpdate(); 1705 m_layoutObject.setNeedsPaintPropertyUpdate();
1706 } 1706 }
1707 void clearNeedsPaintPropertyUpdate() { 1707 void clearNeedsPaintPropertyUpdate() {
1708 m_layoutObject.clearNeedsPaintPropertyUpdate(); 1708 m_layoutObject.clearNeedsPaintPropertyUpdate();
1709 } 1709 }
1710 void clearDescendantNeedsPaintPropertyUpdate() {
1711 m_layoutObject.clearDescendantNeedsPaintPropertyUpdate();
1712 }
1710 1713
1711 protected: 1714 protected:
1712 friend class PaintPropertyTreeBuilder; 1715 friend class PaintPropertyTreeBuilder;
1713 // The following two functions can be called from PaintPropertyTreeBuilder 1716 // The following two functions can be called from PaintPropertyTreeBuilder
1714 // only. 1717 // only.
1715 ObjectPaintProperties& ensurePaintProperties() { 1718 ObjectPaintProperties& ensurePaintProperties() {
1716 return m_layoutObject.ensurePaintProperties(); 1719 return m_layoutObject.ensurePaintProperties();
1717 } 1720 }
1718 ObjectPaintProperties* paintProperties() { 1721 ObjectPaintProperties* paintProperties() {
1719 return const_cast<ObjectPaintProperties*>( 1722 return const_cast<ObjectPaintProperties*>(
1720 m_layoutObject.paintProperties()); 1723 m_layoutObject.paintProperties());
1721 } 1724 }
1722 1725
1723 friend class LayoutObject; 1726 friend class LayoutObject;
1724 MutableForPainting(const LayoutObject& layoutObject) 1727 MutableForPainting(const LayoutObject& layoutObject)
1725 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {} 1728 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {}
1726 1729
1727 LayoutObject& m_layoutObject; 1730 LayoutObject& m_layoutObject;
1728 }; 1731 };
1729 MutableForPainting getMutableForPainting() const { 1732 MutableForPainting getMutableForPainting() const {
1730 return MutableForPainting(*this); 1733 return MutableForPainting(*this);
1731 } 1734 }
1732 1735
1733 // Paint properties (see: |ObjectPaintProperties|) are built from an object's 1736 // Paint properties (see: |ObjectPaintProperties|) are built from an object's
1734 // state (location, transform, etc) as well as properties from ancestors. 1737 // state (location, transform, etc) as well as properties from ancestors.
1735 // When these inputs change, setNeedsPaintPropertyUpdate will cause a property 1738 // When these inputs change, setNeedsPaintPropertyUpdate will cause a property
1736 // tree update during the next document lifecycle update. 1739 // tree update during the next document lifecycle update.
1737 // TODO(pdr): Add additional granularity such as the ability to signal that 1740 //
1738 // only a local paint property update is needed. 1741 // In addition to tracking if an object needs its own paint properties
1739 void setNeedsPaintPropertyUpdate() { 1742 // updated, |descendantNeedsPaintPropertyUpdate| is used to track if any
1740 m_bitfields.setNeedsPaintPropertyUpdate(true); 1743 // descendant needs an update too. This bit is up the tree, crossing frames,
1741 } 1744 // when calling |setNeedsPaintPropertyUpdate|.
1742 // TODO(pdr): This can be removed once we have more granular update flags. 1745 void setNeedsPaintPropertyUpdate();
1743 void setAllAncestorsNeedPaintPropertyUpdate() { 1746 bool needsPaintPropertyUpdate() const {
1744 if (m_parent) { 1747 return m_bitfields.needsPaintPropertyUpdate();
1745 m_parent->setNeedsPaintPropertyUpdate();
1746 m_parent->setAllAncestorsNeedPaintPropertyUpdate();
1747 }
1748 } 1748 }
1749 void clearNeedsPaintPropertyUpdate() { 1749 void clearNeedsPaintPropertyUpdate() {
1750 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint); 1750 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint);
1751 m_bitfields.setNeedsPaintPropertyUpdate(false); 1751 m_bitfields.setNeedsPaintPropertyUpdate(false);
1752 } 1752 }
1753 bool needsPaintPropertyUpdate() const { 1753 bool descendantNeedsPaintPropertyUpdate() const {
1754 return m_bitfields.needsPaintPropertyUpdate(); 1754 return m_bitfields.descendantNeedsPaintPropertyUpdate();
1755 } 1755 }
1756 void clearDescendantNeedsPaintPropertyUpdate() {
1757 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint);
1758 m_bitfields.setDescendantNeedsPaintPropertyUpdate(false);
1759 }
1760 // Main thread scrolling reasons require fully updating paint propeties of all
1761 // ancestors (see: ScrollPaintPropertyNode.h).
1762 void setAncestorsNeedPaintPropertyUpdateForMainThreadScrolling();
1756 1763
1757 void setIsScrollAnchorObject() { m_bitfields.setIsScrollAnchorObject(true); } 1764 void setIsScrollAnchorObject() { m_bitfields.setIsScrollAnchorObject(true); }
1758 // Clears the IsScrollAnchorObject bit if and only if no ScrollAnchors still 1765 // Clears the IsScrollAnchorObject bit if and only if no ScrollAnchors still
1759 // reference this LayoutObject. 1766 // reference this LayoutObject.
1760 void maybeClearIsScrollAnchorObject(); 1767 void maybeClearIsScrollAnchorObject();
1761 1768
1762 bool scrollAnchorDisablingStyleChanged() { 1769 bool scrollAnchorDisablingStyleChanged() {
1763 return m_bitfields.scrollAnchorDisablingStyleChanged(); 1770 return m_bitfields.scrollAnchorDisablingStyleChanged();
1764 } 1771 }
1765 void setScrollAnchorDisablingStyleChanged(bool changed) { 1772 void setScrollAnchorDisablingStyleChanged(bool changed) {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 return isText() || (isSVG() && !isSVGRoot()); 2054 return isText() || (isSVG() && !isSVGRoot());
2048 } 2055 }
2049 2056
2050 static bool isAllowedToModifyLayoutTreeStructure(Document&); 2057 static bool isAllowedToModifyLayoutTreeStructure(Document&);
2051 2058
2052 // Returns the parent for paint invalidation. 2059 // Returns the parent for paint invalidation.
2053 // - For LayoutView, returns the owner layout object in the containing frame 2060 // - For LayoutView, returns the owner layout object in the containing frame
2054 // if any or nullptr; 2061 // if any or nullptr;
2055 // - For multi-column spanner, returns the spanner placeholder; 2062 // - For multi-column spanner, returns the spanner placeholder;
2056 // - Otherwise returns parent(). 2063 // - Otherwise returns parent().
2057 LayoutObject* paintInvalidationParent() const; 2064 inline LayoutObject* paintInvalidationParent() const;
2065 LayoutObject* slowPaintInvalidationParentForTesting() const;
Xianzhu 2016/11/23 00:12:48 I wonder if it works to omit 'inline' in header bu
2058 2066
2059 RefPtr<ComputedStyle> m_style; 2067 RefPtr<ComputedStyle> m_style;
2060 2068
2061 // Oilpan: This untraced pointer to the owning Node is considered safe. 2069 // Oilpan: This untraced pointer to the owning Node is considered safe.
2062 UntracedMember<Node> m_node; 2070 UntracedMember<Node> m_node;
2063 2071
2064 LayoutObject* m_parent; 2072 LayoutObject* m_parent;
2065 LayoutObject* m_previous; 2073 LayoutObject* m_previous;
2066 LayoutObject* m_next; 2074 LayoutObject* m_next;
2067 2075
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 m_alwaysCreateLineBoxesForLayoutInline(false), 2150 m_alwaysCreateLineBoxesForLayoutInline(false),
2143 m_previousBackgroundObscured(false), 2151 m_previousBackgroundObscured(false),
2144 m_isBackgroundAttachmentFixedObject(false), 2152 m_isBackgroundAttachmentFixedObject(false),
2145 m_isScrollAnchorObject(false), 2153 m_isScrollAnchorObject(false),
2146 m_scrollAnchorDisablingStyleChanged(false), 2154 m_scrollAnchorDisablingStyleChanged(false),
2147 m_hasBoxDecorationBackground(false), 2155 m_hasBoxDecorationBackground(false),
2148 m_hasPreviousLocationInBacking(false), 2156 m_hasPreviousLocationInBacking(false),
2149 m_hasPreviousSelectionVisualRect(false), 2157 m_hasPreviousSelectionVisualRect(false),
2150 m_hasPreviousBoxGeometries(false), 2158 m_hasPreviousBoxGeometries(false),
2151 m_needsPaintPropertyUpdate(true), 2159 m_needsPaintPropertyUpdate(true),
2160 m_descendantNeedsPaintPropertyUpdate(true),
2152 m_backgroundChangedSinceLastPaintInvalidation(false), 2161 m_backgroundChangedSinceLastPaintInvalidation(false),
2153 m_positionedState(IsStaticallyPositioned), 2162 m_positionedState(IsStaticallyPositioned),
2154 m_selectionState(SelectionNone), 2163 m_selectionState(SelectionNone),
2155 m_backgroundObscurationState(BackgroundObscurationStatusInvalid), 2164 m_backgroundObscurationState(BackgroundObscurationStatusInvalid),
2156 m_fullPaintInvalidationReason(PaintInvalidationNone) {} 2165 m_fullPaintInvalidationReason(PaintInvalidationNone) {}
2157 2166
2158 // Self needs layout means that this layout object is marked for a full 2167 // Self needs layout means that this layout object is marked for a full
2159 // layout. This is the default layout but it is expensive as it recomputes 2168 // layout. This is the default layout but it is expensive as it recomputes
2160 // everything. For CSS boxes, this includes the width (laying out the line 2169 // everything. For CSS boxes, this includes the width (laying out the line
2161 // boxes again), the margins (due to block collapsing margins), the 2170 // boxes again), the margins (due to block collapsing margins), the
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 2323
2315 ADD_BOOLEAN_BITFIELD(hasPreviousLocationInBacking, 2324 ADD_BOOLEAN_BITFIELD(hasPreviousLocationInBacking,
2316 HasPreviousLocationInBacking); 2325 HasPreviousLocationInBacking);
2317 ADD_BOOLEAN_BITFIELD(hasPreviousSelectionVisualRect, 2326 ADD_BOOLEAN_BITFIELD(hasPreviousSelectionVisualRect,
2318 HasPreviousSelectionVisualRect); 2327 HasPreviousSelectionVisualRect);
2319 ADD_BOOLEAN_BITFIELD(hasPreviousBoxGeometries, HasPreviousBoxGeometries); 2328 ADD_BOOLEAN_BITFIELD(hasPreviousBoxGeometries, HasPreviousBoxGeometries);
2320 2329
2321 // Whether the paint properties need to be updated. For more details, see 2330 // Whether the paint properties need to be updated. For more details, see
2322 // LayoutObject::needsPaintPropertyUpdate(). 2331 // LayoutObject::needsPaintPropertyUpdate().
2323 ADD_BOOLEAN_BITFIELD(needsPaintPropertyUpdate, NeedsPaintPropertyUpdate); 2332 ADD_BOOLEAN_BITFIELD(needsPaintPropertyUpdate, NeedsPaintPropertyUpdate);
2333 // Whether the paint properties of a descendant need to be updated. For more
2334 // details, see LayoutObject::descendantNeedsPaintPropertyUpdate().
2335 ADD_BOOLEAN_BITFIELD(descendantNeedsPaintPropertyUpdate,
2336 DescendantNeedsPaintPropertyUpdate);
2324 2337
2325 ADD_BOOLEAN_BITFIELD(backgroundChangedSinceLastPaintInvalidation, 2338 ADD_BOOLEAN_BITFIELD(backgroundChangedSinceLastPaintInvalidation,
2326 BackgroundChangedSinceLastPaintInvalidation); 2339 BackgroundChangedSinceLastPaintInvalidation);
2327 2340
2328 protected: 2341 protected:
2329 // Use protected to avoid warning about unused variable. 2342 // Use protected to avoid warning about unused variable.
2330 unsigned m_unusedBits : 8; 2343 unsigned m_unusedBits : 7;
2331 2344
2332 private: 2345 private:
2333 // This is the cached 'position' value of this object 2346 // This is the cached 'position' value of this object
2334 // (see ComputedStyle::position). 2347 // (see ComputedStyle::position).
2335 unsigned m_positionedState : 2; // PositionedState 2348 unsigned m_positionedState : 2; // PositionedState
2336 unsigned m_selectionState : 3; // SelectionState 2349 unsigned m_selectionState : 3; // SelectionState
2337 // Mutable for getter which lazily update this field. 2350 // Mutable for getter which lazily update this field.
2338 mutable unsigned 2351 mutable unsigned
2339 m_backgroundObscurationState : 2; // BackgroundObscurationState 2352 m_backgroundObscurationState : 2; // BackgroundObscurationState
2340 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason 2353 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 CORE_EXPORT void showLineTree(const blink::LayoutObject*); 2658 CORE_EXPORT void showLineTree(const blink::LayoutObject*);
2646 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); 2659 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1);
2647 // We don't make object2 an optional parameter so that showLayoutTree 2660 // We don't make object2 an optional parameter so that showLayoutTree
2648 // can be called from gdb easily. 2661 // can be called from gdb easily.
2649 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, 2662 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1,
2650 const blink::LayoutObject* object2); 2663 const blink::LayoutObject* object2);
2651 2664
2652 #endif 2665 #endif
2653 2666
2654 #endif // LayoutObject_h 2667 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.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