1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_layout_ScrollSnap_h_
8 #define mozilla_layout_ScrollSnap_h_
10 #include "mozilla/ScrollTypes.h"
11 #include "mozilla/Maybe.h"
19 struct ScrollSnapInfo
;
22 struct ScrollSnapUtils
{
24 * GetSnapPointForDestination determines which point to snap to after
25 * scrolling. |aStartPos| gives the position before scrolling and
26 * |aDestination| gives the position after scrolling, with no snapping.
27 * Behaviour is dependent on the value of |aUnit|.
28 * |aSnapInfo| and |aScrollRange| are characteristics of the scroll frame for
29 * which snapping is being performed.
30 * If a suitable snap point could be found, it is returned. Otherwise, an
31 * empty Maybe is returned.
32 * IMPORTANT NOTE: This function is designed to be called both on and off
33 * the main thread. If modifying its implementation, be sure
34 * not to touch main-thread-only data structures without
35 * appropriate locking.
37 static mozilla::Maybe
<nsPoint
> GetSnapPointForDestination(
38 const layers::ScrollSnapInfo
& aSnapInfo
, ScrollUnit aUnit
,
39 const nsRect
& aScrollRange
, const nsPoint
& aStartPos
,
40 const nsPoint
& aDestination
);
43 } // namespace mozilla
45 #endif // mozilla_layout_ScrollSnap_h_