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

Side by Side Diff: ui/gfx/text_elider.cc

Issue 681123006: Fix a 'type-limits' warning in StringSlicer::FindValidBoundaryAfter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file implements utility functions for eliding and formatting UI text. 5 // This file implements utility functions for eliding and formatting UI text.
6 // 6 //
7 // Note that several of the functions declared in text_elider.h are implemented 7 // Note that several of the functions declared in text_elider.h are implemented
8 // in this file using helper classes in an unnamed namespace. 8 // in this file using helper classes in an unnamed namespace.
9 9
10 #include "ui/gfx/text_elider.h" 10 #include "ui/gfx/text_elider.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 size_t StringSlicer::FindValidBoundaryBefore(size_t index) const { 140 size_t StringSlicer::FindValidBoundaryBefore(size_t index) const {
141 DCHECK_LE(index, text_.length()); 141 DCHECK_LE(index, text_.length());
142 if (index != text_.length()) 142 if (index != text_.length())
143 U16_SET_CP_START(text_.data(), 0, index); 143 U16_SET_CP_START(text_.data(), 0, index);
144 return index; 144 return index;
145 } 145 }
146 146
147 size_t StringSlicer::FindValidBoundaryAfter(size_t index) const { 147 size_t StringSlicer::FindValidBoundaryAfter(size_t index) const {
148 #if defined(__GNUC__)
149 #pragma GCC diagnostic push
150 #pragma GCC diagnostic ignored "-Wtype-limits"
151 #endif
Peter Kasting 2014/10/29 17:08:00 Definitely don't fix the warning this way -- the r
148 DCHECK_LE(index, text_.length()); 152 DCHECK_LE(index, text_.length());
149 if (index != text_.length()) 153 if (index != text_.length())
150 U16_SET_CP_LIMIT(text_.data(), 0, index, text_.length()); 154 U16_SET_CP_LIMIT(text_.data(), 0, index, text_.length());
151 return index; 155 return index;
156 #if defined(__GCC__)
157 #pragma GCC diagnostic pop
158 #endif
152 } 159 }
153 160
154 base::string16 ElideFilename(const base::FilePath& filename, 161 base::string16 ElideFilename(const base::FilePath& filename,
155 const FontList& font_list, 162 const FontList& font_list,
156 float available_pixel_width) { 163 float available_pixel_width) {
157 #if defined(OS_WIN) 164 #if defined(OS_WIN)
158 base::string16 filename_utf16 = filename.value(); 165 base::string16 filename_utf16 = filename.value();
159 base::string16 extension = filename.Extension(); 166 base::string16 extension = filename.Extension();
160 base::string16 rootname = filename.BaseName().RemoveExtension().value(); 167 base::string16 rootname = filename.BaseName().RemoveExtension().value();
161 #elif defined(OS_POSIX) 168 #elif defined(OS_POSIX)
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 index = char_iterator.getIndex(); 824 index = char_iterator.getIndex();
818 } else { 825 } else {
819 // String has leading whitespace, return the elide string. 826 // String has leading whitespace, return the elide string.
820 return kElideString; 827 return kElideString;
821 } 828 }
822 829
823 return string.substr(0, index) + kElideString; 830 return string.substr(0, index) + kElideString;
824 } 831 }
825 832
826 } // namespace gfx 833 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698