OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2211 | 2211 |
2212 void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { | 2212 void RenderWidgetHostImpl::SetIgnoreInputEvents(bool ignore_input_events) { |
2213 ignore_input_events_ = ignore_input_events; | 2213 ignore_input_events_ = ignore_input_events; |
2214 } | 2214 } |
2215 | 2215 |
2216 bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( | 2216 bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( |
2217 const NativeWebKeyboardEvent& event) { | 2217 const NativeWebKeyboardEvent& event) { |
2218 if (event.skip_in_browser || event.type != WebKeyboardEvent::RawKeyDown) | 2218 if (event.skip_in_browser || event.type != WebKeyboardEvent::RawKeyDown) |
2219 return false; | 2219 return false; |
2220 | 2220 |
2221 for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); | 2221 std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
2222 it != keyboard_listeners_.end(); ++it) { | 2222 while(it != keyboard_listeners_.end()) { |
2223 if ((*it)->HandleKeyPressEvent(event)) | 2223 // It is possible for the handler to delete itself and not handle the key |
2224 // press. | |
2225 if ((*(it++))->HandleKeyPressEvent(event)) | |
Ilya Sherman
2013/04/18 00:33:32
This isn't guaranteed to work. You should (a) use
csharp
2013/04/18 19:53:02
Ah, I didn't know about ObserverList, awesome.
| |
2224 return true; | 2226 return true; |
2225 } | 2227 } |
2226 | 2228 |
2227 return false; | 2229 return false; |
2228 } | 2230 } |
2229 | 2231 |
2230 void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) { | 2232 void RenderWidgetHostImpl::ProcessKeyboardEventAck(int type, bool processed) { |
2231 if (key_queue_.empty()) { | 2233 if (key_queue_.empty()) { |
2232 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " | 2234 LOG(ERROR) << "Got a KeyEvent back from the renderer but we " |
2233 << "don't seem to have sent it to the renderer!"; | 2235 << "don't seem to have sent it to the renderer!"; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2480 return; | 2482 return; |
2481 | 2483 |
2482 OnRenderAutoResized(new_size); | 2484 OnRenderAutoResized(new_size); |
2483 } | 2485 } |
2484 | 2486 |
2485 void RenderWidgetHostImpl::DetachDelegate() { | 2487 void RenderWidgetHostImpl::DetachDelegate() { |
2486 delegate_ = NULL; | 2488 delegate_ = NULL; |
2487 } | 2489 } |
2488 | 2490 |
2489 } // namespace content | 2491 } // namespace content |
OLD | NEW |