Index: third_party/WebKit/Source/platform/bindings/V8ObjectConstructor.h |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V0CustomElementBinding.h b/third_party/WebKit/Source/platform/bindings/V8ObjectConstructor.h |
similarity index 60% |
copy from third_party/WebKit/Source/bindings/core/v8/V0CustomElementBinding.h |
copy to third_party/WebKit/Source/platform/bindings/V8ObjectConstructor.h |
index 268df98e9ddb395237473dcd8e91c91b05ff4c75..323853903272c93d334a05918efd02cd4fee7cee 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V0CustomElementBinding.h |
+++ b/third_party/WebKit/Source/platform/bindings/V8ObjectConstructor.h |
@@ -28,31 +28,56 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef V0CustomElementBinding_h |
-#define V0CustomElementBinding_h |
+#ifndef V8ObjectConstructor_h |
+#define V8ObjectConstructor_h |
-#include <memory> |
- |
-#include "bindings/core/v8/ScopedPersistent.h" |
+#include "platform/PlatformExport.h" |
+#include "platform/bindings/V8PerIsolateData.h" |
#include "platform/wtf/Allocator.h" |
#include "v8/include/v8.h" |
namespace blink { |
-class V0CustomElementBinding { |
- USING_FAST_MALLOC(V0CustomElementBinding); |
+class ConstructorMode { |
+ STACK_ALLOCATED(); |
public: |
- static std::unique_ptr<V0CustomElementBinding> Create( |
- v8::Isolate*, |
- v8::Local<v8::Object> prototype); |
- ~V0CustomElementBinding(); |
+ enum Mode { kWrapExistingObject, kCreateNewObject }; |
+ |
+ ConstructorMode(v8::Isolate* isolate) : isolate_(isolate) { |
+ V8PerIsolateData* data = V8PerIsolateData::From(isolate_); |
+ previous_ = data->constructor_mode_; |
+ data->constructor_mode_ = kWrapExistingObject; |
+ } |
+ |
+ ~ConstructorMode() { |
+ V8PerIsolateData* data = V8PerIsolateData::From(isolate_); |
+ data->constructor_mode_ = previous_; |
+ } |
+ |
+ static bool Current(v8::Isolate* isolate) { |
+ return V8PerIsolateData::From(isolate)->constructor_mode_; |
+ } |
private: |
- V0CustomElementBinding(v8::Isolate*, v8::Local<v8::Object> prototype); |
- ScopedPersistent<v8::Object> prototype_; |
+ v8::Isolate* isolate_; |
+ bool previous_; |
+}; |
+ |
+class PLATFORM_EXPORT V8ObjectConstructor { |
+ STATIC_ONLY(V8ObjectConstructor); |
+ |
+ public: |
+ static v8::MaybeLocal<v8::Object> NewInstance( |
+ v8::Isolate*, |
+ v8::Local<v8::Function>, |
+ int argc = 0, |
+ v8::Local<v8::Value> argv[] = nullptr); |
+ |
+ static void IsValidConstructorMode( |
+ const v8::FunctionCallbackInfo<v8::Value>&); |
}; |
} // namespace blink |
-#endif // V0CustomElementBinding_h |
+#endif // V8ObjectConstructor_h |