OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "bindings/core/v8/ScriptWrappable.h" | 42 #include "bindings/core/v8/ScriptWrappable.h" |
43 #include "bindings/core/v8/V8BindingMacros.h" | 43 #include "bindings/core/v8/V8BindingMacros.h" |
44 #include "bindings/core/v8/V8PerIsolateData.h" | 44 #include "bindings/core/v8/V8PerIsolateData.h" |
45 #include "bindings/core/v8/V8ScriptRunner.h" | 45 #include "bindings/core/v8/V8ScriptRunner.h" |
46 #include "bindings/core/v8/V8StringResource.h" | 46 #include "bindings/core/v8/V8StringResource.h" |
47 #include "bindings/core/v8/V8ThrowException.h" | 47 #include "bindings/core/v8/V8ThrowException.h" |
48 #include "bindings/core/v8/V8ValueCache.h" | 48 #include "bindings/core/v8/V8ValueCache.h" |
49 #include "core/CoreExport.h" | 49 #include "core/CoreExport.h" |
50 #include "platform/JSONValues.h" | 50 #include "platform/JSONValues.h" |
51 #include "platform/heap/Handle.h" | 51 #include "platform/heap/Handle.h" |
| 52 #include "platform/text/CompressibleString.h" |
52 #include "wtf/text/AtomicString.h" | 53 #include "wtf/text/AtomicString.h" |
53 #include <v8.h> | 54 #include <v8.h> |
54 | 55 |
55 namespace blink { | 56 namespace blink { |
56 | 57 |
57 class DOMWindow; | 58 class DOMWindow; |
58 class EventListener; | 59 class EventListener; |
59 class EventTarget; | 60 class EventTarget; |
60 class ExceptionState; | 61 class ExceptionState; |
61 class ExecutionContext; | 62 class ExecutionContext; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 // Return a V8 external string that shares the underlying buffer with the given | 430 // Return a V8 external string that shares the underlying buffer with the given |
430 // WebCore string. The reference counting mechanism is used to keep the | 431 // WebCore string. The reference counting mechanism is used to keep the |
431 // underlying buffer alive while the string is still live in the V8 engine. | 432 // underlying buffer alive while the string is still live in the V8 engine. |
432 inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const String& string
) | 433 inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const String& string
) |
433 { | 434 { |
434 if (string.isNull()) | 435 if (string.isNull()) |
435 return v8::String::Empty(isolate); | 436 return v8::String::Empty(isolate); |
436 return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(isol
ate, string.impl()); | 437 return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(isol
ate, string.impl()); |
437 } | 438 } |
438 | 439 |
| 440 inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const CompressibleSt
ring& string) |
| 441 { |
| 442 if (string.isNull()) |
| 443 return v8::String::Empty(isolate); |
| 444 return V8PerIsolateData::from(isolate)->stringCache()->v8ExternalString(isol
ate, string); |
| 445 } |
| 446 |
439 inline v8::Local<v8::String> v8AtomicString(v8::Isolate* isolate, const char* st
r, int length = -1) | 447 inline v8::Local<v8::String> v8AtomicString(v8::Isolate* isolate, const char* st
r, int length = -1) |
440 { | 448 { |
441 ASSERT(isolate); | 449 ASSERT(isolate); |
442 v8::Local<v8::String> value; | 450 v8::Local<v8::String> value; |
443 if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInterna
lized, length).ToLocal(&value))) | 451 if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInterna
lized, length).ToLocal(&value))) |
444 return value; | 452 return value; |
445 // Immediately crashes when NewFromUtf8() fails because it only fails the | 453 // Immediately crashes when NewFromUtf8() fails because it only fails the |
446 // given str is too long. | 454 // given str is too long. |
447 RELEASE_ASSERT_NOT_REACHED(); | 455 RELEASE_ASSERT_NOT_REACHED(); |
448 return v8::String::Empty(isolate); | 456 return v8::String::Empty(isolate); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 | 1120 |
1113 template <size_t N> | 1121 template <size_t N> |
1114 v8::Local<v8::Value> v8CallExtraOrCrash(ScriptState* scriptState, const char* na
me, v8::Local<v8::Value>(&args)[N]) | 1122 v8::Local<v8::Value> v8CallExtraOrCrash(ScriptState* scriptState, const char* na
me, v8::Local<v8::Value>(&args)[N]) |
1115 { | 1123 { |
1116 return v8CallOrCrash(v8CallExtraHelper(scriptState, name, N, args)); | 1124 return v8CallOrCrash(v8CallExtraHelper(scriptState, name, N, args)); |
1117 } | 1125 } |
1118 | 1126 |
1119 } // namespace blink | 1127 } // namespace blink |
1120 | 1128 |
1121 #endif // V8Binding_h | 1129 #endif // V8Binding_h |
OLD | NEW |