- [mac] Add selector implementations for edit commands (issue #276).

- [mac] Don't generate character events for arrow key presses (issue #294).
- Call OnSetFocus when the browser view receives focus/becomes first responder (issue #314).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@281 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-08-27 18:41:21 +00:00
parent 723e5877e9
commit 16e468bb8c
4 changed files with 69 additions and 4 deletions

View File

@ -81,8 +81,21 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
return 0;
case WM_SETFOCUS:
if (browser)
browser->UIT_SetFocus(browser->UIT_GetWebViewHost(), true);
if (browser) {
WebViewHost* host = browser->UIT_GetWebViewHost();
if (host) {
bool handled = false;
CefRefPtr<CefClient> client = browser->GetClient();
if (client.get()) {
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
if (handler.get())
handled = handler->OnSetFocus(browser, false);
}
if (!handled)
browser->UIT_SetFocus(host, true);
}
}
return 0;
case WM_ERASEBKGND:

View File

@ -507,6 +507,12 @@ void BrowserWebViewDelegate::scheduleAnimation() {
host->ScheduleAnimation();
}
// This method is called when:
// A. A request is loaded in a window other than the source window
// (FrameLoader::loadFrameRequest), or
// B. A request is loaded in an already existing popup window
// (FrameLoader::createWindow), or
// C. A DOM window receives a focus event (DOMWindow::focus)
void BrowserWebViewDelegate::didFocus() {
if (WebWidgetHost* host = GetWidgetHost()) {
bool handled = false;
@ -522,6 +528,8 @@ void BrowserWebViewDelegate::didFocus() {
}
}
// This method is called when a DOM window receives a blur event
// (DOMWindow::blur).
void BrowserWebViewDelegate::didBlur() {
if (WebWidgetHost* host = GetWidgetHost())
browser_->UIT_SetFocus(host, false);

View File

@ -156,6 +156,13 @@
- (BOOL)becomeFirstResponder {
if (browser_ && browser_->UIT_GetWebView()) {
CefRefPtr<CefClient> client = browser_->GetClient();
if (client.get()) {
CefRefPtr<CefFocusHandler> handler = client->GetFocusHandler();
if (handler.get() && handler->OnSetFocus(browser_, false))
return NO;
}
browser_->UIT_GetWebViewHost()->SetFocus(YES);
return [super becomeFirstResponder];
}
@ -181,6 +188,41 @@
[self setNeedsDisplay:YES];
}
- (void)undo:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Undo();
}
- (void)redo:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Redo();
}
- (void)cut:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Cut();
}
- (void)copy:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Copy();
}
- (void)paste:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Paste();
}
- (void)delete:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->Delete();
}
- (void)selectAll:(id)sender {
if (browser_)
browser_->GetFocusedFrame()->SelectAll();
}
- (void)registerDragDrop {
dropTarget_.reset([[WebDropTarget alloc] initWithWebView:self]);

View File

@ -220,8 +220,10 @@ void WebWidgetHost::WheelEvent(NSEvent *event) {
void WebWidgetHost::KeyEvent(NSEvent *event) {
WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event));
webwidget_->handleInputEvent(keyboard_event);
if ([event type] == NSKeyDown) {
// Send a Char event here to emulate the keyboard events.
if ([event type] == NSKeyDown &&
!([event modifierFlags] & NSNumericPadKeyMask)) {
// Send a Char event here to emulate the keyboard events. Do not send a
// Char event for arrow keys (NSNumericPadKeyMask modifier will be set).
// TODO(hbono): Bug 20852 <http://crbug.com/20852> implement the
// NSTextInput protocol and remove this code.
keyboard_event.type = WebInputEvent::Char;