Make uploading work with the new file upload control.
* css/html4.css: Remove unnecessary style (this is already done in
RenderFileUpload.cpp)
* html/HTMLInputElement.cpp: Don't get the button text from the value
attribute for file controls.
(WebCore::HTMLInputElement::valueWithDefault):
* platform/mac/FileChooserMac.mm: Call
RenderFileUploadControl::valueChanged when the user selects a file.
(WebCore::FileChooser::chooseFile):
* rendering/RenderFileUploadControl.cpp: Add valueChanged() method to
update the form and fire the onChange event.
(WebCore::RenderFileUploadControl::valueChanged):
(WebCore::RenderFileUploadControl::updateFromElement):
* rendering/RenderFileUploadControl.h: Add valueChanged() declaration.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16326
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-12 Adam Roben <aroben@apple.com>
+
+ Reviewed by adele.
+
+ Make uploading work with the new file upload control.
+
+ * css/html4.css: Remove unnecessary style (this is already done in
+ RenderFileUpload.cpp)
+ * html/HTMLInputElement.cpp: Don't get the button text from the value
+ attribute for file controls.
+ (WebCore::HTMLInputElement::valueWithDefault):
+ * platform/mac/FileChooserMac.mm: Call
+ RenderFileUploadControl::valueChanged when the user selects a file.
+ (WebCore::FileChooser::chooseFile):
+ * rendering/RenderFileUploadControl.cpp: Add valueChanged() method to
+ update the form and fire the onChange event.
+ (WebCore::RenderFileUploadControl::valueChanged):
+ (WebCore::RenderFileUploadControl::updateFromElement):
+ * rendering/RenderFileUploadControl.h: Add valueChanged() declaration.
+
2006-09-12 Adam Roben <aroben@apple.com>
Adding rules to html4.css to style the button in file upload controls.
-webkit-box-align: baseline;
}
-input[type="file"]::-webkit-file-upload-button {
- display: -webkit-box;
-}
-
input:-webkit-autofill {
background-color: #FAFFBD !important;
background-image:none !important;
switch (inputType()) {
case BUTTON:
case CHECKBOX:
+ case FILE:
case HIDDEN:
case IMAGE:
case ISINDEX:
case SEARCH:
case TEXT:
break;
- case FILE:
- v = fileButtonChooseFileLabel();
- break;
case RESET:
v = resetButtonDefaultLabel();
break;
void FileChooser::chooseFile(const String& filename)
{
+ if (m_filename == filename)
+ return;
+
m_filename = filename;
// Need unsigned 0 here to disambiguate String::operator[] from operator(NSString*, int)[]
else
m_icon.set(Icon::newIconForFile(m_filename).release());
- uploadControl()->updateIconAndFilename();
+ uploadControl()->valueChanged();
}
}
setReplaced(isInline());
}
+void RenderFileUploadControl::valueChanged()
+{
+ static_cast<HTMLInputElement*>(node())->setValueFromRenderer(m_fileChooser->filename());
+ static_cast<HTMLInputElement*>(node())->onChange();
+ updateIconAndFilename();
+}
+
void RenderFileUploadControl::updateIconAndFilename()
{
if (m_fileChooser->icon())
RenderStyle* buttonStyle = createButtonStyle(style());
m_button->setRenderer(m_button->createRenderer(renderArena(), buttonStyle));
m_button->renderer()->setStyle(buttonStyle);
+ static_cast<RenderButton*>(m_button->renderer())->setText(fileButtonChooseFileLabel());
m_button->setAttached();
m_button->setInDocument(true);
addChild(m_fileBox);
}
- HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
- RenderButton* buttonRenderer = static_cast<RenderButton*>(m_button->renderer());
- buttonRenderer->setText(input->valueWithDefault());
-
updateIconAndFilename();
}
virtual void click(bool sendMouseEvents);
+ void valueChanged();
void updateIconAndFilename();
virtual const char* renderName() const { return "RenderFileUploadControl"; }