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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handling that minimumThumbLength > trackLen. Created 5 years 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 16 matching lines...) Expand all
27 #include "platform/scroll/ScrollbarThemeOverlay.h" 27 #include "platform/scroll/ScrollbarThemeOverlay.h"
28 28
29 #include "platform/PlatformMouseEvent.h" 29 #include "platform/PlatformMouseEvent.h"
30 #include "platform/graphics/GraphicsContext.h" 30 #include "platform/graphics/GraphicsContext.h"
31 #include "platform/graphics/paint/DrawingRecorder.h" 31 #include "platform/graphics/paint/DrawingRecorder.h"
32 #include "platform/scroll/ScrollbarThemeClient.h" 32 #include "platform/scroll/ScrollbarThemeClient.h"
33 #include "platform/transforms/TransformationMatrix.h" 33 #include "platform/transforms/TransformationMatrix.h"
34 #include "public/platform/Platform.h" 34 #include "public/platform/Platform.h"
35 #include "public/platform/WebRect.h" 35 #include "public/platform/WebRect.h"
36 #include "public/platform/WebThemeEngine.h" 36 #include "public/platform/WebThemeEngine.h"
37 #include "wtf/MathExtras.h"
37 38
38 #include <algorithm> 39 #include <algorithm>
39 40
40 namespace blink { 41 namespace blink {
41 42
42 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa rgin, HitTestBehavior allowHitTest, Color color) 43 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa rgin, HitTestBehavior allowHitTest, Color color)
43 : ScrollbarTheme() 44 : ScrollbarTheme()
44 , m_thumbThickness(thumbThickness) 45 , m_thumbThickness(thumbThickness)
45 , m_scrollbarMargin(scrollbarMargin) 46 , m_scrollbarMargin(scrollbarMargin)
46 , m_allowHitTest(allowHitTest) 47 , m_allowHitTest(allowHitTest)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 86
86 int ScrollbarThemeOverlay::thumbLength(const ScrollbarThemeClient& scrollbar) 87 int ScrollbarThemeOverlay::thumbLength(const ScrollbarThemeClient& scrollbar)
87 { 88 {
88 int trackLen = trackLength(scrollbar); 89 int trackLen = trackLength(scrollbar);
89 90
90 if (!scrollbar.totalSize()) 91 if (!scrollbar.totalSize())
91 return trackLen; 92 return trackLen;
92 93
93 float proportion = static_cast<float>(scrollbar.visibleSize()) / scrollbar.t otalSize(); 94 float proportion = static_cast<float>(scrollbar.visibleSize()) / scrollbar.t otalSize();
94 int length = round(proportion * trackLen); 95 int length = round(proportion * trackLen);
95 length = std::min(std::max(length, minimumThumbLength(scrollbar)), trackLen) ; 96 int minLen = std::min(minimumThumbLength(scrollbar), trackLen);
97 length = clampTo(length, minLen, trackLen);
96 return length; 98 return length;
97 } 99 }
98 100
99 bool ScrollbarThemeOverlay::hasThumb(const ScrollbarThemeClient& scrollbar) 101 bool ScrollbarThemeOverlay::hasThumb(const ScrollbarThemeClient& scrollbar)
100 { 102 {
101 return true; 103 return true;
102 } 104 }
103 105
104 IntRect ScrollbarThemeOverlay::backButtonRect(const ScrollbarThemeClient&, Scrol lbarPart, bool) 106 IntRect ScrollbarThemeOverlay::backButtonRect(const ScrollbarThemeClient&, Scrol lbarPart, bool)
105 { 107 {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return ScrollbarTheme::hitTest(scrollbar, position); 172 return ScrollbarTheme::hitTest(scrollbar, position);
171 } 173 }
172 174
173 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme() 175 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme()
174 { 176 {
175 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (3, 3, ScrollbarThemeOverl ay::DisallowHitTest, Color(128, 128, 128, 128))); 177 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (3, 3, ScrollbarThemeOverl ay::DisallowHitTest, Color(128, 128, 128, 128)));
176 return theme; 178 return theme;
177 } 179 }
178 180
179 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698