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

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

Issue 1544423002: Improve positioned/percentHeight descendant/container tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: virtual destructor Created 4 years, 11 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 struct LayoutBoxRareData { 52 struct LayoutBoxRareData {
53 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData ); 53 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData );
54 public: 54 public:
55 LayoutBoxRareData() 55 LayoutBoxRareData()
56 : m_inlineBoxWrapper(nullptr) 56 : m_inlineBoxWrapper(nullptr)
57 , m_spannerPlaceholder(nullptr) 57 , m_spannerPlaceholder(nullptr)
58 , m_overrideLogicalContentHeight(-1) 58 , m_overrideLogicalContentHeight(-1)
59 , m_overrideLogicalContentWidth(-1) 59 , m_overrideLogicalContentWidth(-1)
60 , m_previousBorderBoxSize(-1, -1) 60 , m_previousBorderBoxSize(-1, -1)
61 , m_positionedContainer(nullptr)
62 , m_percentHeightContainer(nullptr)
61 { 63 {
62 } 64 }
65 virtual ~LayoutBoxRareData() { }
esprehn 2016/01/06 19:37:25 we make this non-virtual in ElementRareData/NodeRa
Xianzhu 2016/01/06 20:49:07 Done.
63 66
64 // For inline replaced elements, the inline box that owns us. 67 // For inline replaced elements, the inline box that owns us.
65 InlineBox* m_inlineBoxWrapper; 68 InlineBox* m_inlineBoxWrapper;
66 69
67 // For spanners, the spanner placeholder that lays us out within the multico l container. 70 // For spanners, the spanner placeholder that lays us out within the multico l container.
68 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder; 71 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder;
69 72
70 LayoutUnit m_overrideLogicalContentHeight; 73 LayoutUnit m_overrideLogicalContentHeight;
71 LayoutUnit m_overrideLogicalContentWidth; 74 LayoutUnit m_overrideLogicalContentWidth;
72 75
73 // Set by LayoutBox::savePreviousBoxSizesIfNeeded(). 76 // Set by LayoutBox::savePreviousBoxSizesIfNeeded().
74 LayoutSize m_previousBorderBoxSize; 77 LayoutSize m_previousBorderBoxSize;
75 LayoutRect m_previousContentBoxRect; 78 LayoutRect m_previousContentBoxRect;
76 LayoutRect m_previousLayoutOverflowRect; 79 LayoutRect m_previousLayoutOverflowRect;
77 80
78 LayoutUnit m_pageLogicalOffset; 81 LayoutUnit m_pageLogicalOffset;
79 82
80 LayoutUnit m_paginationStrut; 83 LayoutUnit m_paginationStrut;
84
85 // Points to the LayoutBlock whose LayoutBlockRareData::m_positionedDescenda nts contains this LayoutBox.
86 LayoutBlock* m_positionedContainer;
87 // Points to the LayoutBlock whose LayoutBlockRareData::m_percentHeightDesce ndants contains this LayoutBox.
88 LayoutBlock* m_percentHeightContainer;
81 }; 89 };
82 90
83 // LayoutBox implements the full CSS box model. 91 // LayoutBox implements the full CSS box model.
84 // 92 //
85 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and 93 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and
86 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the 94 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the
87 // rectangle and offset forming the CSS box (m_frameRect) and the getters for 95 // rectangle and offset forming the CSS box (m_frameRect) and the getters for
88 // the different boxes. 96 // the different boxes.
89 // 97 //
90 // LayoutBox is also the uppermost class to support scrollbars, however the 98 // LayoutBox is also the uppermost class to support scrollbars, however the
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 850
843 void setIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeig ht) const { m_intrinsicContentLogicalHeight = intrinsicContentLogicalHeight; } 851 void setIntrinsicContentLogicalHeight(LayoutUnit intrinsicContentLogicalHeig ht) const { m_intrinsicContentLogicalHeight = intrinsicContentLogicalHeight; }
844 852
845 bool canRenderBorderImage() const; 853 bool canRenderBorderImage() const;
846 854
847 void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidationContai ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr, const PaintInvalidationState* = nullptr) const override; 855 void mapLocalToContainer(const LayoutBoxModelObject* paintInvalidationContai ner, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr, const PaintInvalidationState* = nullptr) const override;
848 void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const ove rride; 856 void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) const ove rride;
849 857
850 void clearPreviousPaintInvalidationRects() override; 858 void clearPreviousPaintInvalidationRects() override;
851 859
860 LayoutBlock* positionedContainer() const { return m_rareData ? m_rareData->m _positionedContainer : nullptr; }
861 void setPositionedContainer(LayoutBlock*);
862 void removeFromPositionedContainer();
863
864 LayoutBlock* percentHeightContainer() const { return m_rareData ? m_rareData ->m_percentHeightContainer : nullptr; }
865 void setPercentHeightContainer(LayoutBlock*);
866 void removeFromPercentHeightContainer();
867 void clearPercentHeightDescendants();
868
852 protected: 869 protected:
853 void willBeDestroyed() override; 870 void willBeDestroyed() override;
854 871
855 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e; 872 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e;
856 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ; 873 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ;
857 void updateFromStyle() override; 874 void updateFromStyle() override;
858 875
859 // Returns false if it could not cheaply compute the extent (e.g. fixed back ground), in which case the returned rect may be incorrect. 876 // Returns false if it could not cheaply compute the extent (e.g. fixed back ground), in which case the returned rect may be incorrect.
860 // FIXME: make this a const method once the LayoutBox reference in BoxPainte r is const. 877 // FIXME: make this a const method once the LayoutBox reference in BoxPainte r is const.
861 bool getBackgroundPaintedExtent(LayoutRect&) const; 878 bool getBackgroundPaintedExtent(LayoutRect&) const;
(...skipping 18 matching lines...) Expand all
880 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInva lidationContainer, 897 const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInva lidationContainer,
881 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInva lidationContainer) const override; 898 const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInva lidationContainer) const override;
882 void incrementallyInvalidatePaint(const LayoutBoxModelObject& paintInvalidat ionContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const La youtPoint& positionFromPaintInvalidationContainer) override; 899 void incrementallyInvalidatePaint(const LayoutBoxModelObject& paintInvalidat ionContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, const La youtPoint& positionFromPaintInvalidationContainer) override;
883 900
884 PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationState&, con st LayoutBoxModelObject& paintInvalidationContainer) override; 901 PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationState&, con st LayoutBoxModelObject& paintInvalidationContainer) override;
885 void invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& childPaintInv alidationState) override; 902 void invalidatePaintOfSubtreesIfNeeded(PaintInvalidationState& childPaintInv alidationState) override;
886 903
887 bool hasNonCompositedScrollbars() const final; 904 bool hasNonCompositedScrollbars() const final;
888 void excludeScrollbars(LayoutRect&, OverlayScrollbarSizeRelevancy = IgnoreOv erlayScrollbarSize) const; 905 void excludeScrollbars(LayoutRect&, OverlayScrollbarSizeRelevancy = IgnoreOv erlayScrollbarSize) const;
889 906
907 LayoutBoxRareData* rareData() const { return m_rareData.get(); }
908 LayoutBoxRareData& ensureRareData()
909 {
910 if (!m_rareData)
911 m_rareData = adoptPtr(createRareData());
esprehn 2016/01/06 19:37:25 adoptPtr should be at the creation site, not aroun
Xianzhu 2016/01/06 20:49:07 Done.
912 return *m_rareData.get();
913 }
914 virtual LayoutBoxRareData* createRareData() { return new LayoutBoxRareData; }
esprehn 2016/01/06 19:37:25 PassOwnPtr, you should never leak like this.
Xianzhu 2016/01/06 20:49:07 Done.
915
890 private: 916 private:
891 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const; 917 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
892 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const; 918 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
893 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st; 919 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st;
894 920
895 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds); 921 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds);
896 922
897 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle); 923 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle);
898 void updateGridPositionAfterStyleChange(const ComputedStyle*); 924 void updateGridPositionAfterStyleChange(const ComputedStyle*);
899 925
(...skipping 30 matching lines...) Expand all
930 // This function calculates the preferred widths for an object. 956 // This function calculates the preferred widths for an object.
931 // 957 //
932 // This function is only expected to be called if 958 // This function is only expected to be called if
933 // the boolean preferredLogicalWidthsDirty is true. It also MUST clear the 959 // the boolean preferredLogicalWidthsDirty is true. It also MUST clear the
934 // boolean before returning. 960 // boolean before returning.
935 // 961 //
936 // See INTRINSIC SIZES / PREFERRED LOGICAL WIDTHS in LayoutObject.h for more 962 // See INTRINSIC SIZES / PREFERRED LOGICAL WIDTHS in LayoutObject.h for more
937 // details about those widths. 963 // details about those widths.
938 virtual void computePreferredLogicalWidths() { clearPreferredLogicalWidthsDi rty(); } 964 virtual void computePreferredLogicalWidths() { clearPreferredLogicalWidthsDi rty(); }
939 965
940 LayoutBoxRareData& ensureRareData()
941 {
942 if (!m_rareData)
943 m_rareData = adoptPtr(new LayoutBoxRareData());
944 return *m_rareData.get();
945 }
946
947 bool needToSavePreviousBoxSizes(); 966 bool needToSavePreviousBoxSizes();
948 void savePreviousBoxSizesIfNeeded(); 967 void savePreviousBoxSizesIfNeeded();
949 LayoutSize computePreviousBorderBoxSize(const LayoutSize& previousBoundsSize ) const; 968 LayoutSize computePreviousBorderBoxSize(const LayoutSize& previousBoundsSize ) const;
950 969
951 bool logicalHeightComputesAsNone(SizeType) const; 970 bool logicalHeightComputesAsNone(SizeType) const;
952 971
953 bool isBox() const = delete; // This will catch anyone doing an unnecessary check. 972 bool isBox() const = delete; // This will catch anyone doing an unnecessary check.
954 973
955 void frameRectChanged() 974 void frameRectChanged()
956 { 975 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (UNLIKELY(inlineBoxWrapper() != nullptr)) 1086 if (UNLIKELY(inlineBoxWrapper() != nullptr))
1068 deleteLineBoxWrapper(); 1087 deleteLineBoxWrapper();
1069 } 1088 }
1070 1089
1071 ensureRareData().m_inlineBoxWrapper = boxWrapper; 1090 ensureRareData().m_inlineBoxWrapper = boxWrapper;
1072 } 1091 }
1073 1092
1074 } // namespace blink 1093 } // namespace blink
1075 1094
1076 #endif // LayoutBox_h 1095 #endif // LayoutBox_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlock.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698