OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "bindings/core/v8/ScriptSourceCode.h" | 5 #include "bindings/core/v8/ScriptSourceCode.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 ScriptSourceCode::ScriptSourceCode() | 9 ScriptSourceCode::ScriptSourceCode() |
10 : m_startPosition(TextPosition::minimumPosition()) | 10 : m_startPosition(TextPosition::minimumPosition()) |
11 { | 11 { |
12 } | 12 } |
13 | 13 |
14 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const
TextPosition& startPosition) | 14 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const
TextPosition& startPosition) |
15 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition) | |
16 { | |
17 } | |
18 | |
19 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL&
url, const TextPosition& startPosition) | |
20 : m_source(source) | 15 : m_source(source) |
21 , m_url(url) | 16 , m_url(url) |
22 , m_startPosition(startPosition) | 17 , m_startPosition(startPosition) |
23 { | 18 { |
24 treatNullSourceAsEmpty(); | 19 treatNullSourceAsEmpty(); |
25 if (!m_url.isEmpty()) | 20 if (!m_url.isEmpty()) |
26 m_url.removeFragmentIdentifier(); | 21 m_url.removeFragmentIdentifier(); |
27 } | 22 } |
28 | 23 |
29 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) | 24 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 void ScriptSourceCode::treatNullSourceAsEmpty() | 74 void ScriptSourceCode::treatNullSourceAsEmpty() |
80 { | 75 { |
81 // ScriptSourceCode allows for the representation of the null/not-there-real
ly ScriptSourceCode value. | 76 // ScriptSourceCode allows for the representation of the null/not-there-real
ly ScriptSourceCode value. |
82 // Encoded by way of a m_source.isNull() being true, with the nullary constr
uctor to be used to | 77 // Encoded by way of a m_source.isNull() being true, with the nullary constr
uctor to be used to |
83 // construct such a value. | 78 // construct such a value. |
84 // | 79 // |
85 // Should the other constructors be passed a null string, that is interprete
d as representing | 80 // Should the other constructors be passed a null string, that is interprete
d as representing |
86 // the empty script. Consequently, we need to disambiguate between such null
string occurrences. | 81 // the empty script. Consequently, we need to disambiguate between such null
string occurrences. |
87 // Do that by converting the latter case's null strings into empty ones. | 82 // Do that by converting the latter case's null strings into empty ones. |
88 if (m_source.isNull()) | 83 if (m_source.isNull()) |
89 m_source = CompressibleString(); | 84 m_source = ""; |
90 } | 85 } |
91 | 86 |
92 } // namespace blink | 87 } // namespace blink |
OLD | NEW |