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

Side by Side Diff: Source/platform/mac/ScrollAnimatorMac.mm

Issue 1234783005: Add API to send NSUserDefault values over IPC, while preserving current behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | Source/platform/scroll/ScrollbarThemeMacCommon.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) 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2010, 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 BEGIN_BLOCK_OBJC_EXCEPTIONS; 681 BEGIN_BLOCK_OBJC_EXCEPTIONS;
682 [m_scrollbarPainterControllerDelegate.get() invalidate]; 682 [m_scrollbarPainterControllerDelegate.get() invalidate];
683 [m_scrollbarPainterController.get() setDelegate:nil]; 683 [m_scrollbarPainterController.get() setDelegate:nil];
684 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 684 [m_horizontalScrollbarPainterDelegate.get() invalidate];
685 [m_verticalScrollbarPainterDelegate.get() invalidate]; 685 [m_verticalScrollbarPainterDelegate.get() invalidate];
686 [m_scrollAnimationHelperDelegate.get() invalidate]; 686 [m_scrollAnimationHelperDelegate.get() invalidate];
687 END_BLOCK_OBJC_EXCEPTIONS; 687 END_BLOCK_OBJC_EXCEPTIONS;
688 } 688 }
689 } 689 }
690 690
691 static bool scrollAnimationEnabledForSystem()
692 {
693 static bool initialized = false;
694 static bool enabled = true;
695 if (!initialized) {
696 // Check setting for OS X 10.8+.
697 id value = [[NSUserDefaults standardUserDefaults] objectForKey:@"NSScrol lAnimationEnabled"];
698 // Check setting for OS X < 10.8.
699 if (!value)
700 value = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleS crollAnimationEnabled"];
701 if (value)
702 enabled = [value boolValue];
703 initialized = true;
704 }
705 return enabled;
706 }
707
708 ScrollResultOneDimensional ScrollAnimatorMac::userScroll(ScrollbarOrientation or ientation, ScrollGranularity granularity, float step, float delta) 691 ScrollResultOneDimensional ScrollAnimatorMac::userScroll(ScrollbarOrientation or ientation, ScrollGranularity granularity, float step, float delta)
709 { 692 {
693 bool scrollAnimationEnabledForSystem = static_cast<ScrollbarThemeMacCommon*> (
694 ScrollbarTheme::theme())
695 ->scrollAnimationEnabledForSystem ();
710 m_haveScrolledSincePageLoad = true; 696 m_haveScrolledSincePageLoad = true;
711 697
712 if (!scrollAnimationEnabledForSystem() || !m_scrollableArea->scrollAnimatorE nabled()) 698 if (!scrollAnimationEnabledForSystem || !m_scrollableArea->scrollAnimatorEna bled())
713 return ScrollAnimator::userScroll(orientation, granularity, step, delta) ; 699 return ScrollAnimator::userScroll(orientation, granularity, step, delta) ;
714 700
715 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel) 701 if (granularity == ScrollByPixel || granularity == ScrollByPrecisePixel)
716 return ScrollAnimator::userScroll(orientation, granularity, step, delta) ; 702 return ScrollAnimator::userScroll(orientation, granularity, step, delta) ;
717 703
718 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu rrentPosY; 704 float currentPos = orientation == HorizontalScrollbar ? m_currentPosX : m_cu rrentPosY;
719 float newPos = std::max<float>(std::min<float>(currentPos + (step * delta), m_scrollableArea->maximumScrollPosition(orientation)), m_scrollableArea->minimum ScrollPosition(orientation)); 705 float newPos = std::max<float>(std::min<float>(currentPos + (step * delta), m_scrollableArea->maximumScrollPosition(orientation)), m_scrollableArea->minimum ScrollPosition(orientation));
720 if (currentPos == newPos) 706 if (currentPos == newPos)
721 return ScrollResultOneDimensional(false); 707 return ScrollResultOneDimensional(false);
722 708
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 return; 1150 return;
1165 1151
1166 m_visibleScrollerThumbRect = rectInViewCoordinates; 1152 m_visibleScrollerThumbRect = rectInViewCoordinates;
1167 } 1153 }
1168 1154
1169 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() { 1155 bool ScrollAnimatorMac::canUseCoordinatedScrollbar() {
1170 return ScrollbarThemeMacCommon::isOverlayAPIAvailable(); 1156 return ScrollbarThemeMacCommon::isOverlayAPIAvailable();
1171 } 1157 }
1172 1158
1173 } // namespace blink 1159 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/scroll/ScrollbarThemeMacCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698