Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/text_field.h" | 5 #include "chrome/views/text_field.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlapp.h> | 8 #include <atlapp.h> |
| 9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
| 10 #include <atlctrls.h> | 10 #include <atlctrls.h> |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 bool is_triple_click) const { | 812 bool is_triple_click) const { |
| 813 // Clip the X coordinate to the left edge of the text. Careful: | 813 // Clip the X coordinate to the left edge of the text. Careful: |
| 814 // PosFromChar(0) may return a negative X coordinate if the beginning of the | 814 // PosFromChar(0) may return a negative X coordinate if the beginning of the |
| 815 // text has scrolled off the edit, so don't go past the clip rect's edge. | 815 // text has scrolled off the edit, so don't go past the clip rect's edge. |
| 816 RECT r; | 816 RECT r; |
| 817 GetRect(&r); | 817 GetRect(&r); |
| 818 const int left_bound = std::max(r.left, PosFromChar(0).x); | 818 const int left_bound = std::max(r.left, PosFromChar(0).x); |
| 819 if (x < left_bound) | 819 if (x < left_bound) |
| 820 return left_bound; | 820 return left_bound; |
| 821 | 821 |
| 822 // See if we need to clip to the right edge of the text. | |
| 823 const int length = GetTextLength(); | |
| 824 // Asking for the coordinate of any character past the end of the text gets | 822 // Asking for the coordinate of any character past the end of the text gets |
| 825 // the pixel just to the right of the last character. | 823 // the pixel just to the right of the last character. |
| 826 const int right_bound = std::min(r.right, PosFromChar(length).x); | 824 const int right_bound = std::min(r.right, PosFromChar(x).x); |
|
Peter Kasting
2008/12/01 00:28:28
The old code is definitely wrong for multiline tex
| |
| 827 if ((length == 0) || (x < right_bound)) | 825 if ((x == 0) || (x < right_bound)) |
| 828 return x; | 826 return x; |
| 829 | 827 |
| 830 // For trailing characters that are 2 pixels wide of less (like "l" in some | 828 // For trailing characters that are 2 pixels wide of less (like "l" in some |
| 831 // fonts), we have a problem: | 829 // fonts), we have a problem: |
| 832 // * Clicks on any pixel within the character will place the cursor before | 830 // * Clicks on any pixel within the character will place the cursor before |
| 833 // the character. | 831 // the character. |
| 834 // * Clicks on the pixel just after the character will not allow triple- | 832 // * Clicks on the pixel just after the character will not allow triple- |
| 835 // click to work properly (true for any last character width). | 833 // click to work properly (true for any last character width). |
| 836 // So, we move to the last pixel of the character when this is a | 834 // So, we move to the last pixel of the character when this is a |
| 837 // triple-click, and moving to one past the last pixel in all other | 835 // triple-click, and moving to one past the last pixel in all other |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1079 | 1077 |
| 1080 COLORREF bg_color; | 1078 COLORREF bg_color; |
| 1081 if (!use_default_background_color_) | 1079 if (!use_default_background_color_) |
| 1082 bg_color = gfx::SkColorToCOLORREF(background_color_); | 1080 bg_color = gfx::SkColorToCOLORREF(background_color_); |
| 1083 else | 1081 else |
| 1084 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); | 1082 bg_color = GetSysColor(read_only_ ? COLOR_3DFACE : COLOR_WINDOW); |
| 1085 edit_->SetBackgroundColor(bg_color); | 1083 edit_->SetBackgroundColor(bg_color); |
| 1086 } | 1084 } |
| 1087 | 1085 |
| 1088 } // namespace views | 1086 } // namespace views |
| OLD | NEW |