Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 setDescendantNeedsPaintPropertyUpdate() { | |
|
chrishtr
2016/11/21 19:23:03
Why do these need to be exposed publicly? Shouldn'
pdr.
2016/11/21 19:28:17
Good catch, was blindly following the original cod
| |
| 1711 m_layoutObject.setDescendantNeedsPaintPropertyUpdate(); | |
| 1712 } | |
| 1713 void clearDescendantNeedsPaintPropertyUpdate() { | |
| 1714 m_layoutObject.clearDescendantNeedsPaintPropertyUpdate(); | |
| 1715 } | |
| 1710 | 1716 |
| 1711 protected: | 1717 protected: |
| 1712 friend class PaintPropertyTreeBuilder; | 1718 friend class PaintPropertyTreeBuilder; |
| 1713 // The following two functions can be called from PaintPropertyTreeBuilder | 1719 // The following two functions can be called from PaintPropertyTreeBuilder |
| 1714 // only. | 1720 // only. |
| 1715 ObjectPaintProperties& ensurePaintProperties() { | 1721 ObjectPaintProperties& ensurePaintProperties() { |
| 1716 return m_layoutObject.ensurePaintProperties(); | 1722 return m_layoutObject.ensurePaintProperties(); |
| 1717 } | 1723 } |
| 1718 ObjectPaintProperties* paintProperties() { | 1724 ObjectPaintProperties* paintProperties() { |
| 1719 return const_cast<ObjectPaintProperties*>( | 1725 return const_cast<ObjectPaintProperties*>( |
| 1720 m_layoutObject.paintProperties()); | 1726 m_layoutObject.paintProperties()); |
| 1721 } | 1727 } |
| 1722 | 1728 |
| 1723 friend class LayoutObject; | 1729 friend class LayoutObject; |
| 1724 MutableForPainting(const LayoutObject& layoutObject) | 1730 MutableForPainting(const LayoutObject& layoutObject) |
| 1725 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {} | 1731 : m_layoutObject(const_cast<LayoutObject&>(layoutObject)) {} |
| 1726 | 1732 |
| 1727 LayoutObject& m_layoutObject; | 1733 LayoutObject& m_layoutObject; |
| 1728 }; | 1734 }; |
| 1729 MutableForPainting getMutableForPainting() const { | 1735 MutableForPainting getMutableForPainting() const { |
| 1730 return MutableForPainting(*this); | 1736 return MutableForPainting(*this); |
| 1731 } | 1737 } |
| 1732 | 1738 |
| 1733 // Paint properties (see: |ObjectPaintProperties|) are built from an object's | 1739 // Paint properties (see: |ObjectPaintProperties|) are built from an object's |
| 1734 // state (location, transform, etc) as well as properties from ancestors. | 1740 // state (location, transform, etc) as well as properties from ancestors. |
| 1735 // When these inputs change, setNeedsPaintPropertyUpdate will cause a property | 1741 // When these inputs change, setNeedsPaintPropertyUpdate will cause a property |
| 1736 // tree update during the next document lifecycle update. | 1742 // tree update during the next document lifecycle update. |
| 1737 // TODO(pdr): Add additional granularity such as the ability to signal that | 1743 // |
| 1738 // only a local paint property update is needed. | 1744 // In addition to tracking if an object needs its own paint properties |
| 1745 // updated, |descendantNeedsPaintPropertyUpdate| is used to track if any | |
| 1746 // descendant needs an update too. This bit is up the tree, crossing frames. | |
| 1747 // | |
| 1748 // TODO(pdr): We may want to add more granular paint property update types | |
| 1749 // such as the ability to only update one property type. | |
| 1739 void setNeedsPaintPropertyUpdate() { | 1750 void setNeedsPaintPropertyUpdate() { |
| 1740 m_bitfields.setNeedsPaintPropertyUpdate(true); | 1751 m_bitfields.setNeedsPaintPropertyUpdate(true); |
| 1752 // TODO(pdr): paintInvalidationParent is not inlined. May want to optimize | |
| 1753 // this to check m_parent first. | |
|
Xianzhu
2016/11/21 19:41:34
I suspect if the TODO would work because even if m
pdr.
2016/11/22 02:55:35
I was thinking more about optimizing the case when
| |
| 1754 if (auto* parent = paintInvalidationParent()) | |
| 1755 parent->setDescendantNeedsPaintPropertyUpdate(); | |
| 1741 } | 1756 } |
| 1742 // TODO(pdr): This can be removed once we have more granular update flags. | 1757 void setDescendantNeedsPaintPropertyUpdate() { |
| 1758 if (!m_bitfields.descendantNeedsPaintPropertyUpdate()) { | |
| 1759 m_bitfields.setDescendantNeedsPaintPropertyUpdate(true); | |
| 1760 // TODO(pdr): paintInvalidationParent is not inlined. May want to optimize | |
| 1761 // this to check m_parent first. | |
| 1762 if (auto* parent = paintInvalidationParent()) | |
| 1763 parent->setDescendantNeedsPaintPropertyUpdate(); | |
| 1764 } else { | |
| 1765 auto* parent = paintInvalidationParent(); | |
| 1766 DCHECK(!parent || parent->descendantNeedsPaintPropertyUpdate()); | |
| 1767 } | |
| 1768 } | |
|
Xianzhu
2016/11/21 19:41:34
Could the impl be moved into LayoutObject.cpp and
pdr.
2016/11/22 02:55:35
Good ideas.
I modified your approach slightly:
*
| |
| 1743 void setAllAncestorsNeedPaintPropertyUpdate() { | 1769 void setAllAncestorsNeedPaintPropertyUpdate() { |
| 1744 if (m_parent) { | 1770 if (auto* parent = paintInvalidationParent()) { |
| 1745 m_parent->setNeedsPaintPropertyUpdate(); | 1771 parent->setNeedsPaintPropertyUpdate(); |
| 1746 m_parent->setAllAncestorsNeedPaintPropertyUpdate(); | 1772 parent->setAllAncestorsNeedPaintPropertyUpdate(); |
| 1747 } | 1773 } |
| 1748 } | 1774 } |
|
Xianzhu
2016/11/21 19:41:34
Where will this function be used?
pdr.
2016/11/22 02:55:35
setAllAncestorsNeedPaintPropertyUpdate is used for
| |
| 1749 void clearNeedsPaintPropertyUpdate() { | 1775 void clearNeedsPaintPropertyUpdate() { |
| 1750 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint); | 1776 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint); |
| 1751 m_bitfields.setNeedsPaintPropertyUpdate(false); | 1777 m_bitfields.setNeedsPaintPropertyUpdate(false); |
| 1752 } | 1778 } |
| 1753 bool needsPaintPropertyUpdate() const { | 1779 bool needsPaintPropertyUpdate() const { |
| 1754 return m_bitfields.needsPaintPropertyUpdate(); | 1780 return m_bitfields.needsPaintPropertyUpdate(); |
| 1755 } | 1781 } |
| 1782 void clearDescendantNeedsPaintPropertyUpdate() { | |
| 1783 DCHECK_EQ(document().lifecycle().state(), DocumentLifecycle::InPrePaint); | |
| 1784 m_bitfields.setDescendantNeedsPaintPropertyUpdate(false); | |
| 1785 } | |
| 1786 bool descendantNeedsPaintPropertyUpdate() const { | |
| 1787 return m_bitfields.descendantNeedsPaintPropertyUpdate(); | |
| 1788 } | |
| 1756 | 1789 |
| 1757 void setIsScrollAnchorObject() { m_bitfields.setIsScrollAnchorObject(true); } | 1790 void setIsScrollAnchorObject() { m_bitfields.setIsScrollAnchorObject(true); } |
| 1758 // Clears the IsScrollAnchorObject bit if and only if no ScrollAnchors still | 1791 // Clears the IsScrollAnchorObject bit if and only if no ScrollAnchors still |
| 1759 // reference this LayoutObject. | 1792 // reference this LayoutObject. |
| 1760 void maybeClearIsScrollAnchorObject(); | 1793 void maybeClearIsScrollAnchorObject(); |
| 1761 | 1794 |
| 1762 bool scrollAnchorDisablingStyleChanged() { | 1795 bool scrollAnchorDisablingStyleChanged() { |
| 1763 return m_bitfields.scrollAnchorDisablingStyleChanged(); | 1796 return m_bitfields.scrollAnchorDisablingStyleChanged(); |
| 1764 } | 1797 } |
| 1765 void setScrollAnchorDisablingStyleChanged(bool changed) { | 1798 void setScrollAnchorDisablingStyleChanged(bool changed) { |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2142 m_alwaysCreateLineBoxesForLayoutInline(false), | 2175 m_alwaysCreateLineBoxesForLayoutInline(false), |
| 2143 m_previousBackgroundObscured(false), | 2176 m_previousBackgroundObscured(false), |
| 2144 m_isBackgroundAttachmentFixedObject(false), | 2177 m_isBackgroundAttachmentFixedObject(false), |
| 2145 m_isScrollAnchorObject(false), | 2178 m_isScrollAnchorObject(false), |
| 2146 m_scrollAnchorDisablingStyleChanged(false), | 2179 m_scrollAnchorDisablingStyleChanged(false), |
| 2147 m_hasBoxDecorationBackground(false), | 2180 m_hasBoxDecorationBackground(false), |
| 2148 m_hasPreviousLocationInBacking(false), | 2181 m_hasPreviousLocationInBacking(false), |
| 2149 m_hasPreviousSelectionVisualRect(false), | 2182 m_hasPreviousSelectionVisualRect(false), |
| 2150 m_hasPreviousBoxGeometries(false), | 2183 m_hasPreviousBoxGeometries(false), |
| 2151 m_needsPaintPropertyUpdate(true), | 2184 m_needsPaintPropertyUpdate(true), |
| 2185 m_descendantNeedsPaintPropertyUpdate(true), | |
| 2152 m_backgroundChangedSinceLastPaintInvalidation(false), | 2186 m_backgroundChangedSinceLastPaintInvalidation(false), |
| 2153 m_positionedState(IsStaticallyPositioned), | 2187 m_positionedState(IsStaticallyPositioned), |
| 2154 m_selectionState(SelectionNone), | 2188 m_selectionState(SelectionNone), |
| 2155 m_backgroundObscurationState(BackgroundObscurationStatusInvalid), | 2189 m_backgroundObscurationState(BackgroundObscurationStatusInvalid), |
| 2156 m_fullPaintInvalidationReason(PaintInvalidationNone) {} | 2190 m_fullPaintInvalidationReason(PaintInvalidationNone) {} |
| 2157 | 2191 |
| 2158 // Self needs layout means that this layout object is marked for a full | 2192 // 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 | 2193 // 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 | 2194 // everything. For CSS boxes, this includes the width (laying out the line |
| 2161 // boxes again), the margins (due to block collapsing margins), the | 2195 // boxes again), the margins (due to block collapsing margins), the |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2314 | 2348 |
| 2315 ADD_BOOLEAN_BITFIELD(hasPreviousLocationInBacking, | 2349 ADD_BOOLEAN_BITFIELD(hasPreviousLocationInBacking, |
| 2316 HasPreviousLocationInBacking); | 2350 HasPreviousLocationInBacking); |
| 2317 ADD_BOOLEAN_BITFIELD(hasPreviousSelectionVisualRect, | 2351 ADD_BOOLEAN_BITFIELD(hasPreviousSelectionVisualRect, |
| 2318 HasPreviousSelectionVisualRect); | 2352 HasPreviousSelectionVisualRect); |
| 2319 ADD_BOOLEAN_BITFIELD(hasPreviousBoxGeometries, HasPreviousBoxGeometries); | 2353 ADD_BOOLEAN_BITFIELD(hasPreviousBoxGeometries, HasPreviousBoxGeometries); |
| 2320 | 2354 |
| 2321 // Whether the paint properties need to be updated. For more details, see | 2355 // Whether the paint properties need to be updated. For more details, see |
| 2322 // LayoutObject::needsPaintPropertyUpdate(). | 2356 // LayoutObject::needsPaintPropertyUpdate(). |
| 2323 ADD_BOOLEAN_BITFIELD(needsPaintPropertyUpdate, NeedsPaintPropertyUpdate); | 2357 ADD_BOOLEAN_BITFIELD(needsPaintPropertyUpdate, NeedsPaintPropertyUpdate); |
| 2358 // Whether the paint properties of a descendant need to be updated. For more | |
| 2359 // details, see LayoutObject::descendantNeedsPaintPropertyUpdate(). | |
| 2360 ADD_BOOLEAN_BITFIELD(descendantNeedsPaintPropertyUpdate, | |
| 2361 DescendantNeedsPaintPropertyUpdate); | |
| 2324 | 2362 |
| 2325 ADD_BOOLEAN_BITFIELD(backgroundChangedSinceLastPaintInvalidation, | 2363 ADD_BOOLEAN_BITFIELD(backgroundChangedSinceLastPaintInvalidation, |
| 2326 BackgroundChangedSinceLastPaintInvalidation); | 2364 BackgroundChangedSinceLastPaintInvalidation); |
| 2327 | 2365 |
| 2328 protected: | 2366 protected: |
| 2329 // Use protected to avoid warning about unused variable. | 2367 // Use protected to avoid warning about unused variable. |
| 2330 unsigned m_unusedBits : 8; | 2368 unsigned m_unusedBits : 7; |
| 2331 | 2369 |
| 2332 private: | 2370 private: |
| 2333 // This is the cached 'position' value of this object | 2371 // This is the cached 'position' value of this object |
| 2334 // (see ComputedStyle::position). | 2372 // (see ComputedStyle::position). |
| 2335 unsigned m_positionedState : 2; // PositionedState | 2373 unsigned m_positionedState : 2; // PositionedState |
| 2336 unsigned m_selectionState : 3; // SelectionState | 2374 unsigned m_selectionState : 3; // SelectionState |
| 2337 // Mutable for getter which lazily update this field. | 2375 // Mutable for getter which lazily update this field. |
| 2338 mutable unsigned | 2376 mutable unsigned |
| 2339 m_backgroundObscurationState : 2; // BackgroundObscurationState | 2377 m_backgroundObscurationState : 2; // BackgroundObscurationState |
| 2340 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason | 2378 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2645 CORE_EXPORT void showLineTree(const blink::LayoutObject*); | 2683 CORE_EXPORT void showLineTree(const blink::LayoutObject*); |
| 2646 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); | 2684 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1); |
| 2647 // We don't make object2 an optional parameter so that showLayoutTree | 2685 // We don't make object2 an optional parameter so that showLayoutTree |
| 2648 // can be called from gdb easily. | 2686 // can be called from gdb easily. |
| 2649 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, | 2687 CORE_EXPORT void showLayoutTree(const blink::LayoutObject* object1, |
| 2650 const blink::LayoutObject* object2); | 2688 const blink::LayoutObject* object2); |
| 2651 | 2689 |
| 2652 #endif | 2690 #endif |
| 2653 | 2691 |
| 2654 #endif // LayoutObject_h | 2692 #endif // LayoutObject_h |
| OLD | NEW |