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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollableArea.h

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase Created 4 years, 12 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) 2008, 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008, 2011 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 15 matching lines...) Expand all
26 #ifndef ScrollableArea_h 26 #ifndef ScrollableArea_h
27 #define ScrollableArea_h 27 #define ScrollableArea_h
28 28
29 #include "platform/PlatformExport.h" 29 #include "platform/PlatformExport.h"
30 #include "platform/RuntimeEnabledFeatures.h" 30 #include "platform/RuntimeEnabledFeatures.h"
31 #include "platform/geometry/DoublePoint.h" 31 #include "platform/geometry/DoublePoint.h"
32 #include "platform/heap/Handle.h" 32 #include "platform/heap/Handle.h"
33 #include "platform/scroll/ScrollAnimatorBase.h" 33 #include "platform/scroll/ScrollAnimatorBase.h"
34 #include "platform/scroll/ScrollTypes.h" 34 #include "platform/scroll/ScrollTypes.h"
35 #include "platform/scroll/Scrollbar.h" 35 #include "platform/scroll/Scrollbar.h"
36 #include "wtf/MathExtras.h"
36 #include "wtf/Noncopyable.h" 37 #include "wtf/Noncopyable.h"
37 #include "wtf/Vector.h" 38 #include "wtf/Vector.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 class DoubleRect; 42 class DoubleRect;
42 class FloatPoint; 43 class FloatPoint;
43 class GraphicsLayer; 44 class GraphicsLayer;
44 class HostWindow; 45 class HostWindow;
45 class PlatformWheelEvent; 46 class PlatformWheelEvent;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Returns true if the GraphicsLayer tree needs to be rebuilt. 225 // Returns true if the GraphicsLayer tree needs to be rebuilt.
225 virtual bool updateAfterCompositingChange() { return false; } 226 virtual bool updateAfterCompositingChange() { return false; }
226 227
227 virtual bool userInputScrollable(ScrollbarOrientation) const = 0; 228 virtual bool userInputScrollable(ScrollbarOrientation) const = 0;
228 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0; 229 virtual bool shouldPlaceVerticalScrollbarOnLeft() const = 0;
229 230
230 // Convenience functions 231 // Convenience functions
231 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); } 232 int scrollPosition(ScrollbarOrientation orientation) { return orientation == HorizontalScrollbar ? scrollPosition().x() : scrollPosition().y(); }
232 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); } 233 int minimumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? minimumScrollPosition().x() : minimumScrollPositio n().y(); }
233 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); } 234 int maximumScrollPosition(ScrollbarOrientation orientation) { return orienta tion == HorizontalScrollbar ? maximumScrollPosition().x() : maximumScrollPositio n().y(); }
234 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return std::max(std::min(pos, maximumScrollPosition(orientation)), minimumScrollPositi on(orientation)); } 235 int clampScrollPosition(ScrollbarOrientation orientation, int pos) { return clampTo(pos, minimumScrollPosition(orientation), maximumScrollPosition(orientat ion)); }
235 236
236 virtual GraphicsLayer* layerForContainer() const; 237 virtual GraphicsLayer* layerForContainer() const;
237 virtual GraphicsLayer* layerForScrolling() const { return 0; } 238 virtual GraphicsLayer* layerForScrolling() const { return 0; }
238 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; } 239 virtual GraphicsLayer* layerForHorizontalScrollbar() const { return 0; }
239 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; } 240 virtual GraphicsLayer* layerForVerticalScrollbar() const { return 0; }
240 virtual GraphicsLayer* layerForScrollCorner() const { return 0; } 241 virtual GraphicsLayer* layerForScrollCorner() const { return 0; }
241 bool hasLayerForHorizontalScrollbar() const; 242 bool hasLayerForHorizontalScrollbar() const;
242 bool hasLayerForVerticalScrollbar() const; 243 bool hasLayerForVerticalScrollbar() const;
243 bool hasLayerForScrollCorner() const; 244 bool hasLayerForScrollCorner() const;
244 245
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // vertical-lr / ltr NO NO 353 // vertical-lr / ltr NO NO
353 // vertical-lr / rtl NO YES 354 // vertical-lr / rtl NO YES
354 // vertical-rl / ltr YES NO 355 // vertical-rl / ltr YES NO
355 // vertical-rl / rtl YES YES 356 // vertical-rl / rtl YES YES
356 IntPoint m_scrollOrigin; 357 IntPoint m_scrollOrigin;
357 }; 358 };
358 359
359 } // namespace blink 360 } // namespace blink
360 361
361 #endif // ScrollableArea_h 362 #endif // ScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698