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

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

Issue 819953002: Mac: Update scrollbar size and input position during impl-overscroll (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Peure virtual Created 6 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
« no previous file with comments | « Source/platform/scroll/Scrollbar.cpp ('k') | Source/platform/scroll/ScrollbarThemeClient.h » ('j') | 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return (pos < 1 && pos > 0) ? 1 : pos; 267 return (pos < 1 && pos > 0) ? 1 : pos;
268 } 268 }
269 return 0; 269 return 0;
270 } 270 }
271 271
272 int ScrollbarTheme::thumbLength(ScrollbarThemeClient* scrollbar) 272 int ScrollbarTheme::thumbLength(ScrollbarThemeClient* scrollbar)
273 { 273 {
274 if (!scrollbar->enabled()) 274 if (!scrollbar->enabled())
275 return 0; 275 return 0;
276 276
277 // It is safe to compute the overhang by adding the result from the main
278 // thread overscroll mode (first) and then adding the result from compositor
279 // thread overscroll (second) because the modes are mutually exclusive (and
280 // determining which mode is in use here will require lots of temporary
281 // plumbing, and the main thread mode is to be deleted).
277 float overhang = 0; 282 float overhang = 0;
278 if (scrollbar->currentPos() < 0) 283 if (scrollbar->currentPos() < 0)
279 overhang = -scrollbar->currentPos(); 284 overhang = -scrollbar->currentPos();
280 else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->tot alSize()) 285 else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->tot alSize())
281 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollba r->totalSize(); 286 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollba r->totalSize();
287 overhang += fabsf(scrollbar->elasticOverscroll());
282 float proportion = 0.0f; 288 float proportion = 0.0f;
283 float totalSize = usedTotalSize(scrollbar); 289 float totalSize = usedTotalSize(scrollbar);
284 if (totalSize > 0.0f) { 290 if (totalSize > 0.0f) {
285 proportion = (scrollbar->visibleSize() - overhang) / totalSize; 291 proportion = (scrollbar->visibleSize() - overhang) / totalSize;
286 } 292 }
287 int trackLen = trackLength(scrollbar); 293 int trackLen = trackLength(scrollbar);
288 int length = round(proportion * trackLen); 294 int length = round(proportion * trackLen);
289 length = std::max(length, minimumThumbLength(scrollbar)); 295 length = std::max(length, minimumThumbLength(scrollbar));
290 if (length > trackLen) 296 if (length > trackLen)
291 length = 0; // Once the thumb is below the track length, it just goes aw ay (to make more room for the track). 297 length = 0; // Once the thumb is below the track length, it just goes aw ay (to make more room for the track).
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 { 370 {
365 gMockScrollbarsEnabled = flag; 371 gMockScrollbarsEnabled = flag;
366 } 372 }
367 373
368 bool ScrollbarTheme::mockScrollbarsEnabled() 374 bool ScrollbarTheme::mockScrollbarsEnabled()
369 { 375 {
370 return gMockScrollbarsEnabled; 376 return gMockScrollbarsEnabled;
371 } 377 }
372 378
373 } // namespace blink 379 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/Scrollbar.cpp ('k') | Source/platform/scroll/ScrollbarThemeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698