Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / core / v8 / custom / V8InspectorFrontendHostCustom.cpp
index 3e93e39..84c513f 100644 (file)
@@ -32,6 +32,7 @@
 #include "bindings/core/v8/V8InspectorFrontendHost.h"
 
 #include "bindings/core/v8/V8Binding.h"
+#include "bindings/core/v8/V8HTMLDocument.h"
 #include "bindings/core/v8/V8MouseEvent.h"
 #include "bindings/core/v8/V8Window.h"
 #include "core/dom/Document.h"
@@ -112,7 +113,7 @@ void V8InspectorFrontendHost::showContextMenuMethodCustom(const v8::FunctionCall
     if (!V8MouseEvent::wrapperTypeInfo.equals(toWrapperTypeInfo(eventWrapper)))
         return;
 
-    Event* event = V8Event::toNative(eventWrapper);
+    Event* event = V8Event::toImpl(eventWrapper);
     if (!info[1]->IsArray())
         return;
 
@@ -121,7 +122,7 @@ void V8InspectorFrontendHost::showContextMenuMethodCustom(const v8::FunctionCall
     if (!populateContextMenuItems(array, menu, info.GetIsolate()))
         return;
 
-    InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(info.Holder());
+    InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.Holder());
     Vector<ContextMenuItem> items = menu.items();
     frontendHost->showContextMenu(event, items);
 }
@@ -146,17 +147,26 @@ void V8InspectorFrontendHost::showContextMenuAtPointMethodCustom(const v8::Funct
     if (!populateContextMenuItems(v8::Local<v8::Array>::Cast(array), menu, info.GetIsolate()))
         return;
 
-    v8::Isolate* isolate = info.GetIsolate();
-    v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(isolate->GetEnteredContext()->Global(), isolate);
-    if (windowWrapper.IsEmpty())
-        return;
-    LocalDOMWindow* window = V8Window::toNative(windowWrapper);
-    if (!window->document() || !window->document()->page())
+    Document* document = nullptr;
+    if (info.Length() >= 4) {
+        v8::Local<v8::Object> documentWrapper = v8::Local<v8::Object>::Cast(info[3]);
+        if (!V8HTMLDocument::wrapperTypeInfo.equals(toWrapperTypeInfo(documentWrapper)))
+            return;
+        document = V8HTMLDocument::toImpl(documentWrapper);
+    } else {
+        v8::Isolate* isolate = info.GetIsolate();
+        v8::Handle<v8::Object> windowWrapper = V8Window::findInstanceInPrototypeChain(isolate->GetEnteredContext()->Global(), isolate);
+        if (windowWrapper.IsEmpty())
+            return;
+        LocalDOMWindow* window = V8Window::toImpl(windowWrapper);
+        document = window ? window->document() : nullptr;
+    }
+    if (!document || !document->page())
         return;
 
-    InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(info.Holder());
+    InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toImpl(info.Holder());
     Vector<ContextMenuItem> items = menu.items();
-    frontendHost->showContextMenu(window->document()->page(), static_cast<float>(x->NumberValue()), static_cast<float>(y->NumberValue()), items);
+    frontendHost->showContextMenu(document->page(), static_cast<float>(x->NumberValue()), static_cast<float>(y->NumberValue()), items);
 }
 
 static void histogramEnumeration(const char* name, const v8::FunctionCallbackInfo<v8::Value>& info, int boundaryValue)