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

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

Issue 1188563005: Compute snap offsets (both repeat and element based) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 4 years, 9 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayS crollbarSize }; 42 enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayS crollbarSize };
43 enum MarginDirection { BlockDirection, InlineDirection }; 43 enum MarginDirection { BlockDirection, InlineDirection };
44 44
45 enum ShouldComputePreferred { ComputeActual, ComputePreferred }; 45 enum ShouldComputePreferred { ComputeActual, ComputePreferred };
46 46
47 enum ScrollOffsetClamping { 47 enum ScrollOffsetClamping {
48 ScrollOffsetUnclamped, 48 ScrollOffsetUnclamped,
49 ScrollOffsetClamped 49 ScrollOffsetClamped
50 }; 50 };
51 51
52 using SnapAreaSet = HashSet<const LayoutBox*>;
53
52 struct LayoutBoxRareData { 54 struct LayoutBoxRareData {
53 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData ); 55 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData );
54 public: 56 public:
55 LayoutBoxRareData() 57 LayoutBoxRareData()
56 : m_spannerPlaceholder(nullptr) 58 : m_spannerPlaceholder(nullptr)
57 , m_overrideLogicalContentHeight(-1) 59 , m_overrideLogicalContentHeight(-1)
58 , m_overrideLogicalContentWidth(-1) 60 , m_overrideLogicalContentWidth(-1)
59 , m_previousBorderBoxSize(LayoutUnit(-1), LayoutUnit(-1)) 61 , m_previousBorderBoxSize(LayoutUnit(-1), LayoutUnit(-1))
60 , m_percentHeightContainer(nullptr) 62 , m_percentHeightContainer(nullptr)
63 , m_snapContainer(nullptr)
64 , m_snapAreas(nullptr)
61 { 65 {
62 } 66 }
63 67
64 // For spanners, the spanner placeholder that lays us out within the multico l container. 68 // For spanners, the spanner placeholder that lays us out within the multico l container.
65 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder; 69 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder;
66 70
67 LayoutUnit m_overrideLogicalContentHeight; 71 LayoutUnit m_overrideLogicalContentHeight;
68 LayoutUnit m_overrideLogicalContentWidth; 72 LayoutUnit m_overrideLogicalContentWidth;
69 73
70 // Set by LayoutBox::savePreviousBoxSizesIfNeeded(). 74 // Set by LayoutBox::savePreviousBoxSizesIfNeeded().
71 LayoutSize m_previousBorderBoxSize; 75 LayoutSize m_previousBorderBoxSize;
72 LayoutRect m_previousContentBoxRect; 76 LayoutRect m_previousContentBoxRect;
73 LayoutRect m_previousLayoutOverflowRect; 77 LayoutRect m_previousLayoutOverflowRect;
74 78
75 LayoutUnit m_pageLogicalOffset; 79 LayoutUnit m_pageLogicalOffset;
76 80
77 LayoutUnit m_paginationStrut; 81 LayoutUnit m_paginationStrut;
78 82
79 LayoutBlock* m_percentHeightContainer; 83 LayoutBlock* m_percentHeightContainer;
84 // For snap area, the owning snap container.
85 LayoutBox* m_snapContainer;
86 // For snap container, the descendant snap areas that contribute snap
87 // points.
88 OwnPtr<SnapAreaSet> m_snapAreas;
89
90 SnapAreaSet& ensureSnapAreas()
91 {
92 if (!m_snapAreas)
93 m_snapAreas = adoptPtr(new SnapAreaSet);
94
95 return *m_snapAreas;
96 }
80 }; 97 };
81 98
82 // LayoutBox implements the full CSS box model. 99 // LayoutBox implements the full CSS box model.
83 // 100 //
84 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and 101 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and
85 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the 102 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the
86 // rectangle and offset forming the CSS box (m_frameRect) and the getters for 103 // rectangle and offset forming the CSS box (m_frameRect) and the getters for
87 // the different boxes. 104 // the different boxes.
88 // 105 //
89 // LayoutBox is also the uppermost class to support scrollbars, however the 106 // LayoutBox is also the uppermost class to support scrollbars, however the
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 905
889 void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, TransformState &, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr, const Pai ntInvalidationState* = nullptr) const override; 906 void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, TransformState &, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = nullptr, const Pai ntInvalidationState* = nullptr) const override;
890 void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState&, MapCoo rdinatesFlags) const override; 907 void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState&, MapCoo rdinatesFlags) const override;
891 908
892 void clearPreviousPaintInvalidationRects() override; 909 void clearPreviousPaintInvalidationRects() override;
893 910
894 LayoutBlock* percentHeightContainer() const { return m_rareData ? m_rareData ->m_percentHeightContainer : nullptr; } 911 LayoutBlock* percentHeightContainer() const { return m_rareData ? m_rareData ->m_percentHeightContainer : nullptr; }
895 void setPercentHeightContainer(LayoutBlock*); 912 void setPercentHeightContainer(LayoutBlock*);
896 void removeFromPercentHeightContainer(); 913 void removeFromPercentHeightContainer();
897 void clearPercentHeightDescendants(); 914 void clearPercentHeightDescendants();
915 // For snap areas, returns the snap container that owns us.
916 LayoutBox* snapContainer() const;
917 void setSnapContainer(LayoutBox*);
918 // For snap containers, returns all associated snap areas.
919 SnapAreaSet* snapAreas() const;
920 void clearSnapAreas();
898 921
899 protected: 922 protected:
900 void willBeDestroyed() override; 923 void willBeDestroyed() override;
901 924
902 void insertedIntoTree() override; 925 void insertedIntoTree() override;
903 void willBeRemovedFromTree() override; 926 void willBeRemovedFromTree() override;
904 927
905 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e; 928 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e;
906 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ; 929 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ;
907 void updateFromStyle() override; 930 void updateFromStyle() override;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 972
950 private: 973 private:
951 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const; 974 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
952 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const; 975 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
953 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st; 976 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st;
954 977
955 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds); 978 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds);
956 979
957 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle); 980 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle);
958 void updateGridPositionAfterStyleChange(const ComputedStyle*); 981 void updateGridPositionAfterStyleChange(const ComputedStyle*);
982 void updateScrollSnapMappingAfterStyleChange(const ComputedStyle*, const Com putedStyle* oldStyle);
983 void clearScrollSnapMapping();
984 void addScrollSnapMapping();
959 985
960 bool autoWidthShouldFitContent() const; 986 bool autoWidthShouldFitContent() const;
961 LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutU nit bordersPlusPadding) const; 987 LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutU nit bordersPlusPadding) const;
962 988
963 // Returns true if we queued up a paint invalidation. 989 // Returns true if we queued up a paint invalidation.
964 bool invalidatePaintOfLayerRectsForImage(WrappedImagePtr, const FillLayer&, bool drawingBackground); 990 bool invalidatePaintOfLayerRectsForImage(WrappedImagePtr, const FillLayer&, bool drawingBackground);
965 991
966 bool stretchesToViewportInQuirksMode() const; 992 bool stretchesToViewportInQuirksMode() const;
967 bool skipContainingBlockForPercentHeightCalculation(const LayoutBox* contain ingBlock) const; 993 bool skipContainingBlockForPercentHeightCalculation(const LayoutBox* contain ingBlock) const;
968 994
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1059
1034 // Our intrinsic height, used for min-height: min-content etc. Maintained by 1060 // Our intrinsic height, used for min-height: min-content etc. Maintained by
1035 // updateLogicalHeight. This is logicalHeight() before it is clamped to 1061 // updateLogicalHeight. This is logicalHeight() before it is clamped to
1036 // min/max. 1062 // min/max.
1037 mutable LayoutUnit m_intrinsicContentLogicalHeight; 1063 mutable LayoutUnit m_intrinsicContentLogicalHeight;
1038 1064
1039 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect&) const; 1065 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect&) const;
1040 1066
1041 LayoutRectOutsets m_marginBoxOutsets; 1067 LayoutRectOutsets m_marginBoxOutsets;
1042 1068
1069 void addSnapArea(const LayoutBox&);
1070 void removeSnapArea(const LayoutBox&);
1071
1043 protected: 1072 protected:
1044 // The logical width of the element if it were to break its lines at every 1073 // The logical width of the element if it were to break its lines at every
1045 // possible opportunity. 1074 // possible opportunity.
1046 // 1075 //
1047 // See LayoutObject::minPreferredLogicalWidth() for more details. 1076 // See LayoutObject::minPreferredLogicalWidth() for more details.
1048 LayoutUnit m_minPreferredLogicalWidth; 1077 LayoutUnit m_minPreferredLogicalWidth;
1049 1078
1050 // The logical width of the element if it never breaks any lines at all. 1079 // The logical width of the element if it never breaks any lines at all.
1051 // 1080 //
1052 // See LayoutObject::maxPreferredLogicalWidth() for more details. 1081 // See LayoutObject::maxPreferredLogicalWidth() for more details.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 if (UNLIKELY(m_inlineBoxWrapper != nullptr)) 1160 if (UNLIKELY(m_inlineBoxWrapper != nullptr))
1132 deleteLineBoxWrapper(); 1161 deleteLineBoxWrapper();
1133 } 1162 }
1134 1163
1135 m_inlineBoxWrapper = boxWrapper; 1164 m_inlineBoxWrapper = boxWrapper;
1136 } 1165 }
1137 1166
1138 } // namespace blink 1167 } // namespace blink
1139 1168
1140 #endif // LayoutBox_h 1169 #endif // LayoutBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698