summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 01:15:33 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 01:15:33 +0000
commited8bf13bccd28196fa2e1ddd30dc98a100167919 (patch)
treee721a87554d87716db83adcbdcc6c1cdeb109f60 /chrome/browser/tab_contents
parent9febdb951b2a75ae69c2b2153c94ee5be86bb3ed (diff)
downloadchromium_src-ed8bf13bccd28196fa2e1ddd30dc98a100167919.zip
chromium_src-ed8bf13bccd28196fa2e1ddd30dc98a100167919.tar.gz
chromium_src-ed8bf13bccd28196fa2e1ddd30dc98a100167919.tar.bz2
Fix conflicts between accelerator keys and HTML DOM accesskeys.
This CL fixes conflicts between accelerator keys and HTML DOM accesskeys by suppressing Char events if corresponding RawKeyDown event was handled by the browser after returning from the renderer unhandled. This CL not only fixes this conflict issue, but also makes the behavior of handling accelerator keys similar than IE, which also suppresses a key press event if the key down event was handled as an accelerator key. BUG=21624 accesskey attributes conflict with browser shortcuts (like tab-switching) TEST=Open http://djmitche.github.com/buildbot/docs/0.7.11/ in one of opened multiple tabs, switch to another tab by pressing an alt-# key binding, then switch back to the original page to see if it's just as you left it before switching tabs. Review URL: http://codereview.chromium.org/235039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29857 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc8
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc8
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_mac.mm23
5 files changed, 23 insertions, 20 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index cb6648a..024f250 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -97,7 +97,7 @@ class InterstitialPage::InterstitialPageRVHViewDelegate
virtual void GotFocus();
virtual void TakeFocus(bool reverse);
virtual bool IsReservedAccelerator(const NativeWebKeyboardEvent& event);
- virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+ virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
virtual void HandleMouseEvent();
virtual void HandleMouseLeave();
virtual void OnFindReply(int request_id,
@@ -584,10 +584,12 @@ bool InterstitialPage::InterstitialPageRVHViewDelegate::IsReservedAccelerator(
return false;
}
-void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
+bool InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
- interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event);
+ return interstitial_page_->tab()->GetViewDelegate()->
+ HandleKeyboardEvent(event);
+ return false;
}
void InterstitialPage::InterstitialPageRVHViewDelegate::HandleMouseEvent() {
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index b738b8a..a51aa10 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -320,14 +320,14 @@ void TabContentsViewGtk::TakeFocus(bool reverse) {
}
}
-void TabContentsViewGtk::HandleKeyboardEvent(
+bool TabContentsViewGtk::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
// This may be an accelerator. Try to pass it on to our browser window
// to handle.
GtkWindow* window = GetTopLevelNativeWindow();
if (!window) {
NOTREACHED();
- return;
+ return false;
}
// Filter out pseudo key events created by GtkIMContext signal handlers.
@@ -339,12 +339,12 @@ void TabContentsViewGtk::HandleKeyboardEvent(
// as an accelerator.
if (event.type == WebKit::WebInputEvent::Char ||
event.type == WebKit::WebInputEvent::KeyUp)
- return;
+ return false;
BrowserWindowGtk* browser_window =
BrowserWindowGtk::GetBrowserWindowForNativeWindow(window);
DCHECK(browser_window);
- browser_window->HandleKeyboardEvent(event.os_event);
+ return browser_window->HandleKeyboardEvent(event.os_event);
}
void TabContentsViewGtk::Observe(NotificationType type,
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h
index d2da996..d4bc0cf 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.h
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h
@@ -70,7 +70,7 @@ class TabContentsViewGtk : public TabContentsView,
virtual void UpdateDragCursor(WebKit::WebDragOperation operation);
virtual void GotFocus();
virtual void TakeFocus(bool reverse);
- virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+ virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
// NotificationObserver implementation ---------------------------------------
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.h b/chrome/browser/tab_contents/tab_contents_view_mac.h
index 79c7fe4..99e9f22 100644
--- a/chrome/browser/tab_contents/tab_contents_view_mac.h
+++ b/chrome/browser/tab_contents/tab_contents_view_mac.h
@@ -74,7 +74,7 @@ class TabContentsViewMac : public TabContentsView,
virtual void UpdateDragCursor(WebKit::WebDragOperation operation);
virtual void GotFocus();
virtual void TakeFocus(bool reverse);
- virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
+ virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
// NotificationObserver implementation ---------------------------------------
diff --git a/chrome/browser/tab_contents/tab_contents_view_mac.mm b/chrome/browser/tab_contents/tab_contents_view_mac.mm
index 908b411..a8933be 100644
--- a/chrome/browser/tab_contents/tab_contents_view_mac.mm
+++ b/chrome/browser/tab_contents/tab_contents_view_mac.mm
@@ -46,7 +46,7 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
@interface TabContentsViewCocoa (Private)
- (id)initWithTabContentsViewMac:(TabContentsViewMac*)w;
-- (void)processKeyboardEvent:(NativeWebKeyboardEvent*)event;
+- (BOOL)processKeyboardEvent:(NativeWebKeyboardEvent*)event;
- (void)registerDragTypes;
- (void)setCurrentDragOperation:(NSDragOperation)operation;
- (void)startDragWithDropData:(const WebDropData&)dropData
@@ -212,10 +212,10 @@ void TabContentsViewMac::TakeFocus(bool reverse) {
}
}
-void TabContentsViewMac::HandleKeyboardEvent(
+bool TabContentsViewMac::HandleKeyboardEvent(
const NativeWebKeyboardEvent& event) {
- [cocoa_view_.get() processKeyboardEvent:
- const_cast<NativeWebKeyboardEvent*>(&event)];
+ return [cocoa_view_.get() processKeyboardEvent:
+ const_cast<NativeWebKeyboardEvent*>(&event)] == YES;
}
void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) {
@@ -310,9 +310,9 @@ void TabContentsViewMac::Observe(NotificationType type,
return tabContentsView_->tab_contents();
}
-- (void)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent {
+- (BOOL)processKeyboardEvent:(NativeWebKeyboardEvent*)wkEvent {
if (wkEvent->skip_in_browser)
- return;
+ return NO;
NSEvent* event = wkEvent->os_event;
@@ -320,13 +320,13 @@ void TabContentsViewMac::Observe(NotificationType type,
// Char events are synthesized and do not contain a real event. We are not
// interested in them anyway.
DCHECK(wkEvent->type == WebKit::WebInputEvent::Char);
- return;
+ return NO;
}
// If this tab is no longer active, its window will be |nil|. In that case,
// best ignore the event.
if (![self window])
- return;
+ return NO;
ChromeEventProcessingWindow* window =
(ChromeEventProcessingWindow*)[self window];
DCHECK([window isKindOfClass:[ChromeEventProcessingWindow class]]);
@@ -334,9 +334,9 @@ void TabContentsViewMac::Observe(NotificationType type,
// Do not fire shortcuts on key up.
if ([event type] == NSKeyDown) {
if ([window handleExtraBrowserKeyboardShortcut:event])
- return;
+ return YES;
if ([window handleExtraWindowKeyboardShortcut:event])
- return;
+ return YES;
}
// We need to re-dispatch the event, so that it is sent to the menu or other
@@ -345,8 +345,9 @@ void TabContentsViewMac::Observe(NotificationType type,
tabContentsView_->GetContentNativeView());
DCHECK([rwhv isKindOfClass:[RenderWidgetHostViewCocoa class]]);
[rwhv setIgnoreKeyEvents:YES];
- [window redispatchEvent:event];
+ BOOL eventHandled = [window redispatchEvent:event];
[rwhv setIgnoreKeyEvents:NO];
+ return eventHandled;
}
- (void)mouseEvent:(NSEvent *)theEvent {