| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 int cap_height = font_.GetBaseline() - tm.tmInternalLeading; | 499 int cap_height = font_.GetBaseline() - tm.tmInternalLeading; |
| 500 // The ratio of a font's x-height to its cap height. Sadly, Windows | 500 // The ratio of a font's x-height to its cap height. Sadly, Windows |
| 501 // doesn't provide a true value for a font's x-height in its text | 501 // doesn't provide a true value for a font's x-height in its text |
| 502 // metrics, so we approximate. | 502 // metrics, so we approximate. |
| 503 const float kXHeightRatio = 0.7f; | 503 const float kXHeightRatio = 0.7f; |
| 504 font_x_height_ = static_cast<int>( | 504 font_x_height_ = static_cast<int>( |
| 505 (static_cast<float>(cap_height) * kXHeightRatio) + 0.5); | 505 (static_cast<float>(cap_height) * kXHeightRatio) + 0.5); |
| 506 | 506 |
| 507 // We set font_y_adjustment_ so that the ascender of the font gets | 507 // We set font_y_adjustment_ so that the ascender of the font gets |
| 508 // centered on the available height of the view. | 508 // centered on the available height of the view. |
| 509 font_y_adjustment_ = (parent_view->GetHeight() - cap_height) / 2 - | 509 font_y_adjustment_ = |
| 510 (parent_view->GetInternalHeight(true) - cap_height) / 2 - |
| 510 tm.tmInternalLeading; | 511 tm.tmInternalLeading; |
| 511 | 512 |
| 512 // Get the number of twips per pixel, which we need below to offset our text | 513 // Get the number of twips per pixel, which we need below to offset our text |
| 513 // by the desired number of pixels. | 514 // by the desired number of pixels. |
| 514 const long kTwipsPerPixel = kTwipsPerInch / GetDeviceCaps(hdc, LOGPIXELSY); | 515 const long kTwipsPerPixel = kTwipsPerInch / GetDeviceCaps(hdc, LOGPIXELSY); |
| 515 // It's unsafe to delete a DC with a non-stock object selected, so restore the | 516 // It's unsafe to delete a DC with a non-stock object selected, so restore the |
| 516 // original font. | 517 // original font. |
| 517 SelectObject(hdc, old_font); | 518 SelectObject(hdc, old_font); |
| 518 ::ReleaseDC(NULL, hdc); | 519 ::ReleaseDC(NULL, hdc); |
| 519 | 520 |
| (...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 bool popup_window_mode, | 2693 bool popup_window_mode, |
| 2693 LocationBarView* location_bar) { | 2694 LocationBarView* location_bar) { |
| 2694 return new OmniboxViewWin(controller, | 2695 return new OmniboxViewWin(controller, |
| 2695 toolbar_model, | 2696 toolbar_model, |
| 2696 location_bar, | 2697 location_bar, |
| 2697 command_updater, | 2698 command_updater, |
| 2698 popup_window_mode, | 2699 popup_window_mode, |
| 2699 location_bar); | 2700 location_bar); |
| 2700 } | 2701 } |
| 2701 #endif | 2702 #endif |
| OLD | NEW |