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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11235023: Redesign: Remove TsfEventRouter interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@ominifix
Patch Set: Address comments Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 font_(parent_view->font()), 473 font_(parent_view->font()),
474 possible_drag_(false), 474 possible_drag_(false),
475 in_drag_(false), 475 in_drag_(false),
476 initiated_drag_(false), 476 initiated_drag_(false),
477 drop_highlight_position_(-1), 477 drop_highlight_position_(-1),
478 ime_candidate_window_open_(false), 478 ime_candidate_window_open_(false),
479 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( 479 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor(
480 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()), 480 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()),
481 ToolbarModel::NONE, LocationBarView::BACKGROUND))), 481 ToolbarModel::NONE, LocationBarView::BACKGROUND))),
482 security_level_(ToolbarModel::NONE), 482 security_level_(ToolbarModel::NONE),
483 text_object_model_(NULL) { 483 text_object_model_(NULL),
484 ALLOW_THIS_IN_INITIALIZER_LIST(
485 tsf_event_router_(base::win::IsTsfAwareRequired() ?
486 new ui::TsfEventRouter(this) : NULL)) {
484 if (!loaded_library_module_) 487 if (!loaded_library_module_)
485 loaded_library_module_ = LoadLibrary(kRichEditDLLName); 488 loaded_library_module_ = LoadLibrary(kRichEditDLLName);
486 489
487 saved_selection_for_focus_change_.cpMin = -1; 490 saved_selection_for_focus_change_.cpMin = -1;
488 491
489 g_paint_patcher.Pointer()->RefPatch(); 492 g_paint_patcher.Pointer()->RefPatch();
490 493
491 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0, 494 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0,
492 l10n_util::GetExtendedStyles()); 495 l10n_util::GetExtendedStyles());
493 SetReadOnly(popup_window_mode_); 496 SetReadOnly(popup_window_mode_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // Non-read-only edit controls have a drop target. Revoke it so that we can 537 // Non-read-only edit controls have a drop target. Revoke it so that we can
535 // install our own. Revoking automatically deletes the existing one. 538 // install our own. Revoking automatically deletes the existing one.
536 HRESULT hr = RevokeDragDrop(m_hWnd); 539 HRESULT hr = RevokeDragDrop(m_hWnd);
537 DCHECK_EQ(S_OK, hr); 540 DCHECK_EQ(S_OK, hr);
538 541
539 // Register our drop target. The scoped_refptr here will delete the drop 542 // Register our drop target. The scoped_refptr here will delete the drop
540 // target if it fails to register itself correctly on |m_hWnd|. Otherwise, 543 // target if it fails to register itself correctly on |m_hWnd|. Otherwise,
541 // the edit control will invoke RevokeDragDrop when it's being destroyed, so 544 // the edit control will invoke RevokeDragDrop when it's being destroyed, so
542 // we don't have to do so. 545 // we don't have to do so.
543 scoped_refptr<EditDropTarget> drop_target(new EditDropTarget(this)); 546 scoped_refptr<EditDropTarget> drop_target(new EditDropTarget(this));
544
545 if (base::win::IsTsfAwareRequired())
546 tsf_event_router_ = ui::TsfEventRouter::Create();
547 } 547 }
548 } 548 }
549 549
550 OmniboxViewWin::~OmniboxViewWin() { 550 OmniboxViewWin::~OmniboxViewWin() {
551 // Explicitly release the text object model now that we're done with it, and 551 // Explicitly release the text object model now that we're done with it, and
552 // before we free the library. If the library gets unloaded before this 552 // before we free the library. If the library gets unloaded before this
553 // released, it becomes garbage. Note that since text_object_model_ is lazy 553 // released, it becomes garbage. Note that since text_object_model_ is lazy
554 // initialized, it may still be null. 554 // initialized, it may still be null.
555 if (text_object_model_) 555 if (text_object_model_)
556 text_object_model_->Release(); 556 text_object_model_->Release();
557 557
558 if (tsf_event_router_) 558 if (tsf_event_router_)
559 tsf_event_router_->SetManager(NULL, NULL); 559 tsf_event_router_->SetManager(NULL);
Peter Kasting 2012/10/26 01:53:47 Is this necessary? Can't we just let the TsfEvent
Seigo Nonaka 2012/10/26 02:23:10 Yes! done. On 2012/10/26 01:53:47, Peter Kasting
560 560
561 // We balance our reference count and unpatch when the last instance has 561 // We balance our reference count and unpatch when the last instance has
562 // been destroyed. This prevents us from relying on the AtExit or static 562 // been destroyed. This prevents us from relying on the AtExit or static
563 // destructor sequence to do our unpatching, which is generally fragile. 563 // destructor sequence to do our unpatching, which is generally fragile.
564 g_paint_patcher.Pointer()->DerefPatch(); 564 g_paint_patcher.Pointer()->DerefPatch();
565 } 565 }
566 566
567 views::View* OmniboxViewWin::parent_view() const { 567 views::View* OmniboxViewWin::parent_view() const {
568 return parent_view_; 568 return parent_view_;
569 } 569 }
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 // 1619 //
1620 // Crazy hack: If we just do PlaceCaretAt(0), and the beginning of the text is 1620 // Crazy hack: If we just do PlaceCaretAt(0), and the beginning of the text is
1621 // currently scrolled out of view, we can wind up with a blinking cursor in 1621 // currently scrolled out of view, we can wind up with a blinking cursor in
1622 // the toolbar at the current X coordinate of the beginning of the text. By 1622 // the toolbar at the current X coordinate of the beginning of the text. By
1623 // first doing a reverse-select-all to scroll the beginning of the text into 1623 // first doing a reverse-select-all to scroll the beginning of the text into
1624 // view, we work around this CRichEditCtrl bug. 1624 // view, we work around this CRichEditCtrl bug.
1625 SelectAll(true); 1625 SelectAll(true);
1626 PlaceCaretAt(0); 1626 PlaceCaretAt(0);
1627 1627
1628 if (tsf_event_router_) 1628 if (tsf_event_router_)
1629 tsf_event_router_->SetManager(NULL, NULL); 1629 tsf_event_router_->SetManager(NULL);
1630 } 1630 }
1631 1631
1632 void OmniboxViewWin::OnLButtonDblClk(UINT keys, const CPoint& point) { 1632 void OmniboxViewWin::OnLButtonDblClk(UINT keys, const CPoint& point) {
1633 // Save the double click info for later triple-click detection. 1633 // Save the double click info for later triple-click detection.
1634 tracking_double_click_ = true; 1634 tracking_double_click_ = true;
1635 double_click_point_ = point; 1635 double_click_point_ = point;
1636 double_click_time_ = GetCurrentMessage()->time; 1636 double_click_time_ = GetCurrentMessage()->time;
1637 possible_drag_ = false; 1637 possible_drag_ = false;
1638 1638
1639 // Modifying the selection counts as accepting any inline autocompletion, so 1639 // Modifying the selection counts as accepting any inline autocompletion, so
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 saved_selection_for_focus_change_.cpMin = -1; 1954 saved_selection_for_focus_change_.cpMin = -1;
1955 } 1955 }
1956 1956
1957 if (!tsf_event_router_) { 1957 if (!tsf_event_router_) {
1958 SetMsgHandled(false); 1958 SetMsgHandled(false);
1959 } else { 1959 } else {
1960 DefWindowProc(); 1960 DefWindowProc();
1961 // Document manager created by RichEdit can be obtained only after 1961 // Document manager created by RichEdit can be obtained only after
1962 // WM_SETFOCUS event is handled. 1962 // WM_SETFOCUS event is handled.
1963 tsf_event_router_->SetManager( 1963 tsf_event_router_->SetManager(
1964 ui::TsfBridge::GetInstance()->GetThreadManager(), 1964 ui::TsfBridge::GetInstance()->GetThreadManager());
1965 this);
1966 SetMsgHandled(true); 1965 SetMsgHandled(true);
1967 } 1966 }
1968 } 1967 }
1969 1968
1970 LRESULT OmniboxViewWin::OnSetText(const wchar_t* text) { 1969 LRESULT OmniboxViewWin::OnSetText(const wchar_t* text) {
1971 // Ignore all IME messages while we process this WM_SETTEXT message. 1970 // Ignore all IME messages while we process this WM_SETTEXT message.
1972 // When SetWindowText() is called while an IME is composing text, the IME 1971 // When SetWindowText() is called while an IME is composing text, the IME
1973 // calls SendMessage() to send a WM_IME_COMPOSITION message. When we receive 1972 // calls SendMessage() to send a WM_IME_COMPOSITION message. When we receive
1974 // this WM_IME_COMPOSITION message, we update the omnibox and may call 1973 // this WM_IME_COMPOSITION message, we update the omnibox and may call
1975 // SetWindowText() again. To stop this recursive message-handler call, we 1974 // SetWindowText() again. To stop this recursive message-handler call, we
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2756 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2758 } 2757 }
2759 2758
2760 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2759 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2761 // Use font_.GetStringWidth() instead of 2760 // Use font_.GetStringWidth() instead of
2762 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2761 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2763 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2762 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2764 // PosFromChar(i) might return 0 when i is greater than 1. 2763 // PosFromChar(i) might return 0 when i is greater than 1.
2765 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2764 return font_.GetStringWidth(text) + GetHorizontalMargin();
2766 } 2765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698