| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |