| 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 #include "platform/HTTPNames.h" |
| 8 |
| 7 namespace blink { | 9 namespace blink { |
| 8 | 10 |
| 9 ScriptSourceCode::ScriptSourceCode() | 11 ScriptSourceCode::ScriptSourceCode() |
| 10 : start_position_(TextPosition::MinimumPosition()) {} | 12 : start_position_(TextPosition::MinimumPosition()) {} |
| 11 | 13 |
| 12 ScriptSourceCode::ScriptSourceCode(const String& source, | 14 ScriptSourceCode::ScriptSourceCode(const String& source, |
| 13 const KURL& url, | 15 const KURL& url, |
| 14 const TextPosition& start_position) | 16 const TextPosition& start_position) |
| 15 : source_(source), url_(url), start_position_(start_position) { | 17 : source_(source), url_(url), start_position_(start_position) { |
| 16 TreatNullSourceAsEmpty(); | 18 TreatNullSourceAsEmpty(); |
| 17 if (!url_.IsEmpty()) | 19 if (!url_.IsEmpty()) |
| 18 url_.RemoveFragmentIdentifier(); | 20 url_.RemoveFragmentIdentifier(); |
| 19 } | 21 } |
| 20 | 22 |
| 21 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) | 23 ScriptSourceCode::ScriptSourceCode(const ScriptResourceData* resource) |
| 22 : ScriptSourceCode(nullptr, resource) {} | 24 : ScriptSourceCode(nullptr, resource) {} |
| 23 | 25 |
| 24 ScriptSourceCode::ScriptSourceCode(ScriptStreamer* streamer, | 26 ScriptSourceCode::ScriptSourceCode(ScriptStreamer* streamer, |
| 25 ScriptResource* resource) | 27 const ScriptResourceData* resource) |
| 26 : source_(resource->SourceText()), | 28 : source_(resource->SourceText()), |
| 27 resource_(resource), | 29 resource_(resource), |
| 28 streamer_(streamer), | 30 streamer_(streamer), |
| 29 start_position_(TextPosition::MinimumPosition()) { | 31 start_position_(TextPosition::MinimumPosition()) { |
| 30 TreatNullSourceAsEmpty(); | 32 TreatNullSourceAsEmpty(); |
| 31 } | 33 } |
| 32 | 34 |
| 33 ScriptSourceCode::~ScriptSourceCode() {} | 35 ScriptSourceCode::~ScriptSourceCode() {} |
| 34 | 36 |
| 35 DEFINE_TRACE(ScriptSourceCode) { | 37 DEFINE_TRACE(ScriptSourceCode) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 65 // | 67 // |
| 66 // Should the other constructors be passed a null string, that is interpreted | 68 // Should the other constructors be passed a null string, that is interpreted |
| 67 // as representing the empty script. Consequently, we need to disambiguate | 69 // as representing the empty script. Consequently, we need to disambiguate |
| 68 // between such null string occurrences. Do that by converting the latter | 70 // between such null string occurrences. Do that by converting the latter |
| 69 // case's null strings into empty ones. | 71 // case's null strings into empty ones. |
| 70 if (source_.IsNull()) | 72 if (source_.IsNull()) |
| 71 source_ = ""; | 73 source_ = ""; |
| 72 } | 74 } |
| 73 | 75 |
| 74 } // namespace blink | 76 } // namespace blink |
| OLD | NEW |