Reviewed by adele.
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Sep 2006 20:57:09 +0000 (20:57 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Sep 2006 20:57:09 +0000 (20:57 +0000)
        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

WebCore/ChangeLog
WebCore/css/html4.css
WebCore/html/HTMLInputElement.cpp
WebCore/platform/mac/FileChooserMac.mm
WebCore/rendering/RenderFileUploadControl.cpp
WebCore/rendering/RenderFileUploadControl.h

index 922c89cfe461a741dd0658af1e8c14b12dfdb093..bbefd089f43eebd6038ce5a6112e23593d7403df 100644 (file)
@@ -1,3 +1,23 @@
+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.
index 23af00a3c350bb68f674813c2e7af8388bed9bf9..788775df1994f289e23f1813eef72863c6a93ea8 100644 (file)
@@ -345,10 +345,6 @@ input[type="file"] {
     -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;
index 9dc44650bb6e0fbd42a9a5bb759cc437bbbc5aa9..0becb203f8f30885189f31522d1237f3474a6522 100644 (file)
@@ -1065,6 +1065,7 @@ String HTMLInputElement::valueWithDefault() const
         switch (inputType()) {
             case BUTTON:
             case CHECKBOX:
+            case FILE:
             case HIDDEN:
             case IMAGE:
             case ISINDEX:
@@ -1074,9 +1075,6 @@ String HTMLInputElement::valueWithDefault() const
             case SEARCH:
             case TEXT:
                 break;
-            case FILE:
-                v = fileButtonChooseFileLabel();
-                break;
             case RESET:
                 v = resetButtonDefaultLabel();
                 break;
index c960e80a4579a9cb363d4c385b15b0565423b883..0dc5170186e7d8f22f922e6ad0212433bb232f8c 100644 (file)
@@ -126,6 +126,9 @@ void FileChooser::uploadControlDetaching()
 
 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)[]
@@ -134,7 +137,7 @@ void FileChooser::chooseFile(const String& filename)
     else
         m_icon.set(Icon::newIconForFile(m_filename).release());
     
-    uploadControl()->updateIconAndFilename();
+    uploadControl()->valueChanged();
 }
 
 }
index 98ab85953874563c7d66b8d372615a013702c5d8..bd84a89e34ff926b4efab480cebca663592c7420 100644 (file)
@@ -113,6 +113,13 @@ void RenderFileUploadControl::setStyle(RenderStyle* s)
     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())
@@ -136,6 +143,7 @@ void RenderFileUploadControl::updateFromElement()
         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);
         
@@ -150,10 +158,6 @@ void RenderFileUploadControl::updateFromElement()
         addChild(m_fileBox);
     }
 
-    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
-    RenderButton* buttonRenderer = static_cast<RenderButton*>(m_button->renderer());
-    buttonRenderer->setText(input->valueWithDefault());
-
     updateIconAndFilename();
 }
 
index 3caae51a000eb1f2b77ffa627563298076772573..5114179578f95d871d2ca725d04beb3e0afe24d5 100644 (file)
@@ -46,6 +46,7 @@ public:
 
     virtual void click(bool sendMouseEvents);
 
+    void valueChanged();
     void updateIconAndFilename();
 
     virtual const char* renderName() const { return "RenderFileUploadControl"; }