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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Modulator.cpp
diff --git a/third_party/WebKit/Source/core/dom/Modulator.cpp b/third_party/WebKit/Source/core/dom/Modulator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dc757c8c3a1643a795fbb16c77f0df814fabd872
--- /dev/null
+++ b/third_party/WebKit/Source/core/dom/Modulator.cpp
@@ -0,0 +1,42 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/dom/Modulator.h"
+
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/V8PerContextData.h"
+
+namespace blink {
+
+Modulator* Modulator::from(LocalFrame* frame) {
+ return ScriptState::forMainWorld(frame)->perContextData()->modulator();
+}
+
+KURL Modulator::resolveModuleSpecifier(const String& moduleRequest,
+ const KURL& baseURL) {
+ // Step 1. Apply the URL parser to specifier. If the result is not failure,
+ // return the result.
+ KURL url(KURL(), moduleRequest);
+ if (url.isValid())
+ return url;
+
+ // Step 2. If specifier does not start with the character U+002F SOLIDUS (/),
+ // the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the
+ // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS
+ // (../), return failure and abort these steps.
+ if (!moduleRequest.startsWith("/") && !moduleRequest.startsWith("./") &&
+ !moduleRequest.startsWith("../"))
+ return KURL();
+
+ // Step 3. Return the result of applying the URL parser to specifier with
+ // script's base URL as the base URL.
+ DCHECK(baseURL.isValid());
+ KURL relativeURL(baseURL, moduleRequest);
dominicc (has gone to gerrit) 2017/01/11 03:23:48 Not sure about this naming; the moduleRequest look
+ if (relativeURL.isValid())
+ return relativeURL;
+
+ return KURL();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698