Browse Source

Add showDefinitionForSelection to webContents/webview

Kevin Sawicki 9 years ago
parent
commit
4f0a52628e

+ 11 - 0
atom/browser/api/atom_api_web_contents.cc

@@ -1094,6 +1094,16 @@ void WebContents::StopFindInPage(content::StopFindAction action) {
   web_contents()->StopFinding(action);
 }
 
+void WebContents::ShowDefinitionForSelection() {
+#if defined(OS_WIN)
+  const auto view = web_contents()->GetRenderWidgetHostView();
+  if (view)
+    view->ShowDefinitionForSelection();
+#else
+  NOTIMPLEMENTED();
+#endif
+}
+
 void WebContents::Focus() {
   web_contents()->Focus();
 }
@@ -1289,6 +1299,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("_printToPDF", &WebContents::PrintToPDF)
       .SetMethod("addWorkSpace", &WebContents::AddWorkSpace)
       .SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace)
+      .SetMethod("showDefinitionForSelection", &WebContents::ShowDefinitionForSelection)
       .SetProperty("id", &WebContents::ID)
       .SetProperty("session", &WebContents::Session)
       .SetProperty("hostWebContents", &WebContents::HostWebContents)

+ 1 - 0
atom/browser/api/atom_api_web_contents.h

@@ -116,6 +116,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
   void ReplaceMisspelling(const base::string16& word);
   uint32_t FindInPage(mate::Arguments* args);
   void StopFindInPage(content::StopFindAction action);
+  void ShowDefinitionForSelection();
 
   // Focus.
   void Focus();

+ 2 - 1
lib/renderer/web-view/web-view.js

@@ -379,7 +379,8 @@ var registerWebViewElement = function () {
     'downloadURL',
     'inspectServiceWorker',
     'print',
-    'printToPDF'
+    'printToPDF',
+    'showDefinitionForSelection'
   ]
   nonblockMethods = [
     'insertCSS',