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

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: Use client and scroll size to handle overlay scrollbars Created 4 years, 7 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 enum ScrollOffsetClamping { 50 enum ScrollOffsetClamping {
51 ScrollOffsetUnclamped, 51 ScrollOffsetUnclamped,
52 ScrollOffsetClamped 52 ScrollOffsetClamped
53 }; 53 };
54 54
55 enum ApplyOverflowClipFlag { 55 enum ApplyOverflowClipFlag {
56 ApplyOverflowClip, 56 ApplyOverflowClip,
57 ApplyNonScrollOverflowClip 57 ApplyNonScrollOverflowClip
58 }; 58 };
59 59
60 using SnapAreaSet = HashSet<const LayoutBox*>;
61
60 struct LayoutBoxRareData { 62 struct LayoutBoxRareData {
61 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData ); 63 WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData );
62 public: 64 public:
63 LayoutBoxRareData() 65 LayoutBoxRareData()
64 : m_spannerPlaceholder(nullptr) 66 : m_spannerPlaceholder(nullptr)
65 , m_overrideLogicalContentHeight(-1) 67 , m_overrideLogicalContentHeight(-1)
66 , m_overrideLogicalContentWidth(-1) 68 , m_overrideLogicalContentWidth(-1)
67 , m_previousBorderBoxSize(LayoutUnit(-1), LayoutUnit(-1)) 69 , m_previousBorderBoxSize(LayoutUnit(-1), LayoutUnit(-1))
68 , m_percentHeightContainer(nullptr) 70 , m_percentHeightContainer(nullptr)
71 , m_snapContainer(nullptr)
72 , m_snapAreas(nullptr)
69 { 73 {
70 } 74 }
71 75
72 // For spanners, the spanner placeholder that lays us out within the multico l container. 76 // For spanners, the spanner placeholder that lays us out within the multico l container.
73 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder; 77 LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder;
74 78
75 LayoutUnit m_overrideLogicalContentHeight; 79 LayoutUnit m_overrideLogicalContentHeight;
76 LayoutUnit m_overrideLogicalContentWidth; 80 LayoutUnit m_overrideLogicalContentWidth;
77 81
78 // Set by LayoutBox::savePreviousBoxSizesIfNeeded(). 82 // Set by LayoutBox::savePreviousBoxSizesIfNeeded().
79 LayoutSize m_previousBorderBoxSize; 83 LayoutSize m_previousBorderBoxSize;
80 LayoutRect m_previousContentBoxRect; 84 LayoutRect m_previousContentBoxRect;
81 LayoutRect m_previousLayoutOverflowRect; 85 LayoutRect m_previousLayoutOverflowRect;
82 86
83 LayoutUnit m_pageLogicalOffset; 87 LayoutUnit m_pageLogicalOffset;
84 88
85 LayoutUnit m_paginationStrut; 89 LayoutUnit m_paginationStrut;
86 90
87 LayoutBlock* m_percentHeightContainer; 91 LayoutBlock* m_percentHeightContainer;
92 // For snap area, the owning snap container.
93 LayoutBox* m_snapContainer;
94 // For snap container, the descendant snap areas that contribute snap
95 // points.
96 OwnPtr<SnapAreaSet> m_snapAreas;
97
98 SnapAreaSet& ensureSnapAreas()
99 {
100 if (!m_snapAreas)
101 m_snapAreas = adoptPtr(new SnapAreaSet);
102
103 return *m_snapAreas;
104 }
88 }; 105 };
89 106
90 // LayoutBox implements the full CSS box model. 107 // LayoutBox implements the full CSS box model.
91 // 108 //
92 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and 109 // LayoutBoxModelObject only introduces some abstractions for LayoutInline and
93 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the 110 // LayoutBox. The logic for the model is in LayoutBox, e.g. the storage for the
94 // rectangle and offset forming the CSS box (m_frameRect) and the getters for 111 // rectangle and offset forming the CSS box (m_frameRect) and the getters for
95 // the different boxes. 112 // the different boxes.
96 // 113 //
97 // LayoutBox is also the uppermost class to support scrollbars, however the 114 // LayoutBox is also the uppermost class to support scrollbars, however the
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 927
911 void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, TransformState &, MapCoordinatesFlags = ApplyContainerFlip) const override; 928 void mapLocalToAncestor(const LayoutBoxModelObject* ancestor, TransformState &, MapCoordinatesFlags = ApplyContainerFlip) const override;
912 void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState&, MapCoo rdinatesFlags) const override; 929 void mapAncestorToLocal(const LayoutBoxModelObject*, TransformState&, MapCoo rdinatesFlags) const override;
913 930
914 void clearPreviousPaintInvalidationRects() override; 931 void clearPreviousPaintInvalidationRects() override;
915 932
916 LayoutBlock* percentHeightContainer() const { return m_rareData ? m_rareData ->m_percentHeightContainer : nullptr; } 933 LayoutBlock* percentHeightContainer() const { return m_rareData ? m_rareData ->m_percentHeightContainer : nullptr; }
917 void setPercentHeightContainer(LayoutBlock*); 934 void setPercentHeightContainer(LayoutBlock*);
918 void removeFromPercentHeightContainer(); 935 void removeFromPercentHeightContainer();
919 void clearPercentHeightDescendants(); 936 void clearPercentHeightDescendants();
937 // For snap areas, returns the snap container that owns us.
938 LayoutBox* snapContainer() const;
939 void setSnapContainer(LayoutBox*);
940 // For snap containers, returns all associated snap areas.
941 SnapAreaSet* snapAreas() const;
942 void clearSnapAreas();
920 943
921 bool hitTestClippedOutByRoundedBorder(const HitTestLocation& locationInConta iner, const LayoutPoint& borderBoxLocation) const; 944 bool hitTestClippedOutByRoundedBorder(const HitTestLocation& locationInConta iner, const LayoutPoint& borderBoxLocation) const;
922 945
923 protected: 946 protected:
924 void willBeDestroyed() override; 947 void willBeDestroyed() override;
925 948
926 void insertedIntoTree() override; 949 void insertedIntoTree() override;
927 void willBeRemovedFromTree() override; 950 void willBeRemovedFromTree() override;
928 951
929 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e; 952 void styleWillChange(StyleDifference, const ComputedStyle& newStyle) overrid e;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 994
972 private: 995 private:
973 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const; 996 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
974 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const; 997 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
975 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st; 998 inline bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) con st;
976 999
977 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds); 1000 void invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModelObject& paintInvalidationContainer, const LayoutRect&, const LayoutRect& oldBounds, con st LayoutRect& newBounds);
978 1001
979 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle); 1002 void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const Comp utedStyle* oldStyle);
980 void updateGridPositionAfterStyleChange(const ComputedStyle*); 1003 void updateGridPositionAfterStyleChange(const ComputedStyle*);
1004 void updateScrollSnapMappingAfterStyleChange(const ComputedStyle*, const Com putedStyle* oldStyle);
1005 void clearScrollSnapMapping();
1006 void addScrollSnapMapping();
981 1007
982 bool autoWidthShouldFitContent() const; 1008 bool autoWidthShouldFitContent() const;
983 LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutU nit bordersPlusPadding) const; 1009 LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutU nit bordersPlusPadding) const;
984 1010
985 // Returns true if we queued up a paint invalidation. 1011 // Returns true if we queued up a paint invalidation.
986 bool invalidatePaintOfLayerRectsForImage(WrappedImagePtr, const FillLayer&, bool drawingBackground); 1012 bool invalidatePaintOfLayerRectsForImage(WrappedImagePtr, const FillLayer&, bool drawingBackground);
987 1013
988 bool stretchesToViewportInQuirksMode() const; 1014 bool stretchesToViewportInQuirksMode() const;
989 bool skipContainingBlockForPercentHeightCalculation(const LayoutBox* contain ingBlock) const; 1015 bool skipContainingBlockForPercentHeightCalculation(const LayoutBox* contain ingBlock) const;
990 1016
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1081
1056 // Our intrinsic height, used for min-height: min-content etc. Maintained by 1082 // Our intrinsic height, used for min-height: min-content etc. Maintained by
1057 // updateLogicalHeight. This is logicalHeight() before it is clamped to 1083 // updateLogicalHeight. This is logicalHeight() before it is clamped to
1058 // min/max. 1084 // min/max.
1059 mutable LayoutUnit m_intrinsicContentLogicalHeight; 1085 mutable LayoutUnit m_intrinsicContentLogicalHeight;
1060 1086
1061 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect&) const; 1087 void inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect&) const;
1062 1088
1063 LayoutRectOutsets m_marginBoxOutsets; 1089 LayoutRectOutsets m_marginBoxOutsets;
1064 1090
1091 void addSnapArea(const LayoutBox&);
1092 void removeSnapArea(const LayoutBox&);
1093
1065 protected: 1094 protected:
1066 // The logical width of the element if it were to break its lines at every 1095 // The logical width of the element if it were to break its lines at every
1067 // possible opportunity. 1096 // possible opportunity.
1068 // 1097 //
1069 // See LayoutObject::minPreferredLogicalWidth() for more details. 1098 // See LayoutObject::minPreferredLogicalWidth() for more details.
1070 LayoutUnit m_minPreferredLogicalWidth; 1099 LayoutUnit m_minPreferredLogicalWidth;
1071 1100
1072 // The logical width of the element if it never breaks any lines at all. 1101 // The logical width of the element if it never breaks any lines at all.
1073 // 1102 //
1074 // See LayoutObject::maxPreferredLogicalWidth() for more details. 1103 // See LayoutObject::maxPreferredLogicalWidth() for more details.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 || breakValue == BreakLeft 1192 || breakValue == BreakLeft
1164 || breakValue == BreakPage 1193 || breakValue == BreakPage
1165 || breakValue == BreakRecto 1194 || breakValue == BreakRecto
1166 || breakValue == BreakRight 1195 || breakValue == BreakRight
1167 || breakValue == BreakVerso; 1196 || breakValue == BreakVerso;
1168 } 1197 }
1169 1198
1170 } // namespace blink 1199 } // namespace blink
1171 1200
1172 #endif // LayoutBox_h 1201 #endif // LayoutBox_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.h ('k') | third_party/WebKit/Source/core/layout/LayoutBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698