| 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 FloatRect textRect(textX, textY - style()->fontMetrics().ascent(), |
| 149 textWidth, style()->fontMetrics().height()); |
| 147 | 150 |
| 148 paintInfo.context->setFillColor(style()->visitedDependentColor(CSSProper
tyColor), style()->colorSpace()); | 151 paintInfo.context->setFillColor(style()->visitedDependentColor(CSSProper
tyColor), style()->colorSpace()); |
| 149 | 152 |
| 150 // Draw the filename | 153 // Draw the filename |
| 151 paintInfo.context->drawBidiText(font, textRun, IntPoint(roundToInt(textX
), roundToInt(textY))); | 154 paintInfo.context->drawBidiText(font, textRun, IntPoint(roundToInt(textX
), roundToInt(textY)), textRect); |
| 152 | 155 |
| 153 if (input->icon()) { | 156 if (input->icon()) { |
| 154 // Determine where the icon should be placed | 157 // Determine where the icon should be placed |
| 155 LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (c
ontentHeight() - iconHeight) / 2; | 158 LayoutUnit iconY = paintOffset.y() + borderTop() + paddingTop() + (c
ontentHeight() - iconHeight) / 2; |
| 156 LayoutUnit iconX; | 159 LayoutUnit iconX; |
| 157 if (style()->isLeftToRightDirection()) | 160 if (style()->isLeftToRightDirection()) |
| 158 iconX = contentLeft + buttonWidth + afterButtonSpacing; | 161 iconX = contentLeft + buttonWidth + afterButtonSpacing; |
| 159 else | 162 else |
| 160 iconX = contentLeft + contentWidth() - buttonWidth - afterButton
Spacing - iconWidth; | 163 iconX = contentLeft + contentWidth() - buttonWidth - afterButton
Spacing - iconWidth; |
| 161 | 164 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 246 } |
| 244 | 247 |
| 245 String RenderFileUploadControl::fileTextValue() const | 248 String RenderFileUploadControl::fileTextValue() const |
| 246 { | 249 { |
| 247 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); | 250 HTMLInputElement* input = static_cast<HTMLInputElement*>(node()); |
| 248 ASSERT(input->files()); | 251 ASSERT(input->files()); |
| 249 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); | 252 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); |
| 250 } | 253 } |
| 251 | 254 |
| 252 } // namespace WebCore | 255 } // namespace WebCore |
| OLD | NEW |