From bde432b64de86c2a232b8054a565872e43a7f8b8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 26 Jul 2016 12:06:11 -0700 Subject: [PATCH 1/2] Add webContents.copyImageAt --- atom/browser/api/atom_api_web_contents.cc | 7 +++++++ atom/browser/api/atom_api_web_contents.h | 1 + 2 files changed, 8 insertions(+) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 1042e4080d33..0083ac71eb96 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1146,6 +1146,12 @@ void WebContents::ShowDefinitionForSelection() { #endif } +void WebContents::CopyImageAt(int x, int y) { + const auto host = web_contents()->GetRenderViewHost(); + if (host) + host->CopyImageAt(x, y); +} + void WebContents::Focus() { web_contents()->Focus(); } @@ -1425,6 +1431,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("removeWorkSpace", &WebContents::RemoveWorkSpace) .SetMethod("showDefinitionForSelection", &WebContents::ShowDefinitionForSelection) + .SetMethod("copyImageAt", &WebContents::CopyImageAt) .SetMethod("capturePage", &WebContents::CapturePage) .SetMethod("isFocused", &WebContents::IsFocused) .SetProperty("id", &WebContents::ID) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index f55ab9ca4410..381f3770d398 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -126,6 +126,7 @@ class WebContents : public mate::TrackableObject, uint32_t FindInPage(mate::Arguments* args); void StopFindInPage(content::StopFindAction action); void ShowDefinitionForSelection(); + void CopyImageAt(int x, int y); // Focus. void Focus(); From 31564f079f1979e728b7c5b48b0b66267beda7a5 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 26 Jul 2016 12:08:05 -0700 Subject: [PATCH 2/2] Document webContents.copyImageAt(x,y) --- docs/api/web-contents.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 714d61eced95..709886e283ed 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -620,6 +620,13 @@ Executes the editing command `cut` in web page. Executes the editing command `copy` in web page. +### `contents.copyImageAt(x, y)` + +* `x` Integer +* `y` Integer + +Copy the image at the given position to the clipboard. + #### `contents.paste()` Executes the editing command `paste` in web page.