| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Determine where the filename should be placed | 124 // Determine where the filename should be placed |
| 125 LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); | 125 LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); |
| 126 HTMLInputElement* button = uploadButton(); | 126 HTMLInputElement* button = uploadButton(); |
| 127 if (!button) | 127 if (!button) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); | 130 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
| 131 LayoutUnit buttonWidth = nodeWidth(button); | 131 LayoutUnit buttonWidth = nodeWidth(button); |
| 132 LayoutUnit buttonAndIconWidth = buttonWidth + afterButtonSpacing | 132 LayoutUnit buttonAndIconWidth = buttonWidth + afterButtonSpacing |
| 133 + (input->icon() ? iconWidth + iconFilenameSpacing : 0); | 133 + (input->icon() ? iconWidth + iconFilenameSpacing : 0); |
| 134 float textWidth = font.width(textRun); |
| 134 LayoutUnit textX; | 135 LayoutUnit textX; |
| 135 if (style()->isLeftToRightDirection()) | 136 if (style()->isLeftToRightDirection()) |
| 136 textX = contentLeft + buttonAndIconWidth; | 137 textX = contentLeft + buttonAndIconWidth; |
| 137 else | 138 else |
| 138 textX = contentLeft + contentWidth() - buttonAndIconWidth - font.wid
th(textRun); | 139 textX = contentLeft + contentWidth() - buttonAndIconWidth - textWidt
h; |
| 139 | 140 |
| 140 LayoutUnit textY = 0; | 141 LayoutUnit textY = 0; |
| 141 // We want to match the button's baseline | 142 // We want to match the button's baseline |
| 142 // FIXME: Make this work with transforms. | 143 // FIXME: Make this work with transforms. |
| 143 if (RenderButton* buttonRenderer = toRenderButton(button->renderer())) | 144 if (RenderButton* buttonRenderer = toRenderButton(button->renderer())) |
| 144 textY = paintOffset.y() + borderTop() + paddingTop() + buttonRendere
r->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContaini
ngLine); | 145 textY = paintOffset.y() + borderTop() + paddingTop() + buttonRendere
r->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContaini
ngLine); |
| 145 else | 146 else |
| 146 textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, P
ositionOnContainingLine); | 147 textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, P
ositionOnContainingLine); |
| 148 TextRunPaintInfo textRunPaintInfo(textRun); |
| 149 textRunPaintInfo.bounds = FloatRect(textX, |
| 150 textY - style()->fontMetrics().ascen
t(), |
| 151 textWidth, |
| 152 style()->fontMetrics().height()); |
| 147 | 153 |
| 148 paintInfo.context->setFillColor(style()->visitedDependentColor(CSSProper
tyColor), style()->colorSpace()); | 154 paintInfo.context->setFillColor(style()->visitedDependentColor(CSSProper
tyColor), style()->colorSpace()); |
| 149 | 155 |
| 150 // Draw the filename | 156 // Draw the filename |
| 151 paintInfo.context->drawBidiText(font, textRun, IntPoint(roundToInt(textX
), roundToInt(textY))); | 157 paintInfo.context->drawBidiText(font, textRunPaintInfo, IntPoint(roundTo
Int(textX), roundToInt(textY))); |
| 152 | 158 |
| 153 if (input->icon()) { | 159 if (input->icon()) { |
| 154 // Determine where the icon should be placed | 160 // Determine where the icon should be placed |
| 155 LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (c
ontentHeight() - iconHeight) / 2; | 161 LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (c
ontentHeight() - iconHeight) / 2; |
| 156 LayoutUnit iconX; | 162 LayoutUnit iconX; |
| 157 if (style()->isLeftToRightDirection()) | 163 if (style()->isLeftToRightDirection()) |
| 158 iconX = contentLeft + buttonWidth + afterButtonSpacing; | 164 iconX = contentLeft + buttonWidth + afterButtonSpacing; |
| 159 else | 165 else |
| 160 iconX = contentLeft + contentWidth() - buttonWidth - afterButton
Spacing - iconWidth; | 166 iconX = contentLeft + contentWidth() - buttonWidth - afterButton
Spacing - iconWidth; |
| 161 | 167 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 249 } |
| 244 | 250 |
| 245 String RenderFileUploadControl::fileTextValue() const | 251 String RenderFileUploadControl::fileTextValue() const |
| 246 { | 252 { |
| 247 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); | 253 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
| 248 ASSERT(input->files()); | 254 ASSERT(input->files()); |
| 249 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); | 255 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); |
| 250 } | 256 } |
| 251 | 257 |
| 252 } // namespace WebCore | 258 } // namespace WebCore |
| OLD | NEW |