Chromium Code Reviews| 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 "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/ScriptSourceCode.h" | 6 #include "bindings/core/v8/ScriptSourceCode.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 ScriptSourceCode::ScriptSourceCode() | 10 ScriptSourceCode::ScriptSourceCode() |
| 11 : m_resource(0) | 11 : m_resource(0) |
| 12 , m_startPosition(TextPosition::minimumPosition()) | 12 , m_startPosition(TextPosition::minimumPosition()) |
| 13 { | 13 { |
| 14 } | 14 } |
| 15 | 15 |
| 16 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const TextPosition& startPosition) | 16 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const TextPosition& startPosition) |
| 17 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition) | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL& url, const TextPosition& startPosition) | |
| 17 : m_source(source) | 22 : m_source(source) |
| 18 , m_resource(0) | 23 , m_resource(0) |
| 19 , m_url(url) | 24 , m_url(url) |
| 20 , m_startPosition(startPosition) | 25 , m_startPosition(startPosition) |
| 21 { | 26 { |
| 22 treatNullSourceAsEmpty(); | 27 treatNullSourceAsEmpty(); |
| 23 if (!m_url.isEmpty()) | 28 if (!m_url.isEmpty()) |
| 24 m_url.removeFragmentIdentifier(); | 29 m_url.removeFragmentIdentifier(); |
| 25 } | 30 } |
| 26 | 31 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 if (sourceMapUrl.isEmpty()) { | 74 if (sourceMapUrl.isEmpty()) { |
| 70 // Try to get deprecated header. | 75 // Try to get deprecated header. |
| 71 sourceMapUrl = response.httpHeaderField("X-SourceMap"); | 76 sourceMapUrl = response.httpHeaderField("X-SourceMap"); |
| 72 } | 77 } |
| 73 return sourceMapUrl; | 78 return sourceMapUrl; |
| 74 } | 79 } |
| 75 | 80 |
| 76 void ScriptSourceCode::treatNullSourceAsEmpty() | 81 void ScriptSourceCode::treatNullSourceAsEmpty() |
| 77 { | 82 { |
| 78 // ScriptSourceCode allows for the representation of the null/not-there-real ly ScriptSourceCode value. | 83 // ScriptSourceCode allows for the representation of the null/not-there-real ly ScriptSourceCode value. |
| 79 // Encoded by way of a m_source.isNull() being true, with the nullary constr uctor to be used to | 84 // Encoded by way of a m_source->isNull() being true, with the nullary const ructor to be used to |
|
hajimehoshi
2015/11/26 10:56:19
nit
| |
| 80 // construct such a value. | 85 // construct such a value. |
| 81 // | 86 // |
| 82 // Should the other constructors be passed a null string, that is interprete d as representing | 87 // Should the other constructors be passed a null string, that is interprete d as representing |
| 83 // the empty script. Consequently, we need to disambiguate between such null string occurrences. | 88 // the empty script. Consequently, we need to disambiguate between such null string occurrences. |
| 84 // Do that by converting the latter case's null strings into empty ones. | 89 // Do that by converting the latter case's null strings into empty ones. |
| 85 if (m_source.isNull()) | 90 if (m_source.isNull()) |
| 86 m_source = ""; | 91 m_source = CompressibleString(StringImpl::empty()); |
| 87 } | 92 } |
| 88 | 93 |
| 89 } // namespace blink | 94 } // namespace blink |
| OLD | NEW |