OLD | NEW |
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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // done so that we don't have to explicitly. | 522 // done so that we don't have to explicitly. |
523 if (!popup_window_mode_) { | 523 if (!popup_window_mode_) { |
524 scoped_refptr<EditDropTarget> drop_target = new EditDropTarget(this); | 524 scoped_refptr<EditDropTarget> drop_target = new EditDropTarget(this); |
525 RegisterDragDrop(m_hWnd, drop_target.get()); | 525 RegisterDragDrop(m_hWnd, drop_target.get()); |
526 } | 526 } |
527 } | 527 } |
528 | 528 |
529 OmniboxViewWin::~OmniboxViewWin() { | 529 OmniboxViewWin::~OmniboxViewWin() { |
530 // Explicitly release the text object model now that we're done with it, and | 530 // Explicitly release the text object model now that we're done with it, and |
531 // before we free the library. If the library gets unloaded before this | 531 // before we free the library. If the library gets unloaded before this |
532 // released, it becomes garbage. | 532 // released, it becomes garbage. Note that since text_object_model_ is lazy |
533 text_object_model_->Release(); | 533 // initialized, it may still be null. |
| 534 if (text_object_model_) |
| 535 text_object_model_->Release(); |
534 | 536 |
535 // We balance our reference count and unpatch when the last instance has | 537 // We balance our reference count and unpatch when the last instance has |
536 // been destroyed. This prevents us from relying on the AtExit or static | 538 // been destroyed. This prevents us from relying on the AtExit or static |
537 // destructor sequence to do our unpatching, which is generally fragile. | 539 // destructor sequence to do our unpatching, which is generally fragile. |
538 g_paint_patcher.Pointer()->DerefPatch(); | 540 g_paint_patcher.Pointer()->DerefPatch(); |
539 } | 541 } |
540 | 542 |
541 views::View* OmniboxViewWin::parent_view() const { | 543 views::View* OmniboxViewWin::parent_view() const { |
542 return parent_view_; | 544 return parent_view_; |
543 } | 545 } |
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2632 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2634 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2633 } | 2635 } |
2634 | 2636 |
2635 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2637 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2636 // Use font_.GetStringWidth() instead of | 2638 // Use font_.GetStringWidth() instead of |
2637 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2639 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2638 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2640 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
2639 // PosFromChar(i) might return 0 when i is greater than 1. | 2641 // PosFromChar(i) might return 0 when i is greater than 1. |
2640 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2642 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2641 } | 2643 } |
OLD | NEW |