~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/rendering/RenderFileUploadControl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "RenderFileUploadControl.h"
23
23
 
24
24
#include "FileList.h"
 
25
#include "Frame.h"
25
26
#include "FrameView.h"
26
27
#include "GraphicsContext.h"
27
28
#include "HTMLInputElement.h"
73
74
    m_fileChooser->disconnectClient();
74
75
}
75
76
 
76
 
void RenderFileUploadControl::styleDidChange(RenderStyle::Diff diff, const RenderStyle* oldStyle)
 
77
void RenderFileUploadControl::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
77
78
{
78
79
    RenderBlock::styleDidChange(diff, oldStyle);
79
80
    if (m_button)
84
85
 
85
86
void RenderFileUploadControl::valueChanged()
86
87
{
87
 
    // onChange may destroy this renderer
 
88
    // dispatchFormControlChangeEvent may destroy this renderer
88
89
    RefPtr<FileChooser> fileChooser = m_fileChooser;
89
90
 
90
91
    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node());
91
92
    inputElement->setFileListFromRenderer(fileChooser->filenames());
92
 
    inputElement->onChange();
 
93
    inputElement->dispatchFormControlChangeEvent();
93
94
 
94
95
    // only repaint if it doesn't seem we have been destroyed
95
96
    if (!fileChooser->disconnected())
147
148
 
148
149
int RenderFileUploadControl::maxFilenameWidth() const
149
150
{
150
 
    return max(0, contentWidth() - m_button->renderer()->width() - afterButtonSpacing
 
151
    return max(0, contentWidth() - m_button->renderBox()->width() - afterButtonSpacing
151
152
        - (m_fileChooser->icon() ? iconWidth + iconFilenameSpacing : 0));
152
153
}
153
154
 
154
155
PassRefPtr<RenderStyle> RenderFileUploadControl::createButtonStyle(const RenderStyle* parentStyle) const
155
156
{
156
 
    RefPtr<RenderStyle> style = getCachedPseudoStyle(RenderStyle::FILE_UPLOAD_BUTTON);
 
157
    RefPtr<RenderStyle> style = getCachedPseudoStyle(FILE_UPLOAD_BUTTON);
157
158
    if (!style) {
158
159
        style = RenderStyle::create();
159
160
        if (parentStyle)
190
191
        
191
192
        // Determine where the filename should be placed
192
193
        int contentLeft = tx + borderLeft() + paddingLeft();
193
 
        int buttonAndIconWidth = m_button->renderer()->width() + afterButtonSpacing
 
194
        int buttonAndIconWidth = m_button->renderBox()->width() + afterButtonSpacing
194
195
            + (m_fileChooser->icon() ? iconWidth + iconFilenameSpacing : 0);
195
196
        int textX;
196
197
        if (style()->direction() == LTR)
198
199
        else
199
200
            textX = contentLeft + contentWidth() - buttonAndIconWidth - style()->font().width(textRun);
200
201
        // We want to match the button's baseline
201
 
        RenderButton* buttonRenderer = static_cast<RenderButton*>(m_button->renderer());
 
202
        RenderButton* buttonRenderer = toRenderButton(m_button->renderer());
202
203
        int textY = buttonRenderer->absoluteBoundingBoxRect().y()
203
204
            + buttonRenderer->marginTop() + buttonRenderer->borderTop() + buttonRenderer->paddingTop()
204
205
            + buttonRenderer->baselinePosition(true, false);
205
206
 
206
 
        paintInfo.context->setFont(style()->font());
207
207
        paintInfo.context->setFillColor(style()->color());
208
208
        
209
209
        // Draw the filename
210
 
        paintInfo.context->drawBidiText(textRun, IntPoint(textX, textY));
 
210
        paintInfo.context->drawBidiText(style()->font(), textRun, IntPoint(textX, textY));
211
211
        
212
212
        if (m_fileChooser->icon()) {
213
213
            // Determine where the icon should be placed
214
214
            int iconY = ty + borderTop() + paddingTop() + (contentHeight() - iconHeight) / 2;
215
215
            int iconX;
216
216
            if (style()->direction() == LTR)
217
 
                iconX = contentLeft + m_button->renderer()->width() + afterButtonSpacing;
 
217
                iconX = contentLeft + m_button->renderBox()->width() + afterButtonSpacing;
218
218
            else
219
 
                iconX = contentLeft + contentWidth() - m_button->renderer()->width() - afterButtonSpacing - iconWidth;
 
219
                iconX = contentLeft + contentWidth() - m_button->renderBox()->width() - afterButtonSpacing - iconWidth;
220
220
 
221
221
            // Draw the file icon
222
222
            m_fileChooser->icon()->paint(paintInfo.context, IntRect(iconX, iconY, iconWidth, iconHeight));