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

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

Issue 2803843002: Change Modulator functions to use ScriptState instead of LocalFrame (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Modulator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/Modulator.h" 5 #include "core/dom/Modulator.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 namespace { 12 namespace {
13 const char kPerContextDataKey[] = "Modulator"; 13 const char kPerContextDataKey[] = "Modulator";
14 } // namespace
14 15
15 V8PerContextData* getPerContextData(LocalFrame* frame) { 16 Modulator* Modulator::from(ScriptState* scriptState) {
16 ScriptState* scriptState = toScriptStateForMainWorld(frame);
17 if (!scriptState) 17 if (!scriptState)
18 return nullptr; 18 return nullptr;
19 return scriptState->perContextData(); 19 V8PerContextData* perContextData = scriptState->perContextData();
20 }
21 } // namespace
22
23 Modulator* Modulator::from(LocalFrame* frame) {
24 return from(getPerContextData(frame));
25 }
26
27 Modulator* Modulator::from(V8PerContextData* perContextData) {
28 if (!perContextData) 20 if (!perContextData)
29 return nullptr; 21 return nullptr;
30 return static_cast<Modulator*>(perContextData->getData(kPerContextDataKey)); 22 return static_cast<Modulator*>(perContextData->getData(kPerContextDataKey));
31 } 23 }
32 24
33 Modulator::~Modulator() {} 25 Modulator::~Modulator() {}
34 26
35 void Modulator::setModulator(LocalFrame* frame, Modulator* modulator) { 27 void Modulator::setModulator(ScriptState* scriptState, Modulator* modulator) {
36 V8PerContextData* perContextData = getPerContextData(frame); 28 DCHECK(scriptState);
29 V8PerContextData* perContextData = scriptState->perContextData();
37 DCHECK(perContextData); 30 DCHECK(perContextData);
38 perContextData->addData(kPerContextDataKey, modulator); 31 perContextData->addData(kPerContextDataKey, modulator);
39 } 32 }
40 33
41 void Modulator::clearModulator(LocalFrame* frame) { 34 void Modulator::clearModulator(ScriptState* scriptState) {
42 V8PerContextData* perContextData = getPerContextData(frame); 35 DCHECK(scriptState);
36 V8PerContextData* perContextData = scriptState->perContextData();
43 DCHECK(perContextData); 37 DCHECK(perContextData);
44 perContextData->clearData(kPerContextDataKey); 38 perContextData->clearData(kPerContextDataKey);
45 } 39 }
46 40
47 KURL Modulator::resolveModuleSpecifier(const String& moduleRequest, 41 KURL Modulator::resolveModuleSpecifier(const String& moduleRequest,
48 const KURL& baseURL) { 42 const KURL& baseURL) {
49 // Step 1. Apply the URL parser to specifier. If the result is not failure, 43 // Step 1. Apply the URL parser to specifier. If the result is not failure,
50 // return the result. 44 // return the result.
51 KURL url(KURL(), moduleRequest); 45 KURL url(KURL(), moduleRequest);
52 if (url.isValid()) 46 if (url.isValid())
(...skipping 11 matching lines...) Expand all
64 // script's base URL as the base URL. 58 // script's base URL as the base URL.
65 DCHECK(baseURL.isValid()); 59 DCHECK(baseURL.isValid());
66 KURL absoluteURL(baseURL, moduleRequest); 60 KURL absoluteURL(baseURL, moduleRequest);
67 if (absoluteURL.isValid()) 61 if (absoluteURL.isValid())
68 return absoluteURL; 62 return absoluteURL;
69 63
70 return KURL(); 64 return KURL();
71 } 65 }
72 66
73 } // namespace blink 67 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Modulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698