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

Unified 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: Fix compile issue Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.h
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.h b/third_party/WebKit/Source/core/layout/LayoutBox.h
index 92d282ed10e4e963f3c68edd7985fd264e581cbc..73d2c97c8bad864a50e7ff7f6cd4eaf5e55c12e1 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.h
@@ -49,6 +49,8 @@ enum ScrollOffsetClamping {
ScrollOffsetClamped
};
+using SnapAreaSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<const LayoutBox>>;
+
struct LayoutBoxRareData {
WTF_MAKE_NONCOPYABLE(LayoutBoxRareData); USING_FAST_MALLOC(LayoutBoxRareData);
public:
@@ -58,6 +60,8 @@ public:
, m_overrideLogicalContentHeight(-1)
, m_overrideLogicalContentWidth(-1)
, m_previousBorderBoxSize(-1, -1)
+ , m_snapContainer(nullptr)
+ , m_snapAreas(nullptr)
{
}
@@ -78,6 +82,21 @@ public:
LayoutUnit m_pageLogicalOffset;
LayoutUnit m_paginationStrut;
+
+ // For snap area, the owning snap container.
+ LayoutBox* m_snapContainer;
+ // For snap container, the descendant snap areas that contribute snap
+ // points.
+ OwnPtrWillBeMember<SnapAreaSet> m_snapAreas;
+
+ SnapAreaSet& ensureSnapAreas()
+ {
+ if (!m_snapAreas)
+ m_snapAreas = adoptPtrWillBeNoop(new SnapAreaSet);
+
+ return *m_snapAreas;
+ }
+
};
// LayoutBox implements the full CSS box model.
@@ -843,8 +862,15 @@ public:
bool canRenderBorderImage() const;
+ // For snap areas, returns the snap container that owns us.
+ LayoutBox* snapContainer() const;
+ void setSnapContainer(LayoutBox*);
+ // For snap containers, returns all associated snap areas.
+ SnapAreaSet* snapAreas() const;
+
protected:
void willBeDestroyed() override;
+ void insertedIntoTree() override;
void styleWillChange(StyleDifference, const ComputedStyle& newStyle) override;
void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override;
@@ -890,6 +916,9 @@ private:
void updateShapeOutsideInfoAfterStyleChange(const ComputedStyle&, const ComputedStyle* oldStyle);
void updateGridPositionAfterStyleChange(const ComputedStyle*);
+ void updateScrollSnapMappingAfterStyleChange(const ComputedStyle*, const ComputedStyle* oldStyle);
+ void clearScrollSnapMapping();
+ void addScrollSnapMapping();
bool autoWidthShouldFitContent() const;
LayoutUnit shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth, LayoutUnit bordersPlusPadding) const;
@@ -971,6 +1000,9 @@ private:
LayoutRectOutsets m_marginBoxOutsets;
+ void addSnapArea(const LayoutBox&);
+ void removeSnapArea(const LayoutBox&);
+
protected:
// The logical width of the element if it were to break its lines at every
// possible opportunity.

Powered by Google App Engine
This is Rietveld 408576698