Changeset 223441 in webkit


Ignore:
Timestamp:
Oct 16, 2017 2:57:27 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[FETCH] Remove Request.type getter
https://bugs.webkit.org/show_bug.cgi?id=177798

Patch by Youenn Fablet <youenn@apple.com> on 2017-10-16
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Refreshing fetch WPT tests.

  • web-platform-tests/fetch/api/request/request-type-attribute-historical-expected.txt: Added.
  • web-platform-tests/fetch/api/request/request-type-attribute-historical.html: Added.
  • web-platform-tests/fetch/api/request/url-encoding-expected.txt: Added.
  • web-platform-tests/fetch/api/request/url-encoding.html: Added.

Source/WebCore:

Tests: imported/w3c/web-platform-tests/fetch/api/request/request-type-attribute-historical.html

imported/w3c/web-platform-tests/fetch/api/request/url-encoding.html

Removing FetchRequest type getter.
Merging Type and Destination as per https://fetch.spec.whatwg.org/#concept-request-destination.
Setting destination of request within CachedResourceLoader as this will be useful to Service Workers.

  • Modules/fetch/FetchRequest.h:
  • Modules/fetch/FetchRequest.idl:
  • loader/FetchOptions.h:

(WebCore::FetchOptions::isolatedCopy const):
(WebCore::FetchOptions::FetchOptions):
(WebCore::FetchOptions::encode const):
(WebCore::FetchOptions::decode):

  • loader/ThreadableLoader.cpp:

(WebCore::ThreadableLoaderOptions::isolatedCopy const):

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::requestFont):
(WebCore::CachedResourceLoader::requestTextTrack):
(WebCore::CachedResourceLoader::requestCSSStyleSheet):
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestScript):
(WebCore::CachedResourceLoader::requestXSLStyleSheet):
(WebCore::CachedResourceLoader::requestMedia):
(WebCore::CachedResourceLoader::requestIcon):
(WebCore::CachedResourceLoader::requestRawResource):
(WebCore::CachedResourceLoader::requestBeaconResource):
(WebCore::CachedResourceLoader::requestMainResource):

  • loader/cache/CachedResourceRequest.cpp:

(WebCore::CachedResourceRequest::setDestinationIfNotSet):

  • loader/cache/CachedResourceRequest.h:
Location:
trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r223413 r223441  
     12017-10-16  Youenn Fablet  <youenn@apple.com>
     2
     3        [FETCH] Remove Request.type getter
     4        https://bugs.webkit.org/show_bug.cgi?id=177798
     5
     6        Reviewed by Chris Dumez.
     7
     8        Refreshing fetch WPT tests.
     9
     10        * web-platform-tests/fetch/api/request/request-type-attribute-historical-expected.txt: Added.
     11        * web-platform-tests/fetch/api/request/request-type-attribute-historical.html: Added.
     12        * web-platform-tests/fetch/api/request/url-encoding-expected.txt: Added.
     13        * web-platform-tests/fetch/api/request/url-encoding.html: Added.
     14
    1152017-10-16  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r223440 r223441  
     12017-10-16  Youenn Fablet  <youenn@apple.com>
     2
     3        [FETCH] Remove Request.type getter
     4        https://bugs.webkit.org/show_bug.cgi?id=177798
     5
     6        Reviewed by Chris Dumez.
     7
     8        Tests: imported/w3c/web-platform-tests/fetch/api/request/request-type-attribute-historical.html
     9               imported/w3c/web-platform-tests/fetch/api/request/url-encoding.html
     10
     11        Removing FetchRequest type getter.
     12        Merging Type and Destination as per https://fetch.spec.whatwg.org/#concept-request-destination.
     13        Setting destination of request within CachedResourceLoader as this will be useful to Service Workers.
     14
     15        * Modules/fetch/FetchRequest.h:
     16        * Modules/fetch/FetchRequest.idl:
     17        * loader/FetchOptions.h:
     18        (WebCore::FetchOptions::isolatedCopy const):
     19        (WebCore::FetchOptions::FetchOptions):
     20        (WebCore::FetchOptions::encode const):
     21        (WebCore::FetchOptions::decode):
     22        * loader/ThreadableLoader.cpp:
     23        (WebCore::ThreadableLoaderOptions::isolatedCopy const):
     24        * loader/cache/CachedResourceLoader.cpp:
     25        (WebCore::CachedResourceLoader::requestImage):
     26        (WebCore::CachedResourceLoader::requestFont):
     27        (WebCore::CachedResourceLoader::requestTextTrack):
     28        (WebCore::CachedResourceLoader::requestCSSStyleSheet):
     29        (WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
     30        (WebCore::CachedResourceLoader::requestScript):
     31        (WebCore::CachedResourceLoader::requestXSLStyleSheet):
     32        (WebCore::CachedResourceLoader::requestMedia):
     33        (WebCore::CachedResourceLoader::requestIcon):
     34        (WebCore::CachedResourceLoader::requestRawResource):
     35        (WebCore::CachedResourceLoader::requestBeaconResource):
     36        (WebCore::CachedResourceLoader::requestMainResource):
     37        * loader/cache/CachedResourceRequest.cpp:
     38        (WebCore::CachedResourceRequest::setDestinationIfNotSet):
     39        * loader/cache/CachedResourceRequest.h:
     40
    1412017-10-15  Ryosuke Niwa  <rniwa@webkit.org>
    242
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.h

    r221397 r223441  
    5252    using Mode = FetchOptions::Mode;
    5353    using Redirect = FetchOptions::Redirect;
    54     using Type = FetchOptions::Type;
    5554
    5655
     
    6362    const FetchHeaders& headers() const { return m_headers.get(); }
    6463
    65     Type type() const { return m_options.type; }
    6664    Destination destination() const { return m_options.destination; }
    6765    String referrer() const;
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.idl

    r221201 r223441  
    2727 */
    2828
    29 enum FetchRequestType { "", "audio", "font", "image", "script", "style", "track", "video" };
    30 enum FetchRequestDestination { "", "document", "sharedworker", "subresource", "unknown", "worker" };
     29enum FetchRequestDestination { "", "audio", "document", "embed", "font", "image", "manifest", "object", "report", "script", "serviceworker", "sharedworker", "style", "track", "video", "worker", "xslt" };
    3130
    3231typedef (FetchRequest or USVString) RequestInfo;
     
    4746    readonly attribute FetchHeaders headers; // FIXME: Should be [SameObject].
    4847
    49     readonly attribute FetchRequestType type;
    5048    readonly attribute FetchRequestDestination destination;
    5149    readonly attribute USVString referrer;
  • trunk/Source/WebCore/loader/FetchOptions.h

    r221086 r223441  
    3535
    3636struct FetchOptions {
    37     enum class Type { EmptyString, Audio, Font, Image, Script, Style, Track, Video };
    38     enum class Destination { EmptyString, Document, Sharedworker, Subresource, Unknown, Worker };
     37    enum class Destination { EmptyString, Audio, Document, Embed, Font, Image, Manifest, Object, Report, Script, Serviceworker, Sharedworker, Style, Track, Video, Worker, Xslt };
    3938    enum class Mode { Navigate, SameOrigin, NoCors, Cors };
    4039    enum class Credentials { Omit, SameOrigin, Include };
     
    4342
    4443    FetchOptions() = default;
    45     FetchOptions(Type, Destination, Mode, Credentials, Cache, Redirect, ReferrerPolicy, String&&, bool);
    46     FetchOptions isolatedCopy() const { return { type, destination, mode, credentials, cache, redirect, referrerPolicy, integrity.isolatedCopy(), keepAlive }; }
     44    FetchOptions(Destination, Mode, Credentials, Cache, Redirect, ReferrerPolicy, String&&, bool);
     45    FetchOptions isolatedCopy() const { return { destination, mode, credentials, cache, redirect, referrerPolicy, integrity.isolatedCopy(), keepAlive }; }
    4746
    4847    template<class Encoder> void encode(Encoder&) const;
    4948    template<class Decoder> static bool decode(Decoder&, FetchOptions&);
    5049
    51     Type type { Type::EmptyString };
    5250    Destination destination { Destination::EmptyString };
    5351    Mode mode { Mode::NoCors };
     
    6058};
    6159
    62 inline FetchOptions::FetchOptions(Type type, Destination destination, Mode mode, Credentials credentials, Cache cache, Redirect redirect, ReferrerPolicy referrerPolicy, String&& integrity, bool keepAlive)
    63     : type(type)
    64     , destination(destination)
     60inline FetchOptions::FetchOptions(Destination destination, Mode mode, Credentials credentials, Cache cache, Redirect redirect, ReferrerPolicy referrerPolicy, String&& integrity, bool keepAlive)
     61    : destination(destination)
    6562    , mode(mode)
    6663    , credentials(credentials)
     
    7774namespace WTF {
    7875
    79 template<> struct EnumTraits<WebCore::FetchOptions::Type> {
    80     using values = EnumValues<
    81         WebCore::FetchOptions::Type,
    82         WebCore::FetchOptions::Type::EmptyString,
    83         WebCore::FetchOptions::Type::Audio,
    84         WebCore::FetchOptions::Type::Font,
    85         WebCore::FetchOptions::Type::Image,
    86         WebCore::FetchOptions::Type::Script,
    87         WebCore::FetchOptions::Type::Style,
    88         WebCore::FetchOptions::Type::Track,
    89         WebCore::FetchOptions::Type::Video
    90     >;
    91 };
    92 
    9376template<> struct EnumTraits<WebCore::FetchOptions::Destination> {
    9477    using values = EnumValues<
    9578        WebCore::FetchOptions::Destination,
    9679        WebCore::FetchOptions::Destination::EmptyString,
     80        WebCore::FetchOptions::Destination::Audio,
    9781        WebCore::FetchOptions::Destination::Document,
     82        WebCore::FetchOptions::Destination::Embed,
     83        WebCore::FetchOptions::Destination::Font,
     84        WebCore::FetchOptions::Destination::Image,
     85        WebCore::FetchOptions::Destination::Manifest,
     86        WebCore::FetchOptions::Destination::Object,
     87        WebCore::FetchOptions::Destination::Report,
     88        WebCore::FetchOptions::Destination::Script,
     89        WebCore::FetchOptions::Destination::Serviceworker,
    9890        WebCore::FetchOptions::Destination::Sharedworker,
    99         WebCore::FetchOptions::Destination::Subresource,
    100         WebCore::FetchOptions::Destination::Unknown,
    101         WebCore::FetchOptions::Destination::Worker
     91        WebCore::FetchOptions::Destination::Style,
     92        WebCore::FetchOptions::Destination::Track,
     93        WebCore::FetchOptions::Destination::Video,
     94        WebCore::FetchOptions::Destination::Worker,
     95        WebCore::FetchOptions::Destination::Xslt
    10296    >;
    10397};
     
    149143template<class Encoder> inline void FetchOptions::encode(Encoder& encoder) const
    150144{
    151     encoder << type;
    152145    encoder << destination;
    153146    encoder << mode;
     
    162155template<class Decoder> inline bool FetchOptions::decode(Decoder& decoder, FetchOptions& options)
    163156{
    164     FetchOptions::Type type;
    165     if (!decoder.decode(type))
    166         return false;
    167 
    168157    FetchOptions::Destination destination;
    169158    if (!decoder.decode(destination))
     
    198187        return false;
    199188
    200     options.type = type;
    201189    options.destination = destination;
    202190    options.mode = mode;
  • trunk/Source/WebCore/loader/ThreadableLoader.cpp

    r222467 r223441  
    6666
    6767    // FetchOptions
    68     copy.type = this->type;
    6968    copy.destination = this->destination;
    7069    copy.mode = this->mode;
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r223001 r223441  
    193193ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::requestImage(CachedResourceRequest&& request)
    194194{
     195    request.setDestinationIfNotSet(FetchOptions::Destination::Image);
    195196    if (Frame* frame = this->frame()) {
    196197        if (frame->loader().pageDismissalEventBeingDispatched() != FrameLoader::PageDismissalType::None) {
     
    210211ResourceErrorOr<CachedResourceHandle<CachedFont>> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG)
    211212{
     213    request.setDestinationIfNotSet(FetchOptions::Destination::Font);
    212214#if ENABLE(SVG_FONTS)
    213215    if (isSVG)
     
    222224ResourceErrorOr<CachedResourceHandle<CachedTextTrack>> CachedResourceLoader::requestTextTrack(CachedResourceRequest&& request)
    223225{
     226    request.setDestinationIfNotSet(FetchOptions::Destination::Track);
    224227    return castCachedResourceTo<CachedTextTrack>(requestResource(CachedResource::TextTrackResource, WTFMove(request)));
    225228}
     
    228231ResourceErrorOr<CachedResourceHandle<CachedCSSStyleSheet>> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest&& request)
    229232{
     233    request.setDestinationIfNotSet(FetchOptions::Destination::Style);
    230234    return castCachedResourceTo<CachedCSSStyleSheet>(requestResource(CachedResource::CSSStyleSheet, WTFMove(request)));
    231235}
     
    233237CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request)
    234238{
     239    request.setDestinationIfNotSet(FetchOptions::Destination::Style);
     240
    235241    ASSERT(document());
    236242    request.setDomainForCachePartition(*document());
     
    259265ResourceErrorOr<CachedResourceHandle<CachedScript>> CachedResourceLoader::requestScript(CachedResourceRequest&& request)
    260266{
     267    request.setDestinationIfNotSet(FetchOptions::Destination::Script);
    261268    return castCachedResourceTo<CachedScript>(requestResource(CachedResource::Script, WTFMove(request)));
    262269}
     
    265272ResourceErrorOr<CachedResourceHandle<CachedXSLStyleSheet>> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request)
    266273{
     274    request.setDestinationIfNotSet(FetchOptions::Destination::Xslt);
    267275    return castCachedResourceTo<CachedXSLStyleSheet>(requestResource(CachedResource::XSLStyleSheet, WTFMove(request)));
    268276}
     
    285293ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestMedia(CachedResourceRequest&& request)
    286294{
     295    // FIXME: Set destination to either audio or video.
    287296    return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::MediaResource, WTFMove(request)));
    288297}
     
    290299ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestIcon(CachedResourceRequest&& request)
    291300{
     301    request.setDestinationIfNotSet(FetchOptions::Destination::Image);
    292302    return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Icon, WTFMove(request)));
    293303}
     
    295305ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestRawResource(CachedResourceRequest&& request)
    296306{
     307    ASSERT(request.options().destination == FetchOptions::Destination::EmptyString);
    297308    return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request)));
    298309}
     
    300311ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request)
    301312{
     313    ASSERT(request.options().destination == FetchOptions::Destination::EmptyString);
    302314    return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Beacon, WTFMove(request)));
    303315}
     
    305317ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request)
    306318{
     319    request.setDestinationIfNotSet(FetchOptions::Destination::Document);
    307320    return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request)));
    308321}
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp

    r222602 r223441  
    267267}
    268268
     269void CachedResourceRequest::setDestinationIfNotSet(FetchOptions::Destination destination)
     270{
     271    if (m_options.destination != FetchOptions::Destination::EmptyString)
     272        return;
     273    m_options.destination = destination;
     274}
     275
    269276} // namespace WebCore
  • trunk/Source/WebCore/loader/cache/CachedResourceRequest.h

    r223001 r223441  
    6969    void setIgnoreForRequestCount(bool ignoreForRequestCount) { m_ignoreForRequestCount = ignoreForRequestCount; }
    7070
     71    void setDestinationIfNotSet(FetchOptions::Destination);
     72
    7173    void setAsPotentiallyCrossOrigin(const String&, Document&);
    7274    void updateForAccessControl(Document&);
Note: See TracChangeset for help on using the changeset viewer.