diff options
author | Ben Murdoch <benm@google.com> | 2010-05-11 18:35:50 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-05-14 10:23:05 +0100 |
commit | 21939df44de1705786c545cd1bf519d47250322d (patch) | |
tree | ef56c310f5c0cdc379c2abb2e212308a3281ce20 /WebCore/platform/mac | |
parent | 4ff1d8891d520763f17675827154340c7c740f90 (diff) | |
download | external_webkit-21939df44de1705786c545cd1bf519d47250322d.zip external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.gz external_webkit-21939df44de1705786c545cd1bf519d47250322d.tar.bz2 |
Merge Webkit at r58956: Initial merge by Git.
Change-Id: I1d9fb60ea2c3f2ddc04c17a871acdb39353be228
Diffstat (limited to 'WebCore/platform/mac')
-rw-r--r-- | WebCore/platform/mac/KeyEventMac.mm | 9 | ||||
-rw-r--r-- | WebCore/platform/mac/PopupMenuMac.mm | 10 | ||||
-rw-r--r-- | WebCore/platform/mac/SharedBufferMac.mm | 1 | ||||
-rw-r--r-- | WebCore/platform/mac/ThemeMac.mm | 101 | ||||
-rw-r--r-- | WebCore/platform/mac/WebCoreObjCExtras.mm | 7 | ||||
-rw-r--r-- | WebCore/platform/mac/WidgetMac.mm | 5 |
6 files changed, 113 insertions, 20 deletions
diff --git a/WebCore/platform/mac/KeyEventMac.mm b/WebCore/platform/mac/KeyEventMac.mm index b8bf500..7b8b2ce 100644 --- a/WebCore/platform/mac/KeyEventMac.mm +++ b/WebCore/platform/mac/KeyEventMac.mm @@ -169,7 +169,14 @@ static int windowsKeyCodeForKeyEvent(NSEvent *event) // 3. Certain punctuation keys. On Windows, these are also remapped depending on current keyboard layout, // but see comment in windowsKeyCodeForCharCode(). if ([event type] == NSKeyDown || [event type] == NSKeyUp) { - NSString* s = [event characters]; // Cannot use charactersIgnoringModifiers, because Cmd switches Roman letters for Dvorak-QWERTY layout. + // Cmd switches Roman letters for Dvorak-QWERTY layout, so try modified characters first. + NSString* s = [event characters]; + code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; + if (code) + return code; + + // Ctrl+A on an AZERTY keyboard would get VK_Q keyCode if we relied on -[NSEvent keyCode] below. + s = [event charactersIgnoringModifiers]; code = [s length] > 0 ? windowsKeyCodeForCharCode([s characterAtIndex:0]) : 0; if (code) return code; diff --git a/WebCore/platform/mac/PopupMenuMac.mm b/WebCore/platform/mac/PopupMenuMac.mm index 0ecaa13..6c067b9 100644 --- a/WebCore/platform/mac/PopupMenuMac.mm +++ b/WebCore/platform/mac/PopupMenuMac.mm @@ -114,8 +114,6 @@ void PopupMenu::populate() [[m_popup.get() menu] setMenuChangedMessagesEnabled:messagesEnabled]; } -#if !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) - void PopupMenu::show(const IntRect& r, FrameView* v, int index) { populate(); @@ -196,14 +194,6 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) [event release]; } -#else - -void PopupMenu::show(const IntRect&, FrameView*, int) -{ -} - -#endif - void PopupMenu::hide() { [m_popup.get() dismissPopUp]; diff --git a/WebCore/platform/mac/SharedBufferMac.mm b/WebCore/platform/mac/SharedBufferMac.mm index c4e7528..3f5e5d4 100644 --- a/WebCore/platform/mac/SharedBufferMac.mm +++ b/WebCore/platform/mac/SharedBufferMac.mm @@ -50,6 +50,7 @@ using namespace WebCore; + (void)initialize { JSC::initializeThreading(); + WTF::initializeMainThreadToProcessMainThread(); #ifndef BUILDING_ON_TIGER WebCoreObjCFinalizeOnMainThread(self); #endif diff --git a/WebCore/platform/mac/ThemeMac.mm b/WebCore/platform/mac/ThemeMac.mm index bbc6d6b..7cc913f 100644 --- a/WebCore/platform/mac/ThemeMac.mm +++ b/WebCore/platform/mac/ThemeMac.mm @@ -46,6 +46,11 @@ using namespace std; return YES; } +- (NSText *)currentEditor +{ + return nil; +} + @end // FIXME: Default buttons really should be more like push buttons and not like buttons. @@ -77,9 +82,9 @@ static NSControlSize controlSizeForFont(const Font& font) return NSMiniControlSize; } -static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes) +static LengthSize sizeFromNSControlSize(NSControlSize nsControlSize, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes) { - IntSize controlSize = sizes[controlSizeForFont(font)]; + IntSize controlSize = sizes[nsControlSize]; if (zoomFactor != 1.0f) controlSize = IntSize(controlSize.width() * zoomFactor, controlSize.height() * zoomFactor); LengthSize result = zoomedSize; @@ -90,6 +95,11 @@ static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, f return result; } +static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes) +{ + return sizeFromNSControlSize(controlSizeForFont(font), zoomedSize, zoomFactor, sizes); +} + static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor) { NSControlSize size; @@ -439,6 +449,65 @@ static void paintButton(ControlPart part, ControlStates states, GraphicsContext* END_BLOCK_OBJC_EXCEPTIONS } +// Stepper + +static const IntSize* stepperSizes() +{ + static const IntSize sizes[3] = { IntSize(19, 27), IntSize(15, 22), IntSize(13, 15) }; + return sizes; +} + +// We don't use controlSizeForFont() for steppers because the stepper height +// should be equal to or less than the corresponding text field height, +static NSControlSize stepperControlSizeForFont(const Font& font) +{ + int fontSize = font.pixelSize(); + if (fontSize >= 18) + return NSRegularControlSize; + if (fontSize >= 13) + return NSSmallControlSize; + return NSMiniControlSize; +} + +static NSStepperCell* stepper(ControlStates states, const IntRect& zoomedRect, float zoomFactor) +{ + static NSStepperCell* cell = [[NSStepperCell alloc] init]; + setControlSize(cell, stepperSizes(), zoomedRect.size(), zoomFactor); + + 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); + + context->save(); + NSControlSize controlSize = [cell controlSize]; + IntSize zoomedSize = stepperSizes()[controlSize]; + IntRect rect(zoomedRect); + + if (zoomFactor != 1.0f) { + rect.setWidth(rect.width() / zoomFactor); + rect.setHeight(rect.height() / zoomFactor); + context->translate(rect.x(), rect.y()); + 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 + + context->restore(); +} + // This will ensure that we always return a valid NSView, even if ScrollView doesn't have an associated document NSView. // If the ScrollView doesn't have an NSView, we will return a fake NSView whose sole purpose is to tell AppKit that it's flipped. NSView *ThemeMac::ensuredView(ScrollView* scrollView) @@ -494,6 +563,13 @@ LengthSize ThemeMac::controlSize(ControlPart part, const Font& font, const Lengt case ListButtonPart: return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, listButtonSizes()); #endif + case InnerSpinButtonPart: + // We don't use inner spin buttons on Mac. + return LengthSize(Length(Fixed), Length(Fixed)); + case OuterSpinButtonPart: + if (!zoomedSize.width().isIntrinsicOrAuto() && !zoomedSize.height().isIntrinsicOrAuto()) + return zoomedSize; + return sizeFromNSControlSize(stepperControlSizeForFont(font), zoomedSize, zoomFactor, stepperSizes()); default: return zoomedSize; } @@ -507,6 +583,14 @@ LengthSize ThemeMac::minimumControlSize(ControlPart part, const Font& font, floa case ButtonPart: case ListButtonPart: return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed)); + case InnerSpinButtonPart: + // We don't use inner spin buttons on Mac. + return LengthSize(Length(Fixed), Length(Fixed)); + case OuterSpinButtonPart: { + IntSize base = stepperSizes()[NSMiniControlSize]; + return LengthSize(Length(static_cast<int>(base.width() * zoomFactor), Fixed), + Length(static_cast<int>(base.height() * zoomFactor), Fixed)); + } default: return Theme::minimumControlSize(part, font, zoomFactor); } @@ -583,6 +667,16 @@ void ThemeMac::inflateControlPaintRect(ControlPart part, ControlStates states, I } break; } + case OuterSpinButtonPart: { + static const int stepperMargin[4] = { 0, 0, 0, 0}; + NSCell *cell = stepper(states, zoomedRect, zoomFactor); + NSControlSize controlSize = [cell controlSize]; + IntSize zoomedSize = stepperSizes()[controlSize]; + zoomedSize.setHeight(zoomedSize.height() * zoomFactor); + zoomedSize.setWidth(zoomedSize.width() * zoomFactor); + zoomedRect = inflateRect(zoomedRect, zoomedSize, stepperMargin, zoomFactor); + break; + } default: break; } @@ -605,6 +699,9 @@ void ThemeMac::paint(ControlPart part, ControlStates states, GraphicsContext* co case ListButtonPart: paintButton(part, states, context, zoomedRect, zoomFactor, scrollView); break; + case OuterSpinButtonPart: + paintStepper(states, context, zoomedRect, zoomFactor, scrollView); + break; default: break; } diff --git a/WebCore/platform/mac/WebCoreObjCExtras.mm b/WebCore/platform/mac/WebCoreObjCExtras.mm index 4fc757c..05d3e01 100644 --- a/WebCore/platform/mac/WebCoreObjCExtras.mm +++ b/WebCore/platform/mac/WebCoreObjCExtras.mm @@ -71,14 +71,9 @@ static void deallocCallback(void* context) bool WebCoreObjCScheduleDeallocateOnMainThread(Class cls, id object) { ASSERT([object isKindOfClass:cls]); - -#if USE(WEB_THREAD) + if (isMainThread()) return false; -#else - if (pthread_main_np() != 0) - return false; -#endif ClassAndIdPair* pair = new ClassAndIdPair(cls, object); callOnMainThread(deallocCallback, pair); diff --git a/WebCore/platform/mac/WidgetMac.mm b/WebCore/platform/mac/WidgetMac.mm index 1aad76f..37c9e9f 100644 --- a/WebCore/platform/mac/WidgetMac.mm +++ b/WebCore/platform/mac/WidgetMac.mm @@ -105,8 +105,11 @@ Widget::~Widget() } // FIXME: Should move this to Chrome; bad layering that this knows about Frame. -void Widget::setFocus() +void Widget::setFocus(bool focused) { + if (!focused) + return; + Frame* frame = Frame::frameForWidget(this); if (!frame) return; |