Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: third_party/WebKit/Source/core/dom/Modulator.cpp

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: address haraken/yhirano comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/dom/Modulator.h"
6
7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8PerContextData.h"
9
10 namespace blink {
11
12 Modulator* Modulator::from(LocalFrame* frame) {
13 return ScriptState::forMainWorld(frame)->perContextData()->modulator();
14 }
15
16 KURL Modulator::resolveModuleSpecifier(const String& moduleRequest,
17 const KURL& baseURL) {
18 // Step 1. Apply the URL parser to specifier. If the result is not failure,
19 // return the result.
20 KURL url(KURL(), moduleRequest);
21 if (url.isValid())
22 return url;
23
24 // Step 2. If specifier does not start with the character U+002F SOLIDUS (/),
25 // the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the
26 // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS
27 // (../), return failure and abort these steps.
28 if (!moduleRequest.startsWith("/") && !moduleRequest.startsWith("./") &&
29 !moduleRequest.startsWith("../"))
30 return KURL();
31
32 // Step 3. Return the result of applying the URL parser to specifier with
33 // script's base URL as the base URL.
34 DCHECK(baseURL.isValid());
35 KURL relativeURL(baseURL, moduleRequest);
dominicc (has gone to gerrit) 2017/01/11 03:23:48 Not sure about this naming; the moduleRequest look
36 if (relativeURL.isValid())
37 return relativeURL;
38
39 return KURL();
40 }
41
42 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698