Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / renderer_host / native_web_keyboard_event_mac.mm
blobfea2939f2c1b5f799eb84f12f82a5d25f00b51e9
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/browser/native_web_keyboard_event.h"
7 #import <AppKit/AppKit.h>
9 #include "third_party/WebKit/public/web/mac/WebInputEventFactory.h"
11 using blink::WebInputEventFactory;
13 namespace content {
15 NativeWebKeyboardEvent::NativeWebKeyboardEvent()
16     : os_event(NULL),
17       skip_in_browser(false) {
20 NativeWebKeyboardEvent::NativeWebKeyboardEvent(gfx::NativeEvent native_event)
21     : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(native_event)),
22       os_event([native_event retain]),
23       skip_in_browser(false) {
26 NativeWebKeyboardEvent::NativeWebKeyboardEvent(wchar_t character,
27                                                int modifiers,
28                                                double time_stamp_seconds)
29     : WebKeyboardEvent(WebInputEventFactory::keyboardEvent(character,
30                                                            modifiers,
31                                                            time_stamp_seconds)),
32       os_event(NULL),
33       skip_in_browser(false) {
36 NativeWebKeyboardEvent::NativeWebKeyboardEvent(
37     const NativeWebKeyboardEvent& other)
38     : WebKeyboardEvent(other),
39       os_event([other.os_event retain]),
40       skip_in_browser(other.skip_in_browser) {
43 NativeWebKeyboardEvent& NativeWebKeyboardEvent::operator=(
44     const NativeWebKeyboardEvent& other) {
45   WebKeyboardEvent::operator=(other);
47   NSObject* previous = os_event;
48   os_event = [other.os_event retain];
49   [previous release];
51   skip_in_browser = other.skip_in_browser;
53   return *this;
56 NativeWebKeyboardEvent::~NativeWebKeyboardEvent() {
57   [os_event release];
60 }  // namespace content