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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 HTMLInputElement* input = toHTMLInputElement(node()); | 91 HTMLInputElement* input = toHTMLInputElement(node()); |
92 return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton(
)) - afterButtonSpacing); | 92 return max(0, contentBoxRect().pixelSnappedWidth() - nodeWidth(uploadButton(
)) - afterButtonSpacing); |
93 } | 93 } |
94 | 94 |
95 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) | 95 void RenderFileUploadControl::paintObject(PaintInfo& paintInfo, const LayoutPoin
t& paintOffset) |
96 { | 96 { |
97 if (style()->visibility() != VISIBLE) | 97 if (style()->visibility() != VISIBLE) |
98 return; | 98 return; |
99 | 99 |
100 // Push a clip. | 100 // Push a clip. |
101 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 101 GraphicsContextStateSaver stateSaver(*(paintInfo.getContext()), false); |
102 if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhase
ChildBlockBackgrounds) { | 102 if (paintInfo.getPhase() == PaintPhaseForeground || paintInfo.getPhase() ==
PaintPhaseChildBlockBackgrounds) { |
103 IntRect clipRect = enclosingIntRect(LayoutRect(paintOffset.x() + borderL
eft(), paintOffset.y() + borderTop(), | 103 IntRect clipRect = enclosingIntRect(LayoutRect(paintOffset.x() + borderL
eft(), paintOffset.y() + borderTop(), |
104 width() - borderLeft() - borderRight(), height() - bord
erBottom() - borderTop() + buttonShadowHeight)); | 104 width() - borderLeft() - borderRight(), height() - bord
erBottom() - borderTop() + buttonShadowHeight)); |
105 if (clipRect.isEmpty()) | 105 if (clipRect.isEmpty()) |
106 return; | 106 return; |
107 stateSaver.save(); | 107 stateSaver.save(); |
108 paintInfo.context->clip(clipRect); | 108 paintInfo.getContext()->clip(clipRect); |
109 } | 109 } |
110 | 110 |
111 if (paintInfo.phase == PaintPhaseForeground) { | 111 if (paintInfo.getPhase() == PaintPhaseForeground) { |
112 const String& displayedFilename = fileTextValue(); | 112 const String& displayedFilename = fileTextValue(); |
113 const Font& font = style()->font(); | 113 const Font& font = style()->font(); |
114 TextRun textRun = constructTextRun(this, font, displayedFilename, style(
), TextRun::AllowTrailingExpansion, RespectDirection | RespectDirectionOverride)
; | 114 TextRun textRun = constructTextRun(this, font, displayedFilename, style(
), TextRun::AllowTrailingExpansion, RespectDirection | RespectDirectionOverride)
; |
115 textRun.disableRoundingHacks(); | 115 textRun.disableRoundingHacks(); |
116 | 116 |
117 // Determine where the filename should be placed | 117 // Determine where the filename should be placed |
118 LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); | 118 LayoutUnit contentLeft = paintOffset.x() + borderLeft() + paddingLeft(); |
119 HTMLInputElement* button = uploadButton(); | 119 HTMLInputElement* button = uploadButton(); |
120 if (!button) | 120 if (!button) |
121 return; | 121 return; |
(...skipping 14 matching lines...) Expand all Loading... |
136 if (RenderButton* buttonRenderer = toRenderButton(button->renderer())) | 136 if (RenderButton* buttonRenderer = toRenderButton(button->renderer())) |
137 textY = paintOffset.y() + borderTop() + paddingTop() + buttonRendere
r->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContaini
ngLine); | 137 textY = paintOffset.y() + borderTop() + paddingTop() + buttonRendere
r->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContaini
ngLine); |
138 else | 138 else |
139 textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, P
ositionOnContainingLine); | 139 textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, P
ositionOnContainingLine); |
140 TextRunPaintInfo textRunPaintInfo(textRun); | 140 TextRunPaintInfo textRunPaintInfo(textRun); |
141 textRunPaintInfo.bounds = FloatRect(textX, | 141 textRunPaintInfo.bounds = FloatRect(textX, |
142 textY - style()->fontMetrics().ascen
t(), | 142 textY - style()->fontMetrics().ascen
t(), |
143 textWidth, | 143 textWidth, |
144 style()->fontMetrics().height()); | 144 style()->fontMetrics().height()); |
145 | 145 |
146 paintInfo.context->setFillColor(resolveColor(CSSPropertyColor)); | 146 paintInfo.getContext()->setFillColor(resolveColor(CSSPropertyColor)); |
147 | 147 |
148 // Draw the filename | 148 // Draw the filename |
149 paintInfo.context->drawBidiText(font, textRunPaintInfo, IntPoint(roundTo
Int(textX), roundToInt(textY))); | 149 paintInfo.getContext()->drawBidiText(font, textRunPaintInfo, IntPoint(ro
undToInt(textX), roundToInt(textY))); |
150 } | 150 } |
151 | 151 |
152 // Paint the children. | 152 // Paint the children. |
153 RenderBlock::paintObject(paintInfo, paintOffset); | 153 RenderBlock::paintObject(paintInfo, paintOffset); |
154 } | 154 } |
155 | 155 |
156 void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogic
alWidth, LayoutUnit& maxLogicalWidth) const | 156 void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogic
alWidth, LayoutUnit& maxLogicalWidth) const |
157 { | 157 { |
158 // Figure out how big the filename space needs to be for a given number of c
haracters | 158 // Figure out how big the filename space needs to be for a given number of c
haracters |
159 // (using "0" as the nominal character). | 159 // (using "0" as the nominal character). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 | 229 |
230 String RenderFileUploadControl::fileTextValue() const | 230 String RenderFileUploadControl::fileTextValue() const |
231 { | 231 { |
232 HTMLInputElement* input = toHTMLInputElement(node()); | 232 HTMLInputElement* input = toHTMLInputElement(node()); |
233 ASSERT(input->files()); | 233 ASSERT(input->files()); |
234 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); | 234 return theme()->fileListNameForWidth(input->files(), style()->font(), maxFil
enameWidth(), input->multiple()); |
235 } | 235 } |
236 | 236 |
237 } // namespace WebCore | 237 } // namespace WebCore |
OLD | NEW |