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

Side by Side Diff: Source/platform/scroll/ScrollbarTheme.cpp

Issue 662593004: Use correct proportion when computing the thumb length (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 2 * Copyright (C) 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 int ScrollbarTheme::thumbLength(ScrollbarThemeClient* scrollbar) 261 int ScrollbarTheme::thumbLength(ScrollbarThemeClient* scrollbar)
262 { 262 {
263 if (!scrollbar->enabled()) 263 if (!scrollbar->enabled())
264 return 0; 264 return 0;
265 265
266 float overhang = 0; 266 float overhang = 0;
267 if (scrollbar->currentPos() < 0) 267 if (scrollbar->currentPos() < 0)
268 overhang = -scrollbar->currentPos(); 268 overhang = -scrollbar->currentPos();
269 else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->tot alSize()) 269 else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->tot alSize())
270 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollba r->totalSize(); 270 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollba r->totalSize();
271 float proportion = (scrollbar->visibleSize() - overhang) / usedTotalSize(scr ollbar); 271 float proportion = 0.0f;
272 float totalSize = usedTotalSize(scrollbar);
273 if (totalSize > 0.0f) {
274 proportion = (scrollbar->visibleSize() - overhang) / totalSize;
275 }
272 int trackLen = trackLength(scrollbar); 276 int trackLen = trackLength(scrollbar);
273 int length = round(proportion * trackLen); 277 int length = round(proportion * trackLen);
274 length = std::max(length, minimumThumbLength(scrollbar)); 278 length = std::max(length, minimumThumbLength(scrollbar));
275 if (length > trackLen) 279 if (length > trackLen)
276 length = 0; // Once the thumb is below the track length, it just goes aw ay (to make more room for the track). 280 length = 0; // Once the thumb is below the track length, it just goes aw ay (to make more room for the track).
277 return length; 281 return length;
278 } 282 }
279 283
280 int ScrollbarTheme::trackPosition(ScrollbarThemeClient* scrollbar) 284 int ScrollbarTheme::trackPosition(ScrollbarThemeClient* scrollbar)
281 { 285 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 353 {
350 gMockScrollbarsEnabled = flag; 354 gMockScrollbarsEnabled = flag;
351 } 355 }
352 356
353 bool ScrollbarTheme::mockScrollbarsEnabled() 357 bool ScrollbarTheme::mockScrollbarsEnabled()
354 { 358 {
355 return gMockScrollbarsEnabled; 359 return gMockScrollbarsEnabled;
356 } 360 }
357 361
358 } 362 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698