| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunct
ion(); | 913 v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunct
ion(); |
| 914 instance = SafeAllocation::newInstance(function); | 914 instance = SafeAllocation::newInstance(function); |
| 915 } | 915 } |
| 916 if (!instance.IsEmpty()) { | 916 if (!instance.IsEmpty()) { |
| 917 // Avoid setting the DOM wrapper for failed allocations. | 917 // Avoid setting the DOM wrapper for failed allocations. |
| 918 setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl); | 918 setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl); |
| 919 } | 919 } |
| 920 return instance; | 920 return instance; |
| 921 } | 921 } |
| 922 | 922 |
| 923 void V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object> object, int type, void*
cptr) | |
| 924 { | |
| 925 ASSERT(object->InternalFieldCount() >= 2); | |
| 926 object->SetPointerInInternalField(V8Custom::kDOMWrapperObjectIndex, cptr); | |
| 927 object->SetInternalField(V8Custom::kDOMWrapperTypeIndex, v8::Integer::New(ty
pe)); | |
| 928 } | |
| 929 | |
| 930 #ifndef NDEBUG | 923 #ifndef NDEBUG |
| 931 bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value) | 924 bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value) |
| 932 { | 925 { |
| 933 if (value.IsEmpty() || !value->IsObject()) | 926 if (value.IsEmpty() || !value->IsObject()) |
| 934 return false; | 927 return false; |
| 935 | 928 |
| 936 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 929 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
| 937 if (!object->InternalFieldCount()) | 930 if (!object->InternalFieldCount()) |
| 938 return false; | 931 return false; |
| 939 | 932 |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 v8::Handle<v8::Context> context = V8Proxy::context(frame); | 1730 v8::Handle<v8::Context> context = V8Proxy::context(frame); |
| 1738 if (context.IsEmpty()) | 1731 if (context.IsEmpty()) |
| 1739 return v8::Handle<v8::Object>(); | 1732 return v8::Handle<v8::Object>(); |
| 1740 | 1733 |
| 1741 v8::Handle<v8::Object> global = context->Global(); | 1734 v8::Handle<v8::Object> global = context->Global(); |
| 1742 ASSERT(!global.IsEmpty()); | 1735 ASSERT(!global.IsEmpty()); |
| 1743 return global; | 1736 return global; |
| 1744 } | 1737 } |
| 1745 | 1738 |
| 1746 } // namespace WebCore | 1739 } // namespace WebCore |
| OLD | NEW |