OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 { | 148 { |
149 // Figure out how big the filename space needs to be for a given number of c
haracters | 149 // Figure out how big the filename space needs to be for a given number of c
haracters |
150 // (using "0" as the nominal character). | 150 // (using "0" as the nominal character). |
151 const UChar character = '0'; | 151 const UChar character = '0'; |
152 const String characterAsString = String(&character, 1); | 152 const String characterAsString = String(&character, 1); |
153 const Font& font = style()->font(); | 153 const Font& font = style()->font(); |
154 // FIXME: Remove the need for this const_cast by making constructTextRun tak
e a const RenderObject*. | 154 // FIXME: Remove the need for this const_cast by making constructTextRun tak
e a const RenderObject*. |
155 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi
s); | 155 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi
s); |
156 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText
Run(renderer, font, characterAsString, style(), TextRun::AllowTrailingExpansion)
); | 156 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText
Run(renderer, font, characterAsString, style(), TextRun::AllowTrailingExpansion)
); |
157 | 157 |
158 const String label = toHTMLInputElement(node())->locale().queryString(blink:
:WebLocalizedString::FileButtonNoFileSelectedLabel); | 158 const String label = toHTMLInputElement(node())->locale().queryString(WebLoc
alizedString::FileButtonNoFileSelectedLabel); |
159 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label,
style(), TextRun::AllowTrailingExpansion)); | 159 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label,
style(), TextRun::AllowTrailingExpansion)); |
160 if (HTMLInputElement* button = uploadButton()) | 160 if (HTMLInputElement* button = uploadButton()) |
161 if (RenderObject* buttonRenderer = button->renderer()) | 161 if (RenderObject* buttonRenderer = button->renderer()) |
162 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af
terButtonSpacing; | 162 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af
terButtonSpacing; |
163 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa
ultLabelWidth))); | 163 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa
ultLabelWidth))); |
164 | 164 |
165 if (!style()->width().isPercent()) | 165 if (!style()->width().isPercent()) |
166 minLogicalWidth = maxLogicalWidth; | 166 minLogicalWidth = maxLogicalWidth; |
167 } | 167 } |
168 | 168 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 218 } |
219 | 219 |
220 String RenderFileUploadControl::fileTextValue() const | 220 String RenderFileUploadControl::fileTextValue() const |
221 { | 221 { |
222 HTMLInputElement* input = toHTMLInputElement(node()); | 222 HTMLInputElement* input = toHTMLInputElement(node()); |
223 ASSERT(input->files()); | 223 ASSERT(input->files()); |
224 return RenderTheme::theme().fileListNameForWidth(input->locale(), input->fil
es(), style()->font(), maxFilenameWidth()); | 224 return RenderTheme::theme().fileListNameForWidth(input->locale(), input->fil
es(), style()->font(), maxFilenameWidth()); |
225 } | 225 } |
226 | 226 |
227 } // namespace blink | 227 } // namespace blink |
OLD | NEW |