Title: [98054] trunk/Source/WebCore
Revision
98054
Author
commit-qu...@webkit.org
Date
2011-10-20 19:08:52 -0700 (Thu, 20 Oct 2011)

Log Message

[Forms][File] Add tooltip to "No file selected" text
https://bugs.webkit.org/show_bug.cgi?id=70474

Patch by Yosifumi Inoue <yo...@chromium.org> on 2011-10-20
Reviewed by Kent Tamura.

No new tests. Existing tests cover all changes.

This patch provides tooltip for text portion of upload file control
tell users to know actual text of truncated text of file name and
"No file selected" text. Tooltip is always displayed even if user
select only one file for truncated displayed file name.

* html/FileInputType.cpp:
(WebCore::FileInputType::defaultToolTip): Implement default tooltip logic.
* html/FileInputType.h: declaration of new method defaultToolTip.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultToolTip): Impelement new method defaultToolTip.
* html/HTMLInputElement.h: declaration of new method defaultToolTip.
* html/InputType.cpp:
(WebCore::InputType::defaultToolTip): Implement default method of defaultToolTip method.
* html/InputType.h: declaration of new method defaultToolTip.
* page/Chrome.cpp:
(WebCore::Chrome::setToolTip): Use new method HTMLInputElement::defaultToolTip and move default tooltip logic to FileInputType::defaultToolTip method.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98053 => 98054)


--- trunk/Source/WebCore/ChangeLog	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/ChangeLog	2011-10-21 02:08:52 UTC (rev 98054)
@@ -1,3 +1,29 @@
+2011-10-20  Yosifumi Inoue  <yo...@chromium.org>
+
+        [Forms][File] Add tooltip to "No file selected" text
+        https://bugs.webkit.org/show_bug.cgi?id=70474
+
+        Reviewed by Kent Tamura.
+
+        No new tests. Existing tests cover all changes.
+
+        This patch provides tooltip for text portion of upload file control
+        tell users to know actual text of truncated text of file name and
+        "No file selected" text. Tooltip is always displayed even if user
+        select only one file for truncated displayed file name.
+
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::defaultToolTip): Implement default tooltip logic.
+        * html/FileInputType.h: declaration of new method defaultToolTip.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::defaultToolTip): Impelement new method defaultToolTip.
+        * html/HTMLInputElement.h: declaration of new method defaultToolTip.
+        * html/InputType.cpp:
+        (WebCore::InputType::defaultToolTip): Implement default method of defaultToolTip method.
+        * html/InputType.h: declaration of new method defaultToolTip.
+        * page/Chrome.cpp:
+        (WebCore::Chrome::setToolTip): Use new method HTMLInputElement::defaultToolTip and move default tooltip logic to FileInputType::defaultToolTip method.
+
 2011-10-20  Darin Adler  <da...@apple.com>
 
         Remove OptionElement (first half)

Modified: trunk/Source/WebCore/html/FileInputType.cpp (98053 => 98054)


--- trunk/Source/WebCore/html/FileInputType.cpp	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2011-10-21 02:08:52 UTC (rev 98054)
@@ -37,6 +37,7 @@
 #include "ScriptController.h"
 #include "ShadowRoot.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -368,4 +369,20 @@
     return m_icon.get();
 }
 
+String FileInputType::defaultToolTip() const
+{
+    FileList* fileList = m_fileList.get();
+    unsigned listSize = fileList->length();
+    if (!listSize)
+        return fileButtonNoFileSelectedLabel();
+
+    StringBuilder names;
+    for (size_t i = 0; i < listSize; ++i) {
+        names.append(fileList->item(i)->fileName());
+        if (i != listSize - 1)
+            names.append('\n');
+    }
+    return names.toString();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/FileInputType.h (98053 => 98054)


--- trunk/Source/WebCore/html/FileInputType.h	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/FileInputType.h	2011-10-21 02:08:52 UTC (rev 98054)
@@ -65,6 +65,7 @@
     virtual bool isFileUpload() const;
     virtual void createShadowSubtree();
     virtual void multipleAttributeChanged();
+    virtual String defaultToolTip() const OVERRIDE;
 
     // FileChooserClient implementation.
     virtual void filesChosen(const Vector<String>&);

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (98053 => 98054)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-10-21 02:08:52 UTC (rev 98054)
@@ -1827,4 +1827,9 @@
         setValue(newValue);
 }
 
+String HTMLInputElement::defaultToolTip() const
+{
+    return m_inputType->defaultToolTip();
+}
+
 } // namespace

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (98053 => 98054)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2011-10-21 02:08:52 UTC (rev 98054)
@@ -232,6 +232,8 @@
     bool connectToColorChooser();
 #endif
 
+    String defaultToolTip() const;
+
     static const int maximumLength;
 
 protected:

Modified: trunk/Source/WebCore/html/InputType.cpp (98053 => 98054)


--- trunk/Source/WebCore/html/InputType.cpp	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/InputType.cpp	2011-10-21 02:08:52 UTC (rev 98054)
@@ -722,6 +722,11 @@
 {
 }
 
+String InputType::defaultToolTip() const
+{
+    return String();
+}
+
 namespace InputTypeNames {
 
 // The type names must be lowercased because they will be the return values of

Modified: trunk/Source/WebCore/html/InputType.h (98053 => 98054)


--- trunk/Source/WebCore/html/InputType.h	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/html/InputType.h	2011-10-21 02:08:52 UTC (rev 98054)
@@ -238,6 +238,7 @@
     virtual void multipleAttributeChanged();
     virtual void disabledAttributeChanged();
     virtual void readonlyAttributeChanged();
+    virtual String defaultToolTip() const;
 
     // Parses the specified string for the type, and return
     // the double value for the parsing result if the parsing

Modified: trunk/Source/WebCore/page/Chrome.cpp (98053 => 98054)


--- trunk/Source/WebCore/page/Chrome.cpp	2011-10-21 01:27:33 UTC (rev 98053)
+++ trunk/Source/WebCore/page/Chrome.cpp	2011-10-21 02:08:52 UTC (rev 98054)
@@ -419,21 +419,14 @@
         if (Node* node = result.innerNonSharedNode()) {
             if (node->hasTagName(inputTag)) {
                 HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
-                if (input->isFileUpload()) {
-                    FileList* files = input->files();
-                    unsigned listSize = files->length();
-                    if (listSize > 1) {
-                        StringBuilder names;
-                        for (size_t i = 0; i < listSize; ++i) {
-                            names.append(files->item(i)->fileName());
-                            if (i != listSize - 1)
-                                names.append('\n');
-                        }
-                        toolTip = names.toString();
-                        // filename always display as LTR.
-                        toolTipDirection = LTR;
-                    }
-                }
+                toolTip = input->defaultToolTip();
+
+                // FIXME: We should obtain text direction of tooltip from
+                // ChromeClient or platform. As of October 2011, all client
+                // implementations don't use text direction information for
+                // ChromeClient::setToolTip. We'll work on tooltip text
+                // direction during bidi cleanup in form inputs.
+                toolTipDirection = LTR;
             }
         }
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to