Title: [182757] trunk/Source/WebCore
Revision
182757
Author
[email protected]
Date
2015-04-13 14:37:42 -0700 (Mon, 13 Apr 2015)

Log Message

[Win] Unreviewed fix after r182161.

The change caused Windows to lose Media UI, since the new 'getFileSize'
signature was being improperly used for a 'UInt8'-based string.

Fix was to provide implementations for the two new methods, and to make
sure RenderThemeWin was using the proper signature.

This should actually be a little more efficient, since we have the file
handle when we call this new method. Previously, a Windows 'find file' was
being done with the requested path, which was unnecessary work.

* platform/win/FileSystemWin.cpp:
(WebCore::getFileSizeFromByHandleFileInformationStructure): Added helper function.
(WebCore::getFileSize): Provide implementation.
(WebCore::renameFile):
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::stringWithContentsOfFile): Use the file handle to
get the file size, rather than using the path-based size lookup (which involves
performing an unnecessary file search.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (182756 => 182757)


--- trunk/Source/WebCore/ChangeLog	2015-04-13 21:23:09 UTC (rev 182756)
+++ trunk/Source/WebCore/ChangeLog	2015-04-13 21:37:42 UTC (rev 182757)
@@ -1,3 +1,26 @@
+2015-04-13  Brent Fulgham  <[email protected]>
+
+        [Win] Unreviewed fix after r182161.
+
+        The change caused Windows to lose Media UI, since the new 'getFileSize'
+        signature was being improperly used for a 'UInt8'-based string.
+
+        Fix was to provide implementations for the two new methods, and to make
+        sure RenderThemeWin was using the proper signature.
+
+        This should actually be a little more efficient, since we have the file
+        handle when we call this new method. Previously, a Windows 'find file' was
+        being done with the requested path, which was unnecessary work.
+
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::getFileSizeFromByHandleFileInformationStructure): Added helper function.
+        (WebCore::getFileSize): Provide implementation.
+        (WebCore::renameFile):
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::stringWithContentsOfFile): Use the file handle to
+        get the file size, rather than using the path-based size lookup (which involves
+        performing an unnecessary file search.
+
 2015-04-13  Brady Eidson  <[email protected]>
 
         Share sheets from Share menus appear outside the browser window.

Modified: trunk/Source/WebCore/platform/win/FileSystemWin.cpp (182756 => 182757)


--- trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2015-04-13 21:23:09 UTC (rev 182756)
+++ trunk/Source/WebCore/platform/win/FileSystemWin.cpp	2015-04-13 21:37:42 UTC (rev 182757)
@@ -68,6 +68,19 @@
     return true;
 }
 
+static bool getFileSizeFromByHandleFileInformationStructure(const BY_HANDLE_FILE_INFORMATION& fileInformation, long long& size)
+{
+    ULARGE_INTEGER fileSize;
+    fileSize.HighPart = fileInformation.nFileSizeHigh;
+    fileSize.LowPart = fileInformation.nFileSizeLow;
+
+    if (fileSize.QuadPart > static_cast<ULONGLONG>(std::numeric_limits<long long>::max()))
+        return false;
+
+    size = fileSize.QuadPart;
+    return true;
+}
+
 static void getFileCreationTimeFromFindData(const WIN32_FIND_DATAW& findData, time_t& time)
 {
     ULARGE_INTEGER fileTime;
@@ -98,10 +111,13 @@
     return getFileSizeFromFindData(findData, size);
 }
 
-bool getFileSize(PlatformFileHandle, long long&)
+bool getFileSize(PlatformFileHandle fileHandle, long long& size)
 {
-    notImplemented();
-    return false;
+    BY_HANDLE_FILE_INFORMATION fileInformation;
+    if (!::GetFileInformationByHandle(fileHandle, &fileInformation))
+        return false;
+
+    return getFileSizeFromByHandleFileInformationStructure(fileInformation, size);
 }
 
 bool getFileModificationTime(const String& path, time_t& time)
@@ -160,8 +176,16 @@
     return !!RemoveDirectoryW(filename.charactersWithNullTermination().data());
 }
 
-bool renameFile(const String&, const String&)
+bool renameFile(const String& oldPath, const String& newPath)
 {
+    CString oldPathFsRep = fileSystemRepresentation(oldPath);
+    if (!oldPathFsRep.data() || oldPathFsRep.data()[0] == '\0')
+        return false;
+
+    CString newPathFsRep = fileSystemRepresentation(newPath);
+    if (!newPathFsRep.data() || newPathFsRep.data()[0] == '\0')
+        return false;
+
     notImplemented();
     return false;
 }

Modified: trunk/Source/WebCore/rendering/RenderThemeWin.cpp (182756 => 182757)


--- trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2015-04-13 21:23:09 UTC (rev 182756)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2015-04-13 21:37:42 UTC (rev 182757)
@@ -1066,7 +1066,7 @@
         return String();
 
     long long filesize = -1;
-    if (!getFileSize(requestedFilePath, filesize)) {
+    if (!getFileSize(requestedFileHandle, filesize)) {
         closeFile(requestedFileHandle);
         return String();
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to