WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
213825
Allow the File object to be created with a replacement file
https://bugs.webkit.org/show_bug.cgi?id=213825
Summary
Allow the File object to be created with a replacement file
Said Abou-Hallawa
Reported
2020-06-30 18:46:55 PDT
This work is towards
bug 213347
. The goal is to enable the UIProcess to pass an original path and an optional replacement path to the WebProcess, e.g. a HIEF image and its transcoded PNG image. The Web process will create the File object with the replacement file but will register the Blob in the NetworkProcess with both: the original file and the replacement file. The Blob in the NetworkProcess will delete the replacement file when it is destroyed. It is important to create the File object with the replacement file because it needs to get the size and the bytes of the replacement file not the original files.
Attachments
Patch
(34.32 KB, patch)
2020-06-30 19:53 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(37.44 KB, patch)
2020-07-01 13:21 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(37.84 KB, patch)
2020-07-01 13:44 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Patch
(37.80 KB, patch)
2020-07-01 14:58 PDT
,
Said Abou-Hallawa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Said Abou-Hallawa
Comment 1
2020-06-30 19:53:55 PDT
Created
attachment 403259
[details]
Patch
Darin Adler
Comment 2
2020-07-01 10:04:11 PDT
Comment on
attachment 403259
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=403259&action=review
"objet" -> "object"
> Source/WebCore/ChangeLog:3 > + Allow the File objet to be created with a replacement file
type: "objet" Am I correct that this adds unused code, to be used later? Is that why there is no test coverage?
> Source/WebCore/ChangeLog:14 > + t is important to create the File object with the replacement file because
typo: "t"
> Source/WebCore/fileapi/File.cpp:59 > + return adoptRef(*new File(WTFMove(internalURL), WTFMove(type), String { effectivePath }, WTFMove(name)));
Why not WTFMove(effectivePath)?
> Source/WebCore/fileapi/File.h:45 > - WEBCORE_EXPORT static Ref<File> create(const String& path, const String& nameOverride = { }); > + WEBCORE_EXPORT static Ref<File> create(const String& path, const String& replacementPath = { }, const String& nameOverride = { });
With this change, we have to inspect every File::create call site, because anyone specifying a nameOverride might now be specifying a replacementPath instead by accident. I presume you did that. This is the kind of refactoring that is risky since it silently changes the behavior of existing code.
> Source/WebCore/platform/FileChooser.h:54 > - FileChooserFileInfo(const String& path, const String& displayName = String()) > + FileChooserFileInfo(const String& path, const String& replacementPath = { }, const String& displayName = { }) > : path(path) > + , replacementPath(replacementPath) > , displayName(displayName) > { > }
Why do we need a constructor? Can’t we delete it and just use aggregate initialization instead?
Said Abou-Hallawa
Comment 3
2020-07-01 13:20:27 PDT
Comment on
attachment 403259
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=403259&action=review
>> Source/WebCore/ChangeLog:3 >> + Allow the File objet to be created with a replacement file > > type: "objet" > > Am I correct that this adds unused code, to be used later? Is that why there is no test coverage?
The typo is fixed. You are right this patch is work towards
webkit.org/b/213347
. I added this to the ChangeLog.
>> Source/WebCore/ChangeLog:14 >> + t is important to create the File object with the replacement file because > > typo: "t"
Fixed.
>> Source/WebCore/fileapi/File.cpp:59 >> + return adoptRef(*new File(WTFMove(internalURL), WTFMove(type), String { effectivePath }, WTFMove(name))); > > Why not WTFMove(effectivePath)?
Fixed.
>> Source/WebCore/fileapi/File.h:45 >> + WEBCORE_EXPORT static Ref<File> create(const String& path, const String& replacementPath = { }, const String& nameOverride = { }); > > With this change, we have to inspect every File::create call site, because anyone specifying a nameOverride might now be specifying a replacementPath instead by accident. I presume you did that. This is the kind of refactoring that is risky since it silently changes the behavior of existing code.
Yes I did that by removing the default values for both replacementPath and nameOverride from the create() method. Then I fixed all compilation errors. And finally I put back the default values and removed the unnecessary initializations in the caller side. This way I made sure nameOverride was never passed as the second argument.
>> Source/WebCore/platform/FileChooser.h:54 >> } > > Why do we need a constructor? Can’t we delete it and just use aggregate initialization instead?
Fixed. But I had to pass three values always in the aggregate initialization because I was getting this error in the caller side: error: missing field 'replacementPath' initializer [-Werror,-Wmissing-field-initializers] I am not sure whether -Wmissing-field-initializers is enabled by default or this is WebKit Xcode project settings.
Said Abou-Hallawa
Comment 4
2020-07-01 13:21:36 PDT
Created
attachment 403314
[details]
Patch
Said Abou-Hallawa
Comment 5
2020-07-01 13:44:00 PDT
Created
attachment 403316
[details]
Patch
Darin Adler
Comment 6
2020-07-01 14:20:42 PDT
Comment on
attachment 403316
[details]
Patch Many of the places we have nullString() here we could alternatively have { }.
Said Abou-Hallawa
Comment 7
2020-07-01 14:58:04 PDT
Created
attachment 403322
[details]
Patch
EWS
Comment 8
2020-07-01 20:09:01 PDT
Committed
r263830
: <
https://trac.webkit.org/changeset/263830
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 403322
[details]
.
Radar WebKit Bug Importer
Comment 9
2020-07-01 20:10:15 PDT
<
rdar://problem/65015820
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug