Diff
Modified: trunk/Source/WebCore/ChangeLog (172542 => 172543)
--- trunk/Source/WebCore/ChangeLog 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/ChangeLog 2014-08-14 00:16:03 UTC (rev 172543)
@@ -1,3 +1,37 @@
+2014-08-13 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Compute and store snap point positions
+ https://bugs.webkit.org/show_bug.cgi?id=135268
+
+ Reviewed by Simon Fraser.
+
+ Working towards implementing a way to extract snap positions (i.e. LayoutUnits) from the parsed snap point properties from CSS,
+ as well as a way of storing the information. Supports both mainframe and overflow scrolling.
+
+ No changes in behavior. I will write tests when I implement snapping for iOS and Mac.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/FrameView.cpp:
+ (WebCore::FrameView::updateSnapOffsets): Invokes the static routine in AxisScrollSnapOffsets to update snap offsets for mainframe.
+ * page/FrameView.h:
+ * page/scrolling/AxisScrollSnapOffsets.cpp: Added.
+ (WebCore::appendAndSortChildSnapOffsets):
+ (WebCore::updateFromStyle):
+ (WebCore::updateSnapOffsetsForScrollableArea): Update the ScrollableArea's snap axes.
+ * page/scrolling/AxisScrollSnapOffsets.h: Added.
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::setHorizontalSnapOffsets):
+ (WebCore::ScrollableArea::setVerticalSnapOffsets):
+ (WebCore::ScrollableArea::clearHorizontalSnapOffsets): Resets the unique_ptr for horizontal snap points.
+ (WebCore::ScrollableArea::clearVerticalSnapOffsets): Resets the unique_ptr for vertical snap points.
+ * platform/ScrollableArea.h:
+ (WebCore::ScrollableArea::horizontalSnapOffsets): Returns a pointer to the ScrollableArea's horizontal snap points.
+ (WebCore::ScrollableArea::verticalSnapOffsets): Returns a pointer to the ScrollableArea's vertical snap points.
+ (WebCore::ScrollableArea::updateSnapOffsets):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::updateSnapOffsets): Invokes the static routine in AxisScrollSnapOffsets to update snap offsets for an overflow area.
+ * rendering/RenderLayer.h:
+
2014-08-13 Mark Rowe <mr...@apple.com>
<https://webkit.org/b/135911> WebKit should build on Yosemite with the public SDK.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (172542 => 172543)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-08-14 00:16:03 UTC (rev 172543)
@@ -6245,6 +6245,8 @@
F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */; };
F3F5CF1312ED81B30084C569 /* InspectorDatabaseInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */; };
F42FFB461984B71600F6837F /* LengthRepeat.h in Headers */ = {isa = PBXBuildFile; fileRef = F42FFB451984B71600F6837F /* LengthRepeat.h */; };
+ F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */; };
+ F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */ = {isa = PBXBuildFile; fileRef = F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */; settings = {ATTRIBUTES = (Private, ); }; };
F47A5E3E195B8C8A00483100 /* StyleScrollSnapPoints.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */; settings = {ATTRIBUTES = (Private, ); }; };
F47A5E3F195B8E4800483100 /* StyleScrollSnapPoints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */; };
F50664F7157F52DC00AC226F /* FormController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F50664F5157F52DC00AC226F /* FormController.cpp */; };
@@ -13762,6 +13764,8 @@
F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorConsoleInstrumentation.h; sourceTree = "<group>"; };
F3F5CF1212ED81B30084C569 /* InspectorDatabaseInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseInstrumentation.h; sourceTree = "<group>"; };
F42FFB451984B71600F6837F /* LengthRepeat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LengthRepeat.h; sourceTree = "<group>"; };
+ F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AxisScrollSnapOffsets.cpp; sourceTree = "<group>"; };
+ F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AxisScrollSnapOffsets.h; sourceTree = "<group>"; };
F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleScrollSnapPoints.cpp; path = style/StyleScrollSnapPoints.cpp; sourceTree = "<group>"; };
F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleScrollSnapPoints.h; path = style/StyleScrollSnapPoints.h; sourceTree = "<group>"; };
F50664F5157F52DC00AC226F /* FormController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormController.cpp; sourceTree = "<group>"; };
@@ -15137,6 +15141,8 @@
9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
0F6383DB18615B29003E5DB5 /* ThreadedScrollingTree.cpp */,
0F6383DC18615B29003E5DB5 /* ThreadedScrollingTree.h */,
+ F45C231B1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp */,
+ F45C231C1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h */,
);
path = scrolling;
sourceTree = "<group>";
@@ -24419,6 +24425,7 @@
A81369E0097374F600D74463 /* HTMLLegendElement.h in Headers */,
A8EA79F60A1916DF00A8EF5F /* HTMLLIElement.h in Headers */,
A871DC200A15205700B12A68 /* HTMLLinkElement.h in Headers */,
+ F45C231E1995B73B00A6E2E3 /* AxisScrollSnapOffsets.h in Headers */,
A8EA7D2C0A19385500A8EF5F /* HTMLMapElement.h in Headers */,
A8EA7CAB0A192B9C00A8EF5F /* HTMLMarqueeElement.h in Headers */,
E44613A50CD6331000FADA75 /* HTMLMediaElement.h in Headers */,
@@ -27754,6 +27761,7 @@
B2AFFC7D0D00A5C10030074D /* FontCustomPlatformData.cpp in Sources */,
371F4F410D25B9AF00ECE0D5 /* FontData.cpp in Sources */,
37ACCF690DA414E70089E602 /* FontDescription.cpp in Sources */,
+ F45C231D1995B73B00A6E2E3 /* AxisScrollSnapOffsets.cpp in Sources */,
72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */,
4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */,
E44EE3A817577EBD00EEE8CF /* FontGenericFamilies.cpp in Sources */,
Modified: trunk/Source/WebCore/page/FrameView.cpp (172542 => 172543)
--- trunk/Source/WebCore/page/FrameView.cpp 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/page/FrameView.cpp 2014-08-14 00:16:03 UTC (rev 172543)
@@ -98,6 +98,10 @@
#include "TextAutosizer.h"
#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+#include "AxisScrollSnapOffsets.h"
+#endif
+
#if PLATFORM(IOS)
#include "DocumentLoader.h"
#include "LegacyTileCache.h"
@@ -847,6 +851,21 @@
#endif // ENABLE(RUBBER_BANDING)
+#if ENABLE(CSS_SCROLL_SNAP)
+void FrameView::updateSnapOffsets()
+{
+ if (!frame().document())
+ return;
+
+ // FIXME: Should we allow specifying snap points through <html> tags too?
+ HTMLElement* body = frame().document()->body();
+ if (!renderView() || !body || !body->renderer())
+ return;
+
+ updateSnapOffsetsForScrollableArea(*this, *body, *renderView(), body->renderer()->style());
+}
+#endif
+
bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
{
RenderView* renderView = this->renderView();
Modified: trunk/Source/WebCore/page/FrameView.h (172542 => 172543)
--- trunk/Source/WebCore/page/FrameView.h 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/page/FrameView.h 2014-08-14 00:16:03 UTC (rev 172543)
@@ -496,6 +496,10 @@
void setExposedRect(FloatRect);
FloatRect exposedRect() const { return m_exposedRect; }
+#if ENABLE(CSS_SCROLL_SNAP)
+ virtual void updateSnapOffsets() override;
+#endif
+
protected:
virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) override;
virtual void scrollContentsSlowPath(const IntRect& updateRect) override;
Added: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (0 => 172543)
--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp (rev 0)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp 2014-08-14 00:16:03 UTC (rev 172543)
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AxisScrollSnapOffsets.h"
+
+#include "HTMLCollection.h"
+#include "HTMLElement.h"
+#include "RenderBox.h"
+#include "ScrollableArea.h"
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+namespace WebCore {
+
+static void appendChildSnapOffsets(HTMLElement& parent, bool shouldAddHorizontalChildOffsets, Vector<LayoutUnit>& horizontalSnapOffsetSubsequence, bool shouldAddVerticalChildOffsets, Vector<LayoutUnit>& verticalSnapOffsetSubsequence)
+{
+ Element* child = parent.children()->collectionBegin();
+ // FIXME: Instead of traversing all children, register children with snap coordinates before appending to snapOffsetSubsequence.
+ while (child) {
+ if (RenderBox* box = child->renderBox()) {
+ LayoutUnit viewWidth = box->width();
+ LayoutUnit viewHeight = box->height();
+ // FIXME: Check behavior with CSS rotations.
+ FloatPoint position = box->localToContainerPoint(FloatPoint(), parent.renderBox());
+ for (SnapCoordinate coordinate : box->style().scrollSnapCoordinates()) {
+ LayoutUnit lastPotentialSnapPositionX = LayoutUnit(position.x()) + valueForLength(coordinate.first, viewWidth);
+ if (shouldAddHorizontalChildOffsets && lastPotentialSnapPositionX > 0)
+ horizontalSnapOffsetSubsequence.append(lastPotentialSnapPositionX);
+
+ LayoutUnit lastPotentialSnapPositionY = LayoutUnit(position.y()) + valueForLength(coordinate.second, viewHeight);
+ if (shouldAddVerticalChildOffsets && lastPotentialSnapPositionY > 0)
+ verticalSnapOffsetSubsequence.append(lastPotentialSnapPositionY);
+ }
+ }
+ child = child->nextElementSibling();
+ }
+}
+
+static void updateFromStyle(Vector<LayoutUnit>* snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence)
+{
+ std::sort(snapOffsetSubsequence.begin(), snapOffsetSubsequence.end());
+ if (!snapOffsetSubsequence.size())
+ snapOffsetSubsequence.append(0);
+
+ bool isHorizontalAxis = axis == ScrollEventAxis::Horizontal;
+ bool hasRepeat = isHorizontalAxis ? style.scrollSnapHasRepeatX() : style.scrollSnapHasRepeatY();
+ LayoutUnit repeatOffset = valueForLength(isHorizontalAxis ? style.scrollSnapRepeatOffsetX() : style.scrollSnapRepeatOffsetY(), viewSize);
+ LayoutUnit destinationOffset = valueForLength(isHorizontalAxis ? style.scrollSnapDestinationX() : style.scrollSnapDestinationY(), viewSize);
+ LayoutUnit curSnapPositionShift = 0;
+ LayoutUnit maxScrollOffset = scrollSize - viewSize;
+ LayoutUnit lastSnapPosition = curSnapPositionShift;
+ snapOffsets->append(0);
+ do {
+ for (LayoutUnit snapPosition : snapOffsetSubsequence) {
+ LayoutUnit potentialSnapPosition = curSnapPositionShift + snapPosition - destinationOffset;
+ if (potentialSnapPosition <= 0)
+ continue;
+
+ if (potentialSnapPosition >= maxScrollOffset)
+ break;
+
+ snapOffsets->append(potentialSnapPosition);
+ lastSnapPosition = potentialSnapPosition + destinationOffset;
+ }
+ curSnapPositionShift = lastSnapPosition + repeatOffset;
+ } while (hasRepeat && curSnapPositionShift < maxScrollOffset);
+ // Always put a snap point on the maximum scroll offset.
+ // Not a part of the spec, but necessary to prevent unreachable content when snapping.
+ if (snapOffsets->last() != maxScrollOffset)
+ snapOffsets->append(maxScrollOffset);
+}
+
+void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle)
+{
+ if (scrollingElementStyle.scrollSnapType() == ScrollSnapType::None) {
+ scrollableArea.clearHorizontalSnapOffsets();
+ scrollableArea.clearVerticalSnapOffsets();
+ return;
+ }
+ LayoutUnit viewWidth = scrollingElementBox.width();
+ LayoutUnit viewHeight = scrollingElementBox.height();
+ LayoutUnit scrollWidth = scrollingElementBox.scrollWidth();
+ LayoutUnit scrollHeight = scrollingElementBox.scrollHeight();
+ bool canComputeHorizontalOffsets = scrollWidth > 0 && viewWidth > 0 && viewWidth < scrollWidth;
+ bool canComputeVerticalOffsets = scrollHeight > 0 && viewHeight > 0 && viewHeight < scrollHeight;
+ if (!canComputeHorizontalOffsets)
+ scrollableArea.clearHorizontalSnapOffsets();
+
+ if (!canComputeVerticalOffsets)
+ scrollableArea.clearVerticalSnapOffsets();
+
+ if (!canComputeHorizontalOffsets && !canComputeVerticalOffsets)
+ return;
+
+ Vector<LayoutUnit> horizontalSnapOffsetSubsequence;
+ Vector<LayoutUnit> verticalSnapOffsetSubsequence;
+ if (scrollingElementStyle.scrollSnapUsesElementsX() || scrollingElementStyle.scrollSnapUsesElementsY()) {
+ bool shouldAddHorizontalChildOffsets = scrollingElementStyle.scrollSnapUsesElementsX() && canComputeHorizontalOffsets;
+ bool shouldAddVerticalChildOffsets = scrollingElementStyle.scrollSnapUsesElementsY() && canComputeVerticalOffsets;
+ appendChildSnapOffsets(scrollingElement, shouldAddHorizontalChildOffsets, horizontalSnapOffsetSubsequence, shouldAddVerticalChildOffsets, verticalSnapOffsetSubsequence);
+ }
+
+ if (!scrollingElementStyle.scrollSnapUsesElementsX() && canComputeHorizontalOffsets) {
+ for (Length snapLength : scrollingElementStyle.scrollSnapOffsetsX())
+ horizontalSnapOffsetSubsequence.append(valueForLength(snapLength, viewWidth));
+ }
+
+ if (!scrollingElementStyle.scrollSnapUsesElementsY() && canComputeVerticalOffsets) {
+ for (Length snapLength : scrollingElementStyle.scrollSnapOffsetsY())
+ verticalSnapOffsetSubsequence.append(valueForLength(snapLength, viewHeight));
+ }
+
+ std::unique_ptr<Vector<LayoutUnit>> horizontalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
+ std::unique_ptr<Vector<LayoutUnit>> verticalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
+ if (canComputeHorizontalOffsets) {
+ updateFromStyle(horizontalSnapOffsets.get(), scrollingElementStyle, ScrollEventAxis::Horizontal, viewWidth, scrollWidth, horizontalSnapOffsetSubsequence);
+ scrollableArea.setHorizontalSnapOffsets(WTF::move(horizontalSnapOffsets));
+ }
+ if (canComputeVerticalOffsets) {
+ updateFromStyle(verticalSnapOffsets.get(), scrollingElementStyle, ScrollEventAxis::Vertical, viewHeight, scrollHeight, verticalSnapOffsetSubsequence);
+ scrollableArea.setVerticalSnapOffsets(WTF::move(verticalSnapOffsets));
+ }
+}
+
+} // namespace WebCore
+
+#endif // CSS_SCROLL_SNAP
Added: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h (0 => 172543)
--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h (rev 0)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h 2014-08-14 00:16:03 UTC (rev 172543)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AxisScrollSnapOffsets_h
+#define AxisScrollSnapOffsets_h
+
+#if ENABLE(CSS_SCROLL_SNAP)
+
+#include "LayoutUnit.h"
+#include "ScrollTypes.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class HTMLElement;
+class RenderBox;
+class RenderStyle;
+class ScrollableArea;
+
+void updateSnapOffsetsForScrollableArea(ScrollableArea&, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle);
+
+} // namespace WebCore
+
+#endif // CSS_SCROLL_SNAP
+
+#endif // AxisScrollSnapOffsets_h
Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (172542 => 172543)
--- trunk/Source/WebCore/platform/ScrollableArea.cpp 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp 2014-08-14 00:16:03 UTC (rev 172543)
@@ -45,7 +45,11 @@
struct SameSizeAsScrollableArea {
virtual ~SameSizeAsScrollableArea();
+#if ENABLE(CSS_SCROLL_SNAP)
+ void* pointers[3];
+#else
void* pointer;
+#endif
IntPoint origin;
unsigned bitfields : 16;
};
@@ -376,6 +380,28 @@
return layerForScrollCorner();
}
+#if ENABLE(CSS_SCROLL_SNAP)
+void ScrollableArea::setHorizontalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>> horizontalSnapOffsets)
+{
+ m_horizontalSnapOffsets = WTF::move(horizontalSnapOffsets);
+}
+
+void ScrollableArea::setVerticalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>> verticalSnapOffsets)
+{
+ m_verticalSnapOffsets = WTF::move(verticalSnapOffsets);
+}
+
+void ScrollableArea::clearHorizontalSnapOffsets()
+{
+ m_horizontalSnapOffsets = nullptr;
+}
+
+void ScrollableArea::clearVerticalSnapOffsets()
+{
+ m_verticalSnapOffsets = nullptr;
+}
+#endif
+
void ScrollableArea::serviceScrollAnimations()
{
if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
Modified: trunk/Source/WebCore/platform/ScrollableArea.h (172542 => 172543)
--- trunk/Source/WebCore/platform/ScrollableArea.h 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/platform/ScrollableArea.h 2014-08-14 00:16:03 UTC (rev 172543)
@@ -58,6 +58,16 @@
bool handleWheelEvent(const PlatformWheelEvent&);
+#if ENABLE(CSS_SCROLL_SNAP)
+ const Vector<LayoutUnit>* horizontalSnapOffsets() const { return m_horizontalSnapOffsets.get(); };
+ const Vector<LayoutUnit>* verticalSnapOffsets() const { return m_verticalSnapOffsets.get(); };
+ virtual void updateSnapOffsets() { };
+ void setHorizontalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>>);
+ void setVerticalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>>);
+ void clearHorizontalSnapOffsets();
+ void clearVerticalSnapOffsets();
+#endif
+
#if ENABLE(TOUCH_EVENTS)
virtual bool isTouchScrollable() const { return false; }
virtual bool handleTouchEvent(const PlatformTouchEvent&);
@@ -275,6 +285,11 @@
mutable OwnPtr<ScrollAnimator> m_scrollAnimator;
+#if ENABLE(CSS_SCROLL_SNAP)
+ std::unique_ptr<Vector<LayoutUnit>> m_horizontalSnapOffsets;
+ std::unique_ptr<Vector<LayoutUnit>> m_verticalSnapOffsets;
+#endif
+
// There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis
// if there is any reversed direction or writing-mode. The combinations are:
// writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (172542 => 172543)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-08-14 00:16:03 UTC (rev 172543)
@@ -122,6 +122,10 @@
#include "RenderLayerFilterInfo.h"
#endif
+#if ENABLE(CSS_SCROLL_SNAP)
+#include "AxisScrollSnapOffsets.h"
+#endif
+
#define MIN_INTERSECT_FOR_REVEAL 32
namespace WebCore {
@@ -3028,6 +3032,18 @@
return 0;
}
+#if ENABLE(CSS_SCROLL_SNAP)
+void RenderLayer::updateSnapOffsets()
+{
+ // FIXME: Extend support beyond HTMLElements.
+ if (!enclosingElement() || !enclosingElement()->renderBox() || !enclosingElement()->isHTMLElement())
+ return;
+
+ RenderBox* box = enclosingElement()->renderBox();
+ updateSnapOffsetsForScrollableArea(*this, *toHTMLElement(enclosingElement()), *box, box->style());
+}
+#endif
+
int RenderLayer::verticalScrollbarWidth(OverlayScrollbarSizeRelevancy relevancy) const
{
if (!m_vBar
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (172542 => 172543)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2014-08-13 23:55:10 UTC (rev 172542)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2014-08-14 00:16:03 UTC (rev 172543)
@@ -439,6 +439,9 @@
virtual Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); }
virtual Scrollbar* verticalScrollbar() const override { return m_vBar.get(); }
virtual ScrollableArea* enclosingScrollableArea() const override;
+#if ENABLE(CSS_SCROLL_SNAP)
+ virtual void updateSnapOffsets() override;
+#endif
#if PLATFORM(IOS)
#if ENABLE(TOUCH_EVENTS)