| 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 <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "app/gfx/native_widget_types.h" | 10 #include "app/gfx/native_widget_types.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 void Replace(const string16& word); | 338 void Replace(const string16& word); |
| 339 | 339 |
| 340 // Makes an IPC call to tell webkit to advance to the next misspelling. | 340 // Makes an IPC call to tell webkit to advance to the next misspelling. |
| 341 void AdvanceToNextMisspelling(); | 341 void AdvanceToNextMisspelling(); |
| 342 | 342 |
| 343 // Sets the active state (i.e., control tints). | 343 // Sets the active state (i.e., control tints). |
| 344 virtual void SetActive(bool active); | 344 virtual void SetActive(bool active); |
| 345 | 345 |
| 346 protected: | 346 protected: |
| 347 // Internal implementation of the public Forward*Event() methods. | 347 // Internal implementation of the public Forward*Event() methods. |
| 348 void ForwardInputEvent( | 348 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, |
| 349 const WebKit::WebInputEvent& input_event, int event_size); | 349 int event_size, bool is_keyboard_shortcut); |
| 350 | 350 |
| 351 // Called when we receive a notification indicating that the renderer | 351 // Called when we receive a notification indicating that the renderer |
| 352 // process has gone. This will reset our state so that our state will be | 352 // process has gone. This will reset our state so that our state will be |
| 353 // consistent if a new renderer is created. | 353 // consistent if a new renderer is created. |
| 354 void RendererExited(); | 354 void RendererExited(); |
| 355 | 355 |
| 356 // Retrieves an id the renderer can use to refer to its view. | 356 // Retrieves an id the renderer can use to refer to its view. |
| 357 // This is used for various IPC messages, including plugins. | 357 // This is used for various IPC messages, including plugins. |
| 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 to handled a keyboard event before sending it to the renderer. |
| 361 // to the renderer or not. | 361 // This is overridden by RenderView to send upwards to its delegate. |
| 362 virtual bool ShouldSendToRenderer(const NativeWebKeyboardEvent& event) { | 362 // Returns true if the event was handled, and then the keyboard event will |
| 363 return true; | 363 // not be sent to the renderer anymore. Otherwise, if the |event| would |
| 364 } | 364 // be handled in HandleKeyboardEvent() method as a normal keyboard shortcut, |
| 365 | 365 // |*is_keyboard_shortcut| should be set to true. |
| 366 // Called when we an InputEvent was not processed by the renderer. This is | 366 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 367 // overridden by RenderView to send upwards to its delegate. | 367 bool* is_keyboard_shortcut) { |
| 368 // Returns true if the event was handled by its delegate. | |
| 369 virtual bool UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) { | |
| 370 return false; | 368 return false; |
| 371 } | 369 } |
| 372 | 370 |
| 371 // Called when a keyboard event was not processed by the renderer. This is |
| 372 // overridden by RenderView to send upwards to its delegate. |
| 373 virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event) {} |
| 374 |
| 373 // Notification that the user has made some kind of input that could | 375 // Notification that the user has made some kind of input that could |
| 374 // perform an action. The render view host overrides this to forward the | 376 // perform an action. The render view host overrides this to forward the |
| 375 // information to its delegate (see corresponding function in | 377 // information to its delegate (see corresponding function in |
| 376 // RenderViewHostDelegate). The gestures that count are 1) any mouse down | 378 // RenderViewHostDelegate). The gestures that count are 1) any mouse down |
| 377 // event and 2) enter or space key presses. | 379 // event and 2) enter or space key presses. |
| 378 virtual void OnUserGesture() {} | 380 virtual void OnUserGesture() {} |
| 379 | 381 |
| 380 // Callbacks for notification when the renderer becomes unresponsive to user | 382 // Callbacks for notification when the renderer becomes unresponsive to user |
| 381 // input events, and subsequently responsive again. RenderViewHost overrides | 383 // input events, and subsequently responsive again. RenderViewHost overrides |
| 382 // these to tell its delegate to show the user a warning. | 384 // these to tell its delegate to show the user a warning. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 // Used for UMA histogram logging to measure the time for a repaint view | 536 // Used for UMA histogram logging to measure the time for a repaint view |
| 535 // operation to finish. | 537 // operation to finish. |
| 536 base::TimeTicks repaint_start_time_; | 538 base::TimeTicks repaint_start_time_; |
| 537 | 539 |
| 538 // Queue of keyboard events that we need to track. | 540 // Queue of keyboard events that we need to track. |
| 539 typedef std::deque<NativeWebKeyboardEvent> KeyQueue; | 541 typedef std::deque<NativeWebKeyboardEvent> KeyQueue; |
| 540 | 542 |
| 541 // A queue of keyboard events. We can't trust data from the renderer so we | 543 // A queue of keyboard events. We can't trust data from the renderer so we |
| 542 // stuff key events into a queue and pop them out on ACK, feeding our copy | 544 // stuff key events into a queue and pop them out on ACK, feeding our copy |
| 543 // back to whatever unhandled handler instead of the returned version. | 545 // back to whatever unhandled handler instead of the returned version. |
| 544 // See the description of |pending_key_events_| below for more details. | |
| 545 KeyQueue key_queue_; | 546 KeyQueue key_queue_; |
| 546 | 547 |
| 547 // Set when we update the text direction of the selected input element. | 548 // Set when we update the text direction of the selected input element. |
| 548 bool text_direction_updated_; | 549 bool text_direction_updated_; |
| 549 WebKit::WebTextDirection text_direction_; | 550 WebKit::WebTextDirection text_direction_; |
| 550 | 551 |
| 551 // Set when we cancel updating the text direction. | 552 // Set when we cancel updating the text direction. |
| 552 // This flag also ignores succeeding update requests until we call | 553 // This flag also ignores succeeding update requests until we call |
| 553 // NotifyTextDirection(). | 554 // NotifyTextDirection(). |
| 554 bool text_direction_canceled_; | 555 bool text_direction_canceled_; |
| 555 | 556 |
| 556 // How many key events in |key_queue_| are not sent to the renderer yet, | |
| 557 // counted from the back of |key_queue_|. | |
| 558 // In order to suppress a Char event when necessary (see the description of | |
| 559 // |suppress_next_char_events_| below), we can't just send it to the | |
| 560 // renderer as soon as we get it. Instead, we need wait for the result of | |
| 561 // preceding RawKeyDown event back from the renderer, and then decide how to | |
| 562 // process the pending Char events according to the result. | |
| 563 // So if we get one or more Char events before receiving the result of | |
| 564 // preceding RawKeyDown event, we need keep them in |key_queue_|. And in | |
| 565 // order to keep the order the key events, all following key events must be | |
| 566 // pending until the pending Char events got processed. | |
| 567 size_t pending_key_events_; | |
| 568 | |
| 569 // Indicates if the next sequence of Char events should be suppressed or not. | 557 // Indicates if the next sequence of Char events should be suppressed or not. |
| 570 // System may translate a RawKeyDown event into zero or more Char events, | 558 // System may translate a RawKeyDown event into zero or more Char events, |
| 571 // usually we send them to the renderer directly in sequence. However, If a | 559 // usually we send them to the renderer directly in sequence. However, If a |
| 572 // RawKeyDown event was not handled by the renderer but was handled by | 560 // RawKeyDown event was not handled by the renderer but was handled by |
| 573 // our UnhandledKeyboardEvent() method, eg. as an accelerator key, then we | 561 // our UnhandledKeyboardEvent() method, eg. as an accelerator key, then we |
| 574 // shall not send the following sequence of Char events, which was generated | 562 // shall not send the following sequence of Char events, which was generated |
| 575 // by this RawKeyDown event, to the renderer. Otherwise the renderer may | 563 // by this RawKeyDown event, to the renderer. Otherwise the renderer may |
| 576 // handle the Char events and cause unexpected behavior. | 564 // handle the Char events and cause unexpected behavior. |
| 577 // For example, pressing alt-2 may let the browser switch to the second tab, | 565 // For example, pressing alt-2 may let the browser switch to the second tab, |
| 578 // but the Char event generated by alt-2 may also activate a HTML element | 566 // but the Char event generated by alt-2 may also activate a HTML element |
| 579 // if its accesskey happens to be "2", then the user may get confused when | 567 // if its accesskey happens to be "2", then the user may get confused when |
| 580 // switching back to the original tab, because the content may already be | 568 // switching back to the original tab, because the content may already be |
| 581 // changed. | 569 // changed. |
| 582 bool suppress_next_char_events_; | 570 bool suppress_next_char_events_; |
| 583 | 571 |
| 584 // True if the PaintRect_ACK message for the last PaintRect message is still | |
| 585 // not sent yet. This is used for optimizing the painting overhead when there | |
| 586 // are many pending key events in the queue. | |
| 587 bool paint_ack_postponed_; | |
| 588 | |
| 589 // The time when a PaintRect_ACK message is postponed, so that we can send the | |
| 590 // message after a certain duration. | |
| 591 base::TimeTicks paint_ack_postponed_time_; | |
| 592 | |
| 593 // During the call to some methods, eg. OnMsgInputEventAck, this | |
| 594 // RenderWidgetHost object may be destroyed before executing some code that | |
| 595 // still want to access this object. To avoid this situation, |death_flag_| | |
| 596 // shall be pointed to a local variable in the method, and then |*death_flag_| | |
| 597 // will be set to true when destroying this RenderWidgetHost object, then the | |
| 598 // method shall exit immediately when |*death_flag_| becomes true. | |
| 599 bool* death_flag_; | |
| 600 | |
| 601 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); | 572 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHost); |
| 602 }; | 573 }; |
| 603 | 574 |
| 604 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ | 575 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_H_ |
| OLD | NEW |