RenderThemeChromiumMac.mm revision ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddb
1/* 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Google, Inc. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public License 16 * along with this library; see the file COPYING.LIB. If not, write to 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21#import "config.h" 22#import "RenderThemeChromiumMac.h" 23#import "PaintInfo.h" 24#import "PlatformBridge.h" 25#import "RenderMediaControlsChromium.h" 26#import "UserAgentStyleSheets.h" 27#import <Carbon/Carbon.h> 28#import <Cocoa/Cocoa.h> 29#import <wtf/RetainPtr.h> 30#import <wtf/StdLibExtras.h> 31#import <math.h> 32 33@interface RTCMFlippedView : NSView 34{} 35 36- (BOOL)isFlipped; 37- (NSText *)currentEditor; 38 39@end 40 41@implementation RTCMFlippedView 42 43- (BOOL)isFlipped { 44 return [[NSGraphicsContext currentContext] isFlipped]; 45} 46 47- (NSText *)currentEditor { 48 return nil; 49} 50 51@end 52 53namespace WebCore { 54 55NSView* FlippedView() 56{ 57 static NSView* view = [[RTCMFlippedView alloc] init]; 58 return view; 59} 60 61PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page*) 62{ 63 static RenderTheme* rt = RenderThemeChromiumMac::create().releaseRef(); 64 return rt; 65} 66 67PassRefPtr<RenderTheme> RenderThemeChromiumMac::create() 68{ 69 return adoptRef(new RenderThemeChromiumMac); 70} 71 72bool RenderThemeChromiumMac::usesTestModeFocusRingColor() const 73{ 74 return PlatformBridge::layoutTestMode(); 75} 76 77NSView* RenderThemeChromiumMac::documentViewFor(RenderObject*) const 78{ 79 return FlippedView(); 80} 81 82// Updates the control tint (a.k.a. active state) of |cell| (from |o|). 83// In the Chromium port, the renderer runs as a background process and controls' 84// NSCell(s) lack a parent NSView. Therefore controls don't have their tint 85// color updated correctly when the application is activated/deactivated. 86// FocusController's setActive() is called when the application is 87// activated/deactivated, which causes a repaint at which time this code is 88// called. 89// This function should be called before drawing any NSCell-derived controls, 90// unless you're sure it isn't needed. 91void RenderThemeChromiumMac::updateActiveState(NSCell* cell, const RenderObject* o) 92{ 93 NSControlTint oldTint = [cell controlTint]; 94 NSControlTint tint = isActive(o) ? [NSColor currentControlTint] : 95 static_cast<NSControlTint>(NSClearControlTint); 96 97 if (tint != oldTint) 98 [cell setControlTint:tint]; 99} 100 101#if ENABLE(VIDEO) 102 103void RenderThemeChromiumMac::adjustMediaSliderThumbSize(RenderObject* o) const 104{ 105 RenderMediaControlsChromium::adjustMediaSliderThumbSize(o); 106} 107 108bool RenderThemeChromiumMac::shouldRenderMediaControlPart(ControlPart part, Element* e) 109{ 110 return RenderMediaControlsChromium::shouldRenderMediaControlPart(part, e); 111} 112 113bool RenderThemeChromiumMac::paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 114{ 115 return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect); 116} 117 118bool RenderThemeChromiumMac::paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 119{ 120 return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect); 121} 122 123bool RenderThemeChromiumMac::paintMediaSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 124{ 125 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, object, paintInfo, rect); 126} 127 128bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 129{ 130 return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); 131} 132 133String RenderThemeChromiumMac::extraMediaControlsStyleSheet() 134{ 135 return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet)); 136} 137 138bool RenderThemeChromiumMac::paintMediaVolumeSliderContainer(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 139{ 140 return true; 141} 142 143bool RenderThemeChromiumMac::paintMediaVolumeSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 144{ 145 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect); 146} 147 148bool RenderThemeChromiumMac::paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 149{ 150 return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect); 151} 152 153bool RenderThemeChromiumMac::paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect) 154{ 155 return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect); 156} 157 158IntPoint RenderThemeChromiumMac::volumeSliderOffsetFromMuteButton(Node* muteButton, const IntSize& size) const 159{ 160 return RenderTheme::volumeSliderOffsetFromMuteButton(muteButton, size); 161} 162#endif 163 164} // namespace WebCore 165