diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/platform/android/FileChooserAndroid.cpp | 12 | ||||
-rw-r--r-- | WebCore/platform/android/FileSystemAndroid.cpp | 11 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 1 | ||||
-rw-r--r-- | WebCore/platform/posix/FileSystemPOSIX.cpp | 2 |
4 files changed, 18 insertions, 8 deletions
diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp index 1f8200f..9e50e67 100644 --- a/WebCore/platform/android/FileChooserAndroid.cpp +++ b/WebCore/platform/android/FileChooserAndroid.cpp @@ -25,7 +25,9 @@ #include "config.h" #include "FileChooser.h" +#include "FileSystem.h" #include "Font.h" +#include "StringTruncator.h" namespace WebCore { @@ -33,14 +35,8 @@ String FileChooser::basenameForWidth(const Font& font, int width) const { if (!m_filenames.size()) return String(); - // FIXME: This could be a lot faster, but assuming the data will not - // often be much longer than the provided width, this may be fast enough. - // If this does not need to be threadsafe, we can use crossThreadString(). - // See http://trac.webkit.org/changeset/49160. - String output = m_filenames[0].threadsafeCopy(); - while (font.width(TextRun(output.impl())) > width && output.length() > 4) - output = output.replace(0, 4, String("...")); - return output; + String output = pathGetFileName(m_filenames[0]); + return StringTruncator::rightTruncate(output, static_cast<float>(width), font, false); } } // namespace WebCore diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp index 3d841d7..cf9830e 100644 --- a/WebCore/platform/android/FileSystemAndroid.cpp +++ b/WebCore/platform/android/FileSystemAndroid.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "FileSystem.h" +#include "PlatformBridge.h" #include "StringBuilder.h" #include "cutils/log.h" #include <dirent.h> @@ -106,4 +107,14 @@ Vector<String> listDirectory(const String& path, const String& filter) return entries; } +String pathGetFileName(const String& path) +{ + // If the path is a content:// URI then ask Java to resolve it for us. + if (path.startsWith("content://")) + return PlatformBridge::resolveFileNameForContentUri(path); + else + return path.substring(path.reverseFind('/') + 1); +} + + } // namespace WebCore diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index ad181e6..cdd22f3 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -137,6 +137,7 @@ public: static bool isWebViewPaused(const FrameView*); static bool canScroll(const FrameView*); + static String resolveFileNameForContentUri(const String&); }; } diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp index ac8c7fa..b7fcd71 100644 --- a/WebCore/platform/posix/FileSystemPOSIX.cpp +++ b/WebCore/platform/posix/FileSystemPOSIX.cpp @@ -213,10 +213,12 @@ bool makeAllDirectories(const String& path) return true; } +#if !PLATFORM(ANDROID) String pathGetFileName(const String& path) { return path.substring(path.reverseFind('/') + 1); } +#endif String directoryName(const String& path) { |