Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc

Issue 6685002: Wires up ability for page to specify instant auto complete (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test and stray char Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/autocomplete_edit_view_gtk.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 } 754 }
755 755
756 gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const { 756 gfx::NativeView AutocompleteEditViewGtk::GetNativeView() const {
757 return alignment_.get(); 757 return alignment_.get();
758 } 758 }
759 759
760 CommandUpdater* AutocompleteEditViewGtk::GetCommandUpdater() { 760 CommandUpdater* AutocompleteEditViewGtk::GetCommandUpdater() {
761 return command_updater_; 761 return command_updater_;
762 } 762 }
763 763
764 void AutocompleteEditViewGtk::SetInstantSuggestion(const string16& suggestion) { 764 void AutocompleteEditViewGtk::SetInstantSuggestion(const string16& suggestion,
765 bool animate_to_complete) {
765 std::string suggestion_utf8 = UTF16ToUTF8(suggestion); 766 std::string suggestion_utf8 = UTF16ToUTF8(suggestion);
766 767
767 gtk_label_set_text(GTK_LABEL(instant_view_), suggestion_utf8.c_str()); 768 gtk_label_set_text(GTK_LABEL(instant_view_), suggestion_utf8.c_str());
768 769
769 StopAnimation(); 770 StopAnimation();
770 771
771 if (suggestion.empty()) { 772 if (suggestion.empty()) {
772 gtk_widget_hide(instant_view_); 773 gtk_widget_hide(instant_view_);
773 return; 774 return;
774 } 775 }
775 if (InstantController::IsEnabled(model_->profile()) 776 if (animate_to_complete
776 #if GTK_CHECK_VERSION(2, 20, 0) 777 #if GTK_CHECK_VERSION(2, 20, 0)
777 && preedit_.empty() 778 && preedit_.empty()
778 #endif 779 #endif
779 ) { 780 ) {
780 instant_animation_->set_delegate(this); 781 instant_animation_->set_delegate(this);
781 instant_animation_->Start(); 782 instant_animation_->Start();
782 } 783 }
783 784
784 gtk_widget_show(instant_view_); 785 gtk_widget_show(instant_view_);
785 AdjustVerticalAlignmentOfInstantView(); 786 AdjustVerticalAlignmentOfInstantView();
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 // baseline, so we need to move the |instant_view_| down to make sure it 2327 // baseline, so we need to move the |instant_view_| down to make sure it
2327 // has the same baseline as the |text_view_|. 2328 // has the same baseline as the |text_view_|.
2328 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2329 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2329 int height; 2330 int height;
2330 pango_layout_get_size(layout, NULL, &height); 2331 pango_layout_get_size(layout, NULL, &height);
2331 PangoLayoutIter* iter = pango_layout_get_iter(layout); 2332 PangoLayoutIter* iter = pango_layout_get_iter(layout);
2332 int baseline = pango_layout_iter_get_baseline(iter); 2333 int baseline = pango_layout_iter_get_baseline(iter);
2333 pango_layout_iter_free(iter); 2334 pango_layout_iter_free(iter);
2334 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2335 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2335 } 2336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698