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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 FileUploadControlPainter(*this).paintObject(paintInfo, paintOffset); | 87 FileUploadControlPainter(*this).paintObject(paintInfo, paintOffset); |
88 } | 88 } |
89 | 89 |
90 void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogic
alWidth, LayoutUnit& maxLogicalWidth) const | 90 void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogic
alWidth, LayoutUnit& maxLogicalWidth) const |
91 { | 91 { |
92 // Figure out how big the filename space needs to be for a given number of c
haracters | 92 // Figure out how big the filename space needs to be for a given number of c
haracters |
93 // (using "0" as the nominal character). | 93 // (using "0" as the nominal character). |
94 const UChar character = '0'; | 94 const UChar character = '0'; |
95 const String characterAsString = String(&character, 1); | 95 const String characterAsString = String(&character, 1); |
96 const Font& font = style()->font(); | 96 const Font& font = style()->font(); |
97 // FIXME: Remove the need for this const_cast by making constructTextRun tak
e a const RenderObject*. | 97 // FIXME: Remove the need for this const_cast by making constructTextRun tak
e a const LayoutObject*. |
98 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi
s); | 98 RenderFileUploadControl* renderer = const_cast<RenderFileUploadControl*>(thi
s); |
99 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText
Run(renderer, font, characterAsString, styleRef(), TextRun::AllowTrailingExpansi
on)); | 99 float minDefaultLabelWidth = defaultWidthNumChars * font.width(constructText
Run(renderer, font, characterAsString, styleRef(), TextRun::AllowTrailingExpansi
on)); |
100 | 100 |
101 const String label = toHTMLInputElement(node())->locale().queryString(WebLoc
alizedString::FileButtonNoFileSelectedLabel); | 101 const String label = toHTMLInputElement(node())->locale().queryString(WebLoc
alizedString::FileButtonNoFileSelectedLabel); |
102 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label,
styleRef(), TextRun::AllowTrailingExpansion)); | 102 float defaultLabelWidth = font.width(constructTextRun(renderer, font, label,
styleRef(), TextRun::AllowTrailingExpansion)); |
103 if (HTMLInputElement* button = uploadButton()) | 103 if (HTMLInputElement* button = uploadButton()) |
104 if (RenderObject* buttonRenderer = button->renderer()) | 104 if (LayoutObject* buttonRenderer = button->renderer()) |
105 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af
terButtonSpacing; | 105 defaultLabelWidth += buttonRenderer->maxPreferredLogicalWidth() + af
terButtonSpacing; |
106 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa
ultLabelWidth))); | 106 maxLogicalWidth = static_cast<int>(ceilf(std::max(minDefaultLabelWidth, defa
ultLabelWidth))); |
107 | 107 |
108 if (!style()->width().isPercent()) | 108 if (!style()->width().isPercent()) |
109 minLogicalWidth = maxLogicalWidth; | 109 minLogicalWidth = maxLogicalWidth; |
110 } | 110 } |
111 | 111 |
112 void RenderFileUploadControl::computePreferredLogicalWidths() | 112 void RenderFileUploadControl::computePreferredLogicalWidths() |
113 { | 113 { |
114 ASSERT(preferredLogicalWidthsDirty()); | 114 ASSERT(preferredLogicalWidthsDirty()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 String RenderFileUploadControl::fileTextValue() const | 163 String RenderFileUploadControl::fileTextValue() const |
164 { | 164 { |
165 HTMLInputElement* input = toHTMLInputElement(node()); | 165 HTMLInputElement* input = toHTMLInputElement(node()); |
166 ASSERT(input->files()); | 166 ASSERT(input->files()); |
167 return LayoutTheme::theme().fileListNameForWidth(input->locale(), input->fil
es(), style()->font(), maxFilenameWidth()); | 167 return LayoutTheme::theme().fileListNameForWidth(input->locale(), input->fil
es(), style()->font(), maxFilenameWidth()); |
168 } | 168 } |
169 | 169 |
170 } // namespace blink | 170 } // namespace blink |
OLD | NEW |