| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "app/gfx/native_widget_types.h" | 10 #include "app/gfx/native_widget_types.h" |
| 11 #include "base/process.h" | 11 #include "base/process.h" |
| 12 #include "base/gfx/size.h" | 12 #include "base/gfx/size.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "chrome/common/edit_command.h" | 16 #include "chrome/common/edit_command.h" |
| 17 #include "chrome/common/native_web_keyboard_event.h" | 17 #include "chrome/common/native_web_keyboard_event.h" |
| 18 #include "chrome/common/property_bag.h" | 18 #include "chrome/common/property_bag.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 gfx::NativeViewId GetNativeViewId(); | 358 gfx::NativeViewId GetNativeViewId(); |
| 359 | 359 |
| 360 // Called when an InputEvent is received to check if the event should be sent | 360 // Called when an InputEvent is received to check if the event should be sent |
| 361 // to the renderer or not. | 361 // to the renderer or not. |
| 362 virtual bool ShouldSendToRenderer(const NativeWebKeyboardEvent& event) { | 362 virtual bool ShouldSendToRenderer(const NativeWebKeyboardEvent& event) { |
| 363 return true; | 363 return true; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // Called when we an InputEvent was not processed by the renderer. This is | 366 // Called when we an InputEvent was not processed by the renderer. This is |
| 367 // overridden by RenderView to send upwards to its delegate. | 367 // overridden by RenderView to send upwards to its delegate. |
| 368 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} | 368 // Returns true if the event was handled by its delegate. |
| 369 virtual bool UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 370 return false; |
| 371 } |
| 369 | 372 |
| 370 // Notification that the user has made some kind of input that could | 373 // Notification that the user has made some kind of input that could |
| 371 // perform an action. The render view host overrides this to forward the | 374 // perform an action. The render view host overrides this to forward the |
| 372 // information to its delegate (see corresponding function in | 375 // information to its delegate (see corresponding function in |
| 373 // RenderViewHostDelegate). The gestures that count are 1) any mouse down | 376 // RenderViewHostDelegate). The gestures that count are 1) any mouse down |
| 374 // event and 2) enter or space key presses. | 377 // event and 2) enter or space key presses. |
| 375 virtual void OnUserGesture() {} | 378 virtual void OnUserGesture() {} |
| 376 | 379 |
| 377 // Callbacks for notification when the renderer becomes unresponsive to user | 380 // Callbacks for notification when the renderer becomes unresponsive to user |
| 378 // input events, and subsequently responsive again. RenderViewHost overrides | 381 // input events, and subsequently responsive again. RenderViewHost overrides |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 bool in_get_backing_store_; | 524 bool in_get_backing_store_; |
| 522 | 525 |
| 523 // Set when we call DidPaintRect/DidScrollRect on the view. | 526 // Set when we call DidPaintRect/DidScrollRect on the view. |
| 524 bool view_being_painted_; | 527 bool view_being_painted_; |
| 525 | 528 |
| 526 // Used for UMA histogram logging to measure the time for a repaint view | 529 // Used for UMA histogram logging to measure the time for a repaint view |
| 527 // operation to finish. | 530 // operation to finish. |
| 528 base::TimeTicks repaint_start_time_; | 531 base::TimeTicks repaint_start_time_; |
| 529 | 532 |
| 530 // Queue of keyboard events that we need to track. | 533 // Queue of keyboard events that we need to track. |
| 531 typedef std::queue<NativeWebKeyboardEvent> KeyQueue; | 534 typedef std::deque<NativeWebKeyboardEvent> KeyQueue; |
| 532 | 535 |
| 533 // A queue of keyboard events. We can't trust data from the renderer so we | 536 // A queue of keyboard events. We can't trust data from the renderer so we |
| 534 // stuff key events into a queue and pop them out on ACK, feeding our copy | 537 // stuff key events into a queue and pop them out on ACK, feeding our copy |
| 535 // back to whatever unhandled handler instead of the returned version. | 538 // back to whatever unhandled handler instead of the returned version. |
| 539 // See the description of |pending_key_events_| below for more details. |
| 536 KeyQueue key_queue_; | 540 KeyQueue key_queue_; |
| 537 | 541 |
| 538 // Set when we update the text direction of the selected input element. | 542 // Set when we update the text direction of the selected input element. |
| 539 bool text_direction_updated_; | 543 bool text_direction_updated_; |
| 540 WebKit::WebTextDirection text_direction_; | 544 WebKit::WebTextDirection text_direction_; |
| 541 | 545 |
| 542 // Set when we cancel updating the text direction. | 546 // Set when we cancel updating the text direction. |
| 543 // This flag also ignores succeeding update requests until we call | 547 // This flag also ignores succeeding update requests until we call |
| 544 // NotifyTextDirection(). | 548 // NotifyTextDirection(). |
| 545 bool text_direction_canceled_; | 549 bool text_direction_canceled_; |
| 546 | 550 |
| 551 // How many key events in |key_queue_| are not sent to the renderer yet, |
| 552 // counted from the back of |key_queue_|. |
| 553 // In order to suppress a Char event when necessary (see the description of |
| 554 // |suppress_next_char_events_| below), we can't just send it to the |
| 555 // renderer as soon as we get it. Instead, we need wait for the result of |
| 556 // preceding RawKeyDown event back from the renderer, and then decide how to |
| 557 // process the pending Char events according to the result. |
| 558 // So if we get one or more Char events before receiving the result of |
| 559 // preceding RawKeyDown event, we need keep them in |key_queue_|. And in |
| 560 // order to keep the order the key events, all following key events must be |
| 561 // pending until the pending Char events got processed. |
| 562 size_t pending_key_events_; |
| 563 |
| 564 // Indicates if the next sequence of Char events should be suppressed or not. |
| 565 // System may translate a RawKeyDown event into zero or more Char events, |
| 566 // usually we send them to the renderer directly in sequence. However, If a |
| 567 // RawKeyDown event was not handled by the renderer but was handled by |
| 568 // our UnhandledKeyboardEvent() method, eg. as an accelerator key, then we |
| 569 // shall not send the following sequence of Char events, which was generated |
| 570 // by this RawKeyDown event, to the renderer. Otherwise the renderer may |
| 571 // handle the Char events and cause unexpected behavior. |
| 572 // For example, pressing alt-2 may let the browser switch to the second tab, |
| 573 // but the Char event generated by alt-2 may also activate a HTML element |
| 574 // if its accesskey happens to be "2", then the user may get confused when |
| 575 // switching back to the original tab, because the content may already be |
| 576 // changed. |
| 577 bool suppress_next_char_events_; |
| 578 |
| 579 // During the call to some methods, eg. OnMsgInputEventAck, this |
| 580 // RenderWidgetHost object may be destroyed before executing some code that |
| 581 // still want to access this object. To avoid this situation, |death_flag_| |
| 582 // shall be pointed to a local variable in the method, and then |*death_flag_| |
| 583 // will be set to true when destroying this RenderWidgetHost object, then the |
| 584 // method shall exit immediately when |*death_flag_| becomes true. |
| 585 bool* death_flag_; |
| 586 |
| 547 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 587 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
| 548 }; | 588 }; |
| 549 | 589 |
| 550 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 590 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| OLD | NEW |