| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 if (ContainsWrapper()) { | 135 if (ContainsWrapper()) { |
| 136 main_world_wrapper_.Reset(); | 136 main_world_wrapper_.Reset(); |
| 137 WrapperTypeInfo::WrapperDestroyed(); | 137 WrapperTypeInfo::WrapperDestroyed(); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool IsEqualTo(const v8::Local<v8::Object>& other) const { | 141 bool IsEqualTo(const v8::Local<v8::Object>& other) const { |
| 142 return main_world_wrapper_ == other; | 142 return main_world_wrapper_ == other; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Provides a way to convert Node* to ScriptWrappable* without including | |
| 146 // "core/dom/Node.h". | |
| 147 // | |
| 148 // Example: | |
| 149 // void foo(const void*) { ... } // [1] | |
| 150 // void foo(ScriptWrappable*) { ... } // [2] | |
| 151 // class Node; | |
| 152 // Node* node; | |
| 153 // foo(node); // This calls [1] because there is no definition of Node | |
| 154 // // and compilers do not know that Node is a subclass of | |
| 155 // // ScriptWrappable. | |
| 156 // foo(ScriptWrappable::fromNode(node)); // This calls [2] as expected. | |
| 157 // | |
| 158 // The definition of fromNode is placed in Node.h because we'd like to | |
| 159 // inline calls to fromNode as much as possible. | |
| 160 static ScriptWrappable* FromNode(Node*); | |
| 161 | |
| 162 bool SetReturnValue(v8::ReturnValue<v8::Value> return_value) { | 145 bool SetReturnValue(v8::ReturnValue<v8::Value> return_value) { |
| 163 return_value.Set(main_world_wrapper_); | 146 return_value.Set(main_world_wrapper_); |
| 164 return ContainsWrapper(); | 147 return ContainsWrapper(); |
| 165 } | 148 } |
| 166 | 149 |
| 167 bool ContainsWrapper() const { return !main_world_wrapper_.IsEmpty(); } | 150 bool ContainsWrapper() const { return !main_world_wrapper_.IsEmpty(); } |
| 168 | 151 |
| 169 // Mark wrapper of this ScriptWrappable as alive in V8. Only marks | 152 // Mark wrapper of this ScriptWrappable as alive in V8. Only marks |
| 170 // wrapper in the main world. To mark wrappers in all worlds call | 153 // wrapper in the main world. To mark wrappers in all worlds call |
| 171 // ScriptWrappableVisitor::markWrapper(ScriptWrappable*, v8::Isolate*) | 154 // ScriptWrappableVisitor::markWrapper(ScriptWrappable*, v8::Isolate*) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 #define DECLARE_WRAPPERTYPEINFO() \ | 204 #define DECLARE_WRAPPERTYPEINFO() \ |
| 222 public: \ | 205 public: \ |
| 223 const WrapperTypeInfo* GetWrapperTypeInfo() const override; \ | 206 const WrapperTypeInfo* GetWrapperTypeInfo() const override; \ |
| 224 \ | 207 \ |
| 225 private: \ | 208 private: \ |
| 226 typedef void end_of_define_wrappertypeinfo_not_reached_t | 209 typedef void end_of_define_wrappertypeinfo_not_reached_t |
| 227 | 210 |
| 228 } // namespace blink | 211 } // namespace blink |
| 229 | 212 |
| 230 #endif // ScriptWrappable_h | 213 #endif // ScriptWrappable_h |
| OLD | NEW |