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

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollTypes.h

Issue 2387883002: Use float for scroll offset. (Closed)
Patch Set: Fix README.md Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scroll/ScrollTypes.h
diff --git a/third_party/WebKit/Source/platform/scroll/ScrollTypes.h b/third_party/WebKit/Source/platform/scroll/ScrollTypes.h
index cf6930baca7d512cf22a42e4c9a8437eb9a8b9f8..618b9d8c72b5a5c58c15d55d96365d362b6ad67e 100644
--- a/third_party/WebKit/Source/platform/scroll/ScrollTypes.h
+++ b/third_party/WebKit/Source/platform/scroll/ScrollTypes.h
@@ -26,11 +26,22 @@
#ifndef ScrollTypes_h
#define ScrollTypes_h
-#include "platform/geometry/FloatSize.h"
+#include "platform/geometry/FloatPoint.h"
#include "wtf/Assertions.h"
namespace blink {
+// A ScrollOffset represents an offset from the scroll origin of a
+// ScrollableArea. Note that "scroll origin" is not the same as the layout
+// concept of "location", nor is it necessarily coincident with the top/left of
+// the ScrollableArea's overflow rect. See core/layout/README.md for more
+// information.
+typedef FloatSize ScrollOffset;
+
+inline ScrollOffset toScrollOffset(const FloatPoint& p) {
+ return ScrollOffset(p.x(), p.y());
+}
+
enum ScrollDirection {
ScrollUpIgnoringWritingMode,
ScrollDownIgnoringWritingMode,
@@ -214,17 +225,18 @@ struct ScrollResult {
float unusedScrollDeltaY;
};
-inline FloatSize toScrollDelta(ScrollbarOrientation orientation, float delta) {
- return orientation == HorizontalScrollbar ? FloatSize(delta, 0.0f)
- : FloatSize(0.0f, delta);
+inline ScrollOffset toScrollDelta(ScrollbarOrientation orientation,
+ float delta) {
+ return orientation == HorizontalScrollbar ? ScrollOffset(delta, 0.0f)
+ : ScrollOffset(0.0f, delta);
}
-inline FloatSize toScrollDelta(ScrollDirectionPhysical dir, float delta) {
+inline ScrollOffset toScrollDelta(ScrollDirectionPhysical dir, float delta) {
if (dir == ScrollUp || dir == ScrollLeft)
delta = -delta;
- return (dir == ScrollLeft || dir == ScrollRight) ? FloatSize(delta, 0)
- : FloatSize(0, delta);
+ return (dir == ScrollLeft || dir == ScrollRight) ? ScrollOffset(delta, 0)
+ : ScrollOffset(0, delta);
}
typedef unsigned ScrollbarControlPartMask;

Powered by Google App Engine
This is Rietveld 408576698