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

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reworked to send ESC down to JS, added test. Created 7 years, 10 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // the text, or in the middle of composition. 566 // the text, or in the middle of composition.
567 CharRange sel = GetSelection(); 567 CharRange sel = GetSelection();
568 bool no_inline_autocomplete = 568 bool no_inline_autocomplete =
569 std::max(sel.cp_max, sel.cp_min) < GetOmniboxTextLength() || 569 std::max(sel.cp_max, sel.cp_min) < GetOmniboxTextLength() ||
570 IsImeComposing(); 570 IsImeComposing();
571 model()->StartAutocomplete(sel.cp_min != sel.cp_max, no_inline_autocomplete); 571 model()->StartAutocomplete(sel.cp_min != sel.cp_max, no_inline_autocomplete);
572 } 572 }
573 573
574 void OmniboxViewGtk::OnTemporaryTextMaybeChanged( 574 void OmniboxViewGtk::OnTemporaryTextMaybeChanged(
575 const string16& display_text, 575 const string16& display_text,
576 bool save_original_selection) { 576 bool save_original_selection,
577 bool notify_text_changed) {
577 if (save_original_selection) 578 if (save_original_selection)
578 saved_temporary_selection_ = GetSelection(); 579 saved_temporary_selection_ = GetSelection();
579 580
580 StartUpdatingHighlightedText(); 581 StartUpdatingHighlightedText();
581 SetWindowTextAndCaretPos(display_text, display_text.length(), false, false); 582 SetWindowTextAndCaretPos(display_text, display_text.length(), false, false);
582 FinishUpdatingHighlightedText(); 583 FinishUpdatingHighlightedText();
583 TextChanged(); 584 if (notify_text_changed)
585 TextChanged();
584 } 586 }
585 587
586 bool OmniboxViewGtk::OnInlineAutocompleteTextMaybeChanged( 588 bool OmniboxViewGtk::OnInlineAutocompleteTextMaybeChanged(
587 const string16& display_text, 589 const string16& display_text,
588 size_t user_text_length) { 590 size_t user_text_length) {
589 if (display_text == GetText()) 591 if (display_text == GetText())
590 return false; 592 return false;
591 593
592 StartUpdatingHighlightedText(); 594 StartUpdatingHighlightedText();
593 CharRange range(display_text.size(), user_text_length); 595 CharRange range(display_text.size(), user_text_length);
594 SetTextAndSelectedRange(display_text, range); 596 SetTextAndSelectedRange(display_text, range);
595 FinishUpdatingHighlightedText(); 597 FinishUpdatingHighlightedText();
596 TextChanged(); 598 TextChanged();
597 return true; 599 return true;
598 } 600 }
599 601
600 void OmniboxViewGtk::OnRevertTemporaryText() { 602 void OmniboxViewGtk::OnRevertTemporaryText() {
601 StartUpdatingHighlightedText(); 603 StartUpdatingHighlightedText();
602 SetSelectedRange(saved_temporary_selection_); 604 SetSelectedRange(saved_temporary_selection_);
603 FinishUpdatingHighlightedText(); 605 FinishUpdatingHighlightedText();
604 TextChanged();
beaudoin 2013/02/07 22:34:59 Shamelessly getting rid of that (see explanation i
605 } 606 }
606 607
607 void OmniboxViewGtk::OnBeforePossibleChange() { 608 void OmniboxViewGtk::OnBeforePossibleChange() {
608 // Record this paste, so we can do different behavior. 609 // Record this paste, so we can do different behavior.
609 if (paste_clipboard_requested_) { 610 if (paste_clipboard_requested_) {
610 paste_clipboard_requested_ = false; 611 paste_clipboard_requested_ = false;
611 model()->on_paste(); 612 model()->on_paste();
612 } 613 }
613 614
614 // This method will be called in HandleKeyPress() method just before 615 // This method will be called in HandleKeyPress() method just before
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { 2139 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() {
2139 // By default, GtkTextView layouts an anchored child widget just above the 2140 // By default, GtkTextView layouts an anchored child widget just above the
2140 // baseline, so we need to move the |instant_view_| down to make sure it 2141 // baseline, so we need to move the |instant_view_| down to make sure it
2141 // has the same baseline as the |text_view_|. 2142 // has the same baseline as the |text_view_|.
2142 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2143 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2143 int height; 2144 int height;
2144 pango_layout_get_size(layout, NULL, &height); 2145 pango_layout_get_size(layout, NULL, &height);
2145 int baseline = pango_layout_get_baseline(layout); 2146 int baseline = pango_layout_get_baseline(layout);
2146 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2147 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2147 } 2148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698