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

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

Issue 2225033003: Separate backgroundObscurationStatus and hasBoxDecorationBackground (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 bool isDragging() const { return m_bitfields.isDragging(); } 666 bool isDragging() const { return m_bitfields.isDragging(); }
667 bool isAtomicInlineLevel() const { return m_bitfields.isAtomicInlineLevel(); } 667 bool isAtomicInlineLevel() const { return m_bitfields.isAtomicInlineLevel(); }
668 bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingM ode(); } 668 bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingM ode(); }
669 bool hasFlippedBlocksWritingMode() const 669 bool hasFlippedBlocksWritingMode() const
670 { 670 {
671 return style()->isFlippedBlocksWritingMode(); 671 return style()->isFlippedBlocksWritingMode();
672 } 672 }
673 673
674 bool hasLayer() const { return m_bitfields.hasLayer(); } 674 bool hasLayer() const { return m_bitfields.hasLayer(); }
675 675
676 // "Box decoration background" includes all box decorations and backgrounds 676 // This may be different from styleRef().hasBoxDecorationBackground() becaus e some objects may
677 // that are painted as the background of the object. It includes borders, 677 // have box decoration background other than from their own style.
678 // box-shadows, background-color and background-image, etc. 678 bool hasBoxDecorationBackground() const { return m_bitfields.hasBoxDecoratio nBackground(); }
679 enum BoxDecorationBackgroundState { 679
680 NoBoxDecorationBackground, 680 bool backgroundIsKnownToBeObscured() const;
681 HasBoxDecorationBackgroundObscurationStatusInvalid,
682 HasBoxDecorationBackgroundKnownToBeObscured,
683 HasBoxDecorationBackgroundMayBeVisible,
684 };
685 bool hasBoxDecorationBackground() const { return m_bitfields.getBoxDecoratio nBackgroundState() != NoBoxDecorationBackground; }
686 bool boxDecorationBackgroundIsKnownToBeObscured() const;
687 bool hasBackground() const { return style()->hasBackground(); }
688 681
689 bool needsLayout() const 682 bool needsLayout() const
690 { 683 {
691 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout() 684 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout()
692 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout(); 685 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout();
693 } 686 }
694 687
695 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); } 688 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); }
696 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); } 689 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); }
697 690
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 { 827 {
835 ASSERT((position != AbsolutePosition && position != FixedPosition) || is Box()); 828 ASSERT((position != AbsolutePosition && position != FixedPosition) || is Box());
836 m_bitfields.setPositionedState(position); 829 m_bitfields.setPositionedState(position);
837 } 830 }
838 void clearPositionedState() { m_bitfields.clearPositionedState(); } 831 void clearPositionedState() { m_bitfields.clearPositionedState(); }
839 832
840 void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); } 833 void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); }
841 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); } 834 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); }
842 835
843 void setHasBoxDecorationBackground(bool); 836 void setHasBoxDecorationBackground(bool);
837
838 enum BackgroundObscurationState {
839 BackgroundObscurationStatusInvalid,
840 BackgroundKnownToBeObscured,
841 BackgroundMayBeVisible,
842 };
844 void invalidateBackgroundObscurationStatus(); 843 void invalidateBackgroundObscurationStatus();
845 virtual bool computeBackgroundIsKnownToBeObscured() const { return false; } 844 virtual bool computeBackgroundIsKnownToBeObscured() const { return false; }
846 845
847 void setIsText() { m_bitfields.setIsText(true); } 846 void setIsText() { m_bitfields.setIsText(true); }
848 void setIsBox() { m_bitfields.setIsBox(true); } 847 void setIsBox() { m_bitfields.setIsBox(true); }
849 void setIsAtomicInlineLevel(bool isAtomicInlineLevel) { m_bitfields.setIsAto micInlineLevel(isAtomicInlineLevel); } 848 void setIsAtomicInlineLevel(bool isAtomicInlineLevel) { m_bitfields.setIsAto micInlineLevel(isAtomicInlineLevel); }
850 void setHorizontalWritingMode(bool hasHorizontalWritingMode) { m_bitfields.s etHorizontalWritingMode(hasHorizontalWritingMode); } 849 void setHorizontalWritingMode(bool hasHorizontalWritingMode) { m_bitfields.s etHorizontalWritingMode(hasHorizontalWritingMode); }
851 void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowCl ip(hasOverflowClip); } 850 void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowCl ip(hasOverflowClip); }
852 void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); } 851 void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); }
853 void setHasTransformRelatedProperty(bool hasTransform) { m_bitfields.setHasT ransformRelatedProperty(hasTransform); } 852 void setHasTransformRelatedProperty(bool hasTransform) { m_bitfields.setHasT ransformRelatedProperty(hasTransform); }
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 , m_everHadLayout(false) 1749 , m_everHadLayout(false)
1751 , m_ancestorLineBoxDirty(false) 1750 , m_ancestorLineBoxDirty(false)
1752 , m_hasPendingResourceUpdate(false) 1751 , m_hasPendingResourceUpdate(false)
1753 , m_isInsideFlowThread(false) 1752 , m_isInsideFlowThread(false)
1754 , m_subtreeChangeListenerRegistered(false) 1753 , m_subtreeChangeListenerRegistered(false)
1755 , m_notifiedOfSubtreeChange(false) 1754 , m_notifiedOfSubtreeChange(false)
1756 , m_consumesSubtreeChangeNotification(false) 1755 , m_consumesSubtreeChangeNotification(false)
1757 , m_childrenInline(false) 1756 , m_childrenInline(false)
1758 , m_containsInlineWithOutlineAndContinuation(false) 1757 , m_containsInlineWithOutlineAndContinuation(false)
1759 , m_alwaysCreateLineBoxesForLayoutInline(false) 1758 , m_alwaysCreateLineBoxesForLayoutInline(false)
1760 , m_lastBoxDecorationBackgroundObscured(false) 1759 , m_previousBackgroundObscured(false)
1761 , m_isBackgroundAttachmentFixedObject(false) 1760 , m_isBackgroundAttachmentFixedObject(false)
1762 , m_isScrollAnchorObject(false) 1761 , m_isScrollAnchorObject(false)
1762 , m_hasBoxDecorationBackground(false)
1763 , m_positionedState(IsStaticallyPositioned) 1763 , m_positionedState(IsStaticallyPositioned)
1764 , m_selectionState(SelectionNone) 1764 , m_selectionState(SelectionNone)
1765 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) 1765 , m_backgroundObscurationState(BackgroundObscurationStatusInvalid)
1766 , m_fullPaintInvalidationReason(PaintInvalidationNone) 1766 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1767 { 1767 {
1768 } 1768 }
1769 1769
1770 // 32 bits have been used in the first word, and 16 in the second. 1770 // 32 bits have been used in the first word, and 17 in the second.
1771 1771
1772 // Self needs layout means that this layout object is marked for a full layout. 1772 // Self needs layout means that this layout object is marked for a full layout.
1773 // This is the default layout but it is expensive as it recomputes every thing. 1773 // This is the default layout but it is expensive as it recomputes every thing.
1774 // For CSS boxes, this includes the width (laying out the line boxes aga in), the margins 1774 // For CSS boxes, this includes the width (laying out the line boxes aga in), the margins
1775 // (due to block collapsing margins), the positions, the height and the potential overflow. 1775 // (due to block collapsing margins), the positions, the height and the potential overflow.
1776 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); 1776 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1777 1777
1778 // A positioned movement layout is a specialized type of layout used on positioned objects 1778 // A positioned movement layout is a specialized type of layout used on positioned objects
1779 // that only visually moved. This layout is used when changing 'top'/'le ft' on a positioned 1779 // that only visually moved. This layout is used when changing 'top'/'le ft' on a positioned
1780 // element or margins on an out-of-flow one. Because the following opera tions don't impact 1780 // element or margins on an out-of-flow one. Because the following opera tions don't impact
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 1884
1885 // from LayoutBlock 1885 // from LayoutBlock
1886 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline); 1886 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1887 1887
1888 // from LayoutBlockFlow 1888 // from LayoutBlockFlow
1889 ADD_BOOLEAN_BITFIELD(containsInlineWithOutlineAndContinuation, ContainsI nlineWithOutlineAndContinuation); 1889 ADD_BOOLEAN_BITFIELD(containsInlineWithOutlineAndContinuation, ContainsI nlineWithOutlineAndContinuation);
1890 1890
1891 // from LayoutInline 1891 // from LayoutInline
1892 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForLayoutInline, AlwaysCreateL ineBoxesForLayoutInline); 1892 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForLayoutInline, AlwaysCreateL ineBoxesForLayoutInline);
1893 1893
1894 // For slimming-paint. 1894 // Background obscuration status of the previous frame.
1895 ADD_BOOLEAN_BITFIELD(lastBoxDecorationBackgroundObscured, LastBoxDecorat ionBackgroundObscured); 1895 ADD_BOOLEAN_BITFIELD(previousBackgroundObscured, PreviousBackgroundObscu red);
1896 1896
1897 ADD_BOOLEAN_BITFIELD(isBackgroundAttachmentFixedObject, IsBackgroundAtta chmentFixedObject); 1897 ADD_BOOLEAN_BITFIELD(isBackgroundAttachmentFixedObject, IsBackgroundAtta chmentFixedObject);
1898 ADD_BOOLEAN_BITFIELD(isScrollAnchorObject, IsScrollAnchorObject); 1898 ADD_BOOLEAN_BITFIELD(isScrollAnchorObject, IsScrollAnchorObject);
1899 1899
1900 ADD_BOOLEAN_BITFIELD(hasBoxDecorationBackground, HasBoxDecorationBackgro und);
1901
1900 private: 1902 private:
1901 // This is the cached 'position' value of this object 1903 // This is the cached 'position' value of this object
1902 // (see ComputedStyle::position). 1904 // (see ComputedStyle::position).
1903 unsigned m_positionedState : 2; // PositionedState 1905 unsigned m_positionedState : 2; // PositionedState
1904 unsigned m_selectionState : 3; // SelectionState 1906 unsigned m_selectionState : 3; // SelectionState
1905 // Mutable for getter which lazily update this field. 1907 // Mutable for getter which lazily update this field.
1906 mutable unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBac kgroundState 1908 mutable unsigned m_backgroundObscurationState : 2; // BackgroundObscurat ionState
1907 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason 1909 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
1908 1910
1909 public: 1911 public:
1910 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; } 1912 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; }
1911 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; } 1913 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; }
1912 bool isStickyPositioned() const { return m_positionedState == IsStickyPo sitioned; } 1914 bool isStickyPositioned() const { return m_positionedState == IsStickyPo sitioned; }
1913 bool isInFlowPositioned() const { return m_positionedState == IsRelative lyPositioned || m_positionedState == IsStickyPositioned; } 1915 bool isInFlowPositioned() const { return m_positionedState == IsRelative lyPositioned || m_positionedState == IsStickyPositioned; }
1914 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; } 1916 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; }
1915 1917
1916 void setPositionedState(int positionState) 1918 void setPositionedState(int positionState)
1917 { 1919 {
1918 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit. 1920 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit.
1919 m_positionedState = static_cast<PositionedState>(positionState & 0x3 ); 1921 m_positionedState = static_cast<PositionedState>(positionState & 0x3 );
1920 } 1922 }
1921 void clearPositionedState() { m_positionedState = StaticPosition; } 1923 void clearPositionedState() { m_positionedState = StaticPosition; }
1922 1924
1923 ALWAYS_INLINE SelectionState getSelectionState() const { return static_c ast<SelectionState>(m_selectionState); } 1925 ALWAYS_INLINE SelectionState getSelectionState() const { return static_c ast<SelectionState>(m_selectionState); }
1924 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; } 1926 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; }
1925 1927
1926 ALWAYS_INLINE BoxDecorationBackgroundState getBoxDecorationBackgroundSta te() const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBac kgroundState); } 1928 ALWAYS_INLINE BackgroundObscurationState getBackgroundObscurationState() const { return static_cast<BackgroundObscurationState>(m_backgroundObscurationS tate); }
1927 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou ndState s) const { m_boxDecorationBackgroundState = s; } 1929 ALWAYS_INLINE void setBackgroundObscurationState(BackgroundObscurationSt ate s) const { m_backgroundObscurationState = s; }
1928 1930
1929 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); } 1931 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); }
1930 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; } 1932 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; }
1931 }; 1933 };
1932 1934
1933 #undef ADD_BOOLEAN_BITFIELD 1935 #undef ADD_BOOLEAN_BITFIELD
1934 1936
1935 LayoutObjectBitfields m_bitfields; 1937 LayoutObjectBitfields m_bitfields;
1936 1938
1937 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } 1939 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 inline void LayoutObject::setSelectionStateIfNeeded(SelectionState state) 2104 inline void LayoutObject::setSelectionStateIfNeeded(SelectionState state)
2103 { 2105 {
2104 if (getSelectionState() == state) 2106 if (getSelectionState() == state)
2105 return; 2107 return;
2106 2108
2107 setSelectionState(state); 2109 setSelectionState(state);
2108 } 2110 }
2109 2111
2110 inline void LayoutObject::setHasBoxDecorationBackground(bool b) 2112 inline void LayoutObject::setHasBoxDecorationBackground(bool b)
2111 { 2113 {
2112 if (!b) { 2114 if (b == m_bitfields.hasBoxDecorationBackground())
2113 m_bitfields.setBoxDecorationBackgroundState(NoBoxDecorationBackground);
2114 return; 2115 return;
2115 } 2116
2116 if (hasBoxDecorationBackground()) 2117 m_bitfields.setHasBoxDecorationBackground(b);
2117 return; 2118 invalidateBackgroundObscurationStatus();
2118 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
2119 } 2119 }
2120 2120
2121 inline void LayoutObject::invalidateBackgroundObscurationStatus() 2121 inline void LayoutObject::invalidateBackgroundObscurationStatus()
2122 { 2122 {
2123 if (!hasBoxDecorationBackground()) 2123 m_bitfields.setBackgroundObscurationState(BackgroundObscurationStatusInvalid );
2124 return;
2125 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
2126 } 2124 }
2127 2125
2128 inline bool LayoutObject::boxDecorationBackgroundIsKnownToBeObscured() const 2126 inline bool LayoutObject::backgroundIsKnownToBeObscured() const
2129 { 2127 {
2130 if (m_bitfields.getBoxDecorationBackgroundState() == HasBoxDecorationBackgro undObscurationStatusInvalid) { 2128 if (m_bitfields.getBackgroundObscurationState() == BackgroundObscurationStat usInvalid) {
2131 BoxDecorationBackgroundState state = computeBackgroundIsKnownToBeObscure d() ? HasBoxDecorationBackgroundKnownToBeObscured : HasBoxDecorationBackgroundMa yBeVisible; 2129 BackgroundObscurationState state = computeBackgroundIsKnownToBeObscured( ) ? BackgroundKnownToBeObscured : BackgroundMayBeVisible;
2132 m_bitfields.setBoxDecorationBackgroundState(state); 2130 m_bitfields.setBackgroundObscurationState(state);
2133 } 2131 }
2134 return m_bitfields.getBoxDecorationBackgroundState() == HasBoxDecorationBack groundKnownToBeObscured; 2132 return m_bitfields.getBackgroundObscurationState() == BackgroundKnownToBeObs cured;
2135 } 2133 }
2136 2134
2137 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi ng) 2135 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi ng)
2138 { 2136 {
2139 if (!has3DRendering) 2137 if (!has3DRendering)
2140 matrix.makeAffine(); 2138 matrix.makeAffine();
2141 } 2139 }
2142 2140
2143 inline int adjustForAbsoluteZoom(int value, LayoutObject* layoutObject) 2141 inline int adjustForAbsoluteZoom(int value, LayoutObject* layoutObject)
2144 { 2142 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2181 void showTree(const blink::LayoutObject*); 2179 void showTree(const blink::LayoutObject*);
2182 void showLineTree(const blink::LayoutObject*); 2180 void showLineTree(const blink::LayoutObject*);
2183 void showLayoutTree(const blink::LayoutObject* object1); 2181 void showLayoutTree(const blink::LayoutObject* object1);
2184 // We don't make object2 an optional parameter so that showLayoutTree 2182 // We don't make object2 an optional parameter so that showLayoutTree
2185 // can be called from gdb easily. 2183 // can be called from gdb easily.
2186 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 2184 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
2187 2185
2188 #endif 2186 #endif
2189 2187
2190 #endif // LayoutObject_h 2188 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutImage.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