summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/mac
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/mac')
-rw-r--r--WebCore/platform/mac/EventLoopMac.mm5
-rw-r--r--WebCore/platform/mac/KeyEventMac.mm16
-rw-r--r--WebCore/platform/mac/PasteboardHelper.h6
-rw-r--r--WebCore/platform/mac/PasteboardMac.mm4
-rw-r--r--WebCore/platform/mac/ThemeMac.mm90
-rw-r--r--WebCore/platform/mac/WebCoreSystemInterface.h45
-rw-r--r--WebCore/platform/mac/WebCoreSystemInterface.mm4
7 files changed, 97 insertions, 73 deletions
diff --git a/WebCore/platform/mac/EventLoopMac.mm b/WebCore/platform/mac/EventLoopMac.mm
index 05ef33a..4c3c8a4 100644
--- a/WebCore/platform/mac/EventLoopMac.mm
+++ b/WebCore/platform/mac/EventLoopMac.mm
@@ -32,7 +32,10 @@ void EventLoop::cycle()
{
// FIXME: Should this use NSRunLoopCommonModes? Switching to NSRunLoopCommonModes causes Safari to hang in a tight loop.
[NSApp setWindowsNeedUpdate:YES];
- NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
+ NSTimeInterval interval = [[NSDate date] timeIntervalSinceReferenceDate];
+ interval += 0.05;
+ NSDate *untilDate = [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
+ NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:untilDate inMode:NSDefaultRunLoopMode dequeue:YES];
[NSApp sendEvent:event];
}
diff --git a/WebCore/platform/mac/KeyEventMac.mm b/WebCore/platform/mac/KeyEventMac.mm
index 7b8b2ce..30f1689 100644
--- a/WebCore/platform/mac/KeyEventMac.mm
+++ b/WebCore/platform/mac/KeyEventMac.mm
@@ -30,6 +30,7 @@
#import "KeyEventCocoa.h"
#import "Logging.h"
+#import "WindowsKeyboardCodes.h"
#import <Carbon/Carbon.h>
using namespace WTF;
@@ -203,20 +204,19 @@ PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event)
, m_macEvent(event)
{
// Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter.
- if (m_windowsVirtualKeyCode == '\r') {
+ if (m_windowsVirtualKeyCode == VK_RETURN) {
m_text = "\r";
m_unmodifiedText = "\r";
}
- // The adjustments below are only needed in backward compatibility mode, but we cannot tell what mode we are in from here.
-
- // Turn 0x7F into 8, because backspace needs to always be 8.
- if (m_text == "\x7F")
+ // AppKit sets text to "\x7F" for backspace, but the correct KeyboardEvent character code is 8.
+ if (m_windowsVirtualKeyCode == VK_BACK) {
m_text = "\x8";
- if (m_unmodifiedText == "\x7F")
m_unmodifiedText = "\x8";
- // Always use 9 for tab -- we don't want to use AppKit's different character for shift-tab.
- if (m_windowsVirtualKeyCode == 9) {
+ }
+
+ // Always use 9 for Tab -- we don't want to use AppKit's different character for shift-tab.
+ if (m_windowsVirtualKeyCode == VK_TAB) {
m_text = "\x9";
m_unmodifiedText = "\x9";
}
diff --git a/WebCore/platform/mac/PasteboardHelper.h b/WebCore/platform/mac/PasteboardHelper.h
index 4ae964d..0e241bb 100644
--- a/WebCore/platform/mac/PasteboardHelper.h
+++ b/WebCore/platform/mac/PasteboardHelper.h
@@ -48,9 +48,9 @@ namespace WebCore {
class PasteboardHelper {
public:
virtual ~PasteboardHelper() {}
- virtual String urlFromPasteboard(const NSPasteboard*, String* title) const = 0;
- virtual String plainTextFromPasteboard(const NSPasteboard*) const = 0;
- virtual DOMDocumentFragment* fragmentFromPasteboard(const NSPasteboard*) const = 0;
+ virtual String urlFromPasteboard(NSPasteboard*, String* title) const = 0;
+ virtual String plainTextFromPasteboard(NSPasteboard*) const = 0;
+ virtual DOMDocumentFragment* fragmentFromPasteboard(NSPasteboard*) const = 0;
virtual NSArray* insertablePasteboardTypes() const = 0;
};
diff --git a/WebCore/platform/mac/PasteboardMac.mm b/WebCore/platform/mac/PasteboardMac.mm
index 03ede03..bba7cac 100644
--- a/WebCore/platform/mac/PasteboardMac.mm
+++ b/WebCore/platform/mac/PasteboardMac.mm
@@ -378,6 +378,10 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
}
}
if ([HTMLString length] != 0) {
+ // FIXME: FragmentScriptingNotAllowed is a HACK and should
+ // be removed or replaced with an enum with a better name.
+ // FragmentScriptingNotAllowed causes the Parser to remove children
+ // of <script> tags (so javascript doesn't show up in pastes).
RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", FragmentScriptingNotAllowed);
if (fragment)
return fragment.release();
diff --git a/WebCore/platform/mac/ThemeMac.mm b/WebCore/platform/mac/ThemeMac.mm
index 7cc913f..20b662f 100644
--- a/WebCore/platform/mac/ThemeMac.mm
+++ b/WebCore/platform/mac/ThemeMac.mm
@@ -31,6 +31,7 @@
#import "LocalCurrentGraphicsContext.h"
#import "ScrollView.h"
#import "WebCoreSystemInterface.h"
+#import <Carbon/Carbon.h>
#include <wtf/StdLibExtras.h>
using namespace std;
@@ -100,19 +101,22 @@ static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, f
return sizeFromNSControlSize(controlSizeForFont(font), zoomedSize, zoomFactor, sizes);
}
-static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
+static ControlSize controlSizeFromPixelSize(const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
{
- NSControlSize size;
if (minZoomedSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomFactor) &&
minZoomedSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomFactor))
- size = NSRegularControlSize;
- else if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) &&
- minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor))
- size = NSSmallControlSize;
- else
- size = NSMiniControlSize;
+ return NSRegularControlSize;
+ if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) &&
+ minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor))
+ return NSSmallControlSize;
+ return NSMiniControlSize;
+}
+
+static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
+{
+ ControlSize size = controlSizeFromPixelSize(sizes, minZoomedSize, zoomFactor);
if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same.
- [cell setControlSize:size];
+ [cell setControlSize:(NSControlSize)size];
}
static void updateStates(NSCell* cell, ControlStates states)
@@ -149,6 +153,22 @@ static void updateStates(NSCell* cell, ControlStates states)
// a view in a window whose key state can be detected.
}
+static ThemeDrawState convertControlStatesToThemeDrawState(ThemeButtonKind kind, ControlStates states)
+{
+ if (states & ReadOnlyState)
+ return kThemeStateUnavailableInactive;
+ if (!(states & EnabledState))
+ return kThemeStateUnavailableInactive;
+
+ // Do not process PressedState if !EnabledState or ReadOnlyState.
+ if (states & PressedState) {
+ if (kind == kThemeIncDecButton || kind == kThemeIncDecButtonSmall || kind == kThemeIncDecButtonMini)
+ return states & SpinUpState ? kThemeStatePressedUp : kThemeStatePressedDown;
+ return kThemeStatePressed;
+ }
+ return kThemeStateActive;
+}
+
static IntRect inflateRect(const IntRect& zoomedRect, const IntSize& zoomedSize, const int* margins, float zoomFactor)
{
// Only do the inflation if the available width/height are too small. Otherwise try to
@@ -469,29 +489,25 @@ static NSControlSize stepperControlSizeForFont(const Font& font)
return NSMiniControlSize;
}
-static NSStepperCell* stepper(ControlStates states, const IntRect& zoomedRect, float zoomFactor)
+static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView*)
{
- static NSStepperCell* cell = [[NSStepperCell alloc] init];
- setControlSize(cell, stepperSizes(), zoomedRect.size(), zoomFactor);
+ // We don't use NSStepperCell because there are no ways to draw an
+ // NSStepperCell with the up button highlighted.
- updateStates(cell, states);
- if (states & PressedState && states & SpinUpState) {
- // FIXME: There is no way to draw a NSSteperCell with the up button hilighted.
- // Disables the hilight of the down button if the up button is pressed.
- [cell setHighlighted:NO];
- }
- return cell;
-}
-
-static void paintStepper(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
-{
- NSStepperCell* cell = stepper(states, zoomedRect, zoomFactor);
+ HIThemeButtonDrawInfo drawInfo;
+ drawInfo.version = 0;
+ drawInfo.state = convertControlStatesToThemeDrawState(kThemeIncDecButton, states);
+ drawInfo.adornment = kThemeAdornmentDefault;
+ ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor);
+ if (controlSize == NSSmallControlSize)
+ drawInfo.kind = kThemeIncDecButtonSmall;
+ else if (controlSize == NSMiniControlSize)
+ drawInfo.kind = kThemeIncDecButtonMini;
+ else
+ drawInfo.kind = kThemeIncDecButton;
- context->save();
- NSControlSize controlSize = [cell controlSize];
- IntSize zoomedSize = stepperSizes()[controlSize];
IntRect rect(zoomedRect);
-
+ context->save();
if (zoomFactor != 1.0f) {
rect.setWidth(rect.width() / zoomFactor);
rect.setHeight(rect.height() / zoomFactor);
@@ -499,12 +515,15 @@ static void paintStepper(ControlStates states, GraphicsContext* context, const I
context->scale(FloatSize(zoomFactor, zoomFactor));
context->translate(-rect.x(), -rect.y());
}
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS
- [cell drawWithFrame:NSRect(rect) inView:ThemeMac::ensuredView(scrollView)];
- [cell setControlView:nil];
- END_BLOCK_OBJC_EXCEPTIONS
-
+ CGRect bounds(rect);
+ // Adjust 'bounds' so that HIThemeDrawButton(bounds,...) draws exactly on 'rect'.
+ CGRect backgroundBounds;
+ HIThemeGetButtonBackgroundBounds(&bounds, &drawInfo, &backgroundBounds);
+ if (bounds.origin.x != backgroundBounds.origin.x)
+ bounds.origin.x += bounds.origin.x - backgroundBounds.origin.x;
+ if (bounds.origin.y != backgroundBounds.origin.y)
+ bounds.origin.y += bounds.origin.y - backgroundBounds.origin.y;
+ HIThemeDrawButton(&bounds, &drawInfo, context->platformContext(), kHIThemeOrientationNormal, 0);
context->restore();
}
@@ -669,8 +688,7 @@ void ThemeMac::inflateControlPaintRect(ControlPart part, ControlStates states, I
}
case OuterSpinButtonPart: {
static const int stepperMargin[4] = { 0, 0, 0, 0};
- NSCell *cell = stepper(states, zoomedRect, zoomFactor);
- NSControlSize controlSize = [cell controlSize];
+ ControlSize controlSize = controlSizeFromPixelSize(stepperSizes(), zoomedRect.size(), zoomFactor);
IntSize zoomedSize = stepperSizes()[controlSize];
zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.h b/WebCore/platform/mac/WebCoreSystemInterface.h
index 88472da..1f14311 100644
--- a/WebCore/platform/mac/WebCoreSystemInterface.h
+++ b/WebCore/platform/mac/WebCoreSystemInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -59,30 +59,27 @@ typedef struct _NSRect NSRect;
@class QTMovie;
@class QTMovieView;
#else
-typedef struct NSArray NSArray;
-typedef struct NSButtonCell NSButtonCell;
-typedef struct NSData NSData;
-typedef struct NSDate NSDate;
-typedef struct NSEvent NSEvent;
-typedef struct NSFont NSFont;
-typedef struct NSImage NSImage;
-typedef struct NSMenu NSMenu;
-typedef struct NSMutableArray NSMutableArray;
-typedef struct NSMutableURLRequest NSMutableURLRequest;
-typedef struct NSURLRequest NSURLRequest;
-typedef struct NSString NSString;
-typedef struct NSTextFieldCell NSTextFieldCell;
-typedef struct NSURLConnection NSURLConnection;
-typedef struct NSURLResponse NSURLResponse;
-typedef struct NSView NSView;
-typedef struct objc_object *id;
-typedef struct QTMovie QTMovie;
-typedef struct QTMovieView QTMovieView;
+class NSArray;
+class NSButtonCell;
+class NSData;
+class NSDate;
+class NSEvent;
+class NSFont;
+class NSImage;
+class NSMenu;
+class NSMutableArray;
+class NSMutableURLRequest;
+class NSURLRequest;
+class NSString;
+class NSTextFieldCell;
+class NSURLConnection;
+class NSURLResponse;
+class NSView;
+class QTMovie;
+class QTMovieView;
#endif
-#ifdef __cplusplus
extern "C" {
-#endif
// In alphabetical order.
@@ -173,12 +170,12 @@ extern BOOL (*wkUseSharedMediaUI)();
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
extern NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
+extern void* wkGetHyphenationLocationBeforeIndex;
#else
extern void* wkNoteOpenPanelFiles;
+extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
#endif
-#ifdef __cplusplus
}
-#endif
#endif
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.mm b/WebCore/platform/mac/WebCoreSystemInterface.mm
index bb54ad0..2a06f15 100644
--- a/WebCore/platform/mac/WebCoreSystemInterface.mm
+++ b/WebCore/platform/mac/WebCoreSystemInterface.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2006, 2007, 2008, 2010 Apple Computer, Inc. All rights reserved.
+ * Copyright 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -112,6 +112,8 @@ BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
NSMutableArray *(*wkNoteOpenPanelFiles)(NSArray *);
+void* wkGetHyphenationLocationBeforeIndex;
#else
void* wkNoteOpenPanelFiles;
+CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index);
#endif