Changeset 103291 in webkit
- Timestamp:
- Dec 19, 2011 6:01:16 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 deleted
- 13 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103290 r103291 1 2011-12-19 Sailesh Agrawal <sail@chromium.org> 2 3 Merge ScrollAnimatorChromiumMac.mm back to ScrollAnimatorMac 4 https://bugs.webkit.org/show_bug.cgi?id=61144 5 6 Reviewed by Beth Dakin. 7 8 At a high level the main changes are: 9 - replace #ifdefs in ScrollAnimatorMac and ScrollbarThemeMac with run time checks 10 - delete duplicate code in ScrollbarThemeChromiumMac. Keep the paint code since it does tickmarks and SKIA stuff. 11 - delete ScrollAnimatorChromiumMac since ScrollAnimatorMac does the exact same thing 12 - delete ScrollbarOverlayUtilitiesChromiumMac since NSScrollerImpDetails does the same thing 13 14 No new tests. Just refactoring. 15 16 * WebCore.gyp/WebCore.gyp: 17 * WebCore.gypi: 18 * WebCore.xcodeproj/project.pbxproj: 19 * platform/chromium/ScrollAnimatorChromiumMac.h: Removed. 20 * platform/chromium/ScrollAnimatorChromiumMac.mm: Removed. 21 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h: Removed. 22 * platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm: Removed. 23 * platform/chromium/ScrollbarThemeChromiumMac.h: 24 * platform/chromium/ScrollbarThemeChromiumMac.mm: 25 (WebCore::ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac): 26 (WebCore::scrollbarPainterPaintTrack): 27 (WebCore::ScrollbarThemeChromiumMac::paint): 28 * platform/mac/EmptyProtocolDefinitions.h: 29 * platform/mac/NSScrollerImpDetails.h: 30 (WebCore::isScrollbarOverlayAPIAvailable): 31 * platform/mac/NSScrollerImpDetails.mm: Added. 32 (WebCore::isScrollbarOverlayAPIAvailable): 33 (WebCore::recommendedScrollerStyle): 34 * platform/mac/ScrollAnimatorMac.h: 35 * platform/mac/ScrollAnimatorMac.mm: 36 (scrollbarPainterForScrollbar): 37 (WebCore::ScrollAnimatorMac::ScrollAnimatorMac): 38 (WebCore::ScrollAnimatorMac::~ScrollAnimatorMac): 39 (WebCore::ScrollAnimatorMac::notifyPositionChanged): 40 (WebCore::ScrollAnimatorMac::contentAreaWillPaint): 41 (WebCore::ScrollAnimatorMac::mouseEnteredContentArea): 42 (WebCore::ScrollAnimatorMac::mouseExitedContentArea): 43 (WebCore::ScrollAnimatorMac::mouseMovedInContentArea): 44 (WebCore::ScrollAnimatorMac::mouseEnteredScrollbar): 45 (WebCore::ScrollAnimatorMac::mouseExitedScrollbar): 46 (WebCore::ScrollAnimatorMac::willStartLiveResize): 47 (WebCore::ScrollAnimatorMac::contentsResized): 48 (WebCore::ScrollAnimatorMac::willEndLiveResize): 49 (WebCore::ScrollAnimatorMac::contentAreaDidShow): 50 (WebCore::ScrollAnimatorMac::contentAreaDidHide): 51 (WebCore::ScrollAnimatorMac::didBeginScrollGesture): 52 (WebCore::ScrollAnimatorMac::didEndScrollGesture): 53 (WebCore::ScrollAnimatorMac::didAddVerticalScrollbar): 54 (WebCore::ScrollAnimatorMac::willRemoveVerticalScrollbar): 55 (WebCore::ScrollAnimatorMac::didAddHorizontalScrollbar): 56 (WebCore::ScrollAnimatorMac::willRemoveHorizontalScrollbar): 57 (WebCore::ScrollAnimatorMac::cancelAnimations): 58 (WebCore::ScrollAnimatorMac::setIsActive): 59 (WebCore::ScrollAnimatorMac::updateScrollerStyle): 60 (WebCore::ScrollAnimatorMac::initialScrollbarPaintTimerFired): 61 * platform/mac/ScrollElasticityController.h: 62 * platform/mac/ScrollbarThemeMac.h: 63 * platform/mac/ScrollbarThemeMac.mm: 64 (+[WebScrollbarPrefsObserver appearancePrefsChanged:]): 65 (+[WebScrollbarPrefsObserver behaviorPrefsChanged:]): 66 (WebCore::updateArrowPlacement): 67 (WebCore::ScrollbarThemeMac::registerScrollbar): 68 (WebCore::ScrollbarThemeMac::setIsCurrentlyDrawingIntoLayer): 69 (WebCore::ScrollbarThemeMac::ScrollbarThemeMac): 70 (WebCore::ScrollbarThemeMac::scrollbarThickness): 71 (WebCore::ScrollbarThemeMac::usesOverlayScrollbars): 72 (WebCore::ScrollbarThemeMac::updateScrollbarOverlayStyle): 73 (WebCore::ScrollbarThemeMac::hasButtons): 74 (WebCore::ScrollbarThemeMac::hasThumb): 75 (WebCore::ScrollbarThemeMac::minimumThumbLength): 76 (WebCore::ScrollbarThemeMac::scrollbarPartToHIPressedState): 77 (WebCore::ScrollbarThemeMac::updateEnabledState): 78 (WebCore::scrollbarPainterPaint): 79 (WebCore::ScrollbarThemeMac::paint): 80 1 81 2011-12-19 James Robinson <jamesr@chromium.org> 2 82 -
trunk/Source/WebCore/WebCore.gyp/WebCore.gyp
r102663 r103291 1300 1300 # com.google.Chrome[] objc[]: Class ScrollbarPrefsObserver is implemented in both .../Google Chrome.app/Contents/Versions/.../Google Chrome Helper.app/Contents/MacOS/../../../Google Chrome Framework.framework/Google Chrome Framework and /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore. One of the two will be used. Which one is undefined. 1301 1301 'WebCascadeList=ChromiumWebCoreObjCWebCascadeList', 1302 ' ScrollbarPrefsObserver=ChromiumWebCoreObjCScrollbarPrefsObserver',1302 'WebScrollbarPrefsObserver=ChromiumWebCoreObjCWebScrollbarPrefsObserver', 1303 1303 'WebCoreRenderThemeNotificationObserver=ChromiumWebCoreObjCWebCoreRenderThemeNotificationObserver', 1304 1304 'WebFontCache=ChromiumWebCoreObjCWebFontCache', 1305 ' ScrollAnimationHelperDelegate=ChromiumWebCoreObjCScrollAnimationHelperDelegate',1306 ' ScrollbarPainterControllerDelegate=ChromiumWebCoreObjCScrollbarPainterControllerDelegate',1307 ' ScrollbarPainterDelegate=ChromiumWebCoreObjCScrollbarPainterDelegate',1308 ' ScrollbarPartAnimation=ChromiumWebCoreObjCScrollbarPartAnimation',1305 'WebScrollAnimationHelperDelegate=ChromiumWebCoreObjCWebScrollAnimationHelperDelegate', 1306 'WebScrollbarPainterControllerDelegate=ChromiumWebCoreObjCWebScrollbarPainterControllerDelegate', 1307 'WebScrollbarPainterDelegate=ChromiumWebCoreObjCWebScrollbarPainterDelegate', 1308 'WebScrollbarPartAnimation=ChromiumWebCoreObjCWebScrollbarPartAnimation', 1309 1309 ], 1310 1310 'include_dirs': [ … … 1566 1566 ['include', 'platform/mac/KillRingMac\\.mm$'], 1567 1567 ['include', 'platform/mac/LocalCurrentGraphicsContext\\.mm$'], 1568 ['include', 'platform/mac/NSScrollerImpDetails\\.mm$'], 1568 1569 ['include', 'platform/mac/PurgeableBufferMac\\.cpp$'], 1570 ['include', 'platform/mac/ScrollbarThemeMac\\.mm$'], 1571 ['include', 'platform/mac/ScrollAnimatorMac\\.mm$'], 1572 ['include', 'platform/mac/ScrollElasticityController\\.mm$'], 1569 1573 ['include', 'platform/mac/WebCoreSystemInterface\\.mm$'], 1570 1574 ['include', 'platform/mac/WebCoreTextRenderer\\.mm$'], -
trunk/Source/WebCore/WebCore.gypi
r103274 r103291 3309 3309 'platform/chromium/PopupMenuPrivate.h', 3310 3310 'platform/chromium/SSLKeyGeneratorChromium.cpp', 3311 'platform/chromium/ScrollAnimatorChromiumMac.h',3312 'platform/chromium/ScrollAnimatorChromiumMac.mm',3313 'platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.h',3314 'platform/chromium/ScrollbarOverlayUtilitiesChromiumMac.mm',3315 3311 'platform/chromium/ScrollbarThemeChromium.cpp', 3316 3312 'platform/chromium/ScrollbarThemeChromium.h', … … 4156 4152 'platform/mac/LoggingMac.mm', 4157 4153 'platform/mac/MIMETypeRegistryMac.mm', 4154 'platform/mac/NSScrollerImpDetails.h', 4155 'platform/mac/NSScrollerImpDetails.mm', 4158 4156 'platform/mac/PasteboardHelper.h', 4159 4157 'platform/mac/PasteboardMac.mm', … … 4167 4165 'platform/mac/ScrollAnimatorMac.h', 4168 4166 'platform/mac/ScrollAnimatorMac.mm', 4167 'platform/mac/ScrollElasticityController.h', 4168 'platform/mac/ScrollElasticityController.mm', 4169 4169 'platform/mac/ScrollViewMac.mm', 4170 4170 'platform/mac/ScrollbarThemeMac.h', -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r103274 r103291 1552 1552 521D46F611AEC98100514613 /* KillRingMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 521D46F511AEC98100514613 /* KillRingMac.mm */; }; 1553 1553 521D46F811AEC9B100514613 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = 521D46F711AEC9B100514613 /* KillRing.h */; }; 1554 52F52E1114A0134F00ACC397 /* NSScrollerImpDetails.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */; }; 1554 1555 5317612213C516690026E454 /* StyleFlexibleBoxData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5317612013C516690026E454 /* StyleFlexibleBoxData.cpp */; }; 1555 1556 5317612313C516690026E454 /* StyleFlexibleBoxData.h in Headers */ = {isa = PBXBuildFile; fileRef = 5317612113C516690026E454 /* StyleFlexibleBoxData.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8824 8825 521D46F511AEC98100514613 /* KillRingMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KillRingMac.mm; sourceTree = "<group>"; }; 8825 8826 521D46F711AEC9B100514613 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; }; 8827 52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NSScrollerImpDetails.mm; sourceTree = "<group>"; }; 8826 8828 5317612013C516690026E454 /* StyleFlexibleBoxData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleFlexibleBoxData.cpp; path = style/StyleFlexibleBoxData.cpp; sourceTree = "<group>"; }; 8827 8829 5317612113C516690026E454 /* StyleFlexibleBoxData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleFlexibleBoxData.h; path = style/StyleFlexibleBoxData.h; sourceTree = "<group>"; }; … … 15602 15604 BC772C5D0C4EB3440083285F /* MIMETypeRegistryMac.mm */, 15603 15605 93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */, 15606 52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */, 15604 15607 A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */, 15605 15608 4B2709810AF2E5E00065127F /* PasteboardMac.mm */, … … 27851 27854 A80A9423149F225E00989291 /* JSDOMWindowWebAudioCustom.cpp in Sources */, 27852 27855 A80A9425149F227100989291 /* JSDOMWindowWebSocketCustom.cpp in Sources */, 27856 52F52E1114A0134F00ACC397 /* NSScrollerImpDetails.mm in Sources */, 27853 27857 ); 27854 27858 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.h
r95901 r103291 28 28 #define ScrollbarThemeChromiumMac_h 29 29 30 #include "ScrollbarOverlayUtilitiesChromiumMac.h" 31 #include "ScrollbarThemeComposite.h" 32 33 // This file (and its associated .mm file) is a clone of ScrollbarThemeMac.h. 34 // See the .mm file for details. 30 #include "ScrollbarThemeMac.h" 35 31 36 32 namespace WebCore { 37 33 38 class ScrollbarThemeChromiumMac : public ScrollbarTheme Composite{34 class ScrollbarThemeChromiumMac : public ScrollbarThemeMac { 39 35 public: 40 36 ScrollbarThemeChromiumMac(); 41 37 virtual ~ScrollbarThemeChromiumMac(); 42 38 43 void preferencesChanged();44 45 virtual void updateEnabledState(Scrollbar*);46 47 39 virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect); 48 49 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);50 51 virtual bool supportsControlTints() const { return true; }52 virtual bool usesOverlayScrollbars() const;53 virtual void updateScrollbarOverlayStyle(Scrollbar*);54 55 virtual double initialAutoscrollTimerDelay();56 virtual double autoscrollTimerDelay();57 58 virtual ScrollbarButtonsPlacement buttonsPlacement() const;59 60 virtual void registerScrollbar(Scrollbar*);61 virtual void unregisterScrollbar(Scrollbar*);62 63 void setNewPainterForScrollbar(Scrollbar*, WKScrollbarPainterRef);64 WKScrollbarPainterRef painterForScrollbar(Scrollbar*);65 40 66 41 virtual void paintOverhangAreas(ScrollView*, GraphicsContext*, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect); 67 42 68 protected:69 virtual bool hasButtons(Scrollbar*);70 virtual bool hasThumb(Scrollbar*);71 72 virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);73 virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);74 virtual IntRect trackRect(Scrollbar*, bool painting = false);75 76 virtual int maxOverlapBetweenPages() { return 40; }77 78 virtual int minimumThumbLength(Scrollbar*);79 80 virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);81 virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&);82 83 43 private: 84 44 void paintGivenTickmarks(GraphicsContext*, Scrollbar*, const IntRect&, const Vector<IntRect>&); 85 45 86 private:87 46 RefPtr<Pattern> m_overhangPattern; 88 47 }; -
trunk/Source/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm
r97237 r103291 28 28 #include "ScrollbarThemeChromiumMac.h" 29 29 30 #include "BitmapImage.h"31 30 #include "FrameView.h" 32 31 #include "Gradient.h" 33 32 #include "ImageBuffer.h" 34 33 #include "LocalCurrentGraphicsContext.h" 35 #include " PlatformMouseEvent.h"34 #include "NSScrollerImpDetails.h" 36 35 #include "PlatformSupport.h" 37 #include "ScrollAnimator ChromiumMac.h"36 #include "ScrollAnimatorMac.h" 38 37 #include "ScrollView.h" 39 38 #include <Carbon/Carbon.h> 40 #include <wtf/HashMap.h>41 #include <wtf/StdLibExtras.h>42 #include <wtf/UnusedParam.h>43 39 44 40 #if USE(SKIA) … … 47 43 #endif 48 44 49 50 51 // FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.52 53 using namespace std;54 using namespace WebCore;55 56 // This file (and its associated .h file) is a clone of ScrollbarThemeMac.mm.57 // Because we want to draw tickmarks in the scrollbar, we must maintain a fork.58 // Please maintain this file by performing parallel changes to it.59 //60 // The only changes from ScrollbarThemeMac should be:61 // - The classname change from ScrollbarThemeMac to ScrollbarThemeChromiumMac.62 // - In paint() the code to paint the track, tickmarks, and thumb separately.63 // - In paint() the thumb is drawn via ChromeBridge/WebThemeEngine.64 // - Various functions that were split using #if USE(WK_SCROLLBAR_PAINTER)65 // have been combined using runtime checks instead.66 //67 // For all other differences, if it was introduced in this file, then the68 // maintainer forgot to include it in the list; otherwise it is an update that69 // should have been applied to this file but was not.70 71 namespace WebCore {72 73 typedef HashMap<Scrollbar*, RetainPtr<WKScrollbarPainterRef> > ScrollbarPainterMap;74 75 static ScrollbarPainterMap* scrollbarMap()76 {77 static ScrollbarPainterMap* map = new ScrollbarPainterMap;78 return map;79 }80 81 }82 83 @interface ScrollbarPrefsObserver : NSObject84 {85 }86 87 + (void)registerAsObserver;88 + (void)appearancePrefsChanged:(NSNotification*)theNotification;89 + (void)behaviorPrefsChanged:(NSNotification*)theNotification;90 91 @end92 93 @implementation ScrollbarPrefsObserver94 95 + (void)appearancePrefsChanged:(NSNotification*)unusedNotification96 {97 UNUSED_PARAM(unusedNotification);98 99 ScrollbarTheme* theme = ScrollbarTheme::theme();100 if (theme->isMockTheme())101 return;102 103 static_cast<ScrollbarThemeChromiumMac*>(theme)->preferencesChanged();104 if (scrollbarMap()->isEmpty())105 return;106 ScrollbarPainterMap::iterator end = scrollbarMap()->end();107 for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) {108 it->first->styleChanged();109 it->first->invalidate();110 }111 }112 113 + (void)behaviorPrefsChanged:(NSNotification*)unusedNotification114 {115 UNUSED_PARAM(unusedNotification);116 117 ScrollbarTheme* theme = ScrollbarTheme::theme();118 if (theme->isMockTheme())119 return;120 121 static_cast<ScrollbarThemeChromiumMac*>(theme)->preferencesChanged();122 }123 124 + (void)registerAsObserver125 {126 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];127 [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];128 }129 130 @end131 132 45 namespace WebCore { 133 46 … … 138 51 } 139 52 140 // FIXME: Get these numbers from CoreUI.141 static int cScrollbarThickness[] = { 15, 11 };142 static int cRealButtonLength[] = { 28, 21 };143 static int cButtonInset[] = { 14, 11 };144 static int cButtonHitInset[] = { 3, 2 };145 // cRealButtonLength - cButtonInset146 static int cButtonLength[] = { 14, 10 };147 static int cThumbMinLength[] = { 26, 20 };148 149 static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double button pair is a bit bigger.150 static int cOuterButtonOverlap = 2;151 152 static float gInitialButtonDelay = 0.5f;153 static float gAutoscrollButtonDelay = 0.05f;154 static bool gJumpOnTrackClick = false;155 static ScrollbarButtonsPlacement gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNone : ScrollbarButtonsDoubleEnd;156 157 static void updateArrowPlacement()158 {159 if (isScrollbarOverlayAPIAvailable())160 return;161 162 NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];163 if ([buttonPlacement isEqualToString:@"Single"])164 gButtonPlacement = ScrollbarButtonsSingle;165 else if ([buttonPlacement isEqualToString:@"DoubleMin"])166 gButtonPlacement = ScrollbarButtonsDoubleStart;167 else if ([buttonPlacement isEqualToString:@"DoubleBoth"])168 gButtonPlacement = ScrollbarButtonsDoubleBoth;169 else170 gButtonPlacement = ScrollbarButtonsDoubleEnd;171 }172 173 void ScrollbarThemeChromiumMac::registerScrollbar(Scrollbar* scrollbar)174 {175 bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;176 WKScrollbarPainterRef scrollbarPainter = wkMakeScrollbarPainter(scrollbar->controlSize(), isHorizontal);177 scrollbarMap()->add(scrollbar, scrollbarPainter);178 updateEnabledState(scrollbar);179 updateScrollbarOverlayStyle(scrollbar);180 }181 182 void ScrollbarThemeChromiumMac::unregisterScrollbar(Scrollbar* scrollbar)183 {184 scrollbarMap()->remove(scrollbar);185 }186 187 void ScrollbarThemeChromiumMac::setNewPainterForScrollbar(Scrollbar* scrollbar, WKScrollbarPainterRef newPainter)188 {189 scrollbarMap()->set(scrollbar, newPainter);190 updateEnabledState(scrollbar);191 updateScrollbarOverlayStyle(scrollbar);192 }193 194 WKScrollbarPainterRef ScrollbarThemeChromiumMac::painterForScrollbar(Scrollbar* scrollbar)195 {196 return scrollbarMap()->get(scrollbar).get();197 }198 199 53 ScrollbarThemeChromiumMac::ScrollbarThemeChromiumMac() 200 54 { 201 static bool initialized; 202 if (!initialized) { 203 initialized = true; 204 205 // Load the linen pattern image used for overhang drawing. 206 RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern"); 207 m_overhangPattern = Pattern::create(patternImage, true, true); 208 209 [ScrollbarPrefsObserver registerAsObserver]; 210 preferencesChanged(); 211 } 55 // Load the linen pattern image used for overhang drawing. 56 RefPtr<Image> patternImage = Image::loadPlatformResource("overhangPattern"); 57 m_overhangPattern = Pattern::create(patternImage, true, true); 212 58 } 213 59 214 60 ScrollbarThemeChromiumMac::~ScrollbarThemeChromiumMac() 215 61 { 216 }217 218 void ScrollbarThemeChromiumMac::preferencesChanged()219 {220 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];221 [defaults synchronize];222 updateArrowPlacement();223 gInitialButtonDelay = [defaults floatForKey:@"NSScrollerButtonDelay"];224 gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"];225 gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"];226 }227 228 int ScrollbarThemeChromiumMac::scrollbarThickness(ScrollbarControlSize controlSize)229 {230 if (isScrollbarOverlayAPIAvailable())231 return wkScrollbarThickness(controlSize);232 else233 return cScrollbarThickness[controlSize];234 }235 236 bool ScrollbarThemeChromiumMac::usesOverlayScrollbars() const237 {238 if (isScrollbarOverlayAPIAvailable())239 return wkScrollbarPainterUsesOverlayScrollers();240 else241 return false;242 }243 244 static inline wkScrollerKnobStyle toScrollbarPainterKnobStyle(ScrollbarOverlayStyle style)245 {246 switch (style) {247 case ScrollbarOverlayStyleDark:248 return wkScrollerKnobStyleDark;249 case ScrollbarOverlayStyleLight:250 return wkScrollerKnobStyleLight;251 default:252 return wkScrollerKnobStyleDefault;253 }254 }255 256 void ScrollbarThemeChromiumMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar)257 {258 if (isScrollbarOverlayAPIAvailable()) {259 wkSetScrollbarPainterKnobStyle(painterForScrollbar(scrollbar), toScrollbarPainterKnobStyle(scrollbar->scrollableArea()->scrollbarOverlayStyle()));260 }261 }262 263 double ScrollbarThemeChromiumMac::initialAutoscrollTimerDelay()264 {265 return gInitialButtonDelay;266 }267 268 double ScrollbarThemeChromiumMac::autoscrollTimerDelay()269 {270 return gAutoscrollButtonDelay;271 }272 273 ScrollbarButtonsPlacement ScrollbarThemeChromiumMac::buttonsPlacement() const274 {275 return gButtonPlacement;276 }277 278 bool ScrollbarThemeChromiumMac::hasButtons(Scrollbar* scrollbar)279 {280 return scrollbar->enabled() && gButtonPlacement != ScrollbarButtonsNone281 && (scrollbar->orientation() == HorizontalScrollbar282 ? scrollbar->width()283 : scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);284 }285 286 bool ScrollbarThemeChromiumMac::hasThumb(Scrollbar* scrollbar)287 {288 int minLengthForThumb;289 if (isScrollbarOverlayAPIAvailable())290 minLengthForThumb = wkScrollbarMinimumTotalLengthNeededForThumb(scrollbarMap()->get(scrollbar).get());291 else292 minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;293 return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?294 scrollbar->width() :295 scrollbar->height()) >= minLengthForThumb;296 }297 298 static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start)299 {300 ASSERT(gButtonPlacement != ScrollbarButtonsNone);301 302 IntRect paintRect(buttonRect);303 if (orientation == HorizontalScrollbar) {304 paintRect.setWidth(cRealButtonLength[controlSize]);305 if (!start)306 paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - buttonRect.width()));307 } else {308 paintRect.setHeight(cRealButtonLength[controlSize]);309 if (!start)310 paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - buttonRect.height()));311 }312 313 return paintRect;314 }315 316 IntRect ScrollbarThemeChromiumMac::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)317 {318 IntRect result;319 320 if (part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd))321 return result;322 323 if (part == BackButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsSingle))324 return result;325 326 int thickness = scrollbarThickness(scrollbar->controlSize());327 bool outerButton = part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsDoubleBoth);328 if (outerButton) {329 if (scrollbar->orientation() == HorizontalScrollbar)330 result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + (painting ? cOuterButtonOverlap : 0), thickness);331 else332 result = IntRect(scrollbar->x(), scrollbar->y(), thickness, cOuterButtonLength[scrollbar->controlSize()] + (painting ? cOuterButtonOverlap : 0));333 return result;334 }335 336 // Our repaint rect is slightly larger, since we are a button that is adjacent to the track.337 if (scrollbar->orientation() == HorizontalScrollbar) {338 int start = part == BackButtonStartPart ? scrollbar->x() : scrollbar->x() + scrollbar->width() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];339 result = IntRect(start, scrollbar->y(), cButtonLength[scrollbar->controlSize()], thickness);340 } else {341 int start = part == BackButtonStartPart ? scrollbar->y() : scrollbar->y() + scrollbar->height() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];342 result = IntRect(scrollbar->x(), start, thickness, cButtonLength[scrollbar->controlSize()]);343 }344 345 if (painting)346 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == BackButtonStartPart);347 return result;348 }349 350 IntRect ScrollbarThemeChromiumMac::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)351 {352 IntRect result;353 354 if (part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart))355 return result;356 357 if (part == ForwardButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsSingle))358 return result;359 360 int thickness = scrollbarThickness(scrollbar->controlSize());361 int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];362 int buttonLength = cButtonLength[scrollbar->controlSize()];363 364 bool outerButton = part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsDoubleBoth);365 if (outerButton) {366 if (scrollbar->orientation() == HorizontalScrollbar) {367 result = IntRect(scrollbar->x() + scrollbar->width() - outerButtonLength, scrollbar->y(), outerButtonLength, thickness);368 if (painting)369 result.inflateX(cOuterButtonOverlap);370 } else {371 result = IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - outerButtonLength, thickness, outerButtonLength);372 if (painting)373 result.inflateY(cOuterButtonOverlap);374 }375 return result;376 }377 378 if (scrollbar->orientation() == HorizontalScrollbar) {379 int start = part == ForwardButtonEndPart ? scrollbar->x() + scrollbar->width() - buttonLength : scrollbar->x() + outerButtonLength;380 result = IntRect(start, scrollbar->y(), buttonLength, thickness);381 } else {382 int start = part == ForwardButtonEndPart ? scrollbar->y() + scrollbar->height() - buttonLength : scrollbar->y() + outerButtonLength;383 result = IntRect(scrollbar->x(), start, thickness, buttonLength);384 }385 if (painting)386 return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == ForwardButtonStartPart);387 return result;388 }389 390 IntRect ScrollbarThemeChromiumMac::trackRect(Scrollbar* scrollbar, bool painting)391 {392 if (painting || !hasButtons(scrollbar))393 return scrollbar->frameRect();394 395 IntRect result;396 int thickness = scrollbarThickness(scrollbar->controlSize());397 int startWidth = 0;398 int endWidth = 0;399 int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];400 int buttonLength = cButtonLength[scrollbar->controlSize()];401 int doubleButtonLength = outerButtonLength + buttonLength;402 switch (buttonsPlacement()) {403 case ScrollbarButtonsSingle:404 startWidth = buttonLength;405 endWidth = buttonLength;406 break;407 case ScrollbarButtonsDoubleStart:408 startWidth = doubleButtonLength;409 break;410 case ScrollbarButtonsDoubleEnd:411 endWidth = doubleButtonLength;412 break;413 case ScrollbarButtonsDoubleBoth:414 startWidth = doubleButtonLength;415 endWidth = doubleButtonLength;416 break;417 default:418 break;419 }420 421 int totalWidth = startWidth + endWidth;422 if (scrollbar->orientation() == HorizontalScrollbar)423 return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->width() - totalWidth, thickness);424 return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrollbar->height() - totalWidth);425 }426 427 int ScrollbarThemeChromiumMac::minimumThumbLength(Scrollbar* scrollbar)428 {429 if (isScrollbarOverlayAPIAvailable())430 return wkScrollbarMinimumThumbLength(scrollbarMap()->get(scrollbar).get());431 else432 return cThumbMinLength[scrollbar->controlSize()];433 }434 435 bool ScrollbarThemeChromiumMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)436 {437 if (evt.button() != LeftButton)438 return false;439 if (gJumpOnTrackClick)440 return !evt.altKey();441 return evt.altKey();442 }443 444 bool ScrollbarThemeChromiumMac::shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent& event)445 {446 return event.altKey();447 }448 449 static int scrollbarPartToHIPressedState(ScrollbarPart part)450 {451 switch (part) {452 case BackButtonStartPart:453 return kThemeTopOutsideArrowPressed;454 case BackButtonEndPart:455 return kThemeTopOutsideArrowPressed; // This does not make much sense. For some reason the outside constant is required.456 case ForwardButtonStartPart:457 return kThemeTopInsideArrowPressed;458 case ForwardButtonEndPart:459 return kThemeBottomOutsideArrowPressed;460 case ThumbPart:461 return kThemeThumbPressed;462 default:463 return 0;464 }465 62 } 466 63 … … 477 74 } 478 75 479 void ScrollbarThemeChromiumMac::updateEnabledState(Scrollbar* scrollbar) 480 { 481 if (isScrollbarOverlayAPIAvailable()) { 482 wkScrollbarPainterSetEnabled(scrollbarMap()->get(scrollbar).get(), scrollbar->enabled()); 483 } 484 } 485 76 static void scrollbarPainterPaintTrack(ScrollbarPainter scrollbarPainter, bool enabled, double value, CGFloat proportion, CGRect frameRect) 77 { 78 [scrollbarPainter setEnabled:enabled]; 79 [scrollbarPainter setBoundsSize: NSSizeFromCGSize(frameRect.size)]; 80 [scrollbarPainter setDoubleValue:value]; 81 [scrollbarPainter setKnobProportion:proportion]; 82 83 // The scrollbar's frameRect includes a side inset for overlay scrollers, so we have to use the 84 // trackWidth for drawKnobSlotInRect 85 NSRect trackRect; 86 if ([scrollbarPainter isHorizontal]) 87 trackRect = NSMakeRect(0, 0, frameRect.size.width, [scrollbarPainter trackWidth]); 88 else 89 trackRect = NSMakeRect(0, 0, [scrollbarPainter trackWidth], frameRect.size.height); 90 [scrollbarPainter drawKnobSlotInRect:trackRect highlight:NO]; 91 } 92 93 // Override ScrollbarThemeMac::paint() to add support for the following: 94 // - drawing using PlatformSupport functions 95 // - drawing tickmarks 96 // - Skia specific changes 486 97 bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) 487 98 { … … 511 122 } 512 123 513 ScrollAnimatorChromiumMac* scrollAnimator = static_cast<ScrollAnimatorChromiumMac*>(scrollbar->scrollableArea()->scrollAnimator());514 124 #if !USE(SKIA) 515 s crollAnimator->setIsDrawingIntoLayer(context->isCALayerContext());125 setIsCurrentlyDrawingIntoLayer(context->isCALayerContext()); 516 126 #else 517 s crollAnimator->setIsDrawingIntoLayer(false);127 setIsCurrentlyDrawingIntoLayer(false); 518 128 #endif 519 129 … … 521 131 CGFloat oldTrackAlpha = 0; 522 132 bool hasTickmarks = tickmarks.size() > 0 && scrollbar->orientation() == VerticalScrollbar; 133 ScrollbarPainter scrollbarPainter = painterForScrollbar(scrollbar); 523 134 if (hasTickmarks) { 524 oldKnobAlpha = wkScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar));525 wkSetScrollbarPainterKnobAlpha(painterForScrollbar(scrollbar), 1.0);526 oldTrackAlpha = wkScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar));527 wkSetScrollbarPainterTrackAlpha(painterForScrollbar(scrollbar), 1.0);135 oldKnobAlpha = [scrollbarPainter knobAlpha]; 136 [scrollbarPainter setKnobAlpha:1.0]; 137 oldTrackAlpha = [scrollbarPainter trackAlpha]; 138 [scrollbarPainter setTrackAlpha:1.0]; 528 139 } 529 140 … … 532 143 context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); 533 144 LocalCurrentGraphicsContext localContext(context); 534 WKScrollbarPainterRef scrollbarPainter = scrollbarMap()->get(scrollbar).get(); 535 wkScrollbarPainterPaintTrack(scrollbarPainter, 536 scrollbar->enabled(), 537 value, 538 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 539 scrollbar->frameRect()); 145 scrollbarPainterPaintTrack(scrollbarPainter, 146 scrollbar->enabled(), 147 value, 148 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 149 scrollbar->frameRect()); 540 150 541 151 IntRect tickmarkTrackRect(IntPoint(), trackRect(scrollbar, false).size()); … … 551 161 paintGivenTickmarks(context, scrollbar, tickmarkTrackRect, tickmarks); 552 162 553 wkScrollbarPainterPaintKnob(scrollbarPainter); 554 555 scrollAnimator->setIsDrawingIntoLayer(false); 163 if (scrollbar->enabled()) 164 [scrollbarPainter drawKnob]; 165 166 setIsCurrentlyDrawingIntoLayer(false); 556 167 557 168 if (hasTickmarks) { 558 wkSetScrollbarPainterKnobAlpha(scrollbarPainter, oldKnobAlpha);559 wkSetScrollbarPainterTrackAlpha(scrollbarPainter, oldTrackAlpha);169 [scrollbarPainter setKnobAlpha:oldKnobAlpha]; 170 [scrollbarPainter setTrackAlpha:oldTrackAlpha]; 560 171 } 561 172 -
trunk/Source/WebCore/platform/mac/EmptyProtocolDefinitions.h
r95901 r103291 35 35 EMPTY_PROTOCOL(NSTableViewDelegate) 36 36 EMPTY_PROTOCOL(NSWindowDelegate) 37 EMPTY_PROTOCOL(NSAnimationDelegate) 37 38 38 39 #endif -
trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h
r99493 r103291 29 29 #include "config.h" 30 30 31 #if USE(SCROLLBAR_PAINTER) 31 // Public APIs not available on versions of Mac on which we build 32 #if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)) 33 enum { 34 NSScrollerStyleLegacy = 0, 35 NSScrollerStyleOverlay = 1 36 }; 37 typedef NSInteger NSScrollerStyle; 38 39 enum { 40 NSScrollerKnobStyleDefault = 0, 41 NSScrollerKnobStyleDark = 1, 42 NSScrollerKnobStyleLight = 2 43 }; 44 typedef NSInteger NSScrollerKnobStyle; 45 #endif 46 47 #if (defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)) 48 @interface NSScroller(NSObject) 49 + (NSScrollerStyle)preferredScrollerStyle; 50 @end 51 #endif 52 32 53 @interface NSObject (ScrollbarPainter) 33 54 + (id)scrollerImpWithStyle:(NSScrollerStyle)newScrollerStyle controlSize:(NSControlSize)newControlSize horizontal:(BOOL)horizontal replacingScrollerImp:(id)previous; … … 82 103 - (void)endScrollGesture; 83 104 @end 105 106 namespace WebCore { 107 108 #if PLATFORM(CHROMIUM) 109 bool isScrollbarOverlayAPIAvailable(); 110 #else 111 static inline bool isScrollbarOverlayAPIAvailable() 112 { 113 #if USE(SCROLLBAR_PAINTER) 114 return true; 115 #else 116 return false; 117 #endif 118 } 84 119 #endif 85 120 121 NSScrollerStyle recommendedScrollerStyle(); 122 123 } 124 86 125 #endif -
trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.mm
r103290 r103291 1 1 /* 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2011 Google Inc. All Rights Reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 24 25 */ 25 26 26 #if defined(__OBJC__)27 27 28 #define EMPTY_PROTOCOL(NAME) \ 29 @protocol NAME <NSObject> \ 30 @end 28 #include "config.h" 29 #include "NSScrollerImpDetails.h" 31 30 32 #ifdef BUILDING_ON_LEOPARD 31 namespace WebCore { 33 32 34 EMPTY_PROTOCOL(NSTableViewDataSource) 35 EMPTY_PROTOCOL(NSTableViewDelegate) 36 EMPTY_PROTOCOL(NSWindowDelegate) 37 33 #if PLATFORM(CHROMIUM) 34 bool isScrollbarOverlayAPIAvailable() 35 { 36 static bool apiAvailable; 37 static bool shouldInitialize = true; 38 if (shouldInitialize) { 39 shouldInitialize = false; 40 Class scrollerImpClass = NSClassFromString(@"NSScrollerImp"); 41 Class scrollerImpPairClass = NSClassFromString(@"NSScrollerImpPair"); 42 apiAvailable = [scrollerImpClass respondsToSelector:@selector(scrollerImpWithStyle:controlSize:horizontal:replacingScrollerImp:)] 43 && [scrollerImpPairClass instancesRespondToSelector:@selector(scrollerStyle)]; 44 } 45 return apiAvailable; 46 } 38 47 #endif 39 48 40 #if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) 49 NSScrollerStyle recommendedScrollerStyle() { 50 if ([NSScroller respondsToSelector:@selector(preferredScrollerStyle)]) 51 return [NSScroller preferredScrollerStyle]; 52 return NSScrollerStyleLegacy; 53 } 41 54 42 EMPTY_PROTOCOL(NSURLConnectionDelegate) 43 EMPTY_PROTOCOL(NSURLDownloadDelegate) 44 45 #endif 46 47 #undef EMPTY_PROTOCOL 48 49 #endif /* defined(__OBJC__) */ 55 } -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h
r102476 r103291 47 47 #endif 48 48 49 #if USE(SCROLLBAR_PAINTER)50 49 typedef id ScrollbarPainterController; 51 #endif52 50 53 51 #if !ENABLE(RUBBER_BANDING) … … 87 85 virtual void setIsActive(); 88 86 89 #if USE(SCROLLBAR_PAINTER)90 87 void updateScrollerStyle(); 91 88 … … 93 90 void startScrollbarPaintTimer(); 94 91 void stopScrollbarPaintTimer(); 95 #endif96 92 97 93 void setVisibleScrollerThumbRect(const IntRect&); … … 101 97 RetainPtr<WebScrollAnimationHelperDelegate> m_scrollAnimationHelperDelegate; 102 98 103 #if USE(SCROLLBAR_PAINTER)104 99 RetainPtr<ScrollbarPainterController> m_scrollbarPainterController; 105 100 RetainPtr<WebScrollbarPainterControllerDelegate> m_scrollbarPainterControllerDelegate; … … 109 104 void initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>*); 110 105 Timer<ScrollAnimatorMac> m_initialScrollbarPaintTimer; 111 #endif112 106 113 107 virtual void notifyPositionChanged(); -
trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm
r103112 r103291 31 31 32 32 #include "BlockExceptions.h" 33 #include "EmptyProtocolDefinitions.h" 33 34 #include "FloatPoint.h" 34 35 #include "NSScrollerImpDetails.h" … … 46 47 using namespace std; 47 48 48 #if USE(SCROLLBAR_PAINTER) 49 #ifdef BUILDING_ON_LEOPARD 50 @interface NSProcessInfo (ScrollAnimatorMacExt) 51 - (NSTimeInterval)systemUptime; 52 @end 53 #endif 54 49 55 static bool supportsUIStateTransitionProgress() 50 56 { … … 67 73 return nil; 68 74 } 69 #endif70 75 71 76 @interface NSObject (ScrollAnimationHelperDetails) … … 172 177 173 178 @end 174 175 #if USE(SCROLLBAR_PAINTER)176 179 177 180 @interface WebScrollbarPainterControllerDelegate : NSObject … … 410 413 } 411 414 415 #if !PLATFORM(CHROMIUM) 412 416 - (CALayer *)layer 413 417 { … … 422 426 return dummyLayer; 423 427 } 428 #endif 424 429 425 430 - (NSPoint)mouseLocationInScrollerForScrollerImp:(id)scrollerImp … … 542 547 @end 543 548 544 #endif // USE(SCROLLBAR_PAINTER)545 546 549 namespace WebCore { 547 550 … … 553 556 ScrollAnimatorMac::ScrollAnimatorMac(ScrollableArea* scrollableArea) 554 557 : ScrollAnimator(scrollableArea) 555 #if USE(SCROLLBAR_PAINTER)556 558 , m_initialScrollbarPaintTimer(this, &ScrollAnimatorMac::initialScrollbarPaintTimerFired) 557 #endif558 559 #if ENABLE(RUBBER_BANDING) 559 560 , m_scrollElasticityController(this) … … 566 567 m_scrollAnimationHelper.adoptNS([[NSClassFromString(@"NSScrollAnimationHelper") alloc] initWithDelegate:m_scrollAnimationHelperDelegate.get()]); 567 568 568 #if USE(SCROLLBAR_PAINTER) 569 m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterControllerDelegate alloc] initWithScrollableArea:scrollableArea]);570 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") alloc] init] autorelease];571 [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterControllerDelegate.get()];572 [m_scrollbarPainterController.get() setScrollerStyle:wkRecommendedScrollerStyle()];573 #endif 569 if (isScrollbarOverlayAPIAvailable()) { 570 m_scrollbarPainterControllerDelegate.adoptNS([[WebScrollbarPainterControllerDelegate alloc] initWithScrollableArea:scrollableArea]); 571 m_scrollbarPainterController = [[[NSClassFromString(@"NSScrollerImpPair") alloc] init] autorelease]; 572 [m_scrollbarPainterController.get() setDelegate:m_scrollbarPainterControllerDelegate.get()]; 573 [m_scrollbarPainterController.get() setScrollerStyle:recommendedScrollerStyle()]; 574 } 574 575 } 575 576 576 577 ScrollAnimatorMac::~ScrollAnimatorMac() 577 578 { 578 #if USE(SCROLLBAR_PAINTER) 579 BEGIN_BLOCK_OBJC_EXCEPTIONS;580 [m_scrollbarPainterControllerDelegate.get() invalidate];581 [m_scrollbarPainterController.get() setDelegate:nil];582 [m_horizontalScrollbarPainterDelegate.get() invalidate];583 [m_verticalScrollbarPainterDelegate.get() invalidate];584 [m_scrollAnimationHelperDelegate.get() invalidate];585 END_BLOCK_OBJC_EXCEPTIONS;586 #endif 579 if (isScrollbarOverlayAPIAvailable()) { 580 BEGIN_BLOCK_OBJC_EXCEPTIONS; 581 [m_scrollbarPainterControllerDelegate.get() invalidate]; 582 [m_scrollbarPainterController.get() setDelegate:nil]; 583 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 584 [m_verticalScrollbarPainterDelegate.get() invalidate]; 585 [m_scrollAnimationHelperDelegate.get() invalidate]; 586 END_BLOCK_OBJC_EXCEPTIONS; 587 } 587 588 } 588 589 … … 696 697 void ScrollAnimatorMac::notifyPositionChanged() 697 698 { 698 #if USE(SCROLLBAR_PAINTER) 699 // This function is called when a page is going into the page cache, but the page700 // isn't really scrolling in that case. We should only pass the message on to the701 // ScrollbarPainterController when we're really scrolling on an active page.702 if (scrollableArea()->isOnActivePage())703 [m_scrollbarPainterController.get() contentAreaScrolled];704 #endif 699 if (isScrollbarOverlayAPIAvailable()) { 700 // This function is called when a page is going into the page cache, but the page 701 // isn't really scrolling in that case. We should only pass the message on to the 702 // ScrollbarPainterController when we're really scrolling on an active page. 703 if (scrollableArea()->isOnActivePage()) 704 [m_scrollbarPainterController.get() contentAreaScrolled]; 705 } 705 706 ScrollAnimator::notifyPositionChanged(); 706 707 } … … 710 711 if (!scrollableArea()->isOnActivePage()) 711 712 return; 712 #if USE(SCROLLBAR_PAINTER) 713 [m_scrollbarPainterController.get() contentAreaWillDraw]; 714 #endif 713 if (isScrollbarOverlayAPIAvailable()) 714 [m_scrollbarPainterController.get() contentAreaWillDraw]; 715 715 } 716 716 … … 719 719 if (!scrollableArea()->isOnActivePage()) 720 720 return; 721 #if USE(SCROLLBAR_PAINTER) 722 [m_scrollbarPainterController.get() mouseEnteredContentArea]; 723 #endif 721 if (isScrollbarOverlayAPIAvailable()) 722 [m_scrollbarPainterController.get() mouseEnteredContentArea]; 724 723 } 725 724 … … 728 727 if (!scrollableArea()->isOnActivePage()) 729 728 return; 730 #if USE(SCROLLBAR_PAINTER) 731 [m_scrollbarPainterController.get() mouseExitedContentArea]; 732 #endif 729 if (isScrollbarOverlayAPIAvailable()) 730 [m_scrollbarPainterController.get() mouseExitedContentArea]; 733 731 } 734 732 … … 737 735 if (!scrollableArea()->isOnActivePage()) 738 736 return; 739 #if USE(SCROLLBAR_PAINTER) 740 [m_scrollbarPainterController.get() mouseMovedInContentArea]; 741 #endif 737 if (isScrollbarOverlayAPIAvailable()) 738 [m_scrollbarPainterController.get() mouseMovedInContentArea]; 742 739 } 743 740 … … 746 743 if (!scrollableArea()->isOnActivePage()) 747 744 return; 748 #if USE(SCROLLBAR_PAINTER) 749 if (!supportsUIStateTransitionProgress()) 750 return; 751 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 752 [painter mouseEnteredScroller]; 753 #else 754 UNUSED_PARAM(scrollbar); 755 #endif 745 if (isScrollbarOverlayAPIAvailable()) { 746 if (!supportsUIStateTransitionProgress()) 747 return; 748 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 749 [painter mouseEnteredScroller]; 750 } 756 751 } 757 752 … … 760 755 if (!scrollableArea()->isOnActivePage()) 761 756 return; 762 #if USE(SCROLLBAR_PAINTER) 763 if (!supportsUIStateTransitionProgress()) 764 return; 765 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 766 [painter mouseExitedScroller]; 767 #else 768 UNUSED_PARAM(scrollbar); 769 #endif 757 if (isScrollbarOverlayAPIAvailable()) { 758 if (!supportsUIStateTransitionProgress()) 759 return; 760 if (ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar)) 761 [painter mouseExitedScroller]; 762 } 770 763 } 771 764 … … 774 767 if (!scrollableArea()->isOnActivePage()) 775 768 return; 776 #if USE(SCROLLBAR_PAINTER) 777 [m_scrollbarPainterController.get() startLiveResize]; 778 #endif 769 if (isScrollbarOverlayAPIAvailable()) 770 [m_scrollbarPainterController.get() startLiveResize]; 779 771 } 780 772 … … 783 775 if (!scrollableArea()->isOnActivePage()) 784 776 return; 785 #if USE(SCROLLBAR_PAINTER) 786 [m_scrollbarPainterController.get() contentAreaDidResize]; 787 #endif 777 if (isScrollbarOverlayAPIAvailable()) 778 [m_scrollbarPainterController.get() contentAreaDidResize]; 788 779 } 789 780 … … 792 783 if (!scrollableArea()->isOnActivePage()) 793 784 return; 794 #if USE(SCROLLBAR_PAINTER) 795 [m_scrollbarPainterController.get() endLiveResize]; 796 #endif 785 if (isScrollbarOverlayAPIAvailable()) 786 [m_scrollbarPainterController.get() endLiveResize]; 797 787 } 798 788 … … 801 791 if (!scrollableArea()->isOnActivePage()) 802 792 return; 803 #if USE(SCROLLBAR_PAINTER) 804 [m_scrollbarPainterController.get() windowOrderedIn]; 805 #endif 793 if (isScrollbarOverlayAPIAvailable()) 794 [m_scrollbarPainterController.get() windowOrderedIn]; 806 795 } 807 796 … … 810 799 if (!scrollableArea()->isOnActivePage()) 811 800 return; 812 #if USE(SCROLLBAR_PAINTER) 813 [m_scrollbarPainterController.get() windowOrderedOut]; 814 #endif 801 if (isScrollbarOverlayAPIAvailable()) 802 [m_scrollbarPainterController.get() windowOrderedOut]; 815 803 } 816 804 … … 819 807 if (!scrollableArea()->isOnActivePage()) 820 808 return; 821 #if USE(SCROLLBAR_PAINTER) 822 [m_scrollbarPainterController.get() beginScrollGesture]; 823 #endif 809 if (isScrollbarOverlayAPIAvailable()) 810 [m_scrollbarPainterController.get() beginScrollGesture]; 824 811 } 825 812 … … 828 815 if (!scrollableArea()->isOnActivePage()) 829 816 return; 830 #if USE(SCROLLBAR_PAINTER) 831 [m_scrollbarPainterController.get() endScrollGesture]; 832 #endif 817 if (isScrollbarOverlayAPIAvailable()) 818 [m_scrollbarPainterController.get() endScrollGesture]; 833 819 } 834 820 835 821 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar) 836 822 { 837 #if USE(SCROLLBAR_PAINTER) 838 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 839 if (!painter) 840 return; 841 842 ASSERT(!m_verticalScrollbarPainterDelegate); 843 m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]); 844 845 [painter setDelegate:m_verticalScrollbarPainterDelegate.get()]; 846 [m_scrollbarPainterController.get() setVerticalScrollerImp:painter]; 847 if (scrollableArea()->inLiveResize()) 848 [painter setKnobAlpha:1]; 849 850 #else 851 UNUSED_PARAM(scrollbar); 852 #endif 823 if (isScrollbarOverlayAPIAvailable()) { 824 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 825 if (!painter) 826 return; 827 828 ASSERT(!m_verticalScrollbarPainterDelegate); 829 m_verticalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]); 830 831 [painter setDelegate:m_verticalScrollbarPainterDelegate.get()]; 832 [m_scrollbarPainterController.get() setVerticalScrollerImp:painter]; 833 if (scrollableArea()->inLiveResize()) 834 [painter setKnobAlpha:1]; 835 } 853 836 } 854 837 855 838 void ScrollAnimatorMac::willRemoveVerticalScrollbar(Scrollbar* scrollbar) 856 839 { 857 #if USE(SCROLLBAR_PAINTER) 858 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 859 if (!painter) 860 return; 861 862 ASSERT(m_verticalScrollbarPainterDelegate); 863 [m_verticalScrollbarPainterDelegate.get() invalidate]; 864 m_verticalScrollbarPainterDelegate = nullptr; 865 866 [painter setDelegate:nil]; 867 [m_scrollbarPainterController.get() setVerticalScrollerImp:nil]; 868 #else 869 UNUSED_PARAM(scrollbar); 870 #endif 840 if (isScrollbarOverlayAPIAvailable()) { 841 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 842 if (!painter) 843 return; 844 845 ASSERT(m_verticalScrollbarPainterDelegate); 846 [m_verticalScrollbarPainterDelegate.get() invalidate]; 847 m_verticalScrollbarPainterDelegate = nullptr; 848 849 [painter setDelegate:nil]; 850 [m_scrollbarPainterController.get() setVerticalScrollerImp:nil]; 851 } 871 852 } 872 853 873 854 void ScrollAnimatorMac::didAddHorizontalScrollbar(Scrollbar* scrollbar) 874 855 { 875 #if USE(SCROLLBAR_PAINTER) 876 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 877 if (!painter) 878 return; 879 880 ASSERT(!m_horizontalScrollbarPainterDelegate); 881 m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]); 882 883 [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()]; 884 [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter]; 885 if (scrollableArea()->inLiveResize()) 886 [painter setKnobAlpha:1]; 887 #else 888 UNUSED_PARAM(scrollbar); 889 #endif 856 if (isScrollbarOverlayAPIAvailable()) { 857 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 858 if (!painter) 859 return; 860 861 ASSERT(!m_horizontalScrollbarPainterDelegate); 862 m_horizontalScrollbarPainterDelegate.adoptNS([[WebScrollbarPainterDelegate alloc] initWithScrollbar:scrollbar]); 863 864 [painter setDelegate:m_horizontalScrollbarPainterDelegate.get()]; 865 [m_scrollbarPainterController.get() setHorizontalScrollerImp:painter]; 866 if (scrollableArea()->inLiveResize()) 867 [painter setKnobAlpha:1]; 868 } 890 869 } 891 870 892 871 void ScrollAnimatorMac::willRemoveHorizontalScrollbar(Scrollbar* scrollbar) 893 872 { 894 #if USE(SCROLLBAR_PAINTER) 895 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 896 if (!painter) 897 return; 898 899 ASSERT(m_horizontalScrollbarPainterDelegate); 900 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 901 m_horizontalScrollbarPainterDelegate = nullptr; 902 903 [painter setDelegate:nil]; 904 [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil]; 905 #else 906 UNUSED_PARAM(scrollbar); 907 #endif 873 if (isScrollbarOverlayAPIAvailable()) { 874 ScrollbarPainter painter = scrollbarPainterForScrollbar(scrollbar); 875 if (!painter) 876 return; 877 878 ASSERT(m_horizontalScrollbarPainterDelegate); 879 [m_horizontalScrollbarPainterDelegate.get() invalidate]; 880 m_horizontalScrollbarPainterDelegate = nullptr; 881 882 [painter setDelegate:nil]; 883 [m_scrollbarPainterController.get() setHorizontalScrollerImp:nil]; 884 } 908 885 } 909 886 … … 912 889 m_haveScrolledSincePageLoad = false; 913 890 914 #if USE(SCROLLBAR_PAINTER) 915 if (scrollbarPaintTimerIsActive())916 stopScrollbarPaintTimer();917 [m_horizontalScrollbarPainterDelegate.get() cancelAnimations];918 [m_verticalScrollbarPainterDelegate.get() cancelAnimations];919 #endif 891 if (isScrollbarOverlayAPIAvailable()) { 892 if (scrollbarPaintTimerIsActive()) 893 stopScrollbarPaintTimer(); 894 [m_horizontalScrollbarPainterDelegate.get() cancelAnimations]; 895 [m_verticalScrollbarPainterDelegate.get() cancelAnimations]; 896 } 920 897 } 921 898 … … 1405 1382 void ScrollAnimatorMac::setIsActive() 1406 1383 { 1407 #if USE(SCROLLBAR_PAINTER) 1408 if (needsScrollerStyleUpdate()) 1409 updateScrollerStyle(); 1410 #endif 1411 } 1412 1413 #if USE(SCROLLBAR_PAINTER) 1384 if (isScrollbarOverlayAPIAvailable()) { 1385 if (needsScrollerStyleUpdate()) 1386 updateScrollerStyle(); 1387 } 1388 } 1389 1414 1390 void ScrollAnimatorMac::updateScrollerStyle() 1415 1391 { 1392 if (!isScrollbarOverlayAPIAvailable()) 1393 return; 1394 1416 1395 if (!scrollableArea()->isOnActivePage()) { 1417 1396 setNeedsScrollerStyleUpdate(true); … … 1487 1466 void ScrollAnimatorMac::initialScrollbarPaintTimerFired(Timer<ScrollAnimatorMac>*) 1488 1467 { 1489 // To force the scrollbars to flash, we have to call hide first. Otherwise, the ScrollbarPainterController 1490 // might think that the scrollbars are already showing and bail early. 1491 [m_scrollbarPainterController.get() hideOverlayScrollers]; 1492 [m_scrollbarPainterController.get() flashScrollers]; 1493 } 1494 #endif 1468 if (isScrollbarOverlayAPIAvailable()) { 1469 // To force the scrollbars to flash, we have to call hide first. Otherwise, the ScrollbarPainterController 1470 // might think that the scrollbars are already showing and bail early. 1471 [m_scrollbarPainterController.get() hideOverlayScrollers]; 1472 [m_scrollbarPainterController.get() flashScrollers]; 1473 } 1474 } 1495 1475 1496 1476 void ScrollAnimatorMac::setVisibleScrollerThumbRect(const IntRect& scrollerThumb) -
trunk/Source/WebCore/platform/mac/ScrollElasticityController.h
r96663 r103291 29 29 #if ENABLE(RUBBER_BANDING) 30 30 31 #include <WebCore/FloatPoint.h>32 #include <WebCore/FloatSize.h>31 #include "FloatPoint.h" 32 #include "FloatSize.h" 33 33 #include <wtf/Noncopyable.h> 34 34 -
trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h
r102476 r103291 29 29 #include "ScrollbarThemeComposite.h" 30 30 31 #if USE(SCROLLBAR_PAINTER)32 31 typedef id ScrollbarPainter; 33 #endif34 32 35 33 namespace WebCore { … … 44 42 virtual void updateEnabledState(Scrollbar*); 45 43 44 #if !PLATFORM(CHROMIUM) 46 45 virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect); 46 #endif 47 47 48 48 virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); … … 60 60 virtual void unregisterScrollbar(Scrollbar*); 61 61 62 #if USE(SCROLLBAR_PAINTER)63 62 void setNewPainterForScrollbar(Scrollbar*, ScrollbarPainter); 64 63 ScrollbarPainter painterForScrollbar(Scrollbar*); 65 64 66 65 static bool isCurrentlyDrawingIntoLayer(); 67 #endif 66 static void setIsCurrentlyDrawingIntoLayer(bool); 68 67 69 68 protected: … … 81 80 virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&); 82 81 virtual bool shouldDragDocumentInsteadOfThumb(Scrollbar*, const PlatformMouseEvent&); 82 int scrollbarPartToHIPressedState(ScrollbarPart); 83 83 }; 84 84 -
trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm
r102476 r103291 47 47 namespace WebCore { 48 48 49 #if USE(SCROLLBAR_PAINTER)50 49 typedef HashMap<Scrollbar*, RetainPtr<ScrollbarPainter> > ScrollbarPainterMap; 51 #else52 typedef HashSet<Scrollbar*> ScrollbarPainterMap;53 #endif54 50 55 51 static ScrollbarPainterMap* scrollbarMap() … … 76 72 { 77 73 UNUSED_PARAM(unusedNotification); 74 75 ScrollbarTheme* theme = ScrollbarTheme::theme(); 76 if (theme->isMockTheme()) 77 return; 78 78 79 79 static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged(); … … 82 82 ScrollbarPainterMap::iterator end = scrollbarMap()->end(); 83 83 for (ScrollbarPainterMap::iterator it = scrollbarMap()->begin(); it != end; ++it) { 84 #if USE(SCROLLBAR_PAINTER)85 84 it->first->styleChanged(); 86 85 it->first->invalidate(); 87 #else88 (*it)->styleChanged();89 (*it)->invalidate();90 #endif91 86 } 92 87 } … … 95 90 { 96 91 UNUSED_PARAM(unusedNotification); 92 93 ScrollbarTheme* theme = ScrollbarTheme::theme(); 94 if (theme->isMockTheme()) 95 return; 97 96 98 97 static_cast<ScrollbarThemeMac*>(ScrollbarTheme::theme())->preferencesChanged(); … … 109 108 namespace WebCore { 110 109 110 #if !PLATFORM(CHROMIUM) 111 111 ScrollbarTheme* ScrollbarTheme::nativeTheme() 112 112 { … … 114 114 return &theme; 115 115 } 116 #endif 116 117 117 118 // FIXME: Get these numbers from CoreUI. … … 120 121 // cRealButtonLength - cButtonInset 121 122 static int cButtonLength[] = { 14, 10 }; 122 #if !USE(SCROLLBAR_PAINTER)123 123 static int cScrollbarThickness[] = { 15, 11 }; 124 124 static int cButtonInset[] = { 14, 11 }; 125 125 static int cThumbMinLength[] = { 26, 20 }; 126 #endif127 126 128 127 static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double button pair is a bit bigger. … … 133 132 static bool gJumpOnTrackClick = false; 134 133 135 #if USE(SCROLLBAR_PAINTER)136 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsNone;137 #else138 134 static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd; 139 #endif140 135 141 136 static void updateArrowPlacement() 142 137 { 143 #if USE(SCROLLBAR_PAINTER)144 return;145 #endif 138 if (isScrollbarOverlayAPIAvailable()) 139 return; 140 146 141 NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"]; 147 142 if ([buttonPlacement isEqualToString:@"Single"]) … … 159 154 void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar) 160 155 { 161 #if USE(SCROLLBAR_PAINTER) 162 bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar;163 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:wkRecommendedScrollerStyle() controlSize:(NSControlSize)scrollbar->controlSize() horizontal:isHorizontal replacingScrollerImp:nil];164 scrollbarMap()->add(scrollbar, scrollbarPainter);165 updateEnabledState(scrollbar);166 updateScrollbarOverlayStyle(scrollbar);167 #else 168 scrollbarMap()->add(scrollbar);169 #endif 156 if (isScrollbarOverlayAPIAvailable()) { 157 bool isHorizontal = scrollbar->orientation() == HorizontalScrollbar; 158 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:(NSControlSize)scrollbar->controlSize() horizontal:isHorizontal replacingScrollerImp:nil]; 159 scrollbarMap()->add(scrollbar, scrollbarPainter); 160 updateEnabledState(scrollbar); 161 updateScrollbarOverlayStyle(scrollbar); 162 } else { 163 scrollbarMap()->add(scrollbar, nil); 164 } 170 165 } 171 166 … … 175 170 } 176 171 177 #if USE(SCROLLBAR_PAINTER)178 172 void ScrollbarThemeMac::setNewPainterForScrollbar(Scrollbar* scrollbar, ScrollbarPainter newPainter) 179 173 { … … 195 189 } 196 190 197 #endif 191 void ScrollbarThemeMac::setIsCurrentlyDrawingIntoLayer(bool b) 192 { 193 g_isCurrentlyDrawingIntoLayer = b; 194 } 198 195 199 196 ScrollbarThemeMac::ScrollbarThemeMac() … … 202 199 if (!initialized) { 203 200 initialized = true; 201 gButtonPlacement = isScrollbarOverlayAPIAvailable() ? ScrollbarButtonsNone : ScrollbarButtonsDoubleEnd; 204 202 [WebScrollbarPrefsObserver registerAsObserver]; 205 203 preferencesChanged(); … … 223 221 int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize) 224 222 { 225 #if USE(SCROLLBAR_PAINTER) 226 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:wkRecommendedScrollerStyle() controlSize:controlSize horizontal:NO replacingScrollerImp:nil]; 227 return [scrollbarPainter trackBoxWidth]; 228 #else 229 return cScrollbarThickness[controlSize]; 230 #endif 223 if (isScrollbarOverlayAPIAvailable()) { 224 ScrollbarPainter scrollbarPainter = [NSClassFromString(@"NSScrollerImp") scrollerImpWithStyle:recommendedScrollerStyle() controlSize:controlSize horizontal:NO replacingScrollerImp:nil]; 225 return [scrollbarPainter trackBoxWidth]; 226 } else 227 return cScrollbarThickness[controlSize]; 231 228 } 232 229 233 230 bool ScrollbarThemeMac::usesOverlayScrollbars() const 234 231 { 235 #if USE(SCROLLBAR_PAINTER) 236 return wkRecommendedScrollerStyle() == NSScrollerStyleOverlay; 237 #else 238 return false; 239 #endif 232 if (isScrollbarOverlayAPIAvailable()) 233 return recommendedScrollerStyle() == NSScrollerStyleOverlay; 234 else 235 return false; 240 236 } 241 237 242 238 void ScrollbarThemeMac::updateScrollbarOverlayStyle(Scrollbar* scrollbar) 243 239 { 244 #if USE(SCROLLBAR_PAINTER)245 240 ScrollbarPainter painter = painterForScrollbar(scrollbar); 246 241 switch (scrollbar->scrollableArea()->scrollbarOverlayStyle()) { … … 255 250 break; 256 251 } 257 #else258 UNUSED_PARAM(scrollbar);259 #endif260 252 } 261 253 … … 277 269 bool ScrollbarThemeMac::hasButtons(Scrollbar* scrollbar) 278 270 { 279 return scrollbar->enabled() && gButtonPlacement!= ScrollbarButtonsNone271 return scrollbar->enabled() && buttonsPlacement() != ScrollbarButtonsNone 280 272 && (scrollbar->orientation() == HorizontalScrollbar 281 273 ? scrollbar->width() … … 286 278 { 287 279 int minLengthForThumb; 288 #if USE(SCROLLBAR_PAINTER) 289 ScrollbarPainter painter = scrollbarMap()->get(scrollbar).get(); 290 minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndInset] + [painter knobOverlapEndInset] 291 + 2 * ([painter trackEndInset] + [painter knobEndInset]); 292 #else 293 minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1; 294 #endif 280 if (isScrollbarOverlayAPIAvailable()) { 281 ScrollbarPainter painter = scrollbarMap()->get(scrollbar).get(); 282 minLengthForThumb = [painter knobMinLength] + [painter trackOverlapEndInset] + [painter knobOverlapEndInset] 283 + 2 * ([painter trackEndInset] + [painter knobEndInset]); 284 } else 285 minLengthForThumb = 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1; 295 286 return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ? 296 287 scrollbar->width() : … … 429 420 int ScrollbarThemeMac::minimumThumbLength(Scrollbar* scrollbar) 430 421 { 431 #if USE(SCROLLBAR_PAINTER) 432 return [scrollbarMap()->get(scrollbar).get() knobMinLength]; 433 #else 434 return cThumbMinLength[scrollbar->controlSize()]; 435 #endif 422 if (isScrollbarOverlayAPIAvailable()) 423 return [scrollbarMap()->get(scrollbar).get() knobMinLength]; 424 else 425 return cThumbMinLength[scrollbar->controlSize()]; 436 426 } 437 427 … … 450 440 } 451 441 452 static intscrollbarPartToHIPressedState(ScrollbarPart part)442 int ScrollbarThemeMac::scrollbarPartToHIPressedState(ScrollbarPart part) 453 443 { 454 444 switch (part) { … … 470 460 void ScrollbarThemeMac::updateEnabledState(Scrollbar* scrollbar) 471 461 { 472 #if USE(SCROLLBAR_PAINTER) 473 [scrollbarMap()->get(scrollbar).get() setEnabled:scrollbar->enabled()]; 474 #else 475 UNUSED_PARAM(scrollbar); 476 #endif 477 } 478 479 #if USE(SCROLLBAR_PAINTER) 462 if (isScrollbarOverlayAPIAvailable()) 463 [scrollbarMap()->get(scrollbar).get() setEnabled:scrollbar->enabled()]; 464 } 465 480 466 static void scrollbarPainterPaint(ScrollbarPainter scrollbarPainter, bool enabled, double value, CGFloat proportion, CGRect frameRect) 481 467 { … … 499 485 [scrollbarPainter drawKnob]; 500 486 } 501 #endif 502 487 488 #if !PLATFORM(CHROMIUM) 503 489 bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect) 504 490 { 505 #if USE(SCROLLBAR_PAINTER) 506 float value = 0; 507 float overhang = 0; 508 509 if (scrollbar->currentPos() < 0) { 510 // Scrolled past the top. 511 value = 0; 512 overhang = -scrollbar->currentPos(); 513 } else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->totalSize()) { 514 // Scrolled past the bottom. 515 value = 1; 516 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollbar->totalSize(); 517 } else { 518 // Within the bounds of the scrollable area. 519 int maximum = scrollbar->maximum(); 520 if (maximum > 0) 521 value = scrollbar->currentPos() / maximum; 522 else 491 if (isScrollbarOverlayAPIAvailable()) { 492 float value = 0; 493 float overhang = 0; 494 495 if (scrollbar->currentPos() < 0) { 496 // Scrolled past the top. 523 497 value = 0; 524 } 525 526 TemporaryChange<bool> isCurrentlyDrawingIntoLayer(g_isCurrentlyDrawingIntoLayer, context->isCALayerContext()); 527 528 GraphicsContextStateSaver stateSaver(*context); 529 context->clip(damageRect); 530 context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); 531 LocalCurrentGraphicsContext localContext(context); 532 scrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(), 533 scrollbar->enabled(), 534 value, 535 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 536 scrollbar->frameRect()); 537 538 return true; 539 #endif 498 overhang = -scrollbar->currentPos(); 499 } else if (scrollbar->visibleSize() + scrollbar->currentPos() > scrollbar->totalSize()) { 500 // Scrolled past the bottom. 501 value = 1; 502 overhang = scrollbar->currentPos() + scrollbar->visibleSize() - scrollbar->totalSize(); 503 } else { 504 // Within the bounds of the scrollable area. 505 int maximum = scrollbar->maximum(); 506 if (maximum > 0) 507 value = scrollbar->currentPos() / maximum; 508 else 509 value = 0; 510 } 511 512 TemporaryChange<bool> isCurrentlyDrawingIntoLayer(g_isCurrentlyDrawingIntoLayer, context->isCALayerContext()); 513 514 GraphicsContextStateSaver stateSaver(*context); 515 context->clip(damageRect); 516 context->translate(scrollbar->frameRect().x(), scrollbar->frameRect().y()); 517 LocalCurrentGraphicsContext localContext(context); 518 scrollbarPainterPaint(scrollbarMap()->get(scrollbar).get(), 519 scrollbar->enabled(), 520 value, 521 (static_cast<CGFloat>(scrollbar->visibleSize()) - overhang) / scrollbar->totalSize(), 522 scrollbar->frameRect()); 523 524 return true; 525 } 540 526 541 527 HIThemeTrackDrawInfo trackInfo; … … 602 588 return true; 603 589 } 604 605 } 606 590 #endif 591 592 } 593
Note: See TracChangeset
for help on using the changeset viewer.