Bug 32366 - HTML input file control "No File Selected" needs more room in some languages
Summary: HTML input file control "No File Selected" needs more room in some languages
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Jon Lee
URL: http://infohound.net/tidy/
Keywords: InRadar, Qt, QtTriaged
Depends on:
Blocks:
 
Reported: 2009-12-10 01:15 PST by Nils Jeisecke
Modified: 2012-02-20 13:55 PST (History)
6 users (show)

See Also:


Attachments
Screenshot with german locale (2.97 KB, image/png)
2009-12-10 01:15 PST, Nils Jeisecke
no flags Details
Screenshot of Qt Demobrowser (57.64 KB, image/png)
2010-03-17 03:36 PDT, Nils Jeisecke
no flags Details
Patch (10.73 KB, patch)
2012-02-18 00:22 PST, Jon Lee
hyatt: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Jeisecke 2009-12-10 01:15:06 PST
Created attachment 44600 [details]
Screenshot with german locale

It simply too small, please see screenshot.
Comment 1 Nils Jeisecke 2009-12-21 05:11:31 PST
Apple's Safari shows a shorter string: "Keine Datei ausgewählt".

Maybe changing the german localisation in qt_de.ts is the easiest fix.
Comment 2 Tor Arne Vestbø 2010-03-05 09:39:35 PST
Please follow the QtWebKit bug reporting guidelines when reporting bugs.

See http://trac.webkit.org/wiki/QtWebKitBugs

Specifically:

  - The 'QtWebKit' component should be used for bugs/features in the public QtWebKit API layer, not to signify that the bug is specific to the Qt port of WebKit

    http://trac.webkit.org/wiki/QtWebKitBugs#Component
Comment 3 Robert Hogan 2010-03-16 11:18:02 PDT
Hi Nils - which browser are you seeing this in exactly? You haven't provided enough information to reproduce this bug so I have to close as INVALID for now. (I suspect it's not even a webkit bug as the screenshot looks like a dialog from a specific browser.)
Comment 4 Nils Jeisecke 2010-03-17 02:16:57 PDT
Hi Robert,

this problem is specific to QtWebKit.

Best regards

Nils
Comment 5 Robert Hogan 2010-03-17 03:07:46 PDT
(In reply to comment #4)
> Hi Robert,
> 
> this problem is specific to QtWebKit.
> 
> Best regards
> 
> Nils

Can you provide a full screenshot of the problem. Is the affected text in a webpage or in a dialog box?
Comment 6 Nils Jeisecke 2010-03-17 03:36:13 PDT
Created attachment 50891 [details]
Screenshot of Qt Demobrowser

This screenshot shows a typical use of an upload form (input type="file") as rendered by Qt Webkit.
Comment 7 Robert Hogan 2010-03-17 04:17:38 PDT
Perfect, get you now.

In FileChooserQt.cpp:

String FileChooser::basenameForWidth(const Font& f, int width) const
{
    if (width <= 0)
        return String();

    String string;
    if (m_filenames.isEmpty())
        string = fileButtonNoFileSelectedLabel();
    else if (m_filenames.size() == 1) {
        String fname = m_filenames[0];
        QFontMetrics fm(f.font());
        string = fm.elidedText(fname, Qt::ElideLeft, width);
    } else {
        int n = m_filenames.size();
        string = QCoreApplication::translate("QWebPage", "%n file(s)",
                                             "number of chosen file",
                                             QCoreApplication::CodecForTr, n);
    }

    return string;
}

is not checking that the width of the localized string is equal to or less than the width of the file input element. I haven't reproduced this directly but it definitely looks like a bug.
Comment 8 Robert Hogan 2010-03-17 04:18:36 PDT
Trying to change this to NEW!
Comment 9 Jon Lee 2012-02-17 11:25:18 PST
This is an issue for not just German, and in some cases it's impossible to come up with a shorter translation.

<rdar://problem/4481028>
Comment 10 Jon Lee 2012-02-17 23:49:08 PST
Changing title to reflect language-agnostic nature of bug :)
Comment 11 Jon Lee 2012-02-18 00:22:02 PST
Created attachment 127697 [details]
Patch
Comment 12 mitz 2012-02-20 09:31:34 PST
Comment on attachment 127697 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=127697&action=review

The code change looks fine, but how do we know that this doesn’t break the layout of existing websites? Also, is there precedent for the user’s preferred UI language affecting the layout of webpages? (To answer my own question: yes, the default line-breaking behavior depends on the user’s preferred UI language; but it is not something authors can rely on anyway).

> Source/WebCore/rendering/RenderFileUploadControl.cpp:189
> +        m_maxPreferredLogicalWidth = (int)ceilf(max(minDefaultLabelWidth, defaultLabelWidth));

Please change this to a static_cast<int> if it’s even necessary.
Comment 13 Dave Hyatt 2012-02-20 13:26:22 PST
Comment on attachment 127697 [details]
Patch

r=me
Comment 14 Jon Lee 2012-02-20 13:55:56 PST
http://trac.webkit.org/changeset/108261