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

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

Issue 2203933002: Replace LayoutObject::skipInvalidationWhenLaidOutChildren() with paintedOutputOfObjectHasNoEffect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix first line invalidation issue Created 4 years, 4 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. All r ights reserved. 6 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2009 Google Inc. All rights reserved. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 348
349 void assertSubtreeClearedPaintInvalidationFlags() const 349 void assertSubtreeClearedPaintInvalidationFlags() const
350 { 350 {
351 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder()) 351 for (const LayoutObject* layoutObject = this; layoutObject; layoutObject = layoutObject->nextInPreOrder())
352 layoutObject->assertClearedPaintInvalidationFlags(); 352 layoutObject->assertClearedPaintInvalidationFlags();
353 } 353 }
354 354
355 #endif 355 #endif
356 356
357 // Correct version of !layoutObjectHasNoBoxEffectObsolete().
358 bool hasBoxEffect() const
359 {
360 return hasBoxDecorationBackground() || style()->hasVisualOverflowingEffe ct();
361 }
362
363 // LayoutObject tree manipulation 357 // LayoutObject tree manipulation
364 ////////////////////////////////////////// 358 //////////////////////////////////////////
365 virtual bool canHaveChildren() const { return virtualChildren(); } 359 virtual bool canHaveChildren() const { return virtualChildren(); }
366 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const { ret urn true; } 360 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const { ret urn true; }
367 361
368 // This function is called whenever a child is inserted under |this|. 362 // This function is called whenever a child is inserted under |this|.
369 // 363 //
370 // The main purpose of this function is to generate a consistent layout 364 // The main purpose of this function is to generate a consistent layout
371 // tree, which means generating the missing anonymous objects. Most of the 365 // tree, which means generating the missing anonymous objects. Most of the
372 // time there'll be no anonymous objects to generate. 366 // time there'll be no anonymous objects to generate.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag ; } 431 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag ; }
438 #endif 432 #endif
439 433
440 void addAbsoluteRectForLayer(IntRect& result); 434 void addAbsoluteRectForLayer(IntRect& result);
441 bool requiresAnonymousTableWrappers(const LayoutObject*) const; 435 bool requiresAnonymousTableWrappers(const LayoutObject*) const;
442 436
443 // Gets pseudoStyle from Shadow host(in case of input elements) 437 // Gets pseudoStyle from Shadow host(in case of input elements)
444 // or from Parent element. 438 // or from Parent element.
445 PassRefPtr<ComputedStyle> getUncachedPseudoStyleFromParentOrShadowHost() con st; 439 PassRefPtr<ComputedStyle> getUncachedPseudoStyleFromParentOrShadowHost() con st;
446 440
447 bool skipInvalidationWhenLaidOutChildren() const;
448
449 public: 441 public:
450 #ifndef NDEBUG 442 #ifndef NDEBUG
451 void showTreeForThis() const; 443 void showTreeForThis() const;
452 void showLayoutTreeForThis() const; 444 void showLayoutTreeForThis() const;
453 void showLineTreeForThis() const; 445 void showLineTreeForThis() const;
454 446
455 void showLayoutObject() const; 447 void showLayoutObject() const;
456 // We don't make stringBuilder an optional parameter so that 448 // We don't make stringBuilder an optional parameter so that
457 // showLayoutObject can be called from gdb easily. 449 // showLayoutObject can be called from gdb easily.
458 void showLayoutObject(StringBuilder&) const; 450 void showLayoutObject(StringBuilder&) const;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 enum BoxDecorationBackgroundState { 679 enum BoxDecorationBackgroundState {
688 NoBoxDecorationBackground, 680 NoBoxDecorationBackground,
689 HasBoxDecorationBackgroundObscurationStatusInvalid, 681 HasBoxDecorationBackgroundObscurationStatusInvalid,
690 HasBoxDecorationBackgroundKnownToBeObscured, 682 HasBoxDecorationBackgroundKnownToBeObscured,
691 HasBoxDecorationBackgroundMayBeVisible, 683 HasBoxDecorationBackgroundMayBeVisible,
692 }; 684 };
693 bool hasBoxDecorationBackground() const { return m_bitfields.getBoxDecoratio nBackgroundState() != NoBoxDecorationBackground; } 685 bool hasBoxDecorationBackground() const { return m_bitfields.getBoxDecoratio nBackgroundState() != NoBoxDecorationBackground; }
694 bool boxDecorationBackgroundIsKnownToBeObscured() const; 686 bool boxDecorationBackgroundIsKnownToBeObscured() const;
695 bool hasBackground() const { return style()->hasBackground(); } 687 bool hasBackground() const { return style()->hasBackground(); }
696 688
697 bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNee dsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayo ut(); }
698
699 bool needsLayout() const 689 bool needsLayout() const
700 { 690 {
701 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout() 691 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout()
702 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout(); 692 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout();
703 } 693 }
704 694
705 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); } 695 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); }
706 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); } 696 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); }
707 697
708 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); } 698 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 // Invalidate the paint of a specific subrectangle within a given object. Th e rect is in the object's coordinate space. 1114 // Invalidate the paint of a specific subrectangle within a given object. Th e rect is in the object's coordinate space.
1125 void invalidatePaintRectangle(const LayoutRect&) const; 1115 void invalidatePaintRectangle(const LayoutRect&) const;
1126 1116
1127 // Walk the tree after layout issuing paint invalidations for layoutObjects that have changed or moved, updating bounds that have changed, and clearing pain t invalidation state. 1117 // Walk the tree after layout issuing paint invalidations for layoutObjects that have changed or moved, updating bounds that have changed, and clearing pain t invalidation state.
1128 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&); 1118 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
1129 1119
1130 void invalidatePaintIncludingNonCompositingDescendants(); 1120 void invalidatePaintIncludingNonCompositingDescendants();
1131 void invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBox ModelObject& paintInvalidationContainer); 1121 void invalidatePaintIncludingNonSelfPaintingLayerDescendants(const LayoutBox ModelObject& paintInvalidationContainer);
1132 void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); 1122 void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants();
1133 1123
1124 // Returns true if the object will not generate any effective painted output .
1125 // It's used to skip unforced paint invalidation (which is when shouldDoFull PaintInvalidation
1126 // is false, but mayNeedPaintInvalidation or childShouldCheckForPaintInvalid ation is true) to
1127 // avoid unnecessary paint invalidations of empty areas covered by such obje cts.
1128 virtual bool paintedOutputOfObjectHasNoEffect() const { return false; }
1129
1134 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's 1130 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
1135 // coordinate space. This method deals with outlines and overflow. 1131 // coordinate space. This method deals with outlines and overflow.
1136 virtual LayoutRect absoluteClippedOverflowRect() const; 1132 virtual LayoutRect absoluteClippedOverflowRect() const;
1137 1133
1138 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the object's 1134 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the object's
1139 // local coordinate space. This is for non-SVG objects and LayoutSVGRoot onl y. SVG objects (except LayoutSVGRoot) 1135 // local coordinate space. This is for non-SVG objects and LayoutSVGRoot onl y. SVG objects (except LayoutSVGRoot)
1140 // should use paintInvalidationRectInLocalSVGCoordinates() and map with SVG transforms instead. 1136 // should use paintInvalidationRectInLocalSVGCoordinates() and map with SVG transforms instead.
1141 virtual LayoutRect localOverflowRectForPaintInvalidation() const; 1137 virtual LayoutRect localOverflowRectForPaintInvalidation() const;
1142 1138
1143 // Given a rect in the object's coordinate space, mutates the rect into one representing the size of its visual painted 1139 // Given a rect in the object's coordinate space, mutates the rect into one representing the size of its visual painted
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 // 1544 //
1549 // If we don't meet the criteria for an incremental paint, the 1545 // If we don't meet the criteria for an incremental paint, the
1550 // alternative is a full paint invalidation. 1546 // alternative is a full paint invalidation.
1551 virtual void incrementallyInvalidatePaint(const LayoutBoxModelObject& paintI nvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationBacking); 1547 virtual void incrementallyInvalidatePaint(const LayoutBoxModelObject& paintI nvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const LayoutPoint& positionFromPaintInvalidationBacking);
1552 1548
1553 virtual bool hasNonCompositedScrollbars() const { return false; } 1549 virtual bool hasNonCompositedScrollbars() const { return false; }
1554 1550
1555 #if ENABLE(ASSERT) 1551 #if ENABLE(ASSERT)
1556 virtual bool paintInvalidationStateIsDirty() const 1552 virtual bool paintInvalidationStateIsDirty() const
1557 { 1553 {
1558 return m_bitfields.neededLayoutBecauseOfChildren() || shouldCheckForPain tInvalidationRegardlessOfPaintInvalidationState(); 1554 return shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState ();
1559 } 1555 }
1560 #endif 1556 #endif
1561 1557
1562 // This function walks the descendants of |this|, following a 1558 // This function walks the descendants of |this|, following a
1563 // layout ordering. 1559 // layout ordering.
1564 // 1560 //
1565 // The ordering is important for PaintInvalidationState, as 1561 // The ordering is important for PaintInvalidationState, as
1566 // it requires to be called following a descendant/container 1562 // it requires to be called following a descendant/container
1567 // relationship. 1563 // relationship.
1568 // 1564 //
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 , m_normalChildNeedsLayout(false) 1737 , m_normalChildNeedsLayout(false)
1742 , m_posChildNeedsLayout(false) 1738 , m_posChildNeedsLayout(false)
1743 , m_needsSimplifiedNormalFlowLayout(false) 1739 , m_needsSimplifiedNormalFlowLayout(false)
1744 , m_selfNeedsOverflowRecalcAfterStyleChange(false) 1740 , m_selfNeedsOverflowRecalcAfterStyleChange(false)
1745 , m_childNeedsOverflowRecalcAfterStyleChange(false) 1741 , m_childNeedsOverflowRecalcAfterStyleChange(false)
1746 , m_preferredLogicalWidthsDirty(false) 1742 , m_preferredLogicalWidthsDirty(false)
1747 , m_childShouldCheckForPaintInvalidation(false) 1743 , m_childShouldCheckForPaintInvalidation(false)
1748 , m_mayNeedPaintInvalidation(false) 1744 , m_mayNeedPaintInvalidation(false)
1749 , m_mayNeedPaintInvalidationSubtree(false) 1745 , m_mayNeedPaintInvalidationSubtree(false)
1750 , m_shouldInvalidateSelection(false) 1746 , m_shouldInvalidateSelection(false)
1751 , m_neededLayoutBecauseOfChildren(false)
1752 , m_floating(false) 1747 , m_floating(false)
1753 , m_isAnonymous(!node) 1748 , m_isAnonymous(!node)
1754 , m_isText(false) 1749 , m_isText(false)
1755 , m_isBox(false) 1750 , m_isBox(false)
1756 , m_isInline(true) 1751 , m_isInline(true)
1757 , m_isAtomicInlineLevel(false) 1752 , m_isAtomicInlineLevel(false)
1758 , m_horizontalWritingMode(true) 1753 , m_horizontalWritingMode(true)
1759 , m_isDragging(false) 1754 , m_isDragging(false)
1760 , m_hasLayer(false) 1755 , m_hasLayer(false)
1761 , m_hasOverflowClip(false) 1756 , m_hasOverflowClip(false)
(...skipping 13 matching lines...) Expand all
1775 , m_lastBoxDecorationBackgroundObscured(false) 1770 , m_lastBoxDecorationBackgroundObscured(false)
1776 , m_isBackgroundAttachmentFixedObject(false) 1771 , m_isBackgroundAttachmentFixedObject(false)
1777 , m_isScrollAnchorObject(false) 1772 , m_isScrollAnchorObject(false)
1778 , m_positionedState(IsStaticallyPositioned) 1773 , m_positionedState(IsStaticallyPositioned)
1779 , m_selectionState(SelectionNone) 1774 , m_selectionState(SelectionNone)
1780 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) 1775 , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
1781 , m_fullPaintInvalidationReason(PaintInvalidationNone) 1776 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1782 { 1777 {
1783 } 1778 }
1784 1779
1785 // 32 bits have been used in the first word, and 17 in the second. 1780 // 32 bits have been used in the first word, and 16 in the second.
1786 1781
1787 // Self needs layout means that this layout object is marked for a full layout. 1782 // Self needs layout means that this layout object is marked for a full layout.
1788 // This is the default layout but it is expensive as it recomputes every thing. 1783 // This is the default layout but it is expensive as it recomputes every thing.
1789 // For CSS boxes, this includes the width (laying out the line boxes aga in), the margins 1784 // For CSS boxes, this includes the width (laying out the line boxes aga in), the margins
1790 // (due to block collapsing margins), the positions, the height and the potential overflow. 1785 // (due to block collapsing margins), the positions, the height and the potential overflow.
1791 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); 1786 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1792 1787
1793 // A positioned movement layout is a specialized type of layout used on positioned objects 1788 // A positioned movement layout is a specialized type of layout used on positioned objects
1794 // that only visually moved. This layout is used when changing 'top'/'le ft' on a positioned 1789 // that only visually moved. This layout is used when changing 'top'/'le ft' on a positioned
1795 // element or margins on an out-of-flow one. Because the following opera tions don't impact 1790 // element or margins on an out-of-flow one. Because the following opera tions don't impact
(...skipping 30 matching lines...) Expand all
1826 1821
1827 // This boolean marks preferred logical widths for lazy recomputation. 1822 // This boolean marks preferred logical widths for lazy recomputation.
1828 // 1823 //
1829 // See INTRINSIC SIZES / PREFERRED LOGICAL WIDTHS above about those 1824 // See INTRINSIC SIZES / PREFERRED LOGICAL WIDTHS above about those
1830 // widths. 1825 // widths.
1831 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty); 1826 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty);
1832 1827
1833 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); 1828 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation);
1834 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; 1829 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ;
1835 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidationSubtree, MayNeedPaintInvali dationSubtree); 1830 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidationSubtree, MayNeedPaintInvali dationSubtree);
1836 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. 1831 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n);
1837 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2.
1838 1832
1839 // This boolean is the cached value of 'float' 1833 // This boolean is the cached value of 'float'
1840 // (see ComputedStyle::isFloating). 1834 // (see ComputedStyle::isFloating).
1841 ADD_BOOLEAN_BITFIELD(floating, Floating); 1835 ADD_BOOLEAN_BITFIELD(floating, Floating);
1842 1836
1843 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); 1837 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
1844 ADD_BOOLEAN_BITFIELD(isText, IsText); 1838 ADD_BOOLEAN_BITFIELD(isText, IsText);
1845 ADD_BOOLEAN_BITFIELD(isBox, IsBox); 1839 ADD_BOOLEAN_BITFIELD(isBox, IsBox);
1846 1840
1847 // This boolean represents whether the LayoutObject is 'inline-level' 1841 // This boolean represents whether the LayoutObject is 'inline-level'
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 { 2038 {
2045 setNeedsLayout(reason, markParents, layouter); 2039 setNeedsLayout(reason, markParents, layouter);
2046 setShouldDoFullPaintInvalidation(); 2040 setShouldDoFullPaintInvalidation();
2047 } 2041 }
2048 2042
2049 inline void LayoutObject::clearNeedsLayout() 2043 inline void LayoutObject::clearNeedsLayout()
2050 { 2044 {
2051 // Set flags for later stages/cycles. 2045 // Set flags for later stages/cycles.
2052 setEverHadLayout(); 2046 setEverHadLayout();
2053 setMayNeedPaintInvalidation(); 2047 setMayNeedPaintInvalidation();
2054 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ;
2055 2048
2056 // Clear needsLayout flags. 2049 // Clear needsLayout flags.
2057 setSelfNeedsLayout(false); 2050 setSelfNeedsLayout(false);
2058 setPosChildNeedsLayout(false); 2051 setPosChildNeedsLayout(false);
2059 setNeedsSimplifiedNormalFlowLayout(false); 2052 setNeedsSimplifiedNormalFlowLayout(false);
2060 setNormalChildNeedsLayout(false); 2053 setNormalChildNeedsLayout(false);
2061 setNeedsPositionedMovementLayout(false); 2054 setNeedsPositionedMovementLayout(false);
2062 setAncestorLineBoxDirty(false); 2055 setAncestorLineBoxDirty(false);
2063 2056
2064 #if ENABLE(ASSERT) 2057 #if ENABLE(ASSERT)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 void showTree(const blink::LayoutObject*); 2180 void showTree(const blink::LayoutObject*);
2188 void showLineTree(const blink::LayoutObject*); 2181 void showLineTree(const blink::LayoutObject*);
2189 void showLayoutTree(const blink::LayoutObject* object1); 2182 void showLayoutTree(const blink::LayoutObject* object1);
2190 // We don't make object2 an optional parameter so that showLayoutTree 2183 // We don't make object2 an optional parameter so that showLayoutTree
2191 // can be called from gdb easily. 2184 // can be called from gdb easily.
2192 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 2185 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
2193 2186
2194 #endif 2187 #endif
2195 2188
2196 #endif // LayoutObject_h 2189 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.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