Implement FileSystemDirectoryEntry.getFile()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Sep 2017 00:19:55 +0000 (00:19 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 Sep 2017 00:19:55 +0000 (00:19 +0000)
commit29bb1df51bed4e854a582330b0ac2345289976c4
tree42c8cbe5bc95a8823ea69bd4af986731b9dc0ca0
parent3157f34ee6163241f219ef691c8936f6dd83cbc1
Implement FileSystemDirectoryEntry.getFile()
https://bugs.webkit.org/show_bug.cgi?id=176167
<rdar://problem/34187775>

Reviewed by Andreas Kling.

Source/WebCore:

Implement FileSystemDirectoryEntry.getFile():
- https://wicg.github.io/entries-api/#dom-filesystemdirectoryentry-getfile

Test: editing/pasteboard/datatransfer-items-drop-getFile.html

* Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::isValidPathNameCharacter):
(WebCore::isValidPathSegment):
(WebCore::isValidRelativeVirtualPath):
(WebCore::isValidAbsoluteVirtualPath):
(WebCore::isValidVirtualPath):
Implement various path validation functions as per:
- https://wicg.github.io/entries-api/#names-paths

(WebCore::resolveRelativeVirtualPath):
- Use StringView for second parameter for efficiency. Had to keep
  a String for the first parameter because I need the split to
  return a Vector.
- If the input path is absolute, call recursively with '/' as
  base path so that the virtual path gets sanitized (i.e. '..'
  and '.' in the absolute URL get resolved).

(WebCore::DOMFileSystem::listDirectory):
Use String instead of auto. It is not much longer and is clearer.

(WebCore::validatePathIsDirectory):
(WebCore::DOMFileSystem::getParent):
Move logic to validate that the path is a directory from getParent() to a
separate function. This only makes sure the ScriptExecutionContext is only
ref'd / deref'd on the main thread.

(WebCore::validatePathIsFile):
Logic for validating that a path is a file, used by getFile().

(WebCore::DOMFileSystem::getFile):
Implement getFile() as per:
- https://wicg.github.io/entries-api/#dom-filesystemdirectoryentry-getfile

* Modules/entriesapi/DOMFileSystem.h:
* Modules/entriesapi/FileSystemDirectoryEntry.cpp:
(WebCore::FileSystemDirectoryEntry::getFile):
Add implementation of FileSystemDirectoryEntry::getFile() which merely calls
DOMFileSystem::getFile().

LayoutTests:

Add layout test coverage.

* editing/pasteboard/datatransfer-items-drop-getFile-expected.txt: Added.
* editing/pasteboard/datatransfer-items-drop-getFile.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221510 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/datatransfer-items-drop-getFile-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/datatransfer-items-drop-getFile.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
Source/WebCore/Modules/entriesapi/DOMFileSystem.h
Source/WebCore/Modules/entriesapi/FileSystemDirectoryEntry.cpp