LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 May 2006 04:33:29 +0000 (04:33 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 May 2006 04:33:29 +0000 (04:33 +0000)
        Reviewed by Darin.

        Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5882:
        disabled type="file" element doesn't appear disabled

        * fast/forms/file-input-disabled.html: Added.
        * fast/forms/file-input-disabled-expected.txt: Added.
        * fast/forms/file-input-disabled-expected.png: Added.
        * fast/forms/file-input-disabled-expected.checksum: Added.

WebCore:

        Reviewed by Darin.

        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5882:
        disabled type="file" element doesn't appear disabled

        Be sure to call setDisabled on the file button when in
        RenderFileButton::updateFromElement.

        * kwq/KWQFileButton.h:
        * kwq/KWQFileButton.mm:
        (-[WebFileChooserButton setEnabled:]):
        (KWQFileButton::setDisabled):
        * rendering/render_form.cpp:
        (WebCore::RenderFileButton::updateFromElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/file-input-disabled-expected.checksum [new file with mode: 0644]
LayoutTests/fast/forms/file-input-disabled-expected.png [new file with mode: 0644]
LayoutTests/fast/forms/file-input-disabled-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/file-input-disabled.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/kwq/KWQFileButton.h
WebCore/kwq/KWQFileButton.mm
WebCore/rendering/render_form.cpp

index 517ae94b6a6ef5e5cceae5390cab47ec4657fa35..714b4568fdfd6c43b74ae15afcbd03226e3ade5b 100644 (file)
@@ -1,3 +1,15 @@
+2006-05-14  Rob Buis  <buis@kde.org>
+
+        Reviewed by Darin.
+
+        Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5882:
+        disabled type="file" element doesn't appear disabled
+
+        * fast/forms/file-input-disabled.html: Added.
+        * fast/forms/file-input-disabled-expected.txt: Added.
+        * fast/forms/file-input-disabled-expected.png: Added.
+        * fast/forms/file-input-disabled-expected.checksum: Added.
+
 2006-05-14  Sam Weinig  <sam.weinig@gmail.com>
 
         Reviewed by Hyatt, landed by ap.
diff --git a/LayoutTests/fast/forms/file-input-disabled-expected.checksum b/LayoutTests/fast/forms/file-input-disabled-expected.checksum
new file mode 100644 (file)
index 0000000..415e4b8
--- /dev/null
@@ -0,0 +1 @@
+371af1a844593e86ff0e749c20e2f907
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/file-input-disabled-expected.png b/LayoutTests/fast/forms/file-input-disabled-expected.png
new file mode 100644 (file)
index 0000000..7e01ae7
Binary files /dev/null and b/LayoutTests/fast/forms/file-input-disabled-expected.png differ
diff --git a/LayoutTests/fast/forms/file-input-disabled-expected.txt b/LayoutTests/fast/forms/file-input-disabled-expected.txt
new file mode 100644 (file)
index 0000000..6bb0b58
--- /dev/null
@@ -0,0 +1,19 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {FORM} at (0,0) size 784x58
+        RenderBlock (anonymous) at (0,0) size 784x56
+          RenderBlock {INPUT} at (3,4) size 12x12
+          RenderInline {B} at (0,0) size 75x18
+            RenderText {#text} at (18,0) size 75x18
+              text run at (18,0) width 75: "Attach File"
+          RenderBR {BR} at (93,14) size 0x0
+          RenderBR {BR} at (0,19) size 0x18
+          RenderText {#text} at (0,37) size 86x18
+            text run at (0,37) width 86: "  Select File:  "
+          RenderFileButton {INPUT} at (86,38) size 234x18
+          RenderBR {BR} at (320,51) size 0x0
+        RenderTable {TABLE} at (0,56) size 4x2
+          RenderTableSection {TBODY} at (0,0) size 4x2
diff --git a/LayoutTests/fast/forms/file-input-disabled.html b/LayoutTests/fast/forms/file-input-disabled.html
new file mode 100644 (file)
index 0000000..42baaee
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>Testing disabling file input</title>
+
+<script language="JavaScript" type="text/javascript">
+<!--
+function checkboxClicked(element) {
+       if (element.checked) {
+               document.getElementById("file_input").disabled = false;
+       } else {
+               document.getElementById("file_input").disabled = true;
+       }
+}
+//-->
+</script>
+</head>
+<body>
+<form>
+<table>
+<input name="attach_screenshot" type="checkbox" onClick="checkboxClicked(this);">
+<b>Attach File</b><br><br>
+&nbsp;&nbsp;Select File:&nbsp;
+<input id="file_input" name="thumbnail_file" type="file" disabled="true"><br>
+</form>
+</body>
+</html>
index 7e3925a5c9c9f2a423171578d0fb5648fff9ab73..5d9efa97ee203dc581b9affac77d1ec4c603fbf7 100644 (file)
@@ -1,3 +1,20 @@
+2006-05-14  Rob Buis  <buis@kde.org>
+
+        Reviewed by Darin.
+
+        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5882:
+        disabled type="file" element doesn't appear disabled
+
+        Be sure to call setDisabled on the file button when in
+        RenderFileButton::updateFromElement.
+
+        * kwq/KWQFileButton.h:
+        * kwq/KWQFileButton.mm:
+        (-[WebFileChooserButton setEnabled:]):
+        (KWQFileButton::setDisabled):
+        * rendering/render_form.cpp:
+        (WebCore::RenderFileButton::updateFromElement):
+
 2006-05-14  Steve Falkenburg  <sfalken@apple.com>
 
         Fix Windows build.
index f7c0aebf3adcff258ce0609daaab2850217b78d6..ee3118db966e5cace99cb3ab126e7a298560d627 100644 (file)
@@ -57,6 +57,8 @@ public:
 
     const WebCore::String& filename() const { return m_name; }
 
+    void setDisabled(bool);
+
 private:
     WebCoreFileButton* _buttonView;
     WebCore::String m_name;
index f33b5350e2f5837b1ca87893bf223b2e0915471f..5d4fadc150a6042dad98623b64567963686c2cf5 100644 (file)
@@ -78,6 +78,7 @@ using namespace WebCore;
 - (NSRect)visualFrame;
 - (NSSize)bestVisualFrameSizeForCharacterCount:(int)count;
 - (id)initWithWidget:(KWQFileButton *)widget;
+- (void)setEnabled:(BOOL)flag;
 @end
 
 @implementation WebCoreFileButton
@@ -361,6 +362,11 @@ using namespace WebCore;
     [_button performClick:nil];
 }
 
+- (void)setEnabled:(BOOL)flag
+{
+    [_button setEnabled:flag];
+}
+
 static NSString *validFilenameFromPasteboard(NSPasteboard* pBoard)
 {
     NSArray *filenames = [pBoard propertyListForType:NSFilenamesPboardType];
@@ -515,3 +521,11 @@ void KWQFileButton::filenameChanged(const DeprecatedString& filename)
     if (client())
         client()->valueChanged(this);
 }
+
+void KWQFileButton::setDisabled(bool flag)
+{
+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    [_buttonView setEnabled:!flag];
+    END_BLOCK_OBJC_EXCEPTIONS;
+}
+
index 917aa1edd5f745a37b9433d5459a59e40f9f656c..b7cc80e591eb0d3b548d6718066e7ebeb9ef9a6b 100644 (file)
@@ -527,6 +527,9 @@ void RenderFileButton::updateFromElement()
     static_cast<KWQFileButton*>(widget())->setFilename(
         static_cast<HTMLInputElement*>(node())->value().deprecatedString());
 
+    static_cast<KWQFileButton*>(widget())->setDisabled(
+        static_cast<HTMLInputElement*>(node())->disabled());
+
     RenderFormElement::updateFromElement();
 }