Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/gtk_im_context_wrapper.h" | 5 #include "chrome/browser/renderer_host/gtk_im_context_wrapper.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 448 // handler, which will send commit text to webkit later. Otherwise, | 448 // handler, which will send commit text to webkit later. Otherwise, |
| 449 // we need send it here. | 449 // we need send it here. |
| 450 // It's possible that commit signal is fired without a key event, for | 450 // It's possible that commit signal is fired without a key event, for |
| 451 // example when user input via a voice or handwriting recognition software. | 451 // example when user input via a voice or handwriting recognition software. |
| 452 // In this case, the text must be committed directly. | 452 // In this case, the text must be committed directly. |
| 453 if (!is_in_key_event_handler_ && host_view_->GetRenderWidgetHost()) | 453 if (!is_in_key_event_handler_ && host_view_->GetRenderWidgetHost()) |
| 454 host_view_->GetRenderWidgetHost()->ImeConfirmComposition(text); | 454 host_view_->GetRenderWidgetHost()->ImeConfirmComposition(text); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void GtkIMContextWrapper::HandlePreeditStart() { | 457 void GtkIMContextWrapper::HandlePreeditStart() { |
| 458 is_composing_text_ = true; | 458 // Ignore preedit related signals triggered by CancelComposition() method. |
| 459 if (!suppress_next_commit_) | |
|
satorux1
2010/11/24 01:56:05
You might want to make the code look like line 466
| |
| 460 is_composing_text_ = true; | |
| 459 } | 461 } |
| 460 | 462 |
| 461 void GtkIMContextWrapper::HandlePreeditChanged(const gchar* text, | 463 void GtkIMContextWrapper::HandlePreeditChanged(const gchar* text, |
| 462 PangoAttrList* attrs, | 464 PangoAttrList* attrs, |
| 463 int cursor_position) { | 465 int cursor_position) { |
| 464 suppress_next_commit_ = false; | 466 // Ignore preedit related signals triggered by CancelComposition() method. |
| 467 if (suppress_next_commit_) | |
| 468 return; | |
| 469 | |
| 465 // Don't set is_preedit_changed_ to false if there is no change, because | 470 // Don't set is_preedit_changed_ to false if there is no change, because |
| 466 // this handler might be called multiple times with the same data. | 471 // this handler might be called multiple times with the same data. |
| 467 is_preedit_changed_ = true; | 472 is_preedit_changed_ = true; |
| 468 preedit_text_.clear(); | 473 preedit_text_.clear(); |
| 469 preedit_underlines_.clear(); | 474 preedit_underlines_.clear(); |
| 470 preedit_selection_start_ = 0; | 475 preedit_selection_start_ = 0; |
| 471 preedit_selection_end_ = 0; | 476 preedit_selection_end_ = 0; |
| 472 | 477 |
| 473 ExtractCompositionInfo(text, attrs, cursor_position, &preedit_text_, | 478 ExtractCompositionInfo(text, attrs, cursor_position, &preedit_text_, |
| 474 &preedit_underlines_, &preedit_selection_start_, | 479 &preedit_underlines_, &preedit_selection_start_, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 } while (pango_attr_iterator_next(iter)); | 650 } while (pango_attr_iterator_next(iter)); |
| 646 pango_attr_iterator_destroy(iter); | 651 pango_attr_iterator_destroy(iter); |
| 647 } | 652 } |
| 648 | 653 |
| 649 // Use a black thin underline by default. | 654 // Use a black thin underline by default. |
| 650 if (underlines->empty()) { | 655 if (underlines->empty()) { |
| 651 underlines->push_back( | 656 underlines->push_back( |
| 652 WebKit::WebCompositionUnderline(0, length, SK_ColorBLACK, false)); | 657 WebKit::WebCompositionUnderline(0, length, SK_ColorBLACK, false)); |
| 653 } | 658 } |
| 654 } | 659 } |
| OLD | NEW |