summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/mac
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/graphics/mac
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/graphics/mac')
-rw-r--r--WebCore/platform/graphics/mac/ColorMac.h1
-rw-r--r--WebCore/platform/graphics/mac/ColorMac.mm20
-rw-r--r--WebCore/platform/graphics/mac/CoreTextController.cpp6
-rw-r--r--WebCore/platform/graphics/mac/FontCacheMac.mm13
-rw-r--r--WebCore/platform/graphics/mac/FontCustomPlatformData.cpp2
-rw-r--r--WebCore/platform/graphics/mac/FontMacATSUI.mm5
-rw-r--r--WebCore/platform/graphics/mac/FontPlatformDataMac.mm4
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContextMac.mm54
-rw-r--r--WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm31
-rw-r--r--WebCore/platform/graphics/mac/SimpleFontDataMac.mm11
10 files changed, 71 insertions, 76 deletions
diff --git a/WebCore/platform/graphics/mac/ColorMac.h b/WebCore/platform/graphics/mac/ColorMac.h
index 3be9094..830e9d9 100644
--- a/WebCore/platform/graphics/mac/ColorMac.h
+++ b/WebCore/platform/graphics/mac/ColorMac.h
@@ -39,6 +39,7 @@ class NSColor;
namespace WebCore {
+ // These functions assume NSColors are in DeviceRGB colorspace
Color colorFromNSColor(NSColor *);
NSColor* nsColor(const Color&);
diff --git a/WebCore/platform/graphics/mac/ColorMac.mm b/WebCore/platform/graphics/mac/ColorMac.mm
index 96fdc39..9b0f770 100644
--- a/WebCore/platform/graphics/mac/ColorMac.mm
+++ b/WebCore/platform/graphics/mac/ColorMac.mm
@@ -28,6 +28,7 @@
#import "ColorMac.h"
#import <wtf/Assertions.h>
+#import <wtf/StdLibExtras.h>
#import <wtf/RetainPtr.h>
@interface WebCoreControlTintObserver : NSObject
@@ -59,37 +60,30 @@ NSColor* nsColor(const Color& color)
switch (c) {
case 0: {
// Need this to avoid returning nil because cachedRGBAValues will default to 0.
- static RetainPtr<NSColor> clearColor = [NSColor clearColor];
+ DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, clearColor, ([NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:0.0f]));
return clearColor.get();
}
case Color::black: {
- static RetainPtr<NSColor> blackColor = [NSColor blackColor];
+ DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, blackColor, ([NSColor colorWithDeviceRed:0.0f green:0.0f blue:0.0f alpha:1.0f]));
return blackColor.get();
}
case Color::white: {
- static RetainPtr<NSColor> whiteColor = [NSColor whiteColor];
+ DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, whiteColor, ([NSColor colorWithDeviceRed:1.0f green:1.0f blue:1.0f alpha:1.0f]));
return whiteColor.get();
}
default: {
const int cacheSize = 32;
static unsigned cachedRGBAValues[cacheSize];
- static RetainPtr<NSColor> cachedColors[cacheSize];
+ static RetainPtr<NSColor>* cachedColors = new RetainPtr<NSColor>[cacheSize];
for (int i = 0; i != cacheSize; ++i)
if (cachedRGBAValues[i] == c)
return cachedColors[i].get();
-#ifdef COLORMATCH_EVERYTHING
- NSColor* result = [NSColor colorWithCalibratedRed:color.red() / 255.0f
- green:color.green() / 255.0f
- blue:color.blue() / 255.0f
- alpha:color.alpha() /255.0f];
-#else
NSColor* result = [NSColor colorWithDeviceRed:color.red() / 255.0f
green:color.green() / 255.0f
blue:color.blue() / 255.0f
alpha:color.alpha() /255.0f];
-#endif
static int cursor;
cachedRGBAValues[cursor] = c;
@@ -158,12 +152,8 @@ void setUsesTestModeFocusRingColor(bool newValue)
+ (void)controlTintDidChange
{
-#ifdef COLORMATCH_EVERYTHING
-#error Not yet implemented.
-#else
NSColor* color = [[NSColor keyboardFocusIndicatorColor] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
WebCore::systemFocusRingColor = WebCore::makeRGBAFromNSColor(color);
-#endif
}
@end
diff --git a/WebCore/platform/graphics/mac/CoreTextController.cpp b/WebCore/platform/graphics/mac/CoreTextController.cpp
index 171a7ec..49e83c4 100644
--- a/WebCore/platform/graphics/mac/CoreTextController.cpp
+++ b/WebCore/platform/graphics/mac/CoreTextController.cpp
@@ -369,9 +369,9 @@ void CoreTextController::collectCoreTextRunsForCharacters(const UChar* cp, unsig
static const void* optionKeys[] = { kCTTypesetterOptionForcedEmbeddingLevel };
static const void* ltrOptionValues[] = { kCFBooleanFalse };
static const void* rtlOptionValues[] = { kCFBooleanTrue };
- static RetainPtr<CFDictionaryRef> ltrTypesetterOptions(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- static RetainPtr<CFDictionaryRef> rtlTypesetterOptions(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- typesetter.adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions.get() : rtlTypesetterOptions.get()));
+ static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ typesetter.adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions : rtlTypesetterOptions));
} else
typesetter.adoptCF(CTTypesetterCreateWithAttributedString(attributedString.get()));
diff --git a/WebCore/platform/graphics/mac/FontCacheMac.mm b/WebCore/platform/graphics/mac/FontCacheMac.mm
index e7cda66..26d84cc 100644
--- a/WebCore/platform/graphics/mac/FontCacheMac.mm
+++ b/WebCore/platform/graphics/mac/FontCacheMac.mm
@@ -35,6 +35,7 @@
#import "FontPlatformData.h"
#import "WebCoreSystemInterface.h"
#import "WebFontCache.h"
+#include <wtf/StdLibExtras.h>
#ifdef BUILDING_ON_TIGER
typedef int NSInteger;
@@ -44,7 +45,7 @@ namespace WebCore {
static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*)
{
- FontCache::invalidate();
+ fontCache()->invalidate();
}
void FontCache::platformInit()
@@ -139,10 +140,10 @@ FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
const FontFamily* currFamily = &font.fontDescription().family();
while (currFamily && !platformData) {
if (currFamily->family().length()) {
- static String matchWords[3] = { String("Arabic"), String("Pashto"), String("Urdu") };
- static AtomicString geezaStr("Geeza Pro");
+ static String* matchWords[3] = { new String("Arabic"), new String("Pashto"), new String("Urdu") };
+ DEFINE_STATIC_LOCAL(AtomicString, geezaStr, ("Geeza Pro"));
for (int j = 0; j < 3 && !platformData; ++j)
- if (currFamily->family().contains(matchWords[j], false))
+ if (currFamily->family().contains(*matchWords[j], false))
platformData = getCachedFontPlatformData(font.fontDescription(), geezaStr);
}
currFamily = currFamily->next();
@@ -153,8 +154,8 @@ FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
{
- static AtomicString timesStr("Times");
- static AtomicString lucidaGrandeStr("Lucida Grande");
+ DEFINE_STATIC_LOCAL(AtomicString, timesStr, ("Times"));
+ DEFINE_STATIC_LOCAL(AtomicString, lucidaGrandeStr, ("Lucida Grande"));
// FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
// the default that the user would get without changing any prefs.
diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
index 1fb144c..9aa4997 100644
--- a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
@@ -68,7 +68,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
CGFontRef cgFontRef = CGFontCreateWithPlatformFont(&fontRef);
#ifndef BUILDING_ON_TIGER
// Workaround for <rdar://problem/5675504>.
- if (!CGFontGetNumberOfGlyphs(cgFontRef)) {
+ if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef)) {
CFRelease(cgFontRef);
cgFontRef = 0;
}
diff --git a/WebCore/platform/graphics/mac/FontMacATSUI.mm b/WebCore/platform/graphics/mac/FontMacATSUI.mm
index 9a45c5a..52493e7 100644
--- a/WebCore/platform/graphics/mac/FontMacATSUI.mm
+++ b/WebCore/platform/graphics/mac/FontMacATSUI.mm
@@ -154,8 +154,7 @@ static void initializeATSUStyle(const SimpleFontData* fontData)
fontData->m_ATSUStyleInitialized = true;
}
-static OSStatus overrideLayoutOperation(ATSULayoutOperationSelector iCurrentOperation, ATSULineRef iLineRef, URefCon iRefCon,
- void *iOperationCallbackParameterPtr, ATSULayoutOperationCallbackStatus *oCallbackStatus)
+static OSStatus overrideLayoutOperation(ATSULayoutOperationSelector, ATSULineRef iLineRef, URefCon iRefCon, void*, ATSULayoutOperationCallbackStatus* oCallbackStatus)
{
ATSULayoutParameters* params = reinterpret_cast<ATSULayoutParameters*>(iRefCon);
OSStatus status;
@@ -592,7 +591,7 @@ float Font::floatWidthForComplexText(const TextRun& run) const
MIN(FixedToFloat(firstGlyphBounds.upperLeft.x), FixedToFloat(firstGlyphBounds.lowerLeft.x));
}
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool /*includePartialGlyphs*/) const
{
OwnArrayPtr<UChar> charactersWithOverride;
TextRun adjustedRun = copyRunForDirectionalOverrideIfNecessary(run, charactersWithOverride);
diff --git a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm
index 15e573d..7cd9ab6 100644
--- a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm
+++ b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm
@@ -34,7 +34,7 @@ FontPlatformData::FontPlatformData(NSFont *f, bool b , bool o)
CFRetain(f);
m_size = f ? [f pointSize] : 0.0f;
#ifndef BUILDING_ON_TIGER
- m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(f), 0);
+ m_cgFont.adoptCF(CTFontCopyGraphicsFont(toCTFontRef(f), 0));
m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(f), 0);
#else
m_cgFont = wkGetCGFontFromNSFont(f);
@@ -86,7 +86,7 @@ void FontPlatformData::setFont(NSFont *font)
m_font = font;
m_size = font ? [font pointSize] : 0.0f;
#ifndef BUILDING_ON_TIGER
- m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(font), 0);
+ m_cgFont.adoptCF(CTFontCopyGraphicsFont(toCTFontRef(font), 0));
m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(font), 0);
#else
m_cgFont = wkGetCGFontFromNSFont(font);
diff --git a/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/WebCore/platform/graphics/mac/GraphicsContextMac.mm
index 3f9176c..ae829e2 100644
--- a/WebCore/platform/graphics/mac/GraphicsContextMac.mm
+++ b/WebCore/platform/graphics/mac/GraphicsContextMac.mm
@@ -27,6 +27,7 @@
#import "GraphicsContext.h"
#import "../cg/GraphicsContextPlatformPrivateCG.h"
+#import <wtf/StdLibExtras.h>
#import "WebCoreSystemInterface.h"
@@ -80,53 +81,42 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op)
[pool drain];
}
#endif
-
+
+static NSColor* createPatternColor(NSString* name, NSColor* defaultColor, bool& usingDot)
+{
+ NSImage *image = [NSImage imageNamed:name];
+ ASSERT(image); // if image is not available, we want to know
+ NSColor *color = (image ? [NSColor colorWithPatternImage:image] : nil);
+ if (color)
+ usingDot = true;
+ else
+ color = defaultColor;
+ return color;
+}
+
void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& point, int width, bool grammar)
{
if (paintingDisabled())
return;
- // Constants for spelling pattern color
- static RetainPtr<NSColor> spellingPatternColor = nil;
- static bool usingDotForSpelling = false;
-
- // Constants for grammar pattern color
- static RetainPtr<NSColor> grammarPatternColor = nil;
- static bool usingDotForGrammar = false;
-
// These are the same for misspelling or bad grammar
int patternHeight = cMisspellingLineThickness;
int patternWidth = cMisspellingLinePatternWidth;
- // Initialize pattern color if needed
- if (!grammar && !spellingPatternColor) {
- NSImage *image = [NSImage imageNamed:@"SpellingDot"];
- ASSERT(image); // if image is not available, we want to know
- NSColor *color = (image ? [NSColor colorWithPatternImage:image] : nil);
- if (color)
- usingDotForSpelling = true;
- else
- color = [NSColor redColor];
- spellingPatternColor = color;
- }
-
- if (grammar && !grammarPatternColor) {
- NSImage *image = [NSImage imageNamed:@"GrammarDot"];
- ASSERT(image); // if image is not available, we want to know
- NSColor *color = (image ? [NSColor colorWithPatternImage:image] : nil);
- if (color)
- usingDotForGrammar = true;
- else
- color = [NSColor greenColor];
- grammarPatternColor = color;
- }
-
bool usingDot;
NSColor *patternColor;
if (grammar) {
+ // Constants for grammar pattern color
+ static bool usingDotForGrammar = false;
+ DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, grammarPatternColor, (createPatternColor(@"GrammarDot", [NSColor greenColor], usingDotForGrammar)));
+
usingDot = usingDotForGrammar;
patternColor = grammarPatternColor.get();
} else {
+ // Constants for spelling pattern color
+ static bool usingDotForSpelling = false;
+ DEFINE_STATIC_LOCAL(RetainPtr<NSColor>, spellingPatternColor, (createPatternColor(@"SpellingDot", [NSColor redColor], usingDotForSpelling)));
+
usingDot = usingDotForSpelling;
patternColor = spellingPatternColor.get();
}
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
index 0ec56d6..a33c8d2 100644
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
@@ -29,14 +29,19 @@
#import "MediaPlayerPrivateQTKit.h"
+#ifdef BUILDING_ON_TIGER
+#import "AutodrainedPool.h"
+#endif
+
#import "BlockExceptions.h"
+#import "FrameView.h"
#import "GraphicsContext.h"
#import "KURL.h"
-#import "FrameView.h"
#import "SoftLinking.h"
#import "WebCoreSystemInterface.h"
#import <QTKit/QTKit.h>
#import <objc/objc-runtime.h>
+#import <wtf/UnusedParam.h>
#if DRAW_FRAME_RATE
#import "Font.h"
@@ -239,7 +244,7 @@ void MediaPlayerPrivate::createQTMovie(const String& url)
object:m_qtMovie.get()];
}
-static void mainThreadSetNeedsDisplay(id self, SEL _cmd)
+static void mainThreadSetNeedsDisplay(id self, SEL)
{
id movieView = [self superview];
ASSERT(!movieView || [movieView isKindOfClass:[QTMovieView class]]);
@@ -772,6 +777,10 @@ void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& r)
context->scale(FloatSize(1.0f, -1.0f));
context->setImageInterpolationQuality(InterpolationLow);
IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
+
+#ifdef BUILDING_ON_TIGER
+ AutodrainedPool pool;
+#endif
NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
// draw the current video frame
@@ -969,48 +978,54 @@ void MediaPlayerPrivate::disableUnsupportedTracks(unsigned& enabledTrackCount)
m_callback->repaint();
}
-- (void)loadStateChanged:(NSNotification *)notification
+- (void)loadStateChanged:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
if (m_delayCallbacks)
[self performSelector:_cmd withObject:nil afterDelay:0];
else
m_callback->loadStateChanged();
}
-- (void)rateChanged:(NSNotification *)notification
+- (void)rateChanged:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
if (m_delayCallbacks)
[self performSelector:_cmd withObject:nil afterDelay:0];
else
m_callback->rateChanged();
}
-- (void)sizeChanged:(NSNotification *)notification
+- (void)sizeChanged:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
if (m_delayCallbacks)
[self performSelector:_cmd withObject:nil afterDelay:0];
else
m_callback->sizeChanged();
}
-- (void)timeChanged:(NSNotification *)notification
+- (void)timeChanged:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
if (m_delayCallbacks)
[self performSelector:_cmd withObject:nil afterDelay:0];
else
m_callback->timeChanged();
}
-- (void)didEnd:(NSNotification *)notification
+- (void)didEnd:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
if (m_delayCallbacks)
[self performSelector:_cmd withObject:nil afterDelay:0];
else
m_callback->didEnd();
}
-- (void)newImageAvailable:(NSNotification *)notification
+- (void)newImageAvailable:(NSNotification *)unusedNotification
{
+ UNUSED_PARAM(unusedNotification);
[self repaint];
}
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index 4ee5933..30dbf97 100644
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -42,6 +42,7 @@
#import <float.h>
#import <unicode/uchar.h>
#import <wtf/Assertions.h>
+#import <wtf/StdLibExtras.h>
#import <wtf/RetainPtr.h>
@interface NSFont (WebAppKitSecretAPI)
@@ -54,7 +55,7 @@ const float smallCapsFontSizeMultiplier = 0.7f;
const float contextDPI = 72.0f;
static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); }
-bool initFontData(SimpleFontData* fontData)
+static bool initFontData(SimpleFontData* fontData)
{
if (!fontData->m_font.cgFont())
return false;
@@ -92,9 +93,7 @@ bool initFontData(SimpleFontData* fontData)
static NSString *webFallbackFontFamily(void)
{
- static RetainPtr<NSString> webFallbackFontFamily = nil;
- if (!webFallbackFontFamily)
- webFallbackFontFamily = [[NSFont systemFontOfSize:16.0f] familyName];
+ DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont systemFontOfSize:16.0f] familyName]));
return webFallbackFontFamily.get();
}
@@ -315,7 +314,7 @@ SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDes
smallCapsFont.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(smallCapsFontTraits & NSBoldFontMask);
smallCapsFont.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(smallCapsFontTraits & NSItalicFontMask);
- m_smallCapsFontData = FontCache::getCachedFontData(&smallCapsFont);
+ m_smallCapsFontData = fontCache()->getCachedFontData(&smallCapsFont);
}
END_BLOCK_OBJC_EXCEPTIONS;
}
@@ -325,7 +324,7 @@ SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDes
bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
{
- NSString *string = [[NSString alloc] initWithCharactersNoCopy:(UniChar*)characters length:length freeWhenDone:NO];
+ NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(characters) length:length freeWhenDone:NO];
NSCharacterSet *set = [[m_font.font() coveredCharacterSet] invertedSet];
bool result = set && [string rangeOfCharacterFromSet:set].location == NSNotFound;
[string release];